Java Code Examples for org.eclipse.jdt.internal.compiler.lookup.TypeBinding#isBaseType()
The following examples show how to use
org.eclipse.jdt.internal.compiler.lookup.TypeBinding#isBaseType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PatchDelegate.java From EasyMPermission with MIT License | 6 votes |
private static String typeBindingToSignature(TypeBinding binding) { binding = binding.erasure(); if (binding != null && binding.isBaseType()) { return new String (binding.sourceName()); } else if (binding instanceof ReferenceBinding) { String pkg = binding.qualifiedPackageName() == null ? "" : new String(binding.qualifiedPackageName()); String qsn = binding.qualifiedSourceName() == null ? "" : new String(binding.qualifiedSourceName()); return pkg.isEmpty() ? qsn : (pkg + "." + qsn); } else if (binding instanceof ArrayBinding) { StringBuilder out = new StringBuilder(); out.append(typeBindingToSignature(binding.leafComponentType())); for (int i = 0; i < binding.dimensions(); i++) out.append("[]"); return out.toString(); } return ""; }
Example 2
Source File: CastExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Casting an enclosing instance will considered as useful if removing it would actually bind to a different type */ public static void checkNeedForEnclosingInstanceCast(BlockScope scope, Expression enclosingInstance, TypeBinding enclosingInstanceType, TypeBinding memberType) { if (scope.compilerOptions().getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return; TypeBinding castedExpressionType = ((CastExpression)enclosingInstance).expression.resolvedType; if (castedExpressionType == null) return; // cannot do better // obvious identity cast if (TypeBinding.equalsEquals(castedExpressionType, enclosingInstanceType)) { scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance); } else if (castedExpressionType == TypeBinding.NULL){ return; // tolerate null enclosing instance cast } else { TypeBinding alternateEnclosingInstanceType = castedExpressionType; if (castedExpressionType.isBaseType() || castedExpressionType.isArrayType()) return; // error case if (TypeBinding.equalsEquals(memberType, scope.getMemberType(memberType.sourceName(), (ReferenceBinding) alternateEnclosingInstanceType))) { scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance); } } }
Example 3
Source File: ASTNode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) { if (type.isArrayType()) { type = ((ArrayBinding) type).leafComponentType; } if (type.isBaseType()) return false; ReferenceBinding refType = (ReferenceBinding) type; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=397888 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385780 if ((this.bits & ASTNode.InsideJavadoc) == 0 && refType instanceof TypeVariableBinding) { refType.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } // ignore references insing Javadoc comments if ((this.bits & ASTNode.InsideJavadoc) == 0 && refType.isOrEnclosedByPrivateType() && !scope.isDefinedInType(refType)) { // ignore cases where type is used from inside itself ((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } if (refType.hasRestrictedAccess()) { AccessRestriction restriction = scope.environment().getAccessRestriction(type.erasure()); if (restriction != null) { scope.problemReporter().forbiddenReference(type, this, restriction.classpathEntryType, restriction.classpathEntryName, restriction.getProblemId()); } } // force annotations resolution before deciding whether the type may be deprecated refType.initializeDeprecatedAnnotationTagBits(); if (!refType.isViewedAsDeprecated()) return false; // inside same unit - no report if (scope.isDefinedInSameUnit(refType)) return false; // if context is deprecated, may avoid reporting if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; return true; }
Example 4
Source File: ReferenceExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope) { if (super.sIsMoreSpecific(s, t, scope)) return true; if (this.exactMethodBinding == null || t.findSuperTypeOriginatingFrom(s) != null) return false; s = s.capture(this.enclosingScope, this.sourceEnd); MethodBinding sSam = s.getSingleAbstractMethod(this.enclosingScope, true); if (sSam == null || !sSam.isValidBinding()) return false; TypeBinding r1 = sSam.returnType; MethodBinding tSam = t.getSingleAbstractMethod(this.enclosingScope, true); if (tSam == null || !tSam.isValidBinding()) return false; TypeBinding r2 = tSam.returnType; if (r2.id == TypeIds.T_void) return true; if (r1.id == TypeIds.T_void) return false; // r1 <: r2 if (r1.isCompatibleWith(r2, scope)) return true; return r1.isBaseType() != r2.isBaseType() && r1.isBaseType() == this.exactMethodBinding.returnType.isBaseType(); }
Example 5
Source File: SingleNameReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding) */ public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) { if (runtimeTimeType == null || compileTimeType == null) return; if ((this.bits & Binding.FIELD) != 0 && this.binding != null && this.binding.isValidBinding()) { // set the generic cast after the fact, once the type expectation is fully known (no need for strict cast) FieldBinding field = (FieldBinding) this.binding; FieldBinding originalBinding = field.original(); TypeBinding originalType = originalBinding.type; // extra cast needed if field type is type variable if (originalType.leafComponentType().isTypeVariable()) { TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) ? compileTimeType // unboxing: checkcast before conversion : runtimeTimeType; this.genericCast = originalType.genericCast(scope.boxing(targetType)); if (this.genericCast instanceof ReferenceBinding) { ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast; if (!referenceCast.canBeSeenBy(scope)) { scope.problemReporter().invalidType(this, new ProblemReferenceBinding( CharOperation.splitOn('.', referenceCast.shortReadableName()), referenceCast, ProblemReasons.NotVisible)); } } } } super.computeConversion(scope, runtimeTimeType, compileTimeType); }
Example 6
Source File: FieldReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding) */ public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) { if (runtimeTimeType == null || compileTimeType == null) return; // set the generic cast after the fact, once the type expectation is fully known (no need for strict cast) if (this.binding != null && this.binding.isValidBinding()) { FieldBinding originalBinding = this.binding.original(); TypeBinding originalType = originalBinding.type; // extra cast needed if field type is type variable if (originalType.leafComponentType().isTypeVariable()) { TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) ? compileTimeType // unboxing: checkcast before conversion : runtimeTimeType; this.genericCast = originalBinding.type.genericCast(targetType); if (this.genericCast instanceof ReferenceBinding) { ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast; if (!referenceCast.canBeSeenBy(scope)) { scope.problemReporter().invalidType(this, new ProblemReferenceBinding( CharOperation.splitOn('.', referenceCast.shortReadableName()), referenceCast, ProblemReasons.NotVisible)); } } } } super.computeConversion(scope, runtimeTimeType, compileTimeType); }
Example 7
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding) */ public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) { if (runtimeTimeType == null || compileTimeType == null) return; // set the generic cast after the fact, once the type expectation is fully known (no need for strict cast) if (this.binding != null && this.binding.isValidBinding()) { MethodBinding originalBinding = this.binding.original(); TypeBinding originalType = originalBinding.returnType; // extra cast needed if method return type is type variable if (originalType.leafComponentType().isTypeVariable()) { TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) ? compileTimeType // unboxing: checkcast before conversion : runtimeTimeType; this.valueCast = originalType.genericCast(targetType); } else if (this.binding == scope.environment().arrayClone && runtimeTimeType.id != TypeIds.T_JavaLangObject && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // from 1.5 source level on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast this.valueCast = runtimeTimeType; } if (this.valueCast instanceof ReferenceBinding) { ReferenceBinding referenceCast = (ReferenceBinding) this.valueCast; if (!referenceCast.canBeSeenBy(scope)) { scope.problemReporter().invalidType(this, new ProblemReferenceBinding( CharOperation.splitOn('.', referenceCast.shortReadableName()), referenceCast, ProblemReasons.NotVisible)); } } } super.computeConversion(scope, runtimeTimeType, compileTimeType); }
Example 8
Source File: CodeSnippetAllocationExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { int pc = codeStream.position; MethodBinding codegenBinding = this.binding.original(); ReferenceBinding allocatedType = codegenBinding.declaringClass; if (codegenBinding.canBeSeenBy(allocatedType, this, currentScope)) { codeStream.new_(this.type, allocatedType); if (valueRequired) { codeStream.dup(); } // better highlight for allocation: display the type individually codeStream.recordPositionsFrom(pc, this.type.sourceStart); // handling innerclass instance allocation - enclosing instance arguments if (allocatedType.isNestedType()) { codeStream.generateSyntheticEnclosingInstanceValues( currentScope, allocatedType, enclosingInstance(), this); } // generate the arguments for constructor if (this.arguments != null) { for (int i = 0, count = this.arguments.length; i < count; i++) { this.arguments[i].generateCode(currentScope, codeStream, true); } } // handling innerclass instance allocation - outer local arguments if (allocatedType.isNestedType()) { codeStream.generateSyntheticOuterArgumentValues( currentScope, allocatedType, this); } // invoke constructor codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */, this.typeArguments); } else { // private emulation using reflect codeStream.generateEmulationForConstructor(currentScope, codegenBinding); // generate arguments if (this.arguments != null) { int argsLength = this.arguments.length; codeStream.generateInlinedValue(argsLength); codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); codeStream.dup(); for (int i = 0; i < argsLength; i++) { codeStream.generateInlinedValue(i); this.arguments[i].generateCode(currentScope, codeStream, true); TypeBinding parameterBinding = codegenBinding.parameters[i]; if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) { codeStream.generateBoxingConversion(codegenBinding.parameters[i].id); } codeStream.aastore(); if (i < argsLength - 1) { codeStream.dup(); } } } else { codeStream.generateInlinedValue(0); codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1)); } codeStream.invokeJavaLangReflectConstructorNewInstance(); codeStream.checkcast(allocatedType); } codeStream.recordPositionsFrom(pc, this.sourceStart); }
Example 9
Source File: LambdaExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope skope) { // 15.12.2.5 if (super.sIsMoreSpecific(s, t, skope)) return true; if (argumentsTypeElided() || t.findSuperTypeOriginatingFrom(s) != null) return false; s = s.capture(this.enclosingScope, this.sourceEnd); MethodBinding sSam = s.getSingleAbstractMethod(this.enclosingScope, true); if (sSam == null || !sSam.isValidBinding()) return false; TypeBinding r1 = sSam.returnType; MethodBinding tSam = t.getSingleAbstractMethod(this.enclosingScope, true); if (tSam == null || !tSam.isValidBinding()) return false; TypeBinding r2 = tSam.returnType; if (r2.id == TypeIds.T_void) return true; if (r1.id == TypeIds.T_void) return false; // r1 <: r2 if (r1.isCompatibleWith(r2, skope)) return true; Expression [] returnExpressions = this.resultExpressions; int returnExpressionsLength = returnExpressions == null ? 0 : returnExpressions.length; int i; // r1 is a primitive type, r2 is a reference type, and each result expression is a standalone expression (15.2) of a primitive type if (r1.isBaseType() && !r2.isBaseType()) { for (i = 0; i < returnExpressionsLength; i++) { if (returnExpressions[i].isPolyExpression() || !returnExpressions[i].resolvedType.isBaseType()) break; } if (i == returnExpressionsLength) return true; } if (!r1.isBaseType() && r2.isBaseType()) { for (i = 0; i < returnExpressionsLength; i++) { if (returnExpressions[i].resolvedType.isBaseType()) break; } if (i == returnExpressionsLength) return true; } if (r1.isFunctionalInterface(this.enclosingScope) && r2.isFunctionalInterface(this.enclosingScope)) { for (i = 0; i < returnExpressionsLength; i++) { Expression resultExpression = returnExpressions[i]; if (!resultExpression.sIsMoreSpecific(r1, r2, skope)) break; } if (i == returnExpressionsLength) return true; } return false; }
Example 10
Source File: Expression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Base types need that the widening is explicitly done by the compiler using some bytecode like i2f. * Also check unsafe type operations. */ public void computeConversion(Scope scope, TypeBinding runtimeType, TypeBinding compileTimeType) { if (runtimeType == null || compileTimeType == null) return; if (this.implicitConversion != 0) return; // already set independently // it is possible for a Byte to be unboxed to a byte & then converted to an int // but it is not possible for a byte to become Byte & then assigned to an Integer, // or to become an int before boxed into an Integer if (runtimeType != TypeBinding.NULL && runtimeType.isBaseType()) { if (!compileTimeType.isBaseType()) { TypeBinding unboxedType = scope.environment().computeBoxingType(compileTimeType); this.implicitConversion = TypeIds.UNBOXING; scope.problemReporter().autoboxing(this, compileTimeType, runtimeType); compileTimeType = unboxedType; } } else if (compileTimeType != TypeBinding.NULL && compileTimeType.isBaseType()) { TypeBinding boxedType = scope.environment().computeBoxingType(runtimeType); if (TypeBinding.equalsEquals(boxedType, runtimeType)) // Object o = 12; boxedType = compileTimeType; this.implicitConversion = TypeIds.BOXING | (boxedType.id << 4) + compileTimeType.id; scope.problemReporter().autoboxing(this, compileTimeType, scope.environment().computeBoxingType(boxedType)); return; } else if (this.constant != Constant.NotAConstant && this.constant.typeID() != TypeIds.T_JavaLangString) { this.implicitConversion = TypeIds.BOXING; return; } int compileTimeTypeID, runtimeTypeID; if ((compileTimeTypeID = compileTimeType.id) >= TypeIds.T_LastWellKnownTypeId) { // e.g. ? extends String ==> String (103227); >= TypeIds.T_LastWellKnownTypeId implies TypeIds.NoId compileTimeTypeID = compileTimeType.erasure().id == TypeIds.T_JavaLangString ? TypeIds.T_JavaLangString : TypeIds.T_JavaLangObject; } else if (runtimeType.isPrimitiveType() && compileTimeType instanceof ReferenceBinding && !compileTimeType.isBoxedPrimitiveType()) { compileTimeTypeID = TypeIds.T_JavaLangObject; // treatment is the same as for jlO. } switch (runtimeTypeID = runtimeType.id) { case T_byte : case T_short : case T_char : if (compileTimeTypeID == TypeIds.T_JavaLangObject) { this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID; } else { this.implicitConversion |= (TypeIds.T_int << 4) + compileTimeTypeID; } break; case T_JavaLangString : case T_float : case T_boolean : case T_double : case T_int : //implicitConversion may result in i2i which will result in NO code gen case T_long : this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID; break; default : // regular object ref // if (compileTimeType.isRawType() && runtimeTimeType.isBoundParameterizedType()) { // scope.problemReporter().unsafeRawExpression(this, compileTimeType, runtimeTimeType); // } } }
Example 11
Source File: IntersectionCastTypeReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public TypeBinding resolveType(BlockScope scope, boolean checkBounds, int location) { int length = this.typeReferences.length; ReferenceBinding[] intersectingTypes = new ReferenceBinding[length]; boolean hasError = false; int typeCount = 0; nextType: for (int i = 0; i < length; i++) { final TypeReference typeReference = this.typeReferences[i]; TypeBinding type = typeReference.resolveType(scope, checkBounds, location); if (type == null || ((type.tagBits & TagBits.HasMissingType) != 0)) { hasError = true; continue; } if (i == 0) { if (type.isBaseType()) { // rejected in grammar for i > 0 scope.problemReporter().onlyReferenceTypesInIntersectionCast(typeReference); hasError = true; continue; } if (type.isArrayType()) { // javac rejects the pedantic cast: (X[] & Serializable & Cloneable) new X[0], what is good for the goose ... scope.problemReporter().illegalArrayTypeInIntersectionCast(typeReference); hasError = true; continue; } } else if (!type.isInterface()) { scope.problemReporter().boundMustBeAnInterface(typeReference, type); hasError = true; continue; } for (int j = 0; j < typeCount; j++) { final ReferenceBinding priorType = intersectingTypes[j]; if (TypeBinding.equalsEquals(priorType, type)) { scope.problemReporter().duplicateBoundInIntersectionCast(typeReference); hasError = true; continue; } if (!priorType.isInterface()) continue; if (TypeBinding.equalsEquals(type.findSuperTypeOriginatingFrom(priorType), priorType)) { intersectingTypes[j] = (ReferenceBinding) type; continue nextType; } if (TypeBinding.equalsEquals(priorType.findSuperTypeOriginatingFrom(type), type)) continue nextType; } intersectingTypes[typeCount++] = (ReferenceBinding) type; } if (hasError) { return null; } if (typeCount != length) { if (typeCount == 1) { return this.resolvedType = intersectingTypes[0]; } System.arraycopy(intersectingTypes, 0, intersectingTypes = new ReferenceBinding[typeCount], 0, typeCount); } IntersectionCastTypeBinding intersectionType = (IntersectionCastTypeBinding) scope.environment().createIntersectionCastType(intersectingTypes); // check for parameterized interface collisions (when different parameterizations occur) ReferenceBinding itsSuperclass = null; ReferenceBinding[] interfaces = intersectingTypes; ReferenceBinding firstType = intersectingTypes[0]; if (firstType.isClass()) { itsSuperclass = firstType.superclass(); System.arraycopy(intersectingTypes, 1, interfaces = new ReferenceBinding[typeCount - 1], 0, typeCount - 1); } Map invocations = new HashMap(2); nextInterface: for (int i = 0, interfaceCount = interfaces.length; i < interfaceCount; i++) { ReferenceBinding one = interfaces[i]; if (one == null) continue nextInterface; if (itsSuperclass != null && scope.hasErasedCandidatesCollisions(itsSuperclass, one, invocations, intersectionType, this)) continue nextInterface; nextOtherInterface: for (int j = 0; j < i; j++) { ReferenceBinding two = interfaces[j]; if (two == null) continue nextOtherInterface; if (scope.hasErasedCandidatesCollisions(one, two, invocations, intersectionType, this)) continue nextInterface; } } if ((intersectionType.tagBits & TagBits.HierarchyHasProblems) != 0) return null; return (this.resolvedType = intersectionType); }
Example 12
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope) { if (super.sIsMoreSpecific(s, t, scope)) return true; return isPolyExpression() ? !s.isBaseType() && t.isBaseType() : false; }
Example 13
Source File: StackMapFrameCodeStream.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Macro for building a class descriptor object */ public void generateClassLiteralAccessForType(TypeBinding accessedType, FieldBinding syntheticFieldBinding) { if (accessedType.isBaseType() && accessedType != TypeBinding.NULL) { getTYPE(accessedType.id); return; } if (this.targetLevel >= ClassFileConstants.JDK1_5) { // generation using the new ldc_w bytecode this.ldc(accessedType); } else { // use in CLDC mode BranchLabel endLabel = new BranchLabel(this); if (syntheticFieldBinding != null) { // non interface case fieldAccess(Opcodes.OPC_getstatic, syntheticFieldBinding, null /* default declaringClass */); dup(); ifnonnull(endLabel); pop(); } /* Macro for building a class descriptor object... using or not a field cache to store it into... this sequence is responsible for building the actual class descriptor. If the fieldCache is set, then it is supposed to be the body of a synthetic access method factoring the actual descriptor creation out of the invocation site (saving space). If the fieldCache is nil, then we are dumping the bytecode on the invocation site, since we have no way to get a hand on the field cache to do better. */ // Wrap the code in an exception handler to convert a ClassNotFoundException into a NoClassDefError ExceptionLabel classNotFoundExceptionHandler = new ExceptionLabel(this, TypeBinding.NULL /*represents ClassNotFoundException*/); classNotFoundExceptionHandler.placeStart(); this.ldc(accessedType == TypeBinding.NULL ? "java.lang.Object" : String.valueOf(accessedType.constantPoolName()).replace('/', '.')); //$NON-NLS-1$ invokeClassForName(); /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=37565 if (accessedType == BaseTypes.NullBinding) { this.ldc("java.lang.Object"); //$NON-NLS-1$ } else if (accessedType.isArrayType()) { this.ldc(String.valueOf(accessedType.constantPoolName()).replace('/', '.')); } else { // we make it an array type (to avoid class initialization) this.ldc("[L" + String.valueOf(accessedType.constantPoolName()).replace('/', '.') + ";"); //$NON-NLS-1$//$NON-NLS-2$ } this.invokeClassForName(); if (!accessedType.isArrayType()) { // extract the component type, which doesn't initialize the class this.invokeJavaLangClassGetComponentType(); } */ /* We need to protect the runtime code from binary inconsistencies in case the accessedType is missing, the ClassNotFoundException has to be converted into a NoClassDefError(old ex message), we thus need to build an exception handler for this one. */ classNotFoundExceptionHandler.placeEnd(); if (syntheticFieldBinding != null) { // non interface case dup(); fieldAccess(Opcodes.OPC_putstatic, syntheticFieldBinding, null /* default declaringClass */); } int fromPC = this.position; goto_(endLabel); int savedStackDepth = this.stackDepth; // Generate the body of the exception handler /* ClassNotFoundException on stack -- the class literal could be doing more things on the stack, which means that the stack may not be empty at this point in the above code gen. So we save its state and restart it from 1. */ pushExceptionOnStack(TypeBinding.NULL);/*represents ClassNotFoundException*/ classNotFoundExceptionHandler.place(); // Transform the current exception, and repush and throw a // NoClassDefFoundError(ClassNotFound.getMessage()) newNoClassDefFoundError(); dup_x1(); swap(); // Retrieve the message from the old exception invokeThrowableGetMessage(); // Send the constructor taking a message string as an argument invokeNoClassDefFoundErrorStringConstructor(); athrow(); endLabel.place(); addStackMarker(fromPC, this.position); this.stackDepth = savedStackDepth; } }