| java.lang.Object sun.tools.java.ClassDefinition
All known Subclasses: sun.tools.javac.SourceClass, sun.tools.java.BinaryClass,
ClassDefinition | public class ClassDefinition implements Constants(Code) | | 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.
|
Method Summary | |
public void | addDependency(ClassDeclaration c) | public void | addLocalClass(ClassDefinition c, String name) | public void | addMember(MemberDefinition field) | public void | addMember(Environment env, MemberDefinition field) | protected void | addMirandaMethods(Environment env, Iterator mirandas) Add a list of methods to this class as miranda methods. | final public void | addModifiers(int mod) | protected UplevelReference | addReference(LocalMember target) | protected void | basicCheck(Environment env) | public boolean | canAccess(Environment env, ClassDeclaration c) Check if another class can be accessed from within the body of this class. | public boolean | canAccess(Environment env, MemberDefinition f) | public void | check(Environment env) Check this class. | public Vset | checkLocalClass(Environment env, Context ctx, Vset vset, ClassDefinition sup, Expression args, Type argTypes) | public 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. | public static boolean | containsDeprecated(String documentation) Return true if the given documentation string contains a deprecation
paragraph. | public boolean | couldImplement(ClassDefinition intDef) Check to see if a class which implements interface `this' could
possibly implement the interface `intDef'. | public 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. | public boolean | enclosingClassOf(ClassDefinition otherClass) | public boolean | extendsCanAccess(Environment env, ClassDeclaration c) Check if another class can be accessed from the 'extends' or 'implements'
clause of this class. | public MemberDefinition | findAnyMethod(Environment env, Identifier nm) Find any method with a given name. | public MemberDefinition | findMethod(Environment env, Identifier nm, Type t) Find a method, ie: exact match in this class or any of the super
classes.
Only called by javadoc. | final public MemberDefinition | findOuterMember() If inner, return an innermost uplevel self pointer, if any exists. | 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. | public Context | getClassContext() | final public ClassDeclaration | getClassDeclaration() | public MemberDefinition | getClassLiteralLookup(long fwhere) Get helper method for class literal lookup. | public String | getDocumentation() | final public boolean | getError() Check if there were any errors in this class. | final public MemberDefinition | getFirstMatch(Identifier name) | final public MemberDefinition | getFirstMember() | public MemberDefinition | getInnerClass(Environment env, Identifier nm) Get an inner class. | final public MemberDefinition | getInnerClassMember() | final public ClassDeclaration | getInterfaces() | public ClassDefinition | getLocalClass(String name) Maintain a hash table of local and anonymous classes
whose internal names are prefixed by the current class. | public Identifier | getLocalName() Return a simple identifier for this class (idNull if anonymous). | public Iterator | getMethods(Environment env) Get an Iterator of all methods which could be accessed in an
instance of this class. | public Iterator | getMethods() Get an Iterator of all methods which could be accessed in an
instance of this class. | final public int | getModifiers() | final public Identifier | getName() | final public boolean | getNestError() Check if there were any errors in our class nest. | final public ClassDefinition | getOuterClass() | protected Iterator | getPermanentlyAbstractMethods() This method returns an Iterator of all abstract methods
in our superclasses which we are unable to implement. | public UplevelReference | getReference(LocalMember target) Find or create an uplevel reference for the given target. | public UplevelReference | getReferences() Return the list of all uplevel references. | public UplevelReference | getReferencesFrozen() Return the same value as getReferences. | final public Object | getSource() | final public ClassDeclaration | 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. | final public ClassDefinition | getTopClass() | final public Type | getType() | 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. | public MemberDefinition | getVariable(Environment env, Identifier nm, ClassDefinition source) Get a field from this class. | final public long | getWhere() | final public boolean | hasConstructor() | public boolean | implementedBy(Environment env, ClassDeclaration c) | final public boolean | inSamePackage(ClassDeclaration c) | final public boolean | inSamePackage(ClassDefinition c) | final public boolean | inSamePackage(Identifier packageName) | public void | inlineLocalClass(Environment env) | public 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. | final public boolean | isAbstract() | final public boolean | isAnonymous() | final public boolean | isClass() | final public boolean | isDeprecated() | final public boolean | isFinal() | final public boolean | isInnerClass() Tell if the class is inner. | final public boolean | isInsideLocal() Tell if the class is local or inside a local class,
which means it cannot be mentioned outside of its file. | final public boolean | isInsideLocalOrAnonymous() Tell if the class is local or or anonymous class, or inside
such a class, which means it cannot be mentioned outside of
its file. | final public boolean | isInterface() | final public boolean | isLocal() | final public boolean | isMember() Tell if the class is a member of another class. | final public boolean | isPackagePrivate() | final public boolean | isPrivate() | final public boolean | isProtected() | final public boolean | isPublic() | final public boolean | isStatic() See if this is a (nested) static class. | final public boolean | isSynthetic() | final public boolean | isTopLevel() Tell if the class is "top-level", which is either a package member,
or a static member of another top-level class. | public 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. | public MemberDefinition | matchMethod(Environment env, ClassDefinition accessor, Identifier methodName, Type[] argumentTypes) Lookup a method. | public MemberDefinition | matchMethod(Environment env, ClassDefinition accessor, Identifier methodName) Lookup a method. | final public boolean | mustBeAbstract(Environment env) Check to see if a class must be abstract. | public void | noteUsedBy(ClassDefinition ref, long where, Environment env) Note that this class is being used somehow by ref. | public boolean | permitInlinedAccess(Environment env, ClassDeclaration c) Check if a class is entitled to inline access to a class from
another class. | public boolean | permitInlinedAccess(Environment env, MemberDefinition f) Check if a class is entitled to inline access to a method from
another class. | public void | print(PrintStream out) | public boolean | protectedAccess(Environment env, MemberDefinition f, Type accessorType) We know the the field is marked protected (and not public) and that
the field is visible (as per canAccess). | final public void | referencesMustNotBeFrozen() | public boolean | reportDeprecated(Environment env) Tells whether to report a deprecation error for this class. | 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 { } ... | 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. | public void | resolveTypeStructure(Environment env) We create a stub for this. | final public void | setError() Mark this class to be erroneous. | public void | setLocalName(Identifier name) Set the local name of a class. | final public void | setNestError() Mark this class, and all siblings in its class nest, to be
erroneous. | final protected void | setOuterClass(ClassDefinition outerClass) Set the class' enclosing class. | final protected void | setOuterMember(MemberDefinition outerMember) Set the class' enclosing current instance pointer. | public boolean | subClassOf(Environment env, ClassDeclaration otherClass) | final public void | subModifiers(int mod) | public boolean | superClassOf(Environment env, ClassDeclaration otherClass) | public String | toString() | public static void | turnOffInheritanceChecks() This is a workaround to allow javadoc to turn off certain
inheritance/override checks which interfere with javadoc
badly. |
doInheritanceChecks | protected static boolean doInheritanceChecks(Code) | | A flag used by turnOffInheritanceChecks() to indicate if
inheritance checks are on or off.
|
error | protected boolean error(Code) | | |
modifiers | protected int modifiers(Code) | | |
nestError | protected boolean nestError(Code) | | |
referencesFrozen | protected boolean referencesFrozen(Code) | | |
resolved | protected boolean resolved(Code) | | |
supersCheckStarted | protected boolean supersCheckStarted(Code) | | |
where | protected long where(Code) | | |
addMirandaMethods | protected void addMirandaMethods(Environment env, Iterator mirandas)(Code) | | 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.
|
addModifiers | final public void addModifiers(int mod)(Code) | | |
cleanup | public void cleanup(Environment env)(Code) | | After the class has been written to disk, try to free up
some storage.
|
collectInheritedMethods | protected void collectInheritedMethods(Environment env)(Code) | | 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.
|
containsDeprecated | public static boolean containsDeprecated(String documentation)(Code) | | 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.
|
couldImplement | public boolean couldImplement(ClassDefinition intDef)(Code) | | 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.
|
diagnoseMismatch | public int diagnoseMismatch(Environment env, Identifier nm, Type argTypes, int start, Type margTypeResult) throws ClassNotFound(Code) | | 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.
|
enclosingClassOf | public boolean enclosingClassOf(ClassDefinition otherClass)(Code) | | Check if this is an enclosing class of another class
|
findMethod | public MemberDefinition findMethod(Environment env, Identifier nm, Type t) throws ClassNotFound(Code) | | 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.
|
findOuterMember | final public MemberDefinition findOuterMember()(Code) | | If inner, return an innermost uplevel self pointer, if any exists.
Otherwise, return null.
|
getClassLiteralLookup | public MemberDefinition getClassLiteralLookup(long fwhere)(Code) | | Get helper method for class literal lookup.
|
getDocumentation | public String getDocumentation()(Code) | | Get the class' documentation
|
getError | final public boolean getError()(Code) | | Check if there were any errors in this class.
|
getInnerClass | public MemberDefinition getInnerClass(Environment env, Identifier nm) throws ClassNotFound(Code) | | 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.
See Also: FieldExpression.checkCommon See Also: resolveName |
getInnerClassMember | final public MemberDefinition getInnerClassMember()(Code) | | If inner, get the field for this class in the enclosing class
|
getLocalClass | public ClassDefinition getLocalClass(String name)(Code) | | 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.
|
getLocalName | public Identifier getLocalName()(Code) | | Return a simple identifier for this class (idNull if anonymous).
|
getMethods | public Iterator getMethods(Environment env)(Code) | | Get an Iterator of all methods which could be accessed in an
instance of this class.
|
getMethods | public Iterator getMethods()(Code) | | 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.
|
getModifiers | final public int getModifiers()(Code) | | Get the class' modifiers
|
getNestError | final public boolean getNestError()(Code) | | Check if there were any errors in our class nest.
|
getOuterClass | final public ClassDefinition getOuterClass()(Code) | | Get the class' enclosing class (or null if not inner)
|
getPermanentlyAbstractMethods | protected Iterator getPermanentlyAbstractMethods()(Code) | | This method returns an Iterator of all abstract methods
in our superclasses which we are unable to implement.
|
getReferencesFrozen | public UplevelReference getReferencesFrozen()(Code) | | Return the same value as getReferences.
Also, mark the set of references frozen.
After that, it is an error to add new references.
|
getSource | final public Object getSource()(Code) | | Get the source of the class
|
getSuperClass | public ClassDeclaration getSuperClass(Environment env)(Code) | | 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.
See Also: ClassDefinition.resolveTypeStructure |
getType | final public Type getType()(Code) | | Get the class' type
|
getVariable | public MemberDefinition getVariable(Environment env, Identifier nm, ClassDefinition source) throws AmbiguousMember, ClassNotFound(Code) | | 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)
|
getWhere | final public long getWhere()(Code) | | Get the position in the input
|
hasConstructor | final public boolean hasConstructor()(Code) | | |
innerClassExists | public boolean innerClassExists(Identifier nm)(Code) | | 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.)
|
isAbstract | final public boolean isAbstract()(Code) | | |
isAnonymous | final public boolean isAnonymous()(Code) | | |
isClass | final public boolean isClass()(Code) | | |
isDeprecated | final public boolean isDeprecated()(Code) | | |
isFinal | final public boolean isFinal()(Code) | | |
isInnerClass | final public boolean isInnerClass()(Code) | | 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().
|
isInsideLocal | final public boolean isInsideLocal()(Code) | | Tell if the class is local or inside a local class,
which means it cannot be mentioned outside of its file.
|
isInsideLocalOrAnonymous | final public boolean isInsideLocalOrAnonymous()(Code) | | Tell if the class is local or or anonymous class, or inside
such a class, which means it cannot be mentioned outside of
its file.
|
isInterface | final public boolean isInterface()(Code) | | Checks
|
isLocal | final public boolean isLocal()(Code) | | |
isMember | final public boolean isMember()(Code) | | Tell if the class is a member of another class.
This is false for package members and for block-local classes.
|
isPackagePrivate | final public boolean isPackagePrivate()(Code) | | |
isPrivate | final public boolean isPrivate()(Code) | | |
isProtected | final public boolean isProtected()(Code) | | |
isPublic | final public boolean isPublic()(Code) | | |
isStatic | final public boolean isStatic()(Code) | | See if this is a (nested) static class.
|
isSynthetic | final public boolean isSynthetic()(Code) | | |
isTopLevel | final public boolean isTopLevel()(Code) | | Tell if the class is "top-level", which is either a package member,
or a static member of another top-level class.
|
matchAnonConstructor | public MemberDefinition matchAnonConstructor(Environment env, Identifier accessPackage, Type argumentTypes) throws AmbiguousMember, ClassNotFound(Code) | | 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.
|
mustBeAbstract | final public boolean mustBeAbstract(Environment env)(Code) | | Check to see if a class must be abstract. This method replaces
isAbstract(env)
|
noteUsedBy | public void noteUsedBy(ClassDefinition ref, long where, Environment env)(Code) | | Note that this class is being used somehow by ref.
Report deprecation errors, etc.
|
protectedAccess | public boolean protectedAccess(Environment env, MemberDefinition f, Type accessorType) throws ClassNotFound(Code) | | We know the 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
|
referencesMustNotBeFrozen | final public void referencesMustNotBeFrozen()(Code) | | assertion check
|
reportDeprecated | public boolean reportDeprecated(Environment env)(Code) | | Tells whether to report a deprecation error for this class.
|
resolveInnerClass | public Identifier resolveInnerClass(Environment env, Identifier nm)(Code) | | 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.
See Also: resolveName |
resolveName | public Identifier resolveName(Environment env, Identifier name)(Code) | | 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().
|
setError | final public void setError()(Code) | | Mark this class to be erroneous.
|
setLocalName | public void setLocalName(Identifier name)(Code) | | Set the local name of a class. Must be a local class.
|
setNestError | final public void setNestError()(Code) | | Mark this class, and all siblings in its class nest, to be
erroneous.
|
setOuterClass | final protected void setOuterClass(ClassDefinition outerClass)(Code) | | Set the class' enclosing class. Must be done at most once.
|
setOuterMember | final protected void setOuterMember(MemberDefinition outerMember)(Code) | | Set the class' enclosing current instance pointer.
Must be done at most once.
|
subModifiers | final public void subModifiers(int mod)(Code) | | |
turnOffInheritanceChecks | public static void turnOffInheritanceChecks()(Code) | | 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.
|
|
|