Class ClassDefinition
- java.lang.Object
-
- org.glassfish.rmic.tools.java.ClassDefinition
-
- All Implemented Interfaces:
Constants
,RuntimeConstants
- Direct Known Subclasses:
AsmClass
,BinaryClass
,SourceClass
public abstract class ClassDefinition extends java.lang.Object implements Constants
This class is a Java class definition WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) MethodSet
allMethods
protected Context
classContext
protected ClassDeclaration
declaration
protected java.lang.String
documentation
protected static boolean
doInheritanceChecks
A flag used by turnOffInheritanceChecks() to indicate if inheritance checks are on or off.protected boolean
error
private java.util.Hashtable<Identifier,MemberDefinition>
fieldHash
protected MemberDefinition
firstMember
protected MemberDefinition
innerClassMember
protected IdentifierToken[]
interfaceIds
protected ClassDeclaration[]
interfaces
protected MemberDefinition
lastMember
private int
LOCAL_CLASSES_SIZE
private java.util.Hashtable<java.lang.String,ClassDefinition>
localClasses
protected Identifier
localName
protected int
modifiers
protected boolean
nestError
protected ClassDefinition
outerClass
protected MemberDefinition
outerMember
private java.util.List<MemberDefinition>
permanentlyAbstractMethods
protected UplevelReference
references
protected boolean
referencesFrozen
protected boolean
resolved
protected java.lang.Object
source
protected ClassDeclaration
superClass
protected IdentifierToken
superClassId
protected boolean
supersCheckStarted
protected long
where
-
Fields inherited from interface org.glassfish.rmic.tools.java.Constants
ABSTRACT, ACCM_CLASS, ACCM_FIELD, ACCM_INNERCLASS, ACCM_MEMBER, ACCM_METHOD, ADD, AND, ARRAY, ARRAYACCESS, ASGADD, ASGBITAND, ASGBITOR, ASGBITXOR, ASGDIV, ASGLSHIFT, ASGMUL, ASGREM, ASGRSHIFT, ASGSUB, ASGURSHIFT, ASSIGN, ATT_ALL, ATT_ALLCLASSES, ATT_CODE, BITAND, BITNOT, BITOR, BITXOR, BOOLEAN, BOOLEANVAL, BREAK, BYTE, BYTEVAL, CASE, CAST, CATCH, CHAR, CHARVAL, CLASS, COLON, COMMA, COMMENT, COND, CONST, CONTINUE, CONVERT, CS_BINARY, CS_CHECKED, CS_COMPILED, CS_NOTFOUND, CS_PARSED, CS_SOURCE, CS_UNDECIDED, CS_UNDEFINED, CT_BLOCK, CT_BRANCH_FALSE, CT_BRANCH_TRUE, CT_CASE, CT_FIKT_METHOD, CT_FIKT_RET, CT_FIRST_KIND, CT_LAST_KIND, CT_METHOD, CT_SWITH_WO_DEF, DEC, DECLARATION, DEFAULT, DIV, DO, DOUBLE, DOUBLEVAL, ELSE, EQ, ERROR, EXPR, EXPRESSION, EXTENDS, F_COVDATA, F_COVERAGE, F_DEBUG_LINES, F_DEBUG_SOURCE, F_DEBUG_VARS, F_DEPENDENCIES, F_DEPRECATION, F_DUMP, F_ERRORSREPORTED, F_OPT, F_OPT_INTERCLASS, F_PRINT_DEPENDENCIES, F_STRICTDEFAULT, F_VERBOSE, F_VERSION12, F_WARNINGS, FALSE, FIELD, FINAL, FINALLY, FLOAT, FLOATVAL, FOR, GE, GOTO, GT, idAppend, idClass, idClassInit, idClone, idCode, idConstantValue, idCoverageTable, idDeprecated, idDocumentation, IDENT, idExceptions, idFinallyReturnValue, idGetClass, idInit, idInnerClasses, idJavaIoSerializable, idJavaLang, idJavaLangClass, idJavaLangCloneable, idJavaLangError, idJavaLangException, idJavaLangObject, idJavaLangRuntimeException, idJavaLangString, idJavaLangStringBuffer, idJavaLangThrowable, idLength, idLineNumberTable, idLocalVariableTable, idNew, idNull, idSourceFile, idStar, idSuper, idSynthetic, idThis, idToString, idTYPE, idValueOf, IF, IMPLEMENTS, IMPORT, INC, INLINEMETHOD, INLINENEWINSTANCE, INLINERETURN, INSTANCEOF, INT, INTERFACE, INTVAL, LBRACE, LE, LENGTH, LONG, LONGVAL, LPAREN, LSHIFT, LSQBRACKET, LT, M_ABSTRACT, M_ANONYMOUS, M_DEPRECATED, M_FINAL, M_INLINEABLE, M_INTERFACE, M_LOCAL, M_NATIVE, M_PRIVATE, M_PROTECTED, M_PUBLIC, M_STATIC, M_STRICTFP, M_SYNCHRONIZED, M_SYNTHETIC, M_TRANSIENT, M_VOLATILE, MAXFILESIZE, MAXLINENUMBER, METHOD, MM_CLASS, MM_FIELD, MM_MEMBER, MM_METHOD, MUL, NATIVE, NE, NEG, NEW, NEWARRAY, NEWFROMNAME, NEWINSTANCE, NOT, NULL, opNames, opPrecedence, OR, PACKAGE, paraDeprecated, POS, POSTDEC, POSTINC, PREDEC, prefixAccess, prefixArray, prefixClass, prefixLoc, prefixThis, prefixVal, PREINC, PRIVATE, PROTECTED, PUBLIC, QUESTIONMARK, RBRACE, REM, RETURN, RPAREN, RSHIFT, RSQBRACKET, SEMICOLON, SHORT, SHORTVAL, SIG_INNERCLASS, SIGC_INNERCLASS, STAT, STATIC, STRICTFP, STRINGVAL, SUB, SUPER, SWITCH, SYNCHRONIZED, TC_ARRAY, TC_BOOLEAN, TC_BYTE, TC_CHAR, TC_CLASS, TC_DOUBLE, TC_ERROR, TC_FLOAT, TC_INT, TC_LONG, TC_METHOD, TC_NULL, TC_SHORT, TC_VOID, THIS, THROW, THROWS, TM_ARRAY, TM_BOOLEAN, TM_BYTE, TM_CHAR, TM_CLASS, TM_DOUBLE, TM_ERROR, TM_FLOAT, TM_INT, TM_INT32, TM_INTEGER, TM_LONG, TM_METHOD, TM_NULL, TM_NUM32, TM_NUM64, TM_NUMBER, TM_REAL, TM_REFERENCE, TM_SHORT, TM_VOID, tracing, TRANSIENT, TRUE, TRY, TYPE, URSHIFT, VARDECLARATION, VOID, VOLATILE, WHEREOFFSETBITS, WHILE
-
Fields inherited from interface org.glassfish.rmic.tools.java.RuntimeConstants
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, CONSTANT_CLASS, CONSTANT_DOUBLE, CONSTANT_FIELD, CONSTANT_FLOAT, CONSTANT_INTEGER, CONSTANT_INTERFACEMETHOD, CONSTANT_INVOKEDYNAMIC, CONSTANT_LONG, CONSTANT_METHOD, CONSTANT_METHODHANDLE, CONSTANT_METHODTYPE, CONSTANT_NAMEANDTYPE, CONSTANT_STRING, CONSTANT_UNICODE, CONSTANT_UTF8, JAVA_DEFAULT_MINOR_VERSION, JAVA_DEFAULT_VERSION, JAVA_MAGIC, JAVA_MAX_SUPPORTED_MINOR_VERSION, JAVA_MAX_SUPPORTED_VERSION, JAVA_MIN_SUPPORTED_VERSION, opc_aaload, opc_aastore, opc_aconst_null, opc_aload, opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3, opc_anewarray, opc_areturn, opc_arraylength, opc_astore, opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3, opc_athrow, opc_baload, opc_bastore, opc_bipush, opc_breakpoint, opc_caload, opc_castore, opc_checkcast, opc_d2f, opc_d2i, opc_d2l, opc_dadd, opc_daload, opc_dastore, opc_dcmpg, opc_dcmpl, opc_dconst_0, opc_dconst_1, opc_ddiv, opc_dead, opc_dload, opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3, opc_dmul, opc_dneg, opc_drem, opc_dreturn, opc_dstore, opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3, opc_dsub, opc_dup, opc_dup_x1, opc_dup_x2, opc_dup2, opc_dup2_x1, opc_dup2_x2, opc_f2d, opc_f2i, opc_f2l, opc_fadd, opc_faload, opc_fastore, opc_fcmpg, opc_fcmpl, opc_fconst_0, opc_fconst_1, opc_fconst_2, opc_fdiv, opc_fload, opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3, opc_fmul, opc_fneg, opc_frem, opc_freturn, opc_fstore, opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3, opc_fsub, opc_getfield, opc_getstatic, opc_goto, opc_goto_w, opc_i2b, opc_i2c, opc_i2d, opc_i2f, opc_i2l, opc_i2s, opc_iadd, opc_iaload, opc_iand, opc_iastore, opc_iconst_0, opc_iconst_1, opc_iconst_2, opc_iconst_3, opc_iconst_4, opc_iconst_5, opc_iconst_m1, opc_idiv, opc_if_acmpeq, opc_if_acmpne, opc_if_icmpeq, opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_icmplt, opc_if_icmpne, opc_ifeq, opc_ifge, opc_ifgt, opc_ifle, opc_iflt, opc_ifne, opc_ifnonnull, opc_ifnull, opc_iinc, opc_iload, opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3, opc_imul, opc_ineg, opc_instanceof, opc_invokedynamic, opc_invokeinterface, opc_invokespecial, opc_invokestatic, opc_invokevirtual, opc_ior, opc_irem, opc_ireturn, opc_ishl, opc_ishr, opc_istore, opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3, opc_isub, opc_iushr, opc_ixor, opc_jsr, opc_jsr_w, opc_l2d, opc_l2f, opc_l2i, opc_label, opc_ladd, opc_laload, opc_land, opc_lastore, opc_lcmp, opc_lconst_0, opc_lconst_1, opc_ldc, opc_ldc_w, opc_ldc2_w, opc_ldiv, opc_lload, opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3, opc_lmul, opc_lneg, opc_lookupswitch, opc_lor, opc_lrem, opc_lreturn, opc_lshl, opc_lshr, opc_lstore, opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3, opc_lsub, opc_lushr, opc_lxor, opc_monitorenter, opc_monitorexit, opc_multianewarray, opc_new, opc_newarray, opc_nop, opc_pop, opc_pop2, opc_putfield, opc_putstatic, opc_ret, opc_return, opc_saload, opc_sastore, opc_sipush, opc_swap, opc_tableswitch, opc_try, opc_wide, opcLengths, opcNames, SIG_ARRAY, SIG_BOOLEAN, SIG_BYTE, SIG_CHAR, SIG_CLASS, SIG_DOUBLE, SIG_ENDCLASS, SIG_ENDMETHOD, SIG_FLOAT, SIG_INT, SIG_LONG, SIG_METHOD, SIG_PACKAGE, SIG_SHORT, SIG_VOID, SIGC_ARRAY, SIGC_BOOLEAN, SIGC_BYTE, SIGC_CHAR, SIGC_CLASS, SIGC_DOUBLE, SIGC_ENDCLASS, SIGC_ENDMETHOD, SIGC_FLOAT, SIGC_INT, SIGC_LONG, SIGC_METHOD, SIGC_PACKAGE, SIGC_SHORT, SIGC_VOID, T_BOOLEAN, T_BYTE, T_CHAR, T_CLASS, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClassDefinition(java.lang.Object source, long where, ClassDeclaration declaration, int modifiers, IdentifierToken superClass, IdentifierToken[] interfaces)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDependency(ClassDeclaration c)
Add a dependencyvoid
addLocalClass(ClassDefinition c, java.lang.String name)
void
addMember(Environment env, MemberDefinition field)
Add a field (subclasses make checks)protected void
addMember(MemberDefinition field)
Add a field (no checks)protected void
addMirandaMethods(Environment env, java.util.Iterator<MemberDefinition> mirandas)
Add a list of methods to this class as miranda methods.void
addModifiers(int mod)
private UplevelReference
addReference(LocalMember target)
protected void
basicCheck(Environment env)
boolean
canAccess(Environment env, ClassDeclaration c)
Check if another class can be accessed from within the body of this class.boolean
canAccess(Environment env, MemberDefinition f)
Check if a field can be accessed from a classvoid
check(Environment env)
Check this class.Vset
checkLocalClass(Environment env, Context ctx, Vset vset, ClassDefinition sup, Expression[] args, Type[] argTypes)
void
cleanup(Environment env)
After the class has been written to disk, try to free up some storage.protected void
collectInheritedMethods(Environment env)
Collect all methods defined in this class or inherited from any of our superclasses or interfaces.private void
collectOneClass(Environment env, ClassDeclaration parent, MethodSet myMethods, MethodSet allMethods, MethodSet mirandaMethods)
Add all of the methods declared in or above `parent' to `allMethods', the set of methods in the current class.static boolean
containsDeprecated(java.lang.String documentation)
Return true if the given documentation string contains a deprecation paragraph.(package private) boolean
couldImplement(ClassDefinition intDef)
Check to see if a class which implements interface `this' could possibly implement the interface `intDef'.private boolean
diagnoseMismatch(Environment env, Identifier nm, Type[] argTypes, int start, int[] haveMatch, Type[] margType)
int
diagnoseMismatch(Environment env, Identifier nm, Type[] argTypes, int start, Type[] margTypeResult)
Given the fact that this class has no method "nm" matching "argTypes", find out if the mismatch can be blamed on a particular actual argument which disagrees with all of the overloadings.boolean
enclosingClassOf(ClassDefinition otherClass)
Check if this is an enclosing class of another classprotected boolean
extendsCanAccess(Environment env, ClassDeclaration c)
Check if another class can be accessed from the 'extends' or 'implements' clause of this class.MemberDefinition
findAnyMethod(Environment env, Identifier nm)
Find any method with a given name.MemberDefinition
findMethod(Environment env, Identifier nm, Type t)
Find a method, ie: exact match in this class or any of the super classes.MemberDefinition
findOuterMember()
If inner, return an innermost uplevel self pointer, if any exists.MemberDefinition
getAccessMember(Environment env, Context ctx, MemberDefinition field, boolean isSuper)
Find or create an access method for a private member, or return null if this is not possible.Context
getClassContext()
ClassDeclaration
getClassDeclaration()
Get the class declarationMemberDefinition
getClassLiteralLookup(long fwhere)
Get helper method for class literal lookup.java.util.Iterator<ClassDeclaration>
getDependencies()
boolean
getError()
Check if there were any errors in this class.MemberDefinition
getFirstMatch(Identifier name)
MemberDefinition
getFirstMember()
Get the class' first field or first matchMemberDefinition
getInnerClass(Environment env, Identifier nm)
Get an inner class.MemberDefinition
getInnerClassMember()
If inner, get the field for this class in the enclosing classClassDeclaration[]
getInterfaces()
Get the class' interfacesClassDefinition
getLocalClass(java.lang.String name)
Maintain a hash table of local and anonymous classes whose internal names are prefixed by the current class.Identifier
getLocalName()
Return a simple identifier for this class (idNull if anonymous).java.util.Iterator<MemberDefinition>
getMethods()
Get an Iterator of all methods which could be accessed in an instance of this class.protected java.util.Iterator<MemberDefinition>
getMethods(Environment env)
Get an Iterator of all methods which could be accessed in an instance of this class.int
getModifiers()
Get the class' modifiersIdentifier
getName()
Get the class' nameprotected boolean
getNestError()
Check if there were any errors in our class nest.ClassDefinition
getOuterClass()
Get the class' enclosing class (or null if not inner)protected java.util.Iterator<MemberDefinition>
getPermanentlyAbstractMethods()
This method returns an Iterator of all abstract methods in our superclasses which we are unable to implement.UplevelReference
getReference(LocalMember target)
Find or create an uplevel reference for the given target.UplevelReference
getReferences()
Return the list of all uplevel references.UplevelReference
getReferencesFrozen()
Return the same value as getReferences.java.lang.Object
getSource()
Get the source of the classClassDeclaration
getSuperClass()
Get the class' super classClassDeclaration
getSuperClass(Environment env)
Get the super class, and resolve names now if necessary.ClassDefinition
getTopClass()
Get the class' top-level enclosing classType
getType()
Get the class' typeMemberDefinition
getUpdateMember(Environment env, Context ctx, MemberDefinition field, boolean isSuper)
Find or create an update method for a private member, or return null if this is not possible.MemberDefinition
getVariable(Environment env, Identifier nm, ClassDefinition source)
Get a field from this class.private MemberDefinition
getVariable0(Environment env, Identifier nm, ClassDefinition source, boolean showPrivate, boolean showPackage)
long
getWhere()
Get the position in the input binaryboolean
hasConstructor()
boolean
implementedBy(Environment env, ClassDeclaration c)
Check if this class is implemented by another classvoid
inlineLocalClass(Environment env)
(package private) boolean
innerClassExists(Identifier nm)
While resolving import directives, the question has arisen: does a given inner class exist? If the top-level class exists, we ask it about an inner class via this method.private boolean
inSamePackage(ClassDeclaration c)
boolean
inSamePackage(ClassDefinition c)
private boolean
inSamePackage(Identifier packageName)
boolean
isAbstract()
boolean
isAnonymous()
boolean
isClass()
boolean
isDeprecated()
boolean
isFinal()
boolean
isInnerClass()
Tell if the class is inner.boolean
isInsideLocal()
Tell if the class is local or inside a local class, which means it cannot be mentioned outside of its file.boolean
isInterface()
Checksboolean
isLocal()
boolean
isMember()
Tell if the class is a member of another class.boolean
isPackagePrivate()
boolean
isPrivate()
boolean
isProtected()
boolean
isPublic()
boolean
isStatic()
See if this is a (nested) static class.boolean
isSynthetic()
boolean
isTopLevel()
Tell if the class is "top-level", which is either a package member, or a static member of another top-level class.void
loadNested(Environment env)
MemberDefinition
matchAnonConstructor(Environment env, Identifier accessPackage, Type[] argumentTypes)
A version of matchMethod to be used only for constructors when we cannot pass in a sourceClass argument.MemberDefinition
matchMethod(Environment env, ClassDefinition accessor, Identifier methodName)
Lookup a method.MemberDefinition
matchMethod(Environment env, ClassDefinition accessor, Identifier methodName, Type[] argumentTypes)
Lookup a method.private MemberDefinition
matchMethod(Environment env, ClassDefinition accessor, Identifier methodName, Type[] argumentTypes, boolean isAnonConstCall, Identifier accessPackage)
Lookup a method.private static void
methodSetAdd(Environment env, MethodSet methodSet, MemberDefinition newMethod)
boolean
mustBeAbstract(Environment env)
Check to see if a class must be abstract.void
noteUsedBy(ClassDefinition ref, long where, Environment env)
Note that this class is being used somehow byref
.boolean
permitInlinedAccess(Environment env, ClassDeclaration c)
Check if a class is entitled to inline access to a class from another class.boolean
permitInlinedAccess(Environment env, MemberDefinition f)
Check if a class is entitled to inline access to a method from another class.void
print(java.io.PrintStream out)
Print for debuggingboolean
protectedAccess(Environment env, MemberDefinition f, Type accessorType)
We know the field is marked protected (and not public) and that the field is visible (as per canAccess).void
referencesMustNotBeFrozen()
assertion checkboolean
reportDeprecated(Environment env)
Tells whether to report a deprecation error for this class.Identifier
resolveInnerClass(Environment env, Identifier nm)
Interpret a qualified class name, which may have further subcomponents..Identifier
resolveName(Environment env, Identifier name)
Look up an inner class name, from somewhere inside this class.void
resolveTypeStructure(Environment env)
We create a stub for this.void
setError()
Mark this class to be erroneous.protected void
setLocalName(Identifier name)
Set the local name of a class.private void
setNestError()
Mark this class, and all siblings in its class nest, to be erroneous.protected void
setOuterClass(ClassDefinition outerClass)
Set the class' enclosing class.protected void
setOuterMember(MemberDefinition outerMember)
Set the class' enclosing current instance pointer.boolean
subClassOf(Environment env, ClassDeclaration otherClass)
Check if this is a sub class of another classvoid
subModifiers(int mod)
boolean
superClassOf(Environment env, ClassDeclaration otherClass)
Check if this is a super class of another classjava.lang.String
toString()
Convert to Stringstatic void
turnOffInheritanceChecks()
This is a workaround to allow javadoc to turn off certain inheritance/override checks which interfere with javadoc badly.
-
-
-
Field Detail
-
source
protected java.lang.Object source
-
where
protected long where
-
modifiers
protected int modifiers
-
localName
protected Identifier localName
-
declaration
protected ClassDeclaration declaration
-
superClassId
protected IdentifierToken superClassId
-
interfaceIds
protected IdentifierToken[] interfaceIds
-
superClass
protected ClassDeclaration superClass
-
interfaces
protected ClassDeclaration[] interfaces
-
outerClass
protected ClassDefinition outerClass
-
outerMember
protected MemberDefinition outerMember
-
innerClassMember
protected MemberDefinition innerClassMember
-
firstMember
protected MemberDefinition firstMember
-
lastMember
protected MemberDefinition lastMember
-
resolved
protected boolean resolved
-
documentation
protected java.lang.String documentation
-
error
protected boolean error
-
nestError
protected boolean nestError
-
references
protected UplevelReference references
-
referencesFrozen
protected boolean referencesFrozen
-
fieldHash
private java.util.Hashtable<Identifier,MemberDefinition> fieldHash
-
localClasses
private java.util.Hashtable<java.lang.String,ClassDefinition> localClasses
-
LOCAL_CLASSES_SIZE
private final int LOCAL_CLASSES_SIZE
- See Also:
- Constant Field Values
-
classContext
protected Context classContext
-
supersCheckStarted
protected boolean supersCheckStarted
-
allMethods
MethodSet allMethods
-
permanentlyAbstractMethods
private java.util.List<MemberDefinition> permanentlyAbstractMethods
-
doInheritanceChecks
protected static boolean doInheritanceChecks
A flag used by turnOffInheritanceChecks() to indicate if inheritance checks are on or off.
-
-
Constructor Detail
-
ClassDefinition
protected ClassDefinition(java.lang.Object source, long where, ClassDeclaration declaration, int modifiers, IdentifierToken superClass, IdentifierToken[] interfaces)
Constructor
-
-
Method Detail
-
getClassContext
public Context getClassContext()
-
getSource
public final java.lang.Object getSource()
Get the source of the class
-
getError
public final boolean getError()
Check if there were any errors in this class.
-
setError
public final void setError()
Mark this class to be erroneous.
-
getNestError
protected final boolean getNestError()
Check if there were any errors in our class nest.
-
setNestError
private void setNestError()
Mark this class, and all siblings in its class nest, to be erroneous.
-
getWhere
public final long getWhere()
Get the position in the input binary
-
getClassDeclaration
public final ClassDeclaration getClassDeclaration()
Get the class declaration
-
getModifiers
public final int getModifiers()
Get the class' modifiers
-
subModifiers
public final void subModifiers(int mod)
-
addModifiers
public final void addModifiers(int mod)
-
getSuperClass
public final ClassDeclaration getSuperClass()
Get the class' super class
-
getSuperClass
public ClassDeclaration getSuperClass(Environment env)
Get the super class, and resolve names now if necessary. It is only possible to resolve names at this point if we are a source class. The provision of this method at this level in the class hierarchy is dubious, but see 'getInnerClass' below. All other calls to 'getSuperClass(env)' appear in 'SourceClass'. NOTE: An older definition of this method has been moved to 'SourceClass', where it overrides this one.
-
getInterfaces
public final ClassDeclaration[] getInterfaces()
Get the class' interfaces
-
getOuterClass
public final ClassDefinition getOuterClass()
Get the class' enclosing class (or null if not inner)
-
setOuterClass
protected final void setOuterClass(ClassDefinition outerClass)
Set the class' enclosing class. Must be done at most once.
-
setOuterMember
protected final void setOuterMember(MemberDefinition outerMember)
Set the class' enclosing current instance pointer. Must be done at most once.
-
isInnerClass
public final boolean isInnerClass()
Tell if the class is inner. This predicate also returns true for top-level nested types. To test for a true inner class as seen by the programmer, use!isTopLevel()
.
-
isMember
public final boolean isMember()
Tell if the class is a member of another class. This is false for package members and for block-local classes.
-
isTopLevel
public final boolean isTopLevel()
Tell if the class is "top-level", which is either a package member, or a static member of another top-level class.
-
isInsideLocal
public final boolean isInsideLocal()
Tell if the class is local or inside a local class, which means it cannot be mentioned outside of its file.
-
getLocalName
public Identifier getLocalName()
Return a simple identifier for this class (idNull if anonymous).
-
setLocalName
protected void setLocalName(Identifier name)
Set the local name of a class. Must be a local class.
-
getInnerClassMember
public final MemberDefinition getInnerClassMember()
If inner, get the field for this class in the enclosing class
-
findOuterMember
public final MemberDefinition findOuterMember()
If inner, return an innermost uplevel self pointer, if any exists. Otherwise, return null.
-
isStatic
public final boolean isStatic()
See if this is a (nested) static class.
-
getTopClass
public final ClassDefinition getTopClass()
Get the class' top-level enclosing class
-
getFirstMember
public final MemberDefinition getFirstMember()
Get the class' first field or first match
-
getFirstMatch
public final MemberDefinition getFirstMatch(Identifier name)
-
getName
public final Identifier getName()
Get the class' name
-
getType
public final Type getType()
Get the class' type
-
containsDeprecated
public static boolean containsDeprecated(java.lang.String documentation)
Return true if the given documentation string contains a deprecation paragraph. This is true if the string contains the tag @deprecated is the first word in a line.
-
inSamePackage
private final boolean inSamePackage(ClassDeclaration c)
-
inSamePackage
public final boolean inSamePackage(ClassDefinition c)
-
inSamePackage
private boolean inSamePackage(Identifier packageName)
-
isInterface
public final boolean isInterface()
Checks
-
isClass
public final boolean isClass()
-
isPublic
public final boolean isPublic()
-
isPrivate
public final boolean isPrivate()
-
isProtected
public final boolean isProtected()
-
isPackagePrivate
public final boolean isPackagePrivate()
-
isFinal
public final boolean isFinal()
-
isAbstract
public final boolean isAbstract()
-
isSynthetic
public final boolean isSynthetic()
-
isDeprecated
public final boolean isDeprecated()
-
isAnonymous
public final boolean isAnonymous()
-
isLocal
public final boolean isLocal()
-
hasConstructor
public final boolean hasConstructor()
-
mustBeAbstract
public final boolean mustBeAbstract(Environment env)
Check to see if a class must be abstract. This method replaces isAbstract(env)
-
superClassOf
public boolean superClassOf(Environment env, ClassDeclaration otherClass) throws ClassNotFound
Check if this is a super class of another class- Throws:
ClassNotFound
-
enclosingClassOf
public boolean enclosingClassOf(ClassDefinition otherClass)
Check if this is an enclosing class of another class
-
subClassOf
public boolean subClassOf(Environment env, ClassDeclaration otherClass) throws ClassNotFound
Check if this is a sub class of another class- Throws:
ClassNotFound
-
implementedBy
public boolean implementedBy(Environment env, ClassDeclaration c) throws ClassNotFound
Check if this class is implemented by another class- Throws:
ClassNotFound
-
couldImplement
boolean couldImplement(ClassDefinition intDef)
Check to see if a class which implements interface `this' could possibly implement the interface `intDef'. Note that the only way that this can fail is if `this' and `intDef' have methods which are of the same signature and different return types. This method is used by Environment.explicitCast() to determine if a cast between two interfaces is legal. This method should only be called on a class after it has been basicCheck()'ed.
-
extendsCanAccess
protected boolean extendsCanAccess(Environment env, ClassDeclaration c) throws ClassNotFound
Check if another class can be accessed from the 'extends' or 'implements' clause of this class.- Throws:
ClassNotFound
-
canAccess
public boolean canAccess(Environment env, ClassDeclaration c) throws ClassNotFound
Check if another class can be accessed from within the body of this class.- Throws:
ClassNotFound
-
canAccess
public boolean canAccess(Environment env, MemberDefinition f) throws ClassNotFound
Check if a field can be accessed from a class- Throws:
ClassNotFound
-
permitInlinedAccess
public boolean permitInlinedAccess(Environment env, ClassDeclaration c) throws ClassNotFound
Check if a class is entitled to inline access to a class from another class.- Throws:
ClassNotFound
-
permitInlinedAccess
public boolean permitInlinedAccess(Environment env, MemberDefinition f) throws ClassNotFound
Check if a class is entitled to inline access to a method from another class.- Throws:
ClassNotFound
-
protectedAccess
public boolean protectedAccess(Environment env, MemberDefinition f, Type accessorType) throws ClassNotFound
We know the field is marked protected (and not public) and that the field is visible (as per canAccess). Can we access the field as. , where has the type ? Protected fields can only be accessed when the accessorType is a subclass of the current class - Throws:
ClassNotFound
-
getAccessMember
public MemberDefinition getAccessMember(Environment env, Context ctx, MemberDefinition field, boolean isSuper)
Find or create an access method for a private member, or return null if this is not possible.
-
getUpdateMember
public MemberDefinition getUpdateMember(Environment env, Context ctx, MemberDefinition field, boolean isSuper)
Find or create an update method for a private member, or return null if this is not possible.
-
getVariable
public MemberDefinition getVariable(Environment env, Identifier nm, ClassDefinition source) throws AmbiguousMember, ClassNotFound
Get a field from this class. Report ambiguous fields. If no accessible field is found, this method may return an inaccessible field to allow a useful error message. getVariable now takes the source class `source' as an argument. This allows getVariable to check whether a field is inaccessible before it signals that a field is ambiguous. The compiler used to signal an ambiguity even when one of the fields involved was not accessible. (bug 4053724)- Throws:
AmbiguousMember
ClassNotFound
-
getVariable0
private MemberDefinition getVariable0(Environment env, Identifier nm, ClassDefinition source, boolean showPrivate, boolean showPackage) throws AmbiguousMember, ClassNotFound
- Throws:
AmbiguousMember
ClassNotFound
-
reportDeprecated
public boolean reportDeprecated(Environment env)
Tells whether to report a deprecation error for this class.
-
noteUsedBy
public void noteUsedBy(ClassDefinition ref, long where, Environment env)
Note that this class is being used somehow byref
. Report deprecation errors, etc.
-
getInnerClass
public MemberDefinition getInnerClass(Environment env, Identifier nm) throws ClassNotFound
Get an inner class. Look in supers but not outers. (This is used directly to resolve expressions like "site.K", and inside a loop to resolve lone names like "K" or the "K" in "K.L".) Called from 'Context' and 'FieldExpression' as well as this class.- Throws:
ClassNotFound
-
matchMethod
private MemberDefinition matchMethod(Environment env, ClassDefinition accessor, Identifier methodName, Type[] argumentTypes, boolean isAnonConstCall, Identifier accessPackage) throws AmbiguousMember, ClassNotFound
Lookup a method. This code implements the method lookup mechanism specified in JLS 15.11.2. This mechanism cannot be used to lookup synthetic methods.- Throws:
AmbiguousMember
ClassNotFound
-
matchMethod
public MemberDefinition matchMethod(Environment env, ClassDefinition accessor, Identifier methodName, Type[] argumentTypes) throws AmbiguousMember, ClassNotFound
Lookup a method. This code implements the method lookup mechanism specified in JLS 15.11.2. This mechanism cannot be used to lookup synthetic methods.- Throws:
AmbiguousMember
ClassNotFound
-
matchMethod
public MemberDefinition matchMethod(Environment env, ClassDefinition accessor, Identifier methodName) throws AmbiguousMember, ClassNotFound
Lookup a method. This code implements the method lookup mechanism specified in JLS 15.11.2. This mechanism cannot be used to lookup synthetic methods.- Throws:
AmbiguousMember
ClassNotFound
-
matchAnonConstructor
public MemberDefinition matchAnonConstructor(Environment env, Identifier accessPackage, Type[] argumentTypes) throws AmbiguousMember, ClassNotFound
A version of matchMethod to be used only for constructors when we cannot pass in a sourceClass argument. We just assert our package name. This is used only for anonymous classes, where we have to look up a (potentially) protected constructor with no valid sourceClass parameter available.- Throws:
AmbiguousMember
ClassNotFound
-
findMethod
public MemberDefinition findMethod(Environment env, Identifier nm, Type t) throws ClassNotFound
Find a method, ie: exact match in this class or any of the super classes. Only called by javadoc. For now I am holding off rewriting this code to rely on collectInheritedMethods(), as that code has not gotten along with javadoc in the past.- Throws:
ClassNotFound
-
basicCheck
protected void basicCheck(Environment env) throws ClassNotFound
- Throws:
ClassNotFound
-
check
public void check(Environment env) throws ClassNotFound
Check this class.- Throws:
ClassNotFound
-
checkLocalClass
public Vset checkLocalClass(Environment env, Context ctx, Vset vset, ClassDefinition sup, Expression[] args, Type[] argTypes) throws ClassNotFound
- Throws:
ClassNotFound
-
getPermanentlyAbstractMethods
protected java.util.Iterator<MemberDefinition> getPermanentlyAbstractMethods()
This method returns an Iterator of all abstract methods in our superclasses which we are unable to implement.
-
turnOffInheritanceChecks
public static void turnOffInheritanceChecks()
This is a workaround to allow javadoc to turn off certain inheritance/override checks which interfere with javadoc badly. In the future it might be good to eliminate the shared sources of javadoc and javac to avoid the need for this sort of workaround.
-
collectOneClass
private void collectOneClass(Environment env, ClassDeclaration parent, MethodSet myMethods, MethodSet allMethods, MethodSet mirandaMethods)
Add all of the methods declared in or above `parent' to `allMethods', the set of methods in the current class. `myMethods' is the set of all methods declared in this class, and `mirandaMethods' is a repository for Miranda methods. If mirandaMethods is null, no mirandaMethods will be generated. For a definition of Miranda methods, see the comment above the method addMirandaMethods() which occurs later in this file.
-
collectInheritedMethods
protected void collectInheritedMethods(Environment env)
Collect all methods defined in this class or inherited from any of our superclasses or interfaces. Look for any incompatible definitions.
This function is also responsible for collecting the Miranda methods for a class. For a definition of Miranda methods, see the comment in addMirandaMethods() below.
-
methodSetAdd
private static void methodSetAdd(Environment env, MethodSet methodSet, MemberDefinition newMethod)
-
getMethods
protected java.util.Iterator<MemberDefinition> getMethods(Environment env)
Get an Iterator of all methods which could be accessed in an instance of this class.
-
getMethods
public java.util.Iterator<MemberDefinition> getMethods()
Get an Iterator of all methods which could be accessed in an instance of this class. Throw a compiler error if we haven't generated this information yet.
-
addMirandaMethods
protected void addMirandaMethods(Environment env, java.util.Iterator<MemberDefinition> mirandas)
Add a list of methods to this class as miranda methods. This gets overridden with a meaningful implementation in SourceClass. BinaryClass should not need to do anything -- it should already have its miranda methods and, if it doesn't, then that doesn't affect our compilation.
-
inlineLocalClass
public void inlineLocalClass(Environment env)
-
resolveTypeStructure
public void resolveTypeStructure(Environment env)
We create a stub for this. Source classes do more work. Some calls from 'SourceClass.checkSupers' execute this method.
-
resolveName
public Identifier resolveName(Environment env, Identifier name)
Look up an inner class name, from somewhere inside this class. Since supers and outers are in scope, search them too.If no inner class is found, env.resolveName() is then called, to interpret the ambient package and import directives.
This routine operates on a "best-efforts" basis. If at some point a class is not found, the partially-resolved identifier is returned. Eventually, someone else has to try to get the ClassDefinition and diagnose the ClassNotFound.
resolveName() looks at surrounding scopes, and hence pulling in both inherited and uplevel types. By contrast, resolveInnerClass() is intended only for interpreting explicitly qualified names, and so look only at inherited types. Also, resolveName() looks for package prefixes, which appear similar to "very uplevel" outer classes.
A similar (but more complex) name-lookup process happens when field and identifier expressions denoting qualified names are type-checked. The added complexity comes from the fact that variables may occur in such names, and take precedence over class and package names.
In the expression type-checker, resolveInnerClass() is paralleled by code in FieldExpression.checkAmbigName(), which also calls ClassDefinition.getInnerClass() to interpret names of the form "OuterClass.Inner" (and also outerObject.Inner). The checking of an identifier expression that fails to be a variable is referred directly to resolveName().
-
resolveInnerClass
public Identifier resolveInnerClass(Environment env, Identifier nm)
Interpret a qualified class name, which may have further subcomponents.. Follow inheritance links, as in: class C { class N { } } class D extends C { } ... new D.N() ... Ignore outer scopes and packages.
-
innerClassExists
boolean innerClassExists(Identifier nm)
While resolving import directives, the question has arisen: does a given inner class exist? If the top-level class exists, we ask it about an inner class via this method. This method looks only at the literal name of the class, and does not attempt to follow inheritance links. This is necessary, since at the time imports are being processed, inheritance links have not been resolved yet. (Thus, an import directive must always spell a class name exactly.)
-
findAnyMethod
public MemberDefinition findAnyMethod(Environment env, Identifier nm) throws ClassNotFound
Find any method with a given name.- Throws:
ClassNotFound
-
diagnoseMismatch
public int diagnoseMismatch(Environment env, Identifier nm, Type[] argTypes, int start, Type[] margTypeResult) throws ClassNotFound
Given the fact that this class has no method "nm" matching "argTypes", find out if the mismatch can be blamed on a particular actual argument which disagrees with all of the overloadings. If so, return the code (i<<2)+(castOK<<1)+ambig, where "i" is the number of the offending argument, and "castOK" is 1 if a cast could fix the problem. The target type for the argument is returned in margTypeResult[0]. If not all methods agree on this type, "ambig" is 1. If there is more than one method, the choice of target type is arbitrary.Return -1 if every argument is acceptable to at least one method. Return -2 if there are no methods of the required arity. The value "start" gives the index of the first argument to begin checking.
- Throws:
ClassNotFound
-
diagnoseMismatch
private boolean diagnoseMismatch(Environment env, Identifier nm, Type[] argTypes, int start, int[] haveMatch, Type[] margType) throws ClassNotFound
- Throws:
ClassNotFound
-
addMember
protected void addMember(MemberDefinition field)
Add a field (no checks)
-
addMember
public void addMember(Environment env, MemberDefinition field)
Add a field (subclasses make checks)
-
getReference
public UplevelReference getReference(LocalMember target)
Find or create an uplevel reference for the given target.
-
addReference
private UplevelReference addReference(LocalMember target)
-
getReferences
public UplevelReference getReferences()
Return the list of all uplevel references.
-
getReferencesFrozen
public UplevelReference getReferencesFrozen()
Return the same value as getReferences. Also, mark the set of references frozen. After that, it is an error to add new references.
-
referencesMustNotBeFrozen
public final void referencesMustNotBeFrozen()
assertion check
-
getClassLiteralLookup
public MemberDefinition getClassLiteralLookup(long fwhere)
Get helper method for class literal lookup.
-
loadNested
public void loadNested(Environment env)
-
getDependencies
public java.util.Iterator<ClassDeclaration> getDependencies()
-
addDependency
public void addDependency(ClassDeclaration c)
Add a dependency
-
getLocalClass
public ClassDefinition getLocalClass(java.lang.String name)
Maintain a hash table of local and anonymous classes whose internal names are prefixed by the current class. The key is the simple internal name, less the prefix.
-
addLocalClass
public void addLocalClass(ClassDefinition c, java.lang.String name)
-
print
public void print(java.io.PrintStream out)
Print for debugging
-
toString
public java.lang.String toString()
Convert to String- Overrides:
toString
in classjava.lang.Object
-
cleanup
public void cleanup(Environment env)
After the class has been written to disk, try to free up some storage.
-
-