Class UnitCompiler
- java.lang.Object
-
- org.codehaus.janino.UnitCompiler
-
public class UnitCompiler extends java.lang.ObjectThis class actually implements the Java compiler. It is associated with exactly one compilation unit which it compiles.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceUnitCompiler.ClassFileConsumer(package private) static interfaceUnitCompiler.CompilableHelper interface for string conversion.(package private) static interfaceUnitCompiler.Compilable2Interface for delayed code generation.static classUnitCompiler.SimpleIFieldShort-hand implementation ofIClass.IFieldthat implements a non-constant, non-static, package-accessible field.private static classUnitCompiler.SwitchKind
-
Field Summary
Fields Modifier and Type Field Description private Java.AbstractCompilationUnitabstractCompilationUnitprivate CodeContextcodeContextprivate intcompileErrorCountprivate ErrorHandlercompileErrorHandlerprivate booleandebugLinesprivate booleandebugSourceprivate booleandebugVarsprivate static intdefaultTargetVersionprivate static intEQprivate static intGEprivate static intGTprivate IClassLoaderiClassLoaderstatic booleanJUMP_IF_FALSESpecial value for the orientation parameter of thecompileBoolean(Java.Rvalue, CodeContext.Offset, boolean)methods, indicating that the code should be generated such that execution branches if the value on top of the operand stack is FALSE.static booleanJUMP_IF_TRUESpecial value for the orientation parameter of thecompileBoolean(Java.Rvalue, CodeContext.Offset, boolean)methods, indicating that the code should be generated such that execution branches if the value on top of the operand stack is TRUE.private static intLEprivate static java.util.logging.LoggerLOGGERprivate static java.util.regex.PatternLOOKS_LIKE_TYPE_PARAMETERprivate static intLTprivate static Visitor.ArrayInitializerOrRvalueVisitor<java.lang.Boolean,java.lang.RuntimeException>MAY_HAVE_SIDE_EFFECTS_VISITORprivate static intNEstatic java.lang.ObjectNOT_CONSTANTSpecial return value for thegetConstantValue(Java.Rvalue)method family indicating that the givenJava.Rvaluedoes not evaluate to a constant value.private java.util.Map<java.lang.String,IClass>onDemandImportableTypesprivate java.util.EnumSet<JaninoOption>optionsprivate static java.util.Map<java.lang.String,int[]>PRIMITIVE_NARROWING_CONVERSIONSprivate static java.util.Map<java.lang.String,int[]>PRIMITIVE_WIDENING_CONVERSIONSprivate java.util.Map<java.lang.String,java.lang.String[]>singleTypeImportsTo be used only bygetSingleTypeImport(String, Location);nullmeans "not yet initialized"private UnitCompiler.ClassFileConsumerstoresClassFilesNon-nullwhilecompileUnit(boolean, boolean, boolean, ClassFileConsumer)is executing.private static intSTRING_CONCAT_LIMITThis constant determines the number of operands up to which theprivate inttargetVersionJava version to compile for.private static java.util.regex.PatternTWO_E_31_INTEGER2147483648 is the special value that can not be stored in an INT, but its negated value (-2147483648) can.private static java.util.regex.PatternTWO_E_63_LONG9223372036854775808 is the special value that can not be stored in a LONG, but its negated value (-9223372036854775808) can.private WarningHandlerwarningHandler
-
Constructor Summary
Constructors Constructor Description UnitCompiler(Java.AbstractCompilationUnit abstractCompilationUnit, IClassLoader iClassLoader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private shortaccessFlags(Java.Modifier[] modifiers)private static Java.Modifier[]accessModifiers(Location location, java.lang.String... keywords)private voidaconstnull(Java.Locatable locatable)private voidadd(Java.Locatable locatable)private voidaddClassFile(ClassFile cf)Adds the givenClassFileto the result set.private shortaddConstantClassInfo(IClass iClass)private shortaddConstantDoubleInfo(double value)private shortaddConstantFieldrefInfo(IClass iClass, java.lang.String fieldName, IClass fieldType)private shortaddConstantFloatInfo(float value)private shortaddConstantIntegerInfo(int value)private shortaddConstantInterfaceMethodrefInfo(IClass iClass, java.lang.String methodName, java.lang.String methodFd)private shortaddConstantLongInfo(long value)private shortaddConstantMethodrefInfo(IClass iClass, java.lang.String methodName, java.lang.String methodFd)private shortaddConstantStringInfo(java.lang.String value)private voidaddFields(Java.FieldDeclaration fd, ClassFile cf)Creates and addsClassFile.FieldInfos to the cf for all fields declared by the fd.private voidaddLineNumberOffset(Java.Locatable locatable)private static ClassFile.MethodInfoaddMethodInfo(Java.Locatable locatable, ClassFile classFile, short accessFlags, java.lang.String methodName, MethodDescriptor methodMd)private static java.lang.String[]allButLast(java.lang.String[] sa)private Java.LocalVariableallocateLocalVariable(boolean finaL, IType localVariableType)private Java.LocalVariableallocateLocalVariableAndMarkAsInitialized(boolean finaL, IType localVariableType)private Java.LocalVariableSlotallocateLocalVariableSlot(IType localVariableType, java.lang.String localVariableName)private Java.LocalVariableSlotallocateLocalVariableSlotAndMarkAsInitialized(IType localVariableType, java.lang.String localVariableName)private voidandOrXor(Java.Locatable locatable, java.lang.String operator)private voidanewarray(Java.Locatable locatable, IClass componentType)private voidarraylength(Java.Locatable locatable)private voidarraystore(Java.Locatable locatable, IType lhsComponentType)private static <T> TassertNonNull(T subject)private voidassignmentConversion(Java.Locatable locatable, IType sourceType, IType targetType, java.lang.Object constantValue)Implements "assignment conversion" (JLS7 5.2) (more precisely: "assignment contexts".)(package private) voidassignSyntheticParametersToSyntheticFields(Java.ConstructorDeclarator cd)Copies the values of the synthetic parameters of this constructor ("this$..." and "val$...") to the synthetic fields of the object ("this$..." and "val$...").private voidathrow(Java.Locatable locatable)private IClassbinaryNumericPromotionType(Java.Locatable locatable, IType type1, IType type2)private voidboxingConversion(Java.Locatable locatable, IType sourceType, IType targetType)private voidbuildLocalVariableMap(Java.Block block, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private java.util.Map<java.lang.String,Java.LocalVariable>buildLocalVariableMap(Java.BlockStatement blockStatement, java.util.Map<java.lang.String,Java.LocalVariable> localVars)Computes and fills in the 'local variable map' for the given blockStatement.protected voidbuildLocalVariableMap(Java.CatchClause catchClause, java.util.Map<java.lang.String,Java.LocalVariable> localVars)Adds the given localVars to the 'local variable map' of the given catchClause.private static java.util.Map<java.lang.String,Java.LocalVariable>buildLocalVariableMap(Java.ConstructorInvocation ci, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.DoStatement ds, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.ForEachStatement fes, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.ForStatement fs, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.FunctionDeclarator fd)private voidbuildLocalVariableMap(Java.IfStatement is, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.Initializer i, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private java.util.Map<java.lang.String,Java.LocalVariable>buildLocalVariableMap(Java.LabeledStatement ls, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private java.util.Map<java.lang.String,Java.LocalVariable>buildLocalVariableMap(Java.LocalVariableDeclarationStatement lvds, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private static java.util.Map<java.lang.String,Java.LocalVariable>buildLocalVariableMap(Java.Statement s, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.SwitchStatement ss, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.SynchronizedStatement ss, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.TryStatement ts, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidbuildLocalVariableMap(Java.WhileStatement ws, java.util.Map<java.lang.String,Java.LocalVariable> localVars)private voidcastConversion(Java.Locatable locatable, IType sourceType, IType targetType, java.lang.Object constantValue)private static shortchangeAccessibility(short accessFlags, short newAccessibility)private voidcheckAccessible(IClass.IMember member, Java.Scope contextScope, Location location)Checks whether the givenIClass.IMemberis accessible in the given context, according to JLS7 6.6.1.BL1.B4.private voidcheckAccessible(IClass type, Java.Scope contextScope, Location location)Checks whether the givenIClassis accessible in the given context, according to JLS7 6.6.1.2 and 6.6.1.4.private voidcheckcast(Java.Locatable locatable, IType targetType)private voidcheckForConflictWithSingleTypeImport(java.lang.String name, Location location)private voidcheckForNameConflictWithAnotherPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)private voidcheckMemberAccessible(IClass iClassDeclaringMember, IClass.IMember member, Java.Scope contextScope, Location location)Verifies that a member (class, interface, field or method) declared in a given class is accessible from a given block statement context, according to JLS7 6.6.1.4.private voidcheckThrownException(Java.Locatable locatable, IType type, Java.Scope scope)private voidcheckThrownExceptions(Java.Invocation in, IClass.IMethod iMethod)private voidcmp(Java.Locatable locatable, int opIdx)private ITypecommonSupertype(IType t1, IType t2)private ITypecommonSupertype2(IType t1, IType t2)private voidcompile(Java.ArrayInitializerOrRvalue aiorv, IType arrayType)private booleancompile(Java.BlockStatement bs)private voidcompile(Java.FunctionDeclarator fd, ClassFile classFile)private voidcompile(Java.Rvalue rv)SomeJava.Rvalues compile more efficiently when their value is not needed, e.g.private voidcompile(Java.TypeDeclaration td)private voidcompile2(Java.AbstractClassDeclaration cd)private booleancompile2(Java.AlternateConstructorInvocation aci)private voidcompile2(Java.AnonymousClassDeclaration acd)private booleancompile2(Java.AssertStatement as)private voidcompile2(Java.Assignment a)private booleancompile2(Java.Block b)private booleancompile2(Java.BreakStatement bs)private voidcompile2(Java.CompilationUnit cu)Compiles an (ordinary, not modular) compilation unitprivate booleancompile2(Java.ContinueStatement cs)private voidcompile2(Java.Crement c)private booleancompile2(Java.DoStatement ds)private booleancompile2(Java.EmptyStatement es)private booleancompile2(Java.ExpressionStatement ee)private booleancompile2(Java.FieldDeclaration fd)private booleancompile2(Java.ForEachStatement fes)private booleancompile2(Java.ForStatement fs)private voidcompile2(Java.FunctionDeclarator fd, ClassFile classFile)private booleancompile2(Java.IfStatement is)private booleancompile2(Java.Initializer i)private voidcompile2(Java.InnerClassDeclaration icd)private voidcompile2(Java.InterfaceDeclaration id)private booleancompile2(Java.LabeledStatement ls)private voidcompile2(Java.LocalClassDeclaration lcd)private booleancompile2(Java.LocalClassDeclarationStatement lcds)private booleancompile2(Java.LocalVariableDeclarationStatement lvds)private voidcompile2(Java.ModularCompilationUnit mcu)private voidcompile2(Java.PackageMemberClassDeclaration pmcd)Compiles a top-level class or enum declaration.private voidcompile2(Java.PackageMemberInterfaceDeclaration pmid)Compiles a top-level interface or annotation type declaration.private voidcompile2(Java.ParenthesizedExpression pe)private booleancompile2(Java.ReturnStatement rs)private voidcompile2(Java.Rvalue rv)private booleancompile2(Java.SuperConstructorInvocation sci)private booleancompile2(Java.SwitchStatement ss)private booleancompile2(Java.SynchronizedStatement ss)private booleancompile2(Java.ThrowStatement ts)private booleancompile2(Java.TryStatement ts)private booleancompile2(Java.WhileStatement ws)private voidcompileAnnotations(Java.Annotation[] annotations, Annotatable target, ClassFile cf)Converts and adds the annotations to the target.private ITypecompileArithmeticBinaryOperation(Java.Locatable locatable, IType lhsType, java.lang.String operator, Java.Rvalue rhs)The LHS operand of type lhsType is expected on the stack.private ITypecompileArithmeticOperation(Java.Locatable locatable, IType firstOperandType, java.util.Iterator<Java.Rvalue> operands, java.lang.String operator)Executes an arithmetic operation on a sequence of operands.private voidcompileBoolean(Java.Rvalue rv, CodeContext.Offset dst, boolean orientation)Compiles anJava.Rvalueand branches, depending on the value.private voidcompileBoolean2(Java.BinaryOperation bo, CodeContext.Offset dst, boolean orientation)private voidcompileBoolean2(Java.ParenthesizedExpression pe, CodeContext.Offset dst, boolean orientation)private voidcompileBoolean2(Java.Rvalue rv, CodeContext.Offset dst, boolean orientation)private voidcompileBoolean2(Java.UnaryOperation ue, CodeContext.Offset dst, boolean orientation)private intcompileContext(Java.Rvalue rv)Generates code that determines the context of theJava.Rvalueand puts it on the operand stack.private intcompileContext2(Java.AmbiguousName an)private intcompileContext2(Java.ArrayAccessExpression aae)Array access expression; see JLS7 15.13 / JLS8+ 15.10.3.private intcompileContext2(Java.ArrayLength al)private intcompileContext2(Java.FieldAccess fa)private intcompileContext2(Java.FieldAccessExpression fae)private intcompileContext2(Java.ParenthesizedExpression pe)private intcompileContext2(Java.Rvalue rv)private intcompileContext2(Java.SuperclassFieldAccessExpression scfae)private voidcompileDeclaredMemberTypes(Java.TypeDeclaration decl, ClassFile cf)Compiles all of the types for this declarationprivate voidcompileDeclaredMethods(Java.TypeDeclaration typeDeclaration, ClassFile cf)Compiles all of the methods for this declarationprivate voidcompileDeclaredMethods(Java.TypeDeclaration typeDeclaration, ClassFile cf, int startPos)Compiles methods for this declaration starting at startPos.private ClassFile.ElementValuecompileElementValue(Java.ElementValue elementValue, ClassFile cf, boolean compileAsArray)private voidcompileError(java.lang.String message)Equivalent withcompileError(String, Location)with anulllocation argument.private voidcompileError(java.lang.String message, Location location)Issues a compile error with the given message.private static CompileExceptioncompileException(Java.Locatable locatable, java.lang.String message)private IClass.IFieldcompileField(Java.TypeDeclaration declaringType, Java.Annotation[] annotations, Access access, boolean statiC, boolean finaL, Java.Type type, int brackets, java.lang.String name, Java.ArrayInitializerOrRvalue initializer)Compiles one variable declarator into anIClass.IField.private IClass.IField[]compileFields(Java.FieldDeclaration fieldDeclaration)private ITypecompileGet(Java.Rvalue rv)Generates code that determines the value of theJava.Rvalueand puts it on the operand stack.private ITypecompileGet2(Java.AmbiguousName an)private ITypecompileGet2(Java.ArrayAccessExpression aae)private IClasscompileGet2(Java.ArrayCreationReference acr)private IClasscompileGet2(Java.ArrayLength al)private ITypecompileGet2(Java.Assignment a)private ITypecompileGet2(Java.BinaryOperation bo)private IClasscompileGet2(Java.BooleanRvalue brv)private ITypecompileGet2(Java.Cast c)private IClasscompileGet2(Java.ClassInstanceCreationReference cicr)private IClasscompileGet2(Java.ClassLiteral cl)private ITypecompileGet2(Java.ConditionalExpression ce)private ITypecompileGet2(Java.Crement c)private ITypecompileGet2(Java.FieldAccess fa)private ITypecompileGet2(Java.FieldAccessExpression fae)private IClasscompileGet2(Java.Instanceof io)private IClasscompileGet2(Java.LambdaExpression le)private IClasscompileGet2(Java.Literal l)private ITypecompileGet2(Java.LocalVariableAccess lva)private IClasscompileGet2(Java.MethodInvocation mi)private IClasscompileGet2(Java.MethodReference mr)private IClasscompileGet2(Java.NewAnonymousClassInstance naci)private IClasscompileGet2(Java.NewArray na)private ITypecompileGet2(Java.NewClassInstance nci)private ITypecompileGet2(Java.NewInitializedArray nia)private ITypecompileGet2(Java.ParameterAccess pa)private ITypecompileGet2(Java.ParenthesizedExpression pe)private ITypecompileGet2(Java.QualifiedThisReference qtr)private IClasscompileGet2(Java.SimpleConstant sl)private ITypecompileGet2(Java.SuperclassFieldAccessExpression scfae)private IClasscompileGet2(Java.SuperclassMethodInvocation scmi)private IClasscompileGet2(Java.ThisReference tr)private IClasscompileGet2(Java.UnaryOperation uo)private voidcompileGetValue(Java.ArrayInitializer ai, IType arrayType)private ITypecompileGetValue(Java.Rvalue rv)Convenience function that callscompileContext(Rvalue)andcompileGet(Rvalue).private voidcompileSet(Java.Lvalue lv)Generates code that stores a value in theJava.Lvalue.private voidcompileSet2(Java.AmbiguousName an)private voidcompileSet2(Java.ArrayAccessExpression aae)private voidcompileSet2(Java.FieldAccess fa)private voidcompileSet2(Java.FieldAccessExpression fae)private voidcompileSet2(Java.LocalVariableAccess lva)private voidcompileSet2(Java.ParenthesizedExpression pe)private voidcompileSet2(Java.SuperclassFieldAccessExpression scfae)private booleancompileStatements(java.util.List<? extends Java.BlockStatement> statements)private IClasscompileStringConcatenation(Java.Locatable locatable, IType type, Java.Rvalue secondOperand, java.util.Iterator<Java.Rvalue> operands)private booleancompileTryCatch(Java.TryStatement tryStatement, UnitCompiler.Compilable2 compileBody, CodeContext.Offset beginningOfBody, CodeContext.Offset afterStatement)Generates code for a TRY statement without resources and without a FINALLY clause.private booleancompileTryCatchFinally(Java.TryStatement ts, UnitCompiler.Compilable2 compileBody, Java.BlockStatement finallY)Generates code for a TRY statement without resources, but with an (optional) FINALLY clause.private booleancompileTryCatchFinallyWithResources(Java.TryStatement ts, java.util.List<Java.TryStatement.Resource> resources, UnitCompiler.Compilable2 compileBody, Java.Block finallY)Generates code for a TRY statement with (possibly zero) resources and an (optional) FINALLY clause.private booleancompileUnconditionalLoop(Java.ContinuableStatement cs, Java.BlockStatement body, Java.Rvalue[] update)private booleancompileUnconditionalLoopWithUpdate(Java.ContinuableStatement cs, Java.BlockStatement body, Java.Rvalue[] update)voidcompileUnit(boolean debugSource, boolean debugLines, boolean debugVars, java.util.Collection<ClassFile> generatedClassFiles)Generates a set ofClassFileobjects which represent the classes and interfaces declared in the compilation unit.voidcompileUnit(boolean debugSource, boolean debugLines, boolean debugVars, UnitCompiler.ClassFileConsumer storesClassFiles)Generates a set ofClassFileobjects which represent the classes and interfaces declared in the compilation unit.private static java.lang.String[]concat(java.lang.String[] sa, java.lang.String s)private voidconsT(Java.Locatable locatable, double value)private voidconsT(Java.Locatable locatable, float value)private voidconsT(Java.Locatable locatable, int value)private voidconsT(Java.Locatable locatable, long value)private IClassconsT(Java.Locatable locatable, java.lang.Object value)Pushes one value on the operand stack and pushes the respectiveClassFile.StackMapTableAttribute.VerificationTypeInfooperand to the stack map.private voidconsT(Java.Locatable locatable, java.lang.String s)private voidconsT(Java.Locatable locatable, IClass iClass)private voidconsT(Java.Locatable locatable, IClass t, int value)private java.lang.ObjectconstantAssignmentConversion(Java.Locatable locatable, java.lang.Object value, IType targetType)Implements "assignment conversion" (JLS7 5.2) on a constant value.private IClassconvertToPrimitiveNumericType(Java.Locatable locatable, IType type)If the given type is a primitive type, return that type.private Java.RvaluedetermineValue(Java.FieldAccessExpression fae)private Java.RvaluedetermineValue(Java.SuperclassFieldAccessExpression scfae)"super.fld", "Type.super.fld"private voiddup(Java.Locatable locatable)Duplicates the top operand: ...private voiddup2(Java.Locatable locatable)Duplicates the top two operands: ...private voiddupn(Java.Locatable locatable, int n)Duplicates the top n operands.private voiddupx(Java.Locatable locatable)Copies the top operand one position down: b a => a b aprivate voiddupx2(Java.Locatable locatable)Copies the top operand two positions down: c b a => a c b a.private voiddupxx(Java.Locatable locatable, int positions)Copies the top operand positions down.private booleanfakeCompile(Java.BlockStatement bs)Called to check whether the givenJava.BlockStatementcompiles or not.private voidfakeCompile(Java.Rvalue rv)Called to check whether the givenJava.Rvaluecompiles or not.private voidfakeCompileVariableDeclaratorsAndInitializers(Java.AbstractClassDeclaration cd)private IClass.IMethodfakeIMethod(IClass targetType, java.lang.String name, Java.Rvalue[] arguments)private static voidfillConversionMap(java.lang.Object[] array, java.util.Map<java.lang.String,int[]> map)IClassfindClass(java.lang.String className)Finds one class or interface declaration in this compilation unit and resolves it into anIClass.private IClass.IFieldfindIField(IClass iClass, java.lang.String name, Location location)Finds a named field in the givenIClass.private IClass.IMethodfindIMethod(IType targetType, Java.Invocation invocation)Finds aIClass.IMethodin the given targetType, its superclasses or superinterfaces which is applicable with the given invocation.IClass.IMethodfindIMethod(Java.MethodInvocation mi)Finds methods of the mi.targetnamed mi.methodName, examines the argument types and chooses the most specific method.IClass.IMethodfindIMethod(Java.SuperclassMethodInvocation superclassMethodInvocation)private static Java.LocalClassDeclarationfindLocalClassDeclaration(Java.Scope s, java.lang.String name)Finds a local class declared in any block enclosing the given block statement.private IClassfindMemberType(IType iType, java.lang.String name, Java.TypeArgument[] typeArguments, Location location)Finds a named type in the givenIClassorIParameterizedType.IClass.IInvocablefindMostSpecificIInvocable(Java.Locatable locatable, IClass.IInvocable[] iInvocables, IClass[] argumentTypes, boolean boxingPermitted, Java.Scope contextScope)Determines the applicable invocables and choose the most specific invocable.private IClass.IInvocablefindMostSpecificIInvocable(Java.Locatable locatable, IClass.IInvocable[] iInvocables, Java.Rvalue[] arguments, Java.Scope contextScope)Determines the arguments' types, determine the applicable invocables and choose the most specific invocable and adjust arguments as needed (for varargs case).private IClassfindTypeByFullyQualifiedName(Location location, java.lang.String[] identifiers)Attempts to load anIClassby fully-qualified name throughiClassLoader.private IClassfindTypeByName(Location location, java.lang.String className)Finds the namedIClassin this compilation unit, or through theiClassLoader.private voidgenerateBridgeMethod(ClassFile cf, IClass declaringIClass, IClass.IMethod base, IClass.IMethod override)Generates and compiles a bridge method with signature base that delegates to override.private booleangeneratesCode(Java.BlockStatement bs)Checks whether invocation ofcompile(BlockStatement)would generate more than zero code bytes.private booleangeneratesCode2(java.util.List<Java.BlockStatement> l)private booleangeneratesCode2(Java.AssertStatement as)private booleangeneratesCode2(Java.Block b)private booleangeneratesCode2(Java.BlockStatement bs)private booleangeneratesCode2(Java.EmptyStatement es)private booleangeneratesCode2(Java.FieldDeclaration fd)private booleangeneratesCode2(Java.Initializer i)private booleangeneratesCode2(Java.LocalClassDeclarationStatement lcds)Java.AbstractCompilationUnitgetAbstractCompilationUnit()private CodeContextgetCodeContext()private static ITypegetComponentType(IType expressionType)java.lang.ObjectgetConstantValue(Java.ArrayInitializerOrRvalue rv)Attempts to evaluate as a constant expression.java.lang.ObjectgetConstantValue(Java.Rvalue rv)Attempts to evaluate as a constant expression.private java.lang.ObjectgetConstantValue2(Java.AmbiguousName an)private java.lang.ObjectgetConstantValue2(Java.BinaryOperation bo)private booleangetConstantValue2(Java.BooleanLiteral bl)private java.lang.ObjectgetConstantValue2(Java.Cast c)private chargetConstantValue2(Java.CharacterLiteral cl)private java.lang.ObjectgetConstantValue2(Java.ConditionalExpression ce)private java.lang.ObjectgetConstantValue2(Java.FieldAccess fa)private java.lang.ObjectgetConstantValue2(Java.FloatingPointLiteral fpl)private java.lang.ObjectgetConstantValue2(Java.IntegerLiteral il)private java.lang.ObjectgetConstantValue2(Java.LocalVariableAccess lva)private java.lang.ObjectgetConstantValue2(Java.NullLiteral nl)private java.lang.ObjectgetConstantValue2(Java.ParenthesizedExpression pe)private java.lang.ObjectgetConstantValue2(Java.Rvalue rv)private java.lang.ObjectgetConstantValue2(Java.SimpleConstant sl)private java.lang.StringgetConstantValue2(Java.StringLiteral sl)private java.lang.ObjectgetConstantValue2(Java.UnaryOperation uo)private Java.AbstractClassDeclarationgetDeclaringClass(Java.QualifiedThisReference qtr)private Java.TypeBodyDeclarationgetDeclaringTypeBodyDeclaration(Java.QualifiedThisReference qtr)private voidgetfield(Java.Locatable locatable, IClass.IField iField)private voidgetfield(Java.Locatable locatable, IClass declaringIClass, java.lang.String fieldName, IClass fieldType, boolean statiC)private IClassgetIClass(Java.ThisReference tr)voidgetIMethods(IClass type, java.lang.String methodName, java.util.List<IClass.IMethod> v)Adds all methods with the given methodName that are declared by the type, its superclasses and all their superinterfaces to the result list v.private static IType[]getInterfaces(IType t1)Java.LocalVariablegetLocalVariable(Java.CatchParameter parameter)Java.LocalVariablegetLocalVariable(Java.FunctionDeclarator.FormalParameter parameter)Java.LocalVariablegetLocalVariable(Java.FunctionDeclarator.FormalParameter parameter, boolean isVariableArityParameter)Java.LocalVariablegetLocalVariable(Java.LocalVariableDeclarationStatement lvds, Java.VariableDeclarator vd)private ClassFile.StackMapTableAttribute.VerificationTypeInfogetLocalVariableTypeInfo(short lvIndex)(package private) Java.ArrayInitializerOrRvaluegetNonConstantFinalInitializer(Java.FieldDeclaration fd, Java.VariableDeclarator vd)Determines the non-constant-final initializer of the givenJava.VariableDeclarator.(package private) static Java.TypeDeclarationgetOuterClass(Java.TypeDeclaration typeDeclaration)private static java.util.List<Java.TypeDeclaration>getOuterClasses(Java.TypeDeclaration inner)Returns a list consisting of the given inner class and all its enclosing (outer) classes.private IClassgetRawReferenceType(Location location, java.lang.String simpleTypeName, Java.Scope scope)private IClassgetRawType(Java.Type t)private ITypegetReferenceType(Location location, java.lang.String simpleTypeName, Java.TypeArgument[] typeArguments, Java.Scope scope)JLS7 6.5.5.1 Simple type name (single identifier)private ITypegetReferenceType(Location location, Java.Scope scope, java.lang.String[] identifiers, int n, Java.TypeArgument[] typeArguments)private ITypegetReturnType(Java.FunctionDeclarator fd)java.lang.String[]getSingleTypeImport(java.lang.String name, Location location)Checks if the given simple name was imported through a single type import.private static ITypegetSuperclass(IType type)private ITypegetTargetIType(Java.QualifiedThisReference qtr)private intgetTargetVersion()private ITypegetType(Java.Atom a)private ITypegetType(Java.Lvalue lv)private ITypegetType(Java.Rvalue rv)private ITypegetType(Java.Type t)private ITypegetType2(Java.AmbiguousName an)private ITypegetType2(Java.ArrayAccessExpression aae)private IClassgetType2(Java.ArrayCreationReference acr)private IClassgetType2(Java.ArrayLength al)private IClassgetType2(Java.ArrayType at)private ITypegetType2(Java.Assignment a)private ITypegetType2(Java.BinaryOperation bo)private IClassgetType2(Java.BooleanLiteral bl)private ITypegetType2(Java.Cast c)private IClassgetType2(Java.CharacterLiteral cl)private IClassgetType2(Java.ClassInstanceCreationReference cicr)private IClassgetType2(Java.ClassLiteral cl)private ITypegetType2(Java.ConditionalExpression ce)private IClassgetType2(Java.ConstructorInvocation ci)private ITypegetType2(Java.Crement c)private ITypegetType2(Java.FieldAccess fa)private ITypegetType2(Java.FieldAccessExpression fae)private IClassgetType2(Java.FloatingPointLiteral fpl)private IClassgetType2(Java.Instanceof io)private IClassgetType2(Java.IntegerLiteral il)private IClassgetType2(Java.LambdaExpression le)private ITypegetType2(Java.LocalVariableAccess lva)private IClassgetType2(Java.MethodInvocation mi)private IClassgetType2(Java.MethodReference mr)private IClassgetType2(Java.NewAnonymousClassInstance naci)private IClassgetType2(Java.NewArray na)private ITypegetType2(Java.NewClassInstance nci)private ITypegetType2(Java.NewInitializedArray nia)private IClassgetType2(Java.NullLiteral nl)private IClassgetType2(Java.Package p)private ITypegetType2(Java.ParameterAccess pa)private ITypegetType2(Java.ParenthesizedExpression pe)private IClassgetType2(Java.PrimitiveType bt)private ITypegetType2(Java.QualifiedThisReference qtr)private ITypegetType2(Java.ReferenceType rt)private IClassgetType2(Java.RvalueMemberType rvmt)private IClassgetType2(Java.SimpleConstant sl)private ITypegetType2(Java.SimpleType st)private IClassgetType2(Java.StringLiteral sl)private ITypegetType2(Java.SuperclassFieldAccessExpression scfae)private IClassgetType2(Java.SuperclassMethodInvocation scmi)private IClassgetType2(Java.ThisReference tr)private IClassgetType2(Java.UnaryOperation uo)private java.util.Collection<Java.AbstractCompilationUnit.TypeImportOnDemandDeclaration>getTypeImportOnDemandImportDeclarations()private IType[]getTypes(Java.Type[] types)private ITypegetUnboxedType(IType type)private CodeContext.OffsetgetWhereToBreak(Java.BreakableStatement bs)private voidgotO(Java.Locatable locatable, CodeContext.Offset dst)private booleanhasAnnotation(Java.FunctionDeclarator fd, IClass annotationType)private voidif_acmpxx(Java.Locatable locatable, int opIdx, CodeContext.Offset dst)private voidif_icmpxx(Java.Locatable locatable, int opIdx, CodeContext.Offset dst)private voidifnonnull(Java.Locatable locatable, CodeContext.Offset dst)private voidifnull(Java.Locatable locatable, CodeContext.Offset dst)private voidifNumeric(Java.Locatable locatable, int opIdx, CodeContext.Offset dst, boolean orientation)private voidifxx(Java.Locatable locatable, int opIdx, CodeContext.Offset dst)private voidiinc(Java.Locatable locatable, Java.LocalVariable lv, java.lang.String operator)private static intil(ClassFile.StackMapTableAttribute.VerificationTypeInfo vti)private static intilfd(IType t)private static intilfd(ClassFile.StackMapTableAttribute.VerificationTypeInfo vti)private static intilfda(IType t)private static intilfdabcs(IClass t)private java.util.List<java.lang.Object>importSingleStatic(java.lang.String simpleName)Imports a member class, member interface, static field or static method via the compilation unit's single static import declarations.private IClassimportSingleType(java.lang.String simpleTypeName, Location location)If the given name was declared in a simple type import, load that class.private voidimportStatic(IClass declaringIClass, java.lang.String simpleName, java.util.Collection<java.lang.Object> result, Location location)Finds all members (member classes, member interfaces, static fields and/or static methods) of the declaringIClass with the given simpleName and adds them to the result.private java.util.List<java.lang.Object>importStaticOnDemand(java.lang.String simpleName)Imports a member class or interface, static field or static method via the compilation unit's static import on-demand declarations.IClassimportTypeOnDemand(java.lang.String simpleTypeName, Location location)6.5.2.BL1.B1.B5, 6.5.2.BL1.B1.B6 Type-import-on-demand.
6.5.5.1.6 Type-import-on-demand declaration.private IClassimportTypeOnDemand2(java.lang.String simpleTypeName, Location location)(package private) voidinitializeInstanceVariablesAndInvokeInstanceInitializers(Java.ConstructorDeclarator cd)Compiles the instance variable initializers and the instance initializers in their lexical order.private voidinstanceoF(Java.Locatable locatable, IType rhsType)private java.lang.StringinternalCheckAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.Scope contextScope)private java.lang.StringinternalCheckAccessible(IClass type, Java.Scope contextScope)private voidinvoke(Java.Locatable locatable, int opcode, IClass declaringIClass, java.lang.String methodName, MethodDescriptor methodDescriptor, boolean useInterfaceMethodRef)Expects the target object and the arguments on the operand stack.private voidinvokeConstructor(Java.Locatable locatable, IClass.IConstructor iConstructor)Invokes the iConstructor; assumes thatthisand the correct number and types of arguments are on the operand stack.private voidinvokeConstructor(Java.Locatable locatable, Java.Scope scope, Java.Rvalue enclosingInstance, IType targetType, Java.Rvalue[] arguments)Expects the object to initialize on the stack.private voidinvokeMethod(Java.Locatable locatable, IClass.IMethod iMethod)Invokes the iMethod; assumes thatthis(unless iMethod is static) and the correct number and types of arguments are on the operand stack.private booleanisAccessible(IClass.IMember member, Java.Scope contextScope)Determines whether the givenIClass.IMemberis accessible in the given context, according to JLS7 6.6.1.BL1.B4.private booleanisAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.Scope contextScope)Determines whether a member (class, interface, field or method) declared in a given class is accessible from a given block statement context, according to JLS7 6.6.1.4.private booleanisAccessible(IClass type, Java.Scope contextScope)Determines whether the givenIClassis accessible in the given context, according to JLS7 6.6.1.2 and 6.6.1.4.private static booleanisArray(IType type)private static booleanisAssignableFrom(IType targetType, IType sourceType)private IClassisBoxingConvertible(IType sourceType)private static java.lang.ByteisByteConstant(java.lang.Object o)private booleanisCastReferenceConvertible(IType sourceType, IType targetType)JLS7 5.5private booleanisConvertibleToPrimitiveNumeric(IType sourceType)private booleanisIdentityConvertible(IType sourceType, IType targetType)Checks whether "identity conversion" (5.1.1) is possible.private static booleanisInterface(IType type)(package private) Java.LocalVariableisIntLv(Java.Crement c)Checks whether the operand is anintlocal variable.private booleanisMethodInvocationConvertible(IClass sourceType, IClass targetType, boolean boxingPermitted)Checks if "method invocation conversion" (5.3) is possible.private booleanisNarrowingPrimitiveConvertible(IType sourceType, IType targetType)Checks whether "narrowing primitive conversion" (JLS7 5.1.3) is possible.private booleanisNarrowingReferenceConvertible(IType sourceType, IType targetType)Checks whether "narrowing reference conversion" (JLS7 5.1.5) is possible.private booleanisNullConvertible(IType sourceType, IType targetType)private static booleanisPrimitive(IType type)private static booleanisStaticContext(Java.TypeBodyDeclaration tbd)private booleanisType(Java.Atom a)private booleanisType2(Java.AmbiguousName an)private booleanisType2(Java.Atom a)private IClassisUnboxingConvertible(IType sourceType)private booleanisWideningPrimitiveConvertible(IClass sourceType, IType targetType)private booleanisWideningReferenceConvertible(IType sourceType, IType targetType)Checks if "widening reference conversion" (5.1.4) is possible.private voidl2i(Java.Locatable locatable)private static java.lang.Stringlast(java.lang.String[] sa)private voidleave(Java.BlockStatement bs)Cleans up the statement context.private voidleave2(Java.BlockStatement bs)private voidleave2(Java.SynchronizedStatement ss)private voidleave2(Java.TryStatement ts)private voidleaveStatements(Java.Scope from, Java.Scope to)Statements that jump out of blocks (return,break,continue) must call this method to make sure that thefinallyclauses of alltry ... catchandsynchronizedstatements are executed.private voidload(Java.Locatable locatable, IType localVariableType, int localVariableIndex)private ITypeload(Java.Locatable locatable, Java.LocalVariable localVariable)private voidlookupswitch(Java.Locatable locatable, java.util.SortedMap<java.lang.Integer,CodeContext.Offset> caseLabelMap, CodeContext.Offset defaultLabelOffset)private static voidmakeLocalVariableNames(CodeContext cc, ClassFile.MethodInfo mi)Makes the variable name and class name Constant Pool names used by local variables.private static java.lang.String[]makeUtf8Able(java.lang.String s)Only strings that can be UTF8-encoded into 65535 bytes can be stored as a constant string info.private voidmaybeCreateInitMethod(Java.TypeDeclaration td, ClassFile cf, java.util.List<Java.BlockStatement> statements)Creates class/interface initialization method iff there is any initialization code.private static booleanmayHaveSideEffects(Java.ArrayInitializerOrRvalue arrayInitializerOrRvalue)private static booleanmayHaveSideEffects(Java.ArrayInitializerOrRvalue... arrayInitializersOrRvalues)private voidmonitorenter(Java.Locatable locatable)private voidmonitorexit(Java.Locatable locatable)private voidmulDivRemAddSub(Java.Locatable locatable, java.lang.String operator)private voidmultianewarray(Java.Locatable locatable, int dimExprCount, int dims, IType componentType)private voidneg(Java.Locatable locatable, IClass operandType)private voidneW(Java.Locatable locatable, IType iType)private voidnewarray(Java.Locatable locatable, IType componentType)private IClassnewArray(Java.Locatable locatable, int dimExprCount, int dims, IType componentType)Expects dimExprCount values of typeinton the operand stack.private ClassFilenewClassFile(short accessFlags, IClass iClass, IClass superclass, IClass[] interfaces)private voidnumericPromotion(Java.Locatable locatable, IType sourceType, IClass targetType)java.util.EnumSet<JaninoOption>options()UnitCompileroptions(java.util.EnumSet<JaninoOption> options)Sets the options for all future compilations.private booleanoverridesMethod(IClass.IMethod method, IClass type)private booleanoverridesMethodFromSupertype(IClass.IMethod m, IClass type)private voidpop(Java.Locatable locatable, IType type)private voidputfield(Java.Locatable locatable, IClass.IField iField)private static IClassrawTypeOf(IType iType)private static IClass[]rawTypesOf(IType[] iTypes)private Java.Atomreclassify(Java.AmbiguousName an)private Java.AtomreclassifyName(Location location, Java.Scope scope, java.lang.String identifier)JLS7 6.5.2.1private Java.AtomreclassifyName(Location location, Java.Scope scope, java.lang.String[] identifiers, int n)Reclassifies the ambiguous name consisting of the first n of the identifiers (JLS7 6.5.2.2).private voidreferenceThis(Java.Locatable locatable, IClass currentIClass)private voidreferenceThis(Java.Locatable locatable, Java.AbstractTypeDeclaration declaringType, Java.TypeBodyDeclaration declaringTypeBodyDeclaration, IType targetIType)private CodeContextreplaceCodeContext(CodeContext newCodeContext)private IClassresolve(Java.TypeDeclaration td)private voidreturN(Java.Locatable locatable)private voidreverseUnaryNumericPromotion(Java.Locatable locatable, IClass sourceType, IType targetType)voidsetCompileErrorHandler(ErrorHandler compileErrorHandler)By default,CompileExceptions are thrown on compile errors, but an application my install its own (thread-local)ErrorHandler.voidsetTargetVersion(int version)Generates class files that target a specified release of the virtual machine, in analogy with JAVAC's-targetcommand line option.voidsetWarningHandler(WarningHandler warningHandler)By default, warnings are discarded, but an application my install a customWarningHandler.private voidshift(Java.Locatable locatable, java.lang.String operator)private voidstore(Java.Locatable locatable, IType lvType, short lvIndex)private voidstore(Java.Locatable locatable, Java.LocalVariable localVariable)Assigns the top operand to the given local variable.private voidstringConversion(Java.Locatable locatable, IType sourceType)Converts object of type "sourceType" to type "String" (JLS7 15.18.1.1).private voidsub(Java.Locatable locatable)private voidswap(Java.Locatable locatable)private voidtableswitch(Java.Locatable locatable, java.util.SortedMap<java.lang.Integer,CodeContext.Offset> caseLabelMap, CodeContext.Offset defaultLabelOffset)private IClass.IAnnotationtoIAnnotation(Java.Annotation annotation)private IClass.IAnnotation[]toIAnnotations(Java.Annotation[] annotations)(package private) IClass.IConstructortoIConstructor(Java.ConstructorDeclarator constructorDeclarator)private IClass.IInvocabletoIInvocable(Java.FunctionDeclarator fd)IClass.IMethodtoIMethod(Java.MethodDeclarator methodDeclarator)private Java.LvaluetoLvalueOrCompileException(Java.Atom a)private Java.RvaluetoRvalueOrCompileException(Java.Atom a)private Java.TypetoTypeOrCompileException(Java.Atom a)private booleantryAssignmentConversion(Java.Locatable locatable, IType sourceType, IType targetType, java.lang.Object constantValue)private booleantryBoxingConversion(Java.Locatable locatable, IType sourceType, IType targetType)private booleantryCastConversion(Java.Locatable locatable, IType sourceType, IType targetType, java.lang.Object constantValue)private booleantryConstantAssignmentConversion(Java.Locatable locatable, java.lang.Object constantValue, IType targetType)Checks if "constant assignment conversion" (JLS7 5.2, paragraph 1) is possible.private booleantryIdentityConversion(IType sourceType, IType targetType)Implements "identity conversion" (5.1.1).private booleantryNarrowingPrimitiveConversion(Java.Locatable locatable, IType sourceType, IType targetType)Implements "narrowing primitive conversion" (JLS7 5.1.3).private booleantryNarrowingReferenceConversion(Java.Locatable locatable, IType sourceType, IType targetType)Implements "narrowing reference conversion" (5.1.5).private booleantryNullConversion(IType sourceType, IType targetType)JLS11 5.2: "Finally, a value of the null type (the null reference is the only such value) may be assigned to any reference type".private booleantryWideningPrimitiveConversion(Java.Locatable locatable, IType sourceType, IType targetType)Implements "widening primitive conversion" (5.1.2).private ITypetypeArgumentToIType(Java.TypeArgument ta)private IClassunaryNumericPromotion(Java.Locatable locatable, IType type)Implements "unary numeric promotion" (JLS7 5.6.1).private IClassunaryNumericPromotionType(Java.Locatable locatable, IType type)private voidunboxingConversion(Java.Locatable locatable, IType sourceType, IClass targetType)private static java.lang.Stringunescape(java.lang.String s, Location location)Decodes any escape sequences like\n, or\377, but not\uxxxx.private voidupdateLocalVariableInCurrentStackMap(short lvIndex, ClassFile.StackMapTableAttribute.VerificationTypeInfo vti)private ClassFile.StackMapTableAttribute.VerificationTypeInfoverificationTypeInfo(IType type)private voidwarning(java.lang.String handle, java.lang.String message, Location location)Issues a warning with the given message an location an returns.private voidwrite(int v)private voidwriteByte(int v)private voidwriteConstantClassInfo(IClass iClass)private voidwriteConstantFieldrefInfo(IClass iClass, java.lang.String fieldName, IClass fieldType)private voidwriteConstantInterfaceMethodrefInfo(IClass iClass, java.lang.String methodName, MethodDescriptor methodMd)private voidwriteConstantMethodrefInfo(IClass iClass, java.lang.String methodName, MethodDescriptor methodMd)private voidwriteInt(int v)private voidwriteLdc(short constantPoolIndex)private voidwriteLdc2(short constantPoolIndex)private voidwriteOffset(CodeContext.Offset src, CodeContext.Offset dst)private voidwriteShort(int v)private voidwriteUnsignedShort(int v)private voidxaload(Java.Locatable locatable, IType componentType)private voidxor(Java.Locatable locatable, int opcode)private voidxreturn(Java.Locatable locatable, IType returnType)
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
defaultTargetVersion
private static final int defaultTargetVersion
-
STRING_CONCAT_LIMIT
private static final int STRING_CONCAT_LIMIT
This constant determines the number of operands up to which thea.concat(b).concat(c)strategy is used to implement string concatenation. For more operands, the
new StringBuilder(a).append(b).append(c).append(d).toString()strategy is chosen.A very good article from Tom Gibara analyzes the impact of this decision and recommends a value of three.
- See Also:
- Constant Field Values
-
JUMP_IF_TRUE
public static final boolean JUMP_IF_TRUE
Special value for the orientation parameter of thecompileBoolean(Java.Rvalue, CodeContext.Offset, boolean)methods, indicating that the code should be generated such that execution branches if the value on top of the operand stack is TRUE.- See Also:
- Constant Field Values
-
JUMP_IF_FALSE
public static final boolean JUMP_IF_FALSE
Special value for the orientation parameter of thecompileBoolean(Java.Rvalue, CodeContext.Offset, boolean)methods, indicating that the code should be generated such that execution branches if the value on top of the operand stack is FALSE.- See Also:
- Constant Field Values
-
LOOKS_LIKE_TYPE_PARAMETER
private static final java.util.regex.Pattern LOOKS_LIKE_TYPE_PARAMETER
-
options
private java.util.EnumSet<JaninoOption> options
-
targetVersion
private int targetVersion
Java version to compile for.
-
MAY_HAVE_SIDE_EFFECTS_VISITOR
private static final Visitor.ArrayInitializerOrRvalueVisitor<java.lang.Boolean,java.lang.RuntimeException> MAY_HAVE_SIDE_EFFECTS_VISITOR
-
NOT_CONSTANT
public static final java.lang.Object NOT_CONSTANT
Special return value for thegetConstantValue(Java.Rvalue)method family indicating that the givenJava.Rvaluedoes not evaluate to a constant value.
-
TWO_E_31_INTEGER
private static final java.util.regex.Pattern TWO_E_31_INTEGER
2147483648 is the special value that can not be stored in an INT, but its negated value (-2147483648) can.
-
TWO_E_63_LONG
private static final java.util.regex.Pattern TWO_E_63_LONG
9223372036854775808 is the special value that can not be stored in a LONG, but its negated value (-9223372036854775808) can.
-
singleTypeImports
@Nullable private java.util.Map<java.lang.String,java.lang.String[]> singleTypeImports
To be used only bygetSingleTypeImport(String, Location);nullmeans "not yet initialized"
-
onDemandImportableTypes
private final java.util.Map<java.lang.String,IClass> onDemandImportableTypes
-
PRIMITIVE_WIDENING_CONVERSIONS
private static final java.util.Map<java.lang.String,int[]> PRIMITIVE_WIDENING_CONVERSIONS
-
PRIMITIVE_NARROWING_CONVERSIONS
private static final java.util.Map<java.lang.String,int[]> PRIMITIVE_NARROWING_CONVERSIONS
-
EQ
private static final int EQ
- See Also:
- Constant Field Values
-
NE
private static final int NE
- See Also:
- Constant Field Values
-
LT
private static final int LT
- See Also:
- Constant Field Values
-
GE
private static final int GE
- See Also:
- Constant Field Values
-
GT
private static final int GT
- See Also:
- Constant Field Values
-
LE
private static final int LE
- See Also:
- Constant Field Values
-
codeContext
@Nullable private CodeContext codeContext
-
compileErrorHandler
@Nullable private ErrorHandler compileErrorHandler
-
compileErrorCount
private int compileErrorCount
-
warningHandler
@Nullable private WarningHandler warningHandler
-
abstractCompilationUnit
private final Java.AbstractCompilationUnit abstractCompilationUnit
-
iClassLoader
private final IClassLoader iClassLoader
-
storesClassFiles
@Nullable private UnitCompiler.ClassFileConsumer storesClassFiles
Non-nullwhilecompileUnit(boolean, boolean, boolean, ClassFileConsumer)is executing.
-
debugSource
private boolean debugSource
-
debugLines
private boolean debugLines
-
debugVars
private boolean debugVars
-
-
Constructor Detail
-
UnitCompiler
public UnitCompiler(Java.AbstractCompilationUnit abstractCompilationUnit, IClassLoader iClassLoader)
-
-
Method Detail
-
options
public java.util.EnumSet<JaninoOption> options()
- Returns:
- A reference to the currently effective compilation options; changes to it take effect immediately
-
options
public UnitCompiler options(java.util.EnumSet<JaninoOption> options)
Sets the options for all future compilations.
-
setTargetVersion
public void setTargetVersion(int version)
Generates class files that target a specified release of the virtual machine, in analogy with JAVAC's-targetcommand line option. By default, Java 6 .class files are generated.
-
getAbstractCompilationUnit
public Java.AbstractCompilationUnit getAbstractCompilationUnit()
- Returns:
- The
Java.AbstractCompilationUnitthat thisUnitCompilercompiles
-
compileUnit
public void compileUnit(boolean debugSource, boolean debugLines, boolean debugVars, java.util.Collection<ClassFile> generatedClassFiles) throws CompileExceptionGenerates a set ofClassFileobjects which represent the classes and interfaces declared in the compilation unit.- Parameters:
generatedClassFiles- Adds generatedClassFiles to thisCollection- Throws:
CompileException
-
compileUnit
public void compileUnit(boolean debugSource, boolean debugLines, boolean debugVars, UnitCompiler.ClassFileConsumer storesClassFiles) throws CompileExceptionGenerates a set ofClassFileobjects which represent the classes and interfaces declared in the compilation unit.- Parameters:
storesClassFiles- Consumes each generatedClassFile- Throws:
CompileException
-
compile2
private void compile2(Java.CompilationUnit cu) throws CompileException
Compiles an (ordinary, not modular) compilation unit- Throws:
CompileException
-
compile2
private void compile2(Java.ModularCompilationUnit mcu) throws CompileException
- Throws:
CompileException
-
compile
private void compile(Java.TypeDeclaration td) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.PackageMemberClassDeclaration pmcd) throws CompileException
Compiles a top-level class or enum declaration.- Throws:
CompileException
-
compile2
private void compile2(Java.PackageMemberInterfaceDeclaration pmid) throws CompileException
Compiles a top-level interface or annotation type declaration.- Throws:
CompileException
-
checkForNameConflictWithAnotherPackageMemberTypeDeclaration
private void checkForNameConflictWithAnotherPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd) throws CompileException
- Throws:
CompileException
-
checkForConflictWithSingleTypeImport
private void checkForConflictWithSingleTypeImport(java.lang.String name, Location location) throws CompileException- Throws:
CompileException
-
compile2
private void compile2(Java.AbstractClassDeclaration cd) throws CompileException
- Throws:
CompileException
-
addFields
private void addFields(Java.FieldDeclaration fd, ClassFile cf) throws CompileException
Creates and addsClassFile.FieldInfos to the cf for all fields declared by the fd.- Throws:
CompileException
-
compile2
private void compile2(Java.AnonymousClassDeclaration acd) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.LocalClassDeclaration lcd) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.InnerClassDeclaration icd) throws CompileException
- Throws:
CompileException
-
fakeCompileVariableDeclaratorsAndInitializers
private void fakeCompileVariableDeclaratorsAndInitializers(Java.AbstractClassDeclaration cd) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.InterfaceDeclaration id) throws CompileException
- Throws:
CompileException
-
newClassFile
private ClassFile newClassFile(short accessFlags, IClass iClass, @Nullable IClass superclass, IClass[] interfaces) throws CompileException
- Parameters:
superclass-nullforObject,Objectfor interfaces- Throws:
CompileException
-
compileAnnotations
private void compileAnnotations(Java.Annotation[] annotations, Annotatable target, ClassFile cf) throws CompileException
Converts and adds the annotations to the target.- Throws:
CompileException
-
compileElementValue
private ClassFile.ElementValue compileElementValue(Java.ElementValue elementValue, ClassFile cf, boolean compileAsArray) throws CompileException
- Throws:
CompileException
-
maybeCreateInitMethod
private void maybeCreateInitMethod(Java.TypeDeclaration td, ClassFile cf, java.util.List<Java.BlockStatement> statements) throws CompileException
Creates class/interface initialization method iff there is any initialization code.- Parameters:
td- The type declarationcf- The class file into which to put the methodstatements- The statements for the method (possibly empty)- Throws:
CompileException
-
compileDeclaredMemberTypes
private void compileDeclaredMemberTypes(Java.TypeDeclaration decl, ClassFile cf) throws CompileException
Compiles all of the types for this declarationNB: as a side effect this will fill in the synthetic field map
- Throws:
CompileException
-
compileDeclaredMethods
private void compileDeclaredMethods(Java.TypeDeclaration typeDeclaration, ClassFile cf) throws CompileException
Compiles all of the methods for this declarationNB: as a side effect this will fill in the synthetic field map
- Throws:
CompileException
-
compileDeclaredMethods
private void compileDeclaredMethods(Java.TypeDeclaration typeDeclaration, ClassFile cf, int startPos) throws CompileException
Compiles methods for this declaration starting at startPos.- Parameters:
startPos- Starting parameter to fill in- Throws:
CompileException
-
hasAnnotation
private boolean hasAnnotation(Java.FunctionDeclarator fd, IClass annotationType) throws CompileException
- Throws:
CompileException
-
overridesMethodFromSupertype
private boolean overridesMethodFromSupertype(IClass.IMethod m, IClass type) throws CompileException
- Throws:
CompileException
-
overridesMethod
private boolean overridesMethod(IClass.IMethod method, IClass type) throws CompileException
- Returns:
- Whether method overrides a method of type or any of its supertypes
- Throws:
CompileException
-
generateBridgeMethod
private void generateBridgeMethod(ClassFile cf, IClass declaringIClass, IClass.IMethod base, IClass.IMethod override) throws CompileException
Generates and compiles a bridge method with signature base that delegates to override.- Throws:
CompileException
-
compile
private boolean compile(Java.BlockStatement bs) throws CompileException
- Returns:
- Whether this statement can complete normally (JLS7 14.1)
- Throws:
CompileException
-
fakeCompile
private boolean fakeCompile(Java.BlockStatement bs) throws CompileException
Called to check whether the givenJava.BlockStatementcompiles or not. Updates the stack map of the current inserter.- Returns:
- Whether the block statement can complete normally
- Throws:
CompileException
-
getCodeContext
private CodeContext getCodeContext()
-
compile2
private boolean compile2(Java.Initializer i) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.Block b) throws CompileException
- Throws:
CompileException
-
compileStatements
private boolean compileStatements(java.util.List<? extends Java.BlockStatement> statements) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.DoStatement ds) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.ForStatement fs) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.ForEachStatement fes) throws CompileException
- Throws:
CompileException
-
allocateLocalVariable
private Java.LocalVariable allocateLocalVariable(boolean finaL, IType localVariableType)
-
allocateLocalVariableAndMarkAsInitialized
private Java.LocalVariable allocateLocalVariableAndMarkAsInitialized(boolean finaL, IType localVariableType)
-
compile2
private boolean compile2(Java.WhileStatement ws) throws CompileException
- Throws:
CompileException
-
compileUnconditionalLoop
private boolean compileUnconditionalLoop(Java.ContinuableStatement cs, Java.BlockStatement body, @Nullable Java.Rvalue[] update) throws CompileException
- Throws:
CompileException
-
compileUnconditionalLoopWithUpdate
private boolean compileUnconditionalLoopWithUpdate(Java.ContinuableStatement cs, Java.BlockStatement body, Java.Rvalue[] update) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.LabeledStatement ls) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.SwitchStatement ss) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.BreakStatement bs) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.ContinueStatement cs) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.AssertStatement as) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.EmptyStatement es)
-
compile2
private boolean compile2(Java.ExpressionStatement ee) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.FieldDeclaration fd) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.IfStatement is) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.LocalClassDeclarationStatement lcds) throws CompileException
- Throws:
CompileException
-
findLocalClassDeclaration
@Nullable private static Java.LocalClassDeclaration findLocalClassDeclaration(Java.Scope s, java.lang.String name)
Finds a local class declared in any block enclosing the given block statement.
-
compile2
private boolean compile2(Java.LocalVariableDeclarationStatement lvds) throws CompileException
- Throws:
CompileException
-
compile
private void compile(Java.ArrayInitializerOrRvalue aiorv, IType arrayType) throws CompileException
- Throws:
CompileException
-
verificationTypeInfo
private ClassFile.StackMapTableAttribute.VerificationTypeInfo verificationTypeInfo(@Nullable IType type)
-
getLocalVariable
public Java.LocalVariable getLocalVariable(Java.LocalVariableDeclarationStatement lvds, Java.VariableDeclarator vd) throws CompileException
- Returns:
- The
Java.LocalVariablecorresponding with the local variable declaration/declarator - Throws:
CompileException
-
compile2
private boolean compile2(Java.ReturnStatement rs) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.SynchronizedStatement ss) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.ThrowStatement ts) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.TryStatement ts) throws CompileException
- Throws:
CompileException
-
compileTryCatchFinallyWithResources
private boolean compileTryCatchFinallyWithResources(Java.TryStatement ts, java.util.List<Java.TryStatement.Resource> resources, UnitCompiler.Compilable2 compileBody, @Nullable Java.Block finallY) throws CompileException
Generates code for a TRY statement with (possibly zero) resources and an (optional) FINALLY clause.- Returns:
- Whether the code can complete normally
- Throws:
CompileException
-
compileTryCatchFinally
private boolean compileTryCatchFinally(Java.TryStatement ts, UnitCompiler.Compilable2 compileBody, @Nullable Java.BlockStatement finallY) throws CompileException
Generates code for a TRY statement without resources, but with an (optional) FINALLY clause.- Returns:
- Whether the code can complete normally
- Throws:
CompileException
-
compileTryCatch
private boolean compileTryCatch(Java.TryStatement tryStatement, UnitCompiler.Compilable2 compileBody, CodeContext.Offset beginningOfBody, CodeContext.Offset afterStatement) throws CompileException
Generates code for a TRY statement without resources and without a FINALLY clause.- Returns:
- Whether the code can complete normally
- Throws:
CompileException
-
compile
private void compile(Java.FunctionDeclarator fd, ClassFile classFile) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.FunctionDeclarator fd, ClassFile classFile) throws CompileException
- Throws:
CompileException
-
addMethodInfo
private static ClassFile.MethodInfo addMethodInfo(Java.Locatable locatable, ClassFile classFile, short accessFlags, java.lang.String methodName, MethodDescriptor methodMd) throws CompileException
- Throws:
CompileException
-
getTargetVersion
private int getTargetVersion()
-
makeLocalVariableNames
private static void makeLocalVariableNames(CodeContext cc, ClassFile.MethodInfo mi)
Makes the variable name and class name Constant Pool names used by local variables.
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.FunctionDeclarator fd) throws CompileException
- Throws:
CompileException
-
allocateLocalVariableSlot
private Java.LocalVariableSlot allocateLocalVariableSlot(IType localVariableType, @Nullable java.lang.String localVariableName)
-
allocateLocalVariableSlotAndMarkAsInitialized
private Java.LocalVariableSlot allocateLocalVariableSlotAndMarkAsInitialized(IType localVariableType, @Nullable java.lang.String localVariableName)
-
buildLocalVariableMap
private java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.BlockStatement blockStatement, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
Computes and fills in the 'local variable map' for the given blockStatement.- Throws:
CompileException
-
buildLocalVariableMap
private static java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.Statement s, java.util.Map<java.lang.String,Java.LocalVariable> localVars)
-
buildLocalVariableMap
private static java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.ConstructorInvocation ci, java.util.Map<java.lang.String,Java.LocalVariable> localVars)
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.Block block, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.DoStatement ds, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.ForStatement fs, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.ForEachStatement fes, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.IfStatement is, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.Initializer i, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.SwitchStatement ss, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.SynchronizedStatement ss, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.TryStatement ts, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private void buildLocalVariableMap(Java.WhileStatement ws, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.LabeledStatement ls, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
private java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.LocalVariableDeclarationStatement lvds, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
- Throws:
CompileException
-
buildLocalVariableMap
protected void buildLocalVariableMap(Java.CatchClause catchClause, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
Adds the given localVars to the 'local variable map' of the given catchClause.- Throws:
CompileException
-
getLocalVariable
public Java.LocalVariable getLocalVariable(Java.FunctionDeclarator.FormalParameter parameter) throws CompileException
- Returns:
- The
Java.LocalVariablecorresponding with the parameter - Throws:
CompileException
-
getLocalVariable
public Java.LocalVariable getLocalVariable(Java.FunctionDeclarator.FormalParameter parameter, boolean isVariableArityParameter) throws CompileException
- Parameters:
isVariableArityParameter- Whether the parameter is the last parameter of a 'variable arity' (a.k.a. 'varargs') method declaration- Returns:
- The
Java.LocalVariablecorresponding with the parameter - Throws:
CompileException
-
getLocalVariable
public Java.LocalVariable getLocalVariable(Java.CatchParameter parameter) throws CompileException
- Returns:
- The
Java.LocalVariablecorresponding with the parameter - Throws:
CompileException
-
fakeCompile
private void fakeCompile(Java.Rvalue rv) throws CompileException
Called to check whether the givenJava.Rvaluecompiles or not.- Throws:
CompileException
-
compile
private void compile(Java.Rvalue rv) throws CompileException
SomeJava.Rvalues compile more efficiently when their value is not needed, e.g. "i++".- Throws:
CompileException
-
compile2
private void compile2(Java.Rvalue rv) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.Assignment a) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.Crement c) throws CompileException
- Throws:
CompileException
-
compile2
private void compile2(Java.ParenthesizedExpression pe) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.AlternateConstructorInvocation aci) throws CompileException
- Throws:
CompileException
-
compile2
private boolean compile2(Java.SuperConstructorInvocation sci) throws CompileException
- Throws:
CompileException
-
compileBoolean
private void compileBoolean(Java.Rvalue rv, CodeContext.Offset dst, boolean orientation) throws CompileException
Compiles anJava.Rvalueand branches, depending on the value.Many
Java.Rvalues compile more efficiently when their value is the condition for a branch, thus this method generally produces more efficient bytecode thancompile(Rvalue)followed by#branch(Locatable, int, Offset).Notice that if rv is a constant, then either dst is never branched to, or it is unconditionally branched to; "Unexamined code" errors may result during bytecode validation.
- Parameters:
rv- The value that determines whether to branch or notdst- Where to jumporientation-JUMP_IF_TRUEorJUMP_IF_FALSE- Throws:
CompileException
-
compileBoolean2
private void compileBoolean2(Java.Rvalue rv, CodeContext.Offset dst, boolean orientation) throws CompileException
- Parameters:
dst- Where to jumporientation-JUMP_IF_TRUEorJUMP_IF_FALSE- Throws:
CompileException
-
compileBoolean2
private void compileBoolean2(Java.UnaryOperation ue, CodeContext.Offset dst, boolean orientation) throws CompileException
- Parameters:
dst- Where to jumporientation-JUMP_IF_TRUEorJUMP_IF_FALSE- Throws:
CompileException
-
compileBoolean2
private void compileBoolean2(Java.BinaryOperation bo, CodeContext.Offset dst, boolean orientation) throws CompileException
- Parameters:
dst- Where to jumporientation-JUMP_IF_TRUEorJUMP_IF_FALSE- Throws:
CompileException
-
compileBoolean2
private void compileBoolean2(Java.ParenthesizedExpression pe, CodeContext.Offset dst, boolean orientation) throws CompileException
- Parameters:
dst- Where to jumporientation-JUMP_IF_TRUEorJUMP_IF_FALSE- Throws:
CompileException
-
compileContext
private int compileContext(Java.Rvalue rv) throws CompileException
Generates code that determines the context of theJava.Rvalueand puts it on the operand stack. Most expressions do not have a "context", but some do. E.g. for "x[y]", the context is "x, y". The bottom line is that for statements like "x[y] += 3" the context is only evaluated once.- Returns:
- The number of operands that is pushed on the operand stack (0, 1 or 2)
- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.Rvalue rv)
-
compileContext2
private int compileContext2(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.FieldAccess fa) throws CompileException
- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.ArrayLength al) throws CompileException
- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.ArrayAccessExpression aae) throws CompileException
Array access expression; see JLS7 15.13 / JLS8+ 15.10.3.- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.FieldAccessExpression fae) throws CompileException
- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
- Throws:
CompileException
-
compileContext2
private int compileContext2(Java.ParenthesizedExpression pe) throws CompileException
- Throws:
CompileException
-
compileGet
private IType compileGet(Java.Rvalue rv) throws CompileException
Generates code that determines the value of theJava.Rvalueand puts it on the operand stack. This method relies on that the "context" of theJava.Rvalueis on top of the operand stack (seecompileContext(Rvalue)).- Returns:
- The type of the
Java.Rvalue - Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.BooleanRvalue brv) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.LocalVariableAccess lva)
-
compileGet2
private IType compileGet2(Java.FieldAccess fa) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.ArrayLength al)
-
compileGet2
private IClass compileGet2(Java.ThisReference tr) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.LambdaExpression le) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.MethodReference mr) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.ClassInstanceCreationReference cicr) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.ArrayCreationReference acr) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.QualifiedThisReference qtr) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.ClassLiteral cl) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.Assignment a) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.ConditionalExpression ce) throws CompileException
- Throws:
CompileException
-
commonSupertype
private IType commonSupertype(IType t1, IType t2) throws CompileException
- Throws:
CompileException
-
commonSupertype2
private IType commonSupertype2(IType t1, IType t2) throws CompileException
- Throws:
CompileException
-
isByteConstant
@Nullable private static java.lang.Byte isByteConstant(@Nullable java.lang.Object o)
-
compileGet2
private IType compileGet2(Java.Crement c) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.ArrayAccessExpression aae) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.FieldAccessExpression fae) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.UnaryOperation uo) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.Instanceof io) throws CompileException
- Throws:
CompileException
-
isPrimitive
private static boolean isPrimitive(IType type)
-
getSuperclass
@Nullable private static IType getSuperclass(IType type) throws CompileException
- Throws:
CompileException
-
isInterface
private static boolean isInterface(IType type)
-
getInterfaces
private static IType[] getInterfaces(IType t1) throws CompileException
- Throws:
CompileException
-
isArray
private static boolean isArray(IType type)
-
isAssignableFrom
private static boolean isAssignableFrom(IType targetType, IType sourceType) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.BinaryOperation bo) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.Cast c) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.ParenthesizedExpression pe) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.MethodInvocation mi) throws CompileException
- Throws:
CompileException
-
isStaticContext
private static boolean isStaticContext(Java.TypeBodyDeclaration tbd)
-
mayHaveSideEffects
private static boolean mayHaveSideEffects(Java.ArrayInitializerOrRvalue... arrayInitializersOrRvalues)
-
mayHaveSideEffects
private static boolean mayHaveSideEffects(Java.ArrayInitializerOrRvalue arrayInitializerOrRvalue)
-
compileGet2
private IClass compileGet2(Java.SuperclassMethodInvocation scmi) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.NewClassInstance nci) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.NewAnonymousClassInstance naci) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.ParameterAccess pa) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.NewArray na) throws CompileException
- Throws:
CompileException
-
compileGet2
private IType compileGet2(Java.NewInitializedArray nia) throws CompileException
- Throws:
CompileException
-
compileGetValue
private void compileGetValue(Java.ArrayInitializer ai, IType arrayType) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.Literal l) throws CompileException
- Throws:
CompileException
-
compileGet2
private IClass compileGet2(Java.SimpleConstant sl) throws CompileException
- Throws:
CompileException
-
compileGetValue
private IType compileGetValue(Java.Rvalue rv) throws CompileException
Convenience function that callscompileContext(Rvalue)andcompileGet(Rvalue).- Returns:
- The type of the Rvalue
- Throws:
CompileException
-
getConstantValue
@Nullable public final java.lang.Object getConstantValue(Java.ArrayInitializerOrRvalue rv) throws CompileException
Attempts to evaluate as a constant expression. The result is one of the following:Boolean,Byte,Short,Integer,Long,Float,Double,Character,String,null(representing thenullliteral.This method cannot be STATIC, because the constant value may refer to a constant declaration in this compilation unit.
- Returns:
NOT_CONSTANTiff the rvalue is not a constant value- Throws:
CompileException
-
getConstantValue
@Nullable public final java.lang.Object getConstantValue(Java.Rvalue rv) throws CompileException
Attempts to evaluate as a constant expression. The result is one of the following:Boolean,Byte,Short,Integer,Long,Float,Double,Character,String,null(representing thenullliteral.This method cannot be STATIC, because the constant value may refer to a constant declaration in this compilation unit.
- Returns:
NOT_CONSTANTiff the rvalue is not a constant value- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.Rvalue rv)
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.FieldAccess fa) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.UnaryOperation uo) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.ConditionalExpression ce) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.BinaryOperation bo) throws CompileException
- Throws:
CompileException
-
getConstantValue2
private java.lang.Object getConstantValue2(Java.Cast c) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.ParenthesizedExpression pe) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.LocalVariableAccess lva) throws CompileException
- Throws:
CompileException
-
getConstantValue2
private java.lang.Object getConstantValue2(Java.IntegerLiteral il) throws CompileException
- Returns:
- An
Integeror aLong - Throws:
CompileException
-
getConstantValue2
private java.lang.Object getConstantValue2(Java.FloatingPointLiteral fpl) throws CompileException
- Returns:
- A
Floator aDouble - Throws:
CompileException
-
getConstantValue2
private boolean getConstantValue2(Java.BooleanLiteral bl)
-
getConstantValue2
private char getConstantValue2(Java.CharacterLiteral cl) throws CompileException
- Throws:
CompileException
-
getConstantValue2
private java.lang.String getConstantValue2(Java.StringLiteral sl) throws CompileException
- Throws:
CompileException
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.NullLiteral nl)
-
getConstantValue2
@Nullable private java.lang.Object getConstantValue2(Java.SimpleConstant sl)
-
generatesCode
private boolean generatesCode(Java.BlockStatement bs) throws CompileException
Checks whether invocation ofcompile(BlockStatement)would generate more than zero code bytes.- Throws:
CompileException
-
generatesCode2
private boolean generatesCode2(Java.BlockStatement bs)
-
generatesCode2
private boolean generatesCode2(Java.AssertStatement as)
-
generatesCode2
private boolean generatesCode2(Java.EmptyStatement es)
-
generatesCode2
private boolean generatesCode2(Java.LocalClassDeclarationStatement lcds)
-
generatesCode2
private boolean generatesCode2(Java.Initializer i) throws CompileException
- Throws:
CompileException
-
generatesCode2
private boolean generatesCode2(java.util.List<Java.BlockStatement> l) throws CompileException
- Throws:
CompileException
-
generatesCode2
private boolean generatesCode2(Java.Block b) throws CompileException
- Throws:
CompileException
-
generatesCode2
private boolean generatesCode2(Java.FieldDeclaration fd) throws CompileException
- Throws:
CompileException
-
leave
private void leave(Java.BlockStatement bs) throws CompileException
Cleans up the statement context. This is currently relevant for "try ... catch ... finally" statements (executefinallyclause) andsynchronizedstatements (monitorexit).Statements like
return,break,continuemust call this method for all the statements they terminate.- Throws:
CompileException
-
leave2
private void leave2(Java.BlockStatement bs)
-
leave2
private void leave2(Java.SynchronizedStatement ss)
-
leave2
private void leave2(Java.TryStatement ts) throws CompileException
- Throws:
CompileException
-
compileSet
private void compileSet(Java.Lvalue lv) throws CompileException
Generates code that stores a value in theJava.Lvalue. Expects theJava.Lvalue's context (seecompileContext(org.codehaus.janino.Java.Rvalue)) and a value of theJava.Lvalue's type on the operand stack.- Throws:
CompileException
-
compileSet2
private void compileSet2(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
compileSet2
private void compileSet2(Java.LocalVariableAccess lva)
-
compileSet2
private void compileSet2(Java.FieldAccess fa) throws CompileException
- Throws:
CompileException
-
compileSet2
private void compileSet2(Java.ArrayAccessExpression aae) throws CompileException
- Throws:
CompileException
-
compileSet2
private void compileSet2(Java.FieldAccessExpression fae) throws CompileException
- Throws:
CompileException
-
compileSet2
private void compileSet2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
- Throws:
CompileException
-
compileSet2
private void compileSet2(Java.ParenthesizedExpression pe) throws CompileException
- Throws:
CompileException
-
getType
private IType getType(Java.Atom a) throws CompileException
- Returns:
- For a
Java.Type, the resolvedIClass, for anJava.Rvalue, the resolvedIClassof the rvalue's type - Throws:
CompileException- See Also:
resolve(TypeDeclaration)
-
getRawType
private IClass getRawType(Java.Type t) throws CompileException
- Throws:
CompileException
-
getType
private IType getType(Java.Type t) throws CompileException
- Throws:
CompileException
-
getTypes
private IType[] getTypes(Java.Type[] types) throws CompileException
- Throws:
CompileException
-
getType
private IType getType(Java.Rvalue rv) throws CompileException
- Throws:
CompileException
-
getType
private IType getType(Java.Lvalue lv) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.ConstructorInvocation ci) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.SimpleType st)
-
getType2
private IClass getType2(Java.PrimitiveType bt)
-
getType2
private IType getType2(Java.ReferenceType rt) throws CompileException
- Throws:
CompileException
-
getReferenceType
@Nullable private IType getReferenceType(Location location, Java.Scope scope, java.lang.String[] identifiers, int n, @Nullable Java.TypeArgument[] typeArguments) throws CompileException
- Parameters:
typeArguments- Zero-length array if type has no type variables- Returns:
- The resolved
IClass, orIParameterizedType, ornull - Throws:
CompileException
-
getReferenceType
private IType getReferenceType(Location location, java.lang.String simpleTypeName, @Nullable Java.TypeArgument[] typeArguments, Java.Scope scope) throws CompileException
JLS7 6.5.5.1 Simple type name (single identifier)- Parameters:
typeArguments- Zero-length array if type is not parameterized- Returns:
- The resolved
IClassorIParameterizedType - Throws:
CompileException
-
typeArgumentToIType
private IType typeArgumentToIType(Java.TypeArgument ta) throws CompileException
- Throws:
CompileException
-
getRawReferenceType
private IClass getRawReferenceType(Location location, java.lang.String simpleTypeName, Java.Scope scope) throws CompileException
- Throws:
CompileException
-
importStaticOnDemand
private java.util.List<java.lang.Object> importStaticOnDemand(java.lang.String simpleName) throws CompileExceptionImports a member class or interface, static field or static method via the compilation unit's static import on-demand declarations.- Returns:
- A list of
IClass.IFields,IClass.IMethods and/orIClasses with that simpleName; may be empty - Throws:
CompileException
-
getType2
private IClass getType2(Java.RvalueMemberType rvmt) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.ArrayType at) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.Package p) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.LocalVariableAccess lva)
-
getType2
private IType getType2(Java.FieldAccess fa) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.ArrayLength al)
-
getType2
private IClass getType2(Java.ThisReference tr) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.LambdaExpression le) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.MethodReference mr) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.ClassInstanceCreationReference cicr) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.ArrayCreationReference acr) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.QualifiedThisReference qtr) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.ClassLiteral cl)
-
getType2
private IType getType2(Java.Assignment a) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.ConditionalExpression ce) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.Crement c) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.ArrayAccessExpression aae) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.FieldAccessExpression fae) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.UnaryOperation uo) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.Instanceof io)
-
getType2
private IType getType2(Java.BinaryOperation bo) throws CompileException
- Throws:
CompileException
-
getUnboxedType
private IType getUnboxedType(IType type)
- Returns:
- The type, or, iff type is a primitive wrapper type, the unwrapped type
-
getType2
private IType getType2(Java.Cast c) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.ParenthesizedExpression pe) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.MethodInvocation mi) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.SuperclassMethodInvocation scmi) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.NewClassInstance nci) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.NewAnonymousClassInstance naci)
-
getType2
private IType getType2(Java.ParameterAccess pa) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.NewArray na) throws CompileException
- Throws:
CompileException
-
getType2
private IType getType2(Java.NewInitializedArray nia) throws CompileException
- Throws:
CompileException
-
getType2
private IClass getType2(Java.IntegerLiteral il)
-
getType2
private IClass getType2(Java.FloatingPointLiteral fpl)
-
getType2
private IClass getType2(Java.BooleanLiteral bl)
-
getType2
private IClass getType2(Java.CharacterLiteral cl)
-
getType2
private IClass getType2(Java.StringLiteral sl)
-
getType2
private IClass getType2(Java.NullLiteral nl)
-
getType2
private IClass getType2(Java.SimpleConstant sl)
-
isType
private boolean isType(Java.Atom a) throws CompileException
- Throws:
CompileException
-
isType2
private boolean isType2(Java.Atom a)
-
isType2
private boolean isType2(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
isAccessible
private boolean isAccessible(IClass.IMember member, Java.Scope contextScope) throws CompileException
Determines whether the givenIClass.IMemberis accessible in the given context, according to JLS7 6.6.1.BL1.B4. Issues acompileError(String)if not.- Throws:
CompileException
-
checkAccessible
private void checkAccessible(IClass.IMember member, Java.Scope contextScope, Location location) throws CompileException
Checks whether the givenIClass.IMemberis accessible in the given context, according to JLS7 6.6.1.BL1.B4. Issues acompileError(String)if not.- Throws:
CompileException
-
isAccessible
private boolean isAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.Scope contextScope) throws CompileException
Determines whether a member (class, interface, field or method) declared in a given class is accessible from a given block statement context, according to JLS7 6.6.1.4.- Throws:
CompileException
-
checkMemberAccessible
private void checkMemberAccessible(IClass iClassDeclaringMember, IClass.IMember member, Java.Scope contextScope, Location location) throws CompileException
Verifies that a member (class, interface, field or method) declared in a given class is accessible from a given block statement context, according to JLS7 6.6.1.4. Issue acompileError(String)if not.- Throws:
CompileException
-
internalCheckAccessible
@Nullable private java.lang.String internalCheckAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.Scope contextScope) throws CompileException
- Returns:
- a descriptive text iff a member declared in that
IClasswith thatAccessis inaccessible - Throws:
CompileException
-
isAccessible
private boolean isAccessible(IClass type, Java.Scope contextScope) throws CompileException
Determines whether the givenIClassis accessible in the given context, according to JLS7 6.6.1.2 and 6.6.1.4.- Throws:
CompileException
-
checkAccessible
private void checkAccessible(IClass type, Java.Scope contextScope, Location location) throws CompileException
Checks whether the givenIClassis accessible in the given context, according to JLS7 6.6.1.2 and 6.6.1.4. Issues acompileError(String)if not.- Throws:
CompileException
-
internalCheckAccessible
@Nullable private java.lang.String internalCheckAccessible(IClass type, Java.Scope contextScope) throws CompileException
- Returns:
- An error message, or
null - Throws:
CompileException
-
toTypeOrCompileException
private Java.Type toTypeOrCompileException(Java.Atom a) throws CompileException
- Throws:
CompileException
-
toRvalueOrCompileException
private Java.Rvalue toRvalueOrCompileException(Java.Atom a) throws CompileException
- Throws:
CompileException
-
toLvalueOrCompileException
private Java.Lvalue toLvalueOrCompileException(Java.Atom a) throws CompileException
- Throws:
CompileException
-
assignSyntheticParametersToSyntheticFields
void assignSyntheticParametersToSyntheticFields(Java.ConstructorDeclarator cd) throws CompileException
Copies the values of the synthetic parameters of this constructor ("this$..." and "val$...") to the synthetic fields of the object ("this$..." and "val$...").- Throws:
CompileException
-
initializeInstanceVariablesAndInvokeInstanceInitializers
void initializeInstanceVariablesAndInvokeInstanceInitializers(Java.ConstructorDeclarator cd) throws CompileException
Compiles the instance variable initializers and the instance initializers in their lexical order.- Throws:
CompileException
-
leaveStatements
private void leaveStatements(Java.Scope from, Java.Scope to) throws CompileException
Statements that jump out of blocks (return,break,continue) must call this method to make sure that thefinallyclauses of alltry ... catchandsynchronizedstatements are executed.- Throws:
CompileException
-
compileArithmeticBinaryOperation
private IType compileArithmeticBinaryOperation(Java.Locatable locatable, IType lhsType, java.lang.String operator, Java.Rvalue rhs) throws CompileException
The LHS operand of type lhsType is expected on the stack.The following operators are supported:
| ^ & * / % + - << >> >>>- Throws:
CompileException
-
compileArithmeticOperation
private IType compileArithmeticOperation(Java.Locatable locatable, @Nullable IType firstOperandType, java.util.Iterator<Java.Rvalue> operands, java.lang.String operator) throws CompileException
Executes an arithmetic operation on a sequence of operands. If type is non-null, then the first operand with that type is already on the stack.The following operators are supported:
| ^ & * / % + - << >> >>>- Throws:
CompileException
-
compileStringConcatenation
private IClass compileStringConcatenation(Java.Locatable locatable, IType type, Java.Rvalue secondOperand, java.util.Iterator<Java.Rvalue> operands) throws CompileException
- Parameters:
type- The type of the first operand, which is already on the stacksecondOperand- The second operandoperands- All following operands- Throws:
CompileException
-
stringConversion
private void stringConversion(Java.Locatable locatable, IType sourceType) throws CompileException
Converts object of type "sourceType" to type "String" (JLS7 15.18.1.1).- Throws:
CompileException
-
invokeConstructor
private void invokeConstructor(Java.Locatable locatable, Java.Scope scope, @Nullable Java.Rvalue enclosingInstance, IType targetType, Java.Rvalue[] arguments) throws CompileException
Expects the object to initialize on the stack.Notice: This method is used both for explicit constructor invocation (first statement of a constructor body) and implicit constructor invocation (right after NEW).
- Parameters:
enclosingInstance- Used if the target class is an inner class- Throws:
CompileException
-
compileFields
private IClass.IField[] compileFields(Java.FieldDeclaration fieldDeclaration)
- Returns:
- The
IClass.IFields that are declared by the fieldDeclaration
-
compileField
private IClass.IField compileField(Java.TypeDeclaration declaringType, Java.Annotation[] annotations, Access access, boolean statiC, boolean finaL, Java.Type type, int brackets, java.lang.String name, @Nullable Java.ArrayInitializerOrRvalue initializer)
Compiles one variable declarator into anIClass.IField.Example: "b" in in the variable declaration
class Foo { @Deprecated private int[] a, b[], c; }- Parameters:
declaringType- "class Foo"type- "int[]"
-
getNonConstantFinalInitializer
@Nullable Java.ArrayInitializerOrRvalue getNonConstantFinalInitializer(Java.FieldDeclaration fd, Java.VariableDeclarator vd) throws CompileException
Determines the non-constant-final initializer of the givenJava.VariableDeclarator.- Returns:
nullif the variable is declared without an initializer or if the initializer is constant-final- Throws:
CompileException
-
reclassify
private Java.Atom reclassify(Java.AmbiguousName an) throws CompileException
- Throws:
CompileException
-
toIAnnotations
private IClass.IAnnotation[] toIAnnotations(Java.Annotation[] annotations) throws CompileException
- Throws:
CompileException
-
toIAnnotation
private IClass.IAnnotation toIAnnotation(Java.Annotation annotation) throws CompileException
- Throws:
CompileException
-
reclassifyName
private Java.Atom reclassifyName(Location location, Java.Scope scope, java.lang.String[] identifiers, int n) throws CompileException
Reclassifies the ambiguous name consisting of the first n of the identifiers (JLS7 6.5.2.2).- Throws:
CompileException
-
findTypeByName
@Nullable private IClass findTypeByName(Location location, java.lang.String className) throws CompileException
Finds the namedIClassin this compilation unit, or through theiClassLoader.- Parameters:
className- Fully qualified class name, e.g. "pkg1.pkg2.Outer$Inner"- Returns:
nulliff anIClasswith that name could not be loaded- Throws:
CompileException- An exception was raised while loading theIClass
-
reclassifyName
private Java.Atom reclassifyName(Location location, Java.Scope scope, java.lang.String identifier) throws CompileException
JLS7 6.5.2.1- Throws:
CompileException
-
importSingleStatic
private java.util.List<java.lang.Object> importSingleStatic(java.lang.String simpleName) throws CompileExceptionImports a member class, member interface, static field or static method via the compilation unit's single static import declarations.- Returns:
- A list of
IClass.IFields,IClass.IMethods and/orIClasses with that simpleName; may be empty - Throws:
CompileException
-
importStatic
private void importStatic(IClass declaringIClass, java.lang.String simpleName, java.util.Collection<java.lang.Object> result, Location location) throws CompileException
Finds all members (member classes, member interfaces, static fields and/or static methods) of the declaringIClass with the given simpleName and adds them to the result.- Parameters:
declaringIClass- The class or interface that declares the membersresult- Results (IClasses,IClass.IFields and/orIClass.IMethods) are added to this collection- Throws:
CompileException
-
determineValue
private Java.Rvalue determineValue(Java.FieldAccessExpression fae) throws CompileException
- Returns:
- Either the
Java.FieldAccessor anJava.ArrayLength - Throws:
CompileException
-
determineValue
private Java.Rvalue determineValue(Java.SuperclassFieldAccessExpression scfae) throws CompileException
"super.fld", "Type.super.fld"- Throws:
CompileException
-
findIMethod
public IClass.IMethod findIMethod(Java.MethodInvocation mi) throws CompileException
Finds methods of the mi.targetnamed mi.methodName, examines the argument types and chooses the most specific method. Checks that only the allowed exceptions are thrown.Notice that the returned
IClass.IMethodmay be declared in an enclosing type.- Returns:
- The selected
IClass.IMethod - Throws:
CompileException
-
findIMethod
@Nullable private IClass.IMethod findIMethod(IType targetType, Java.Invocation invocation) throws CompileException
Finds aIClass.IMethodin the given targetType, its superclasses or superinterfaces which is applicable with the given invocation. If more than one such method exists, chooses the most specific one (JLS7 15.11.2).- Returns:
nullif no appropriate method could be found- Throws:
CompileException
-
fakeIMethod
private IClass.IMethod fakeIMethod(IClass targetType, java.lang.String name, Java.Rvalue[] arguments) throws CompileException
- Throws:
CompileException
-
getIMethods
public void getIMethods(IClass type, java.lang.String methodName, java.util.List<IClass.IMethod> v) throws CompileException
Adds all methods with the given methodName that are declared by the type, its superclasses and all their superinterfaces to the result list v.- Throws:
CompileException
-
findIMethod
public IClass.IMethod findIMethod(Java.SuperclassMethodInvocation superclassMethodInvocation) throws CompileException
- Returns:
- The
IClass.IMethodthat implements the superclassMethodInvocation - Throws:
CompileException
-
findMostSpecificIInvocable
private IClass.IInvocable findMostSpecificIInvocable(Java.Locatable locatable, IClass.IInvocable[] iInvocables, Java.Rvalue[] arguments, Java.Scope contextScope) throws CompileException
Determines the arguments' types, determine the applicable invocables and choose the most specific invocable and adjust arguments as needed (for varargs case).- Parameters:
iInvocables- Length must be greater than zero- Returns:
- The selected
IClass.IInvocable - Throws:
CompileException
-
findMostSpecificIInvocable
@Nullable public IClass.IInvocable findMostSpecificIInvocable(Java.Locatable locatable, IClass.IInvocable[] iInvocables, IClass[] argumentTypes, boolean boxingPermitted, Java.Scope contextScope) throws CompileException
Determines the applicable invocables and choose the most specific invocable.- Returns:
- The maximally specific
IClass.IInvocableornullif noIClass.IInvocableis applicable - Throws:
CompileException
-
assertNonNull
private static <T> T assertNonNull(@Nullable T subject)
-
isMethodInvocationConvertible
private boolean isMethodInvocationConvertible(IClass sourceType, IClass targetType, boolean boxingPermitted) throws CompileException
Checks if "method invocation conversion" (5.3) is possible.- Throws:
CompileException
-
checkThrownExceptions
private void checkThrownExceptions(Java.Invocation in, IClass.IMethod iMethod) throws CompileException
- Throws:
CompileException- if theJava.Invocationthrows exceptions that are disallowed in the given scope
-
checkThrownException
private void checkThrownException(Java.Locatable locatable, IType type, Java.Scope scope) throws CompileException
- Throws:
CompileException- The exception with the given type must not be thrown in the given scope
-
getTargetIType
private IType getTargetIType(Java.QualifiedThisReference qtr) throws CompileException
- Throws:
CompileException
-
isIntLv
@Nullable Java.LocalVariable isIntLv(Java.Crement c) throws CompileException
Checks whether the operand is anintlocal variable.- Returns:
nulliff c is not anintlocal variable- Throws:
CompileException
-
resolve
private IClass resolve(Java.TypeDeclaration td)
-
referenceThis
private void referenceThis(Java.Locatable locatable, Java.AbstractTypeDeclaration declaringType, Java.TypeBodyDeclaration declaringTypeBodyDeclaration, IType targetIType) throws CompileException
- Throws:
CompileException
-
getOuterClasses
private static java.util.List<Java.TypeDeclaration> getOuterClasses(Java.TypeDeclaration inner)
Returns a list consisting of the given inner class and all its enclosing (outer) classes.- Returns:
ListofJava.TypeDeclaration; has length one iff inner has no enclosing instance
-
getOuterClass
@Nullable static Java.TypeDeclaration getOuterClass(Java.TypeDeclaration typeDeclaration)
- Returns:
- The
Java.TypeDeclarationthat immediately encloses the typeDeclaration, ornull
-
getIClass
private IClass getIClass(Java.ThisReference tr) throws CompileException
- Throws:
CompileException
-
getReturnType
private IType getReturnType(Java.FunctionDeclarator fd) throws CompileException
- Throws:
CompileException
-
toIConstructor
IClass.IConstructor toIConstructor(Java.ConstructorDeclarator constructorDeclarator)
- Returns:
- the
IClass.IConstructorthat implements the constructorDeclarator
-
toIMethod
public IClass.IMethod toIMethod(Java.MethodDeclarator methodDeclarator)
- Returns:
- The
IClass.IMethodthat implements the methodDeclarator
-
toIInvocable
private IClass.IInvocable toIInvocable(Java.FunctionDeclarator fd)
-
importSingleType
@Nullable private IClass importSingleType(java.lang.String simpleTypeName, Location location) throws CompileException
If the given name was declared in a simple type import, load that class.- Throws:
CompileException
-
getSingleTypeImport
@Nullable public java.lang.String[] getSingleTypeImport(java.lang.String name, Location location) throws CompileException
Checks if the given simple name was imported through a single type import.- Parameters:
name- The simple type name, e.g."Inner"- Returns:
- The fully qualified name, e.g.
{ "pkg", "Outer", "Inner" }, ornull - Throws:
CompileException
-
importTypeOnDemand
@Nullable public IClass importTypeOnDemand(java.lang.String simpleTypeName, Location location) throws CompileException
6.5.2.BL1.B1.B5, 6.5.2.BL1.B1.B6 Type-import-on-demand.
6.5.5.1.6 Type-import-on-demand declaration.- Returns:
nullif the given simpleTypeName cannot be resolved through any of the type-import-on-demand declarations- Throws:
CompileException
-
importTypeOnDemand2
@Nullable private IClass importTypeOnDemand2(java.lang.String simpleTypeName, Location location) throws CompileException
- Returns:
nullif the given simpleTypeName cannot be resolved through any of the type-import-on-demand declarations- Throws:
CompileException
-
getTypeImportOnDemandImportDeclarations
private java.util.Collection<Java.AbstractCompilationUnit.TypeImportOnDemandDeclaration> getTypeImportOnDemandImportDeclarations()
-
consT
private IClass consT(Java.Locatable locatable, @Nullable java.lang.Object value) throws CompileException
Pushes one value on the operand stack and pushes the respectiveClassFile.StackMapTableAttribute.VerificationTypeInfooperand to the stack map.value Operand stack value Verification type info Character
Byte
Short
Integer
Booleanintinteger_variable_infoFloatfloatfloat_variable_infoLongmsb+lsboflonglong_variable_infoDoublemsb+lsbofdoubledouble_variable_infoStringConstantStringInfoCP indexobject_variable_info(String)IClassConstantClassInfoCP indexobject_variable_info(iClass.descriptor())nullnullnull_variable_info(iClass.descriptor())- Returns:
- The computational type of the value that was pushed, e.g.
IClass.INTforByteorIClass.NULLfornull - Throws:
CompileException
-
makeUtf8Able
private static java.lang.String[] makeUtf8Able(java.lang.String s)
Only strings that can be UTF8-encoded into 65535 bytes can be stored as a constant string info.- Parameters:
s- The string to split into suitable chunks- Returns:
- Strings that can be UTF8-encoded into 65535 bytes
-
consT
private void consT(Java.Locatable locatable, IClass t, int value)
-
consT
private void consT(Java.Locatable locatable, int value)
-
consT
private void consT(Java.Locatable locatable, long value)
-
consT
private void consT(Java.Locatable locatable, float value)
-
consT
private void consT(Java.Locatable locatable, double value)
-
consT
private void consT(Java.Locatable locatable, java.lang.String s)
-
consT
private void consT(Java.Locatable locatable, IClass iClass)
-
castConversion
private void castConversion(Java.Locatable locatable, IType sourceType, IType targetType, @Nullable java.lang.Object constantValue) throws CompileException
- Throws:
CompileException
-
tryCastConversion
private boolean tryCastConversion(Java.Locatable locatable, IType sourceType, IType targetType, @Nullable java.lang.Object constantValue) throws CompileException
- Throws:
CompileException
-
assignmentConversion
private void assignmentConversion(Java.Locatable locatable, IType sourceType, IType targetType, @Nullable java.lang.Object constantValue) throws CompileException
Implements "assignment conversion" (JLS7 5.2) (more precisely: "assignment contexts".)- Throws:
CompileException
-
tryAssignmentConversion
private boolean tryAssignmentConversion(Java.Locatable locatable, IType sourceType, IType targetType, @Nullable java.lang.Object constantValue) throws CompileException
- Throws:
CompileException
-
constantAssignmentConversion
@Nullable private java.lang.Object constantAssignmentConversion(Java.Locatable locatable, @Nullable java.lang.Object value, IType targetType) throws CompileException
Implements "assignment conversion" (JLS7 5.2) on a constant value.- Parameters:
value- Must be aBoolean,String,Byte,Short,Integer,Character,Long,Float,Doubleornull- Returns:
- A
Boolean,String,Byte,Short,Integer,Character,Long,Float,Doubleornull(representing thenullliteral) - Throws:
CompileException
-
unaryNumericPromotion
private IClass unaryNumericPromotion(Java.Locatable locatable, IType type) throws CompileException
Implements "unary numeric promotion" (JLS7 5.6.1).- Returns:
- The promoted type
- Throws:
CompileException
-
reverseUnaryNumericPromotion
private void reverseUnaryNumericPromotion(Java.Locatable locatable, IClass sourceType, IType targetType)
-
convertToPrimitiveNumericType
private IClass convertToPrimitiveNumericType(Java.Locatable locatable, IType type) throws CompileException
If the given type is a primitive type, return that type. If the given type is a primitive wrapper class, unbox the operand on top of the operand stack and return the primitive type. Otherwise, issue a compile error.- Throws:
CompileException
-
numericPromotion
private void numericPromotion(Java.Locatable locatable, IType sourceType, IClass targetType)
-
unaryNumericPromotionType
private IClass unaryNumericPromotionType(Java.Locatable locatable, IType type) throws CompileException
- Throws:
CompileException
-
binaryNumericPromotionType
private IClass binaryNumericPromotionType(Java.Locatable locatable, IType type1, IType type2) throws CompileException
- Throws:
CompileException
-
isIdentityConvertible
private boolean isIdentityConvertible(IType sourceType, IType targetType)
Checks whether "identity conversion" (5.1.1) is possible.- Returns:
- Whether the conversion is possible
-
tryIdentityConversion
private boolean tryIdentityConversion(IType sourceType, IType targetType)
Implements "identity conversion" (5.1.1).- Returns:
- Whether the conversion was possible
-
isWideningPrimitiveConvertible
private boolean isWideningPrimitiveConvertible(IClass sourceType, IType targetType)
-
tryWideningPrimitiveConversion
private boolean tryWideningPrimitiveConversion(Java.Locatable locatable, IType sourceType, IType targetType)
Implements "widening primitive conversion" (5.1.2).- Returns:
- Whether the conversion succeeded
-
fillConversionMap
private static void fillConversionMap(java.lang.Object[] array, java.util.Map<java.lang.String,int[]> map)
-
isWideningReferenceConvertible
private boolean isWideningReferenceConvertible(IType sourceType, IType targetType) throws CompileException
Checks if "widening reference conversion" (5.1.4) is possible.- Returns:
- Whether the conversion is possible
- Throws:
CompileException
-
isNarrowingPrimitiveConvertible
private boolean isNarrowingPrimitiveConvertible(IType sourceType, IType targetType)
Checks whether "narrowing primitive conversion" (JLS7 5.1.3) is possible.
-
tryNarrowingPrimitiveConversion
private boolean tryNarrowingPrimitiveConversion(Java.Locatable locatable, IType sourceType, IType targetType)
Implements "narrowing primitive conversion" (JLS7 5.1.3).- Returns:
- Whether the conversion succeeded
-
tryConstantAssignmentConversion
private boolean tryConstantAssignmentConversion(Java.Locatable locatable, @Nullable java.lang.Object constantValue, IType targetType)
Checks if "constant assignment conversion" (JLS7 5.2, paragraph 1) is possible.- Parameters:
constantValue- The constant value that is to be convertedtargetType- The type to convert to
-
isNarrowingReferenceConvertible
private boolean isNarrowingReferenceConvertible(IType sourceType, IType targetType) throws CompileException
Checks whether "narrowing reference conversion" (JLS7 5.1.5) is possible.- Throws:
CompileException
-
tryNarrowingReferenceConversion
private boolean tryNarrowingReferenceConversion(Java.Locatable locatable, IType sourceType, IType targetType) throws CompileException
Implements "narrowing reference conversion" (5.1.5).- Returns:
- Whether the conversion succeeded
- Throws:
CompileException
-
isCastReferenceConvertible
private boolean isCastReferenceConvertible(IType sourceType, IType targetType) throws CompileException
JLS7 5.5- Throws:
CompileException
-
isBoxingConvertible
@Nullable private IClass isBoxingConvertible(IType sourceType)
- Returns:
- The boxed type or
null
-
tryBoxingConversion
private boolean tryBoxingConversion(Java.Locatable locatable, IType sourceType, IType targetType)
-
tryNullConversion
private boolean tryNullConversion(IType sourceType, IType targetType)
JLS11 5.2: "Finally, a value of the null type (the null reference is the only such value) may be assigned to any reference type".
-
boxingConversion
private void boxingConversion(Java.Locatable locatable, IType sourceType, IType targetType)
- Parameters:
sourceType- a primitive type (except VOID)targetType- the corresponding wrapper type
-
isUnboxingConvertible
@Nullable private IClass isUnboxingConvertible(IType sourceType)
- Returns:
- Iff sourceType is a primitive wrapper type, the unboxed type, otherwise
null
-
isConvertibleToPrimitiveNumeric
private boolean isConvertibleToPrimitiveNumeric(IType sourceType)
- Returns:
- Whether the sourceType is a primitive numeric type, or a wrapper type of a primitive numeric type
-
unboxingConversion
private void unboxingConversion(Java.Locatable locatable, IType sourceType, IClass targetType)
- Parameters:
targetType- a primitive type (except VOID)sourceType- the corresponding wrapper type
-
findTypeByFullyQualifiedName
@Nullable private IClass findTypeByFullyQualifiedName(Location location, java.lang.String[] identifiers) throws CompileException
Attempts to load anIClassby fully-qualified name throughiClassLoader.- Parameters:
identifiers- The fully qualified type name, e.g. '{ "pkg", "Outer", "Inner" }'- Returns:
nullif a class with the given name could not be loaded- Throws:
CompileException- The type exists, but a problem occurred when it was loaded
-
ifNumeric
private void ifNumeric(Java.Locatable locatable, int opIdx, CodeContext.Offset dst, boolean orientation)
- Parameters:
opIdx- One ofEQ,NE,LT,GE,GTorLEorientation-JUMP_IF_TRUEorJUMP_IF_FALSE
-
aconstnull
private void aconstnull(Java.Locatable locatable)
-
add
private void add(Java.Locatable locatable)
-
andOrXor
private void andOrXor(Java.Locatable locatable, java.lang.String operator)
-
anewarray
private void anewarray(Java.Locatable locatable, IClass componentType)
-
arraylength
private void arraylength(Java.Locatable locatable)
-
arraystore
private void arraystore(Java.Locatable locatable, IType lhsComponentType)
-
athrow
private void athrow(Java.Locatable locatable)
-
checkcast
private void checkcast(Java.Locatable locatable, IType targetType)
-
cmp
private void cmp(Java.Locatable locatable, int opIdx)
-
dup
private void dup(Java.Locatable locatable)
Duplicates the top operand: ... a => ... a a
-
dup2
private void dup2(Java.Locatable locatable)
Duplicates the top two operands: ... a b => ... a b a b. This works iff both the top operand and the top-but-one operand have size 1.
-
dupn
private void dupn(Java.Locatable locatable, int n)
Duplicates the top n operands.- n == 0
- (nothing)
- n == 1
- ... a => ... a a
- n == 2
- ... a b => ... a b a b
-
dupx
private void dupx(Java.Locatable locatable)
Copies the top operand one position down: b a => a b a
-
dupx2
private void dupx2(Java.Locatable locatable)
Copies the top operand two positions down: c b a => a c b a. This works iff the top-but-one and top-but-two operands both have size 1.
-
dupxx
private void dupxx(Java.Locatable locatable, int positions)
Copies the top operand positions down.- n == 0
- ... a => ... a a
- n == 1
- ... b a => ... a b a
- n == 2
- ... c b a => ... a c b a
-
getfield
private void getfield(Java.Locatable locatable, IClass.IField iField) throws CompileException
- Throws:
CompileException
-
getfield
private void getfield(Java.Locatable locatable, IClass declaringIClass, java.lang.String fieldName, IClass fieldType, boolean statiC)
-
gotO
private void gotO(Java.Locatable locatable, CodeContext.Offset dst)
- Parameters:
opcode- One of IF* and GOTO
-
if_acmpxx
private void if_acmpxx(Java.Locatable locatable, int opIdx, CodeContext.Offset dst)
-
if_icmpxx
private void if_icmpxx(Java.Locatable locatable, int opIdx, CodeContext.Offset dst)
-
ifnonnull
private void ifnonnull(Java.Locatable locatable, CodeContext.Offset dst)
-
ifnull
private void ifnull(Java.Locatable locatable, CodeContext.Offset dst)
-
ifxx
private void ifxx(Java.Locatable locatable, int opIdx, CodeContext.Offset dst)
-
iinc
private void iinc(Java.Locatable locatable, Java.LocalVariable lv, java.lang.String operator)
- Parameters:
operator- Must be either "++" or "--", as an @linkinternedstring
-
instanceoF
private void instanceoF(Java.Locatable locatable, IType rhsType)
-
invoke
private void invoke(Java.Locatable locatable, int opcode, IClass declaringIClass, java.lang.String methodName, MethodDescriptor methodDescriptor, boolean useInterfaceMethodRef)
Expects the target object and the arguments on the operand stack.
-
l2i
private void l2i(Java.Locatable locatable)
-
load
private IType load(Java.Locatable locatable, Java.LocalVariable localVariable)
-
load
private void load(Java.Locatable locatable, IType localVariableType, int localVariableIndex)
-
lookupswitch
private void lookupswitch(Java.Locatable locatable, java.util.SortedMap<java.lang.Integer,CodeContext.Offset> caseLabelMap, CodeContext.Offset defaultLabelOffset)
-
monitorenter
private void monitorenter(Java.Locatable locatable)
-
monitorexit
private void monitorexit(Java.Locatable locatable)
-
mulDivRemAddSub
private void mulDivRemAddSub(Java.Locatable locatable, java.lang.String operator)
- Parameters:
operator- One of* / % + -
-
multianewarray
private void multianewarray(Java.Locatable locatable, int dimExprCount, int dims, IType componentType)
-
neg
private void neg(Java.Locatable locatable, IClass operandType)
- Parameters:
operandType- One of BYTE, CHAR, INT, SHORT, LONG, BOOLEAN, LONG, FLOAT, DOUBLE
-
neW
private void neW(Java.Locatable locatable, IType iType)
-
newarray
private void newarray(Java.Locatable locatable, IType componentType)
-
pop
private void pop(Java.Locatable locatable, IType type)
-
putfield
private void putfield(Java.Locatable locatable, IClass.IField iField) throws CompileException
- Throws:
CompileException
-
returN
private void returN(Java.Locatable locatable)
-
shift
private void shift(Java.Locatable locatable, java.lang.String operator)
- Parameters:
operator- One of<< >> >>>
-
store
private void store(Java.Locatable locatable, Java.LocalVariable localVariable)
Assigns the top operand to the given local variable.
-
store
private void store(Java.Locatable locatable, IType lvType, short lvIndex)
- Parameters:
lvIndex- (two slots for LONG and DOUBLE local variables)
-
sub
private void sub(Java.Locatable locatable)
-
swap
private void swap(Java.Locatable locatable)
-
tableswitch
private void tableswitch(Java.Locatable locatable, java.util.SortedMap<java.lang.Integer,CodeContext.Offset> caseLabelMap, CodeContext.Offset defaultLabelOffset)
-
xaload
private void xaload(Java.Locatable locatable, IType componentType)
-
xor
private void xor(Java.Locatable locatable, int opcode)
-
xreturn
private void xreturn(Java.Locatable locatable, IType returnType)
-
ilfd
private static int ilfd(IType t)
- Parameters:
t- One of BYTE, CHAR, INT, SHORT, LONG, BOOLEAN, LONG, FLOAT, DOUBLE
-
ilfd
private static int ilfd(ClassFile.StackMapTableAttribute.VerificationTypeInfo vti)
-
ilfda
private static int ilfda(IType t)
-
il
private static int il(ClassFile.StackMapTableAttribute.VerificationTypeInfo vti)
-
ilfdabcs
private static int ilfdabcs(IClass t)
-
findIField
@Nullable private IClass.IField findIField(IClass iClass, java.lang.String name, Location location) throws CompileException
Finds a named field in the givenIClass. Honors superclasses and interfaces. See JLS7 8.3.- Returns:
nullif no field is found- Throws:
CompileException
-
findMemberType
@Nullable private IClass findMemberType(IType iType, java.lang.String name, @Nullable Java.TypeArgument[] typeArguments, Location location) throws CompileException
Finds a named type in the givenIClassorIParameterizedType. Honors superclasses, interfaces and enclosing type declarations.- Returns:
nullif no type with the given name is found- Throws:
CompileException
-
findClass
@Nullable public IClass findClass(java.lang.String className)
Finds one class or interface declaration in this compilation unit and resolves it into anIClass.- Parameters:
className- Fully qualified class name, e.g. "pkg1.pkg2.Outer$Inner"- Returns:
nullif a class or an interface with that name is not declared in this compilation unit
-
compileError
private void compileError(java.lang.String message) throws CompileExceptionEquivalent withcompileError(String, Location)with anulllocation argument.- Throws:
CompileException
-
compileError
private void compileError(java.lang.String message, @Nullable Location location) throws CompileExceptionIssues a compile error with the given message. This is done through theErrorHandlerthat was installed throughsetCompileErrorHandler(ErrorHandler). Such a handler typically throws aCompileException, but it may as well decide to return normally. Consequently, the calling code must be prepared thatcompileError(String, Location)returns normally, and must attempt to continue compiling.- Parameters:
message- The message to reportlocation- The location to report- Throws:
CompileException
-
warning
private void warning(java.lang.String handle, java.lang.String message, @Nullable Location location) throws CompileExceptionIssues a warning with the given message an location an returns. This is done through aWarningHandlerthat was installed throughsetWarningHandler(WarningHandler).The handle argument qualifies the warning and is typically used by the
WarningHandlerto suppress individual warnings.- Throws:
CompileException
-
setCompileErrorHandler
public void setCompileErrorHandler(@Nullable ErrorHandler compileErrorHandler)
By default,CompileExceptions are thrown on compile errors, but an application my install its own (thread-local)ErrorHandler.Be aware that a single problem during compilation often causes a bunch of compile errors, so a good
ErrorHandlercounts errors and throws aCompileExceptionwhen a limit is reached.If the given
ErrorHandlerdoes not throwCompileExceptions, thencompileUnit(boolean, boolean, boolean, ClassFileConsumer)will throw one when the compilation of the unit is finished, and errors had occurred. In other words: TheErrorHandlermay throw aCompileExceptionor not, butcompileUnit(boolean, boolean, boolean, ClassFileConsumer)will definitely throw aCompileExceptionif one or more compile errors have occurred.- Parameters:
compileErrorHandler-nullto restore the default behavior (throwing aCompileException)
-
setWarningHandler
public void setWarningHandler(@Nullable WarningHandler warningHandler)
By default, warnings are discarded, but an application my install a customWarningHandler.- Parameters:
warningHandler-nullto indicate that no warnings be issued
-
replaceCodeContext
@Nullable private CodeContext replaceCodeContext(@Nullable CodeContext newCodeContext)
-
addLineNumberOffset
private void addLineNumberOffset(Java.Locatable locatable)
-
write
private void write(int v)
-
writeByte
private void writeByte(int v)
-
writeShort
private void writeShort(int v)
-
writeUnsignedShort
private void writeUnsignedShort(int v)
-
writeInt
private void writeInt(int v)
-
writeLdc
private void writeLdc(short constantPoolIndex)
-
writeLdc2
private void writeLdc2(short constantPoolIndex)
-
invokeMethod
private void invokeMethod(Java.Locatable locatable, IClass.IMethod iMethod) throws CompileException
Invokes the iMethod; assumes thatthis(unless iMethod is static) and the correct number and types of arguments are on the operand stack.- Throws:
CompileException
-
invokeConstructor
private void invokeConstructor(Java.Locatable locatable, IClass.IConstructor iConstructor) throws CompileException
Invokes the iConstructor; assumes thatthisand the correct number and types of arguments are on the operand stack.- Throws:
CompileException
-
writeOffset
private void writeOffset(CodeContext.Offset src, CodeContext.Offset dst)
-
addConstantStringInfo
private short addConstantStringInfo(java.lang.String value)
-
addConstantIntegerInfo
private short addConstantIntegerInfo(int value)
-
addConstantLongInfo
private short addConstantLongInfo(long value)
-
addConstantFloatInfo
private short addConstantFloatInfo(float value)
-
addConstantDoubleInfo
private short addConstantDoubleInfo(double value)
-
addConstantClassInfo
private short addConstantClassInfo(IClass iClass)
-
addConstantFieldrefInfo
private short addConstantFieldrefInfo(IClass iClass, java.lang.String fieldName, IClass fieldType)
-
addConstantMethodrefInfo
private short addConstantMethodrefInfo(IClass iClass, java.lang.String methodName, java.lang.String methodFd)
-
addConstantInterfaceMethodrefInfo
private short addConstantInterfaceMethodrefInfo(IClass iClass, java.lang.String methodName, java.lang.String methodFd)
-
writeConstantClassInfo
private void writeConstantClassInfo(IClass iClass)
-
writeConstantFieldrefInfo
private void writeConstantFieldrefInfo(IClass iClass, java.lang.String fieldName, IClass fieldType)
-
writeConstantMethodrefInfo
private void writeConstantMethodrefInfo(IClass iClass, java.lang.String methodName, MethodDescriptor methodMd)
-
writeConstantInterfaceMethodrefInfo
private void writeConstantInterfaceMethodrefInfo(IClass iClass, java.lang.String methodName, MethodDescriptor methodMd)
-
getWhereToBreak
private CodeContext.Offset getWhereToBreak(Java.BreakableStatement bs)
-
getDeclaringTypeBodyDeclaration
private Java.TypeBodyDeclaration getDeclaringTypeBodyDeclaration(Java.QualifiedThisReference qtr) throws CompileException
- Throws:
CompileException
-
getDeclaringClass
private Java.AbstractClassDeclaration getDeclaringClass(Java.QualifiedThisReference qtr) throws CompileException
- Throws:
CompileException
-
referenceThis
private void referenceThis(Java.Locatable locatable, IClass currentIClass)
-
newArray
private IClass newArray(Java.Locatable locatable, int dimExprCount, int dims, IType componentType)
Expects dimExprCount values of typeinton the operand stack. Creates an array of dimExprCount+dims dimensions of componentType.- Returns:
- The type of the created array
-
last
private static java.lang.String last(java.lang.String[] sa)
-
allButLast
private static java.lang.String[] allButLast(java.lang.String[] sa)
-
concat
private static java.lang.String[] concat(java.lang.String[] sa, java.lang.String s)
-
compileException
private static CompileException compileException(Java.Locatable locatable, java.lang.String message)
-
unescape
private static java.lang.String unescape(java.lang.String s, @Nullable Location location) throws CompileExceptionDecodes any escape sequences like\n, or\377, but not\uxxxx.- Returns:
- s, with all escape sequences replaced with their literal values
- Throws:
CompileException- s contains an invalid escape sequencejava.lang.IndexOutOfBoundsException- sends with a backslash
-
accessFlags
private short accessFlags(Java.Modifier[] modifiers) throws CompileException
- Throws:
CompileException
-
accessModifiers
private static Java.Modifier[] accessModifiers(Location location, java.lang.String... keywords)
-
changeAccessibility
private static short changeAccessibility(short accessFlags, short newAccessibility)
-
getLocalVariableTypeInfo
private ClassFile.StackMapTableAttribute.VerificationTypeInfo getLocalVariableTypeInfo(short lvIndex)
- Parameters:
lvIndex- (two slots for LONG and DOUBLE local variables)
-
updateLocalVariableInCurrentStackMap
private void updateLocalVariableInCurrentStackMap(short lvIndex, ClassFile.StackMapTableAttribute.VerificationTypeInfo vti)
-
-