/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** Root class for Java symbols. It contains subclasses
* for specific sorts of symbols, such as variables, methods and operators,
* types, packages. Each subclass is represented as a static inner class
* inside Symbol.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
// public Throwable debug = new Throwable();
/** The kind of this symbol.
* @see Kinds
*/
public int kind;
/** The flags of this symbol.
*/
public long flags_field;
/** An accessor method for the flags of this symbol.
* Flags of class symbols should be accessed through the accessor
* method to make sure that the class symbol is loaded.
*/
/** The attributes of this symbol.
*/
/** An accessor method for the attributes of this symbol.
* Attributes of class symbols should be accessed through the accessor
* method to make sure that the class symbol is loaded.
*/
}
/** Fetch a particular annotation from a symbol. */
return null;
}
/** The name of this symbol in Utf8 representation.
*/
/** The type of this symbol.
*/
/** The owner of this symbol.
*/
/** The completer of this symbol.
*/
/** A cache for the type erasure of this symbol.
*/
/** Construct a symbol with given kind, flags, name, type and owner.
*/
this.flags_field = flags;
this.erasure_field = null;
}
/** Clone this symbol with new owner.
* Legal only for fields and methods.
*/
throw new AssertionError();
}
return v.visitSymbol(this, p);
}
/** The Java source which this symbol represents.
* A description of this symbol; overrides Object.
*/
}
/** A Java source description of the location of this symbol; used for
* error reporting.
*
* @return null if the symbol is a package or a toplevel class defined in
* the default package; otherwise, the owner symbol is returned
*/
return null;
}
return owner;
}
return location();
}
}
return owner;
}
/** The symbol's erased type.
*/
if (erasure_field == null)
return erasure_field;
}
/** The external type of a symbol. This is the symbol's erased type
* except for constructors of inner classes which get the enclosing
* instance class added as first argument.
*/
t.getReturnType(),
t.getThrownTypes(),
t.tsym);
} else {
return t;
}
}
public boolean isStatic() {
return
}
public boolean isInterface() {
}
/** Recognize if this symbol was marked @PolymorphicSignature in the source. */
public boolean isPolymorphicSignatureGeneric() {
}
/** Recognize if this symbol was split from a @PolymorphicSignature symbol in the source. */
public boolean isPolymorphicSignatureInstance() {
return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == (POLYMORPHIC_SIGNATURE | HYPOTHETICAL);
}
/** Is this symbol declared (directly or indirectly) local
* to a method or variable initializer?
* Also includes fields of inner classes which are in
* turn local to a method or variable initializer.
*/
public boolean isLocal() {
return
}
/** Has this symbol an empty name? This includes anonymous
* inner classses.
*/
public boolean isAnonymous() {
}
/** Is this symbol a constructor?
*/
public boolean isConstructor() {
}
/** The fully qualified name of this symbol.
* This is the same as the symbol's name except for class symbols,
* which are handled separately.
*/
return name;
}
/** The fully qualified name of this symbol after converting to flat
* representation. This is the same as the symbol's name except for
* class symbols, which are handled separately.
*/
return getQualifiedName();
}
/** If this is a class or package, its members, otherwise null.
*/
return null;
}
/** A class is an inner class if it it has an enclosing instance class.
*/
public boolean isInner() {
}
/** An inner class has an outer instance if it is not an interface
* it has an enclosing instance class which might be referenced from the class.
* Nested classes can see instance members of their enclosing class.
* Their constructors carry an additional this$n parameter, inserted
* implicitly by the compiler.
*
* @see #isInner
*/
public boolean hasOuterInstance() {
return
}
/** The closest enclosing class of this symbol's declaration.
*/
Symbol c = this;
while (c != null &&
c = c.owner;
}
return (ClassSymbol)c;
}
/** The outermost class which indirectly owns this symbol.
*/
}
return (ClassSymbol) prev;
}
/** The package which indirectly owns this symbol.
*/
}
return (PackageSymbol) sym;
}
/** Is this symbol a subclass of `base'? Only defined for ClassSymbols.
*/
throw new AssertionError("isSubClass " + this);
}
/** Fully check membership: hierarchy, protection, and hiding.
* Does not exclude methods not inherited due to overriding.
*/
return
}
/** Is this symbol the same as or enclosed by the given class? */
return false;
}
/** Check for hiding. Note that this doesn't handle multiple
* (interface) inheritance. */
while (true) {
if (e.sym == this) return false;
return true;
e = e.next();
}
}
}
/** Is this symbol inherited into a given class?
* PRE: If symbol's owner is a interface,
* it is already assumed that the interface is a superinterface
* of given class.
* @param clazz The class for which we want to establish membership.
* This must be a subclass of the member's owner.
*/
default: // error recovery
case PUBLIC:
return true;
case PRIVATE:
case PROTECTED:
// we model interfaces as extending Object
case 0:
return true; // error recovery
continue;
return false;
}
}
}
/** The (variable or method) symbol seen as a member of given
* class type`site' (this might change the symbol's type).
* This is used exclusively for producing diagnostics.
*/
throw new AssertionError();
}
/** Does this method symbol override `other' symbol, when both are seen as
* members of class `origin'? It is assumed that _other is a member
* of origin.
*
* It is assumed that both symbols have the same name. The static
* modifier is ignored for this test.
*
* See JLS 8.4.6.1 (without transitivity) and 8.4.6.4
*/
return false;
}
/** Complete the elaboration of this symbol's definition.
*/
c.complete(this);
}
}
/** True if the symbol represents an entity that exists.
*/
public boolean exists() {
return true;
}
return type;
}
return owner;
}
}
}
return name;
}
/**
* @deprecated this method should never be used by javac internally.
*/
}
// TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList
}
}
return l.toList();
}
}
public boolean isInheritedIn(Symbol clazz, Types types) { return other.isInheritedIn(clazz, types); }
}
return v.visitSymbol(other, p);
}
}
/** A class for type symbols. Type variables are represented by instances
* of this class, classes and packages by instances of subclasses.
*/
public static class TypeSymbol
extends Symbol implements TypeParameterElement {
// Implements TypeParameterElement because type parameters don't
// have their own TypeSymbol subclass.
// TODO: type parameters should have their own TypeSymbol subclass
}
/** form a fully qualified name from a name and an owner
*/
)) return name;
return name;
}
/** form a fully qualified name from a name and an owner, after
* converting to flat representation
*/
) return name;
return name;
}
/**
* A total ordering between type symbols that refines the
* class inheritance graph.
*
* Typevariables always precede other kinds of symbols.
*/
if (this == that)
return false;
return
}
}
}
// For type params; overridden in subclasses.
return ElementKind.TYPE_PARAMETER;
}
return list;
}
}
return list;
}
// For type params.
// Perhaps not needed if getEnclosingElement can be spec'ed
// to do the same thing.
// TODO: getGenericElement() might not be needed
return owner;
}
return v.visitTypeParameter(this, p);
}
return v.visitTypeSymbol(this, p);
}
if (!bound.isCompound())
} else {
// No superclass was given in bounds.
// In this case, supertype is Object, erasure is first interface.
return ct.interfaces_field;
}
}
}
/** A class for package symbols
*/
implements PackageElement {
this.members_field = null;
}
this.type = new PackageType(this);
}
}
return fullname;
}
public boolean isUnnamed() {
}
return members_field;
}
public long flags() {
return flags_field;
}
if (attributes_field.isEmpty())
}
}
/** A package "exists" if a type or package that exists has
* been seen within it.
*/
public boolean exists() {
}
return ElementKind.PACKAGE;
}
return null;
}
return v.visitPackage(this, p);
}
return v.visitPackageSymbol(this, p);
}
}
/** A class for class symbols
*/
/** a scope for all class members; variables, methods and inner classes
* type parameters are not part of this scope
*/
/** the fully qualified name of the class, i.e. pck.outer.inner.
* null for anonymous classes
*/
/** the fully qualified name of the class after converting to flat
* representation, i.e. pck.outer$inner,
* set externally for local and anonymous classes
*/
/** the sourcefile where the class came from
*/
/** the classfile from where to load this class
* this will have extension .class or .java
*/
/** the list of translated local classes (used for generating
* InnerClasses attribute)
*/
/** the constant pool of the class
*/
this.members_field = null;
this.sourcefile = null;
}
this(
name,
owner);
}
/** The Java source which this symbol represents.
*/
return className();
}
public long flags() {
return flags_field;
}
return members_field;
}
}
if (erasure_field == null)
return erasure_field;
}
return
else
}
return fullname;
}
return flatname;
}
if (this == base) {
return true;
} else {
}
return false;
}
/** Complete the elaboration of this symbol's definition.
*/
try {
super.complete();
} catch (CompletionFailure ex) {
// quiet error recovery
throw ex;
}
}
complete();
if (t.all_interfaces_field != null)
return t.interfaces_field;
} else {
}
}
complete();
// An interface has no superclass; its supertype is Object.
return t.isInterface()
: t.supertype_field.getModelType();
} else {
}
}
return ElementKind.ANNOTATION_TYPE;
return ElementKind.INTERFACE;
return ElementKind.ENUM;
else
return ElementKind.CLASS;
}
complete();
return NestingKind.TOP_LEVEL;
return NestingKind.ANONYMOUS;
return NestingKind.LOCAL;
else
return NestingKind.MEMBER;
}
/**
* @deprecated this method should never be used by javac internally.
*/
}
return v.visitType(this, p);
}
return v.visitClassSymbol(this, p);
}
}
/** A class for variable symbols
*/
/** The variable's declaration position.
*/
/** The variable's address. Used for different purposes during
* flow analysis, translation and code generation.
* Flow analysis:
* If this is a blank final or local variable, its sequence number.
* Translation:
* If this is a private field, its access number.
* Code generation:
* If this is a local variable, its logical slot number.
*/
/** Construct a variable symbol, given its flags, name, type and owner.
*/
}
/** Clone this symbol with new owner.
*/
// System.out.println("clone " + v + " in " + newOwner);//DEBUG
return v;
}
}
}
if (isExceptionParameter())
return ElementKind.EXCEPTION_PARAMETER;
else
return ElementKind.PARAMETER;
return ElementKind.ENUM_CONSTANT;
return ElementKind.FIELD;
} else if (isResourceVariable()) {
return ElementKind.RESOURCE_VARIABLE;
} else {
return ElementKind.LOCAL_VARIABLE;
}
}
return v.visitVariable(this, p);
}
}
{
}
});
}
/**
* The variable's constant value, if this is a constant.
* Before the constant value is evaluated, it points to an
* initalizer environment. If this is not a constant, it can
* be used for other stuff.
*/
public boolean isExceptionParameter() {
}
public boolean isResourceVariable() {
}
// TODO: Consider if getConstValue and getConstantValue can be collapsed
return null;
// In this case, this is a final variable, with an as
// yet unevaluated initializer.
try {
throw new AssertionError(ex);
}
}
return data;
}
}
return v.visitVarSymbol(this, p);
}
}
/** A class for method symbols.
*/
/** The code of the method. */
/** The parameters of the method. */
/** The names of the parameters */
/** For an attribute field accessor, its default value if any.
* The value is null if none appeared in the method
* declaration.
*/
/** Construct a method symbol, given its flags, name, type and owner.
*/
}
/** Clone this symbol with new owner.
*/
return m;
}
/** The Java source which this symbol represents.
*/
} else {
}
return s;
}
}
/** find a symbol that this (proxy method) symbol implements.
* @param c The class whose members are searched for
* implementations
*/
}
return impl;
}
e = e.next()) {
// FIXME: I suspect the following requires a
// subst() for a parametric return type.
}
}
return impl;
}
/** Will the erasure of this method be considered by the VM to
* override the erasure of the other when seen from class `origin'?
*/
if (this == _other) return true;
// check for a direct implementation
return true;
// check for an inherited implementation
return
}
/** The implementation of this (abstract) symbol in class origin,
* from the VM's point of view, null if method does not have an
* implementation in class.
* @param origin The class of which the implementation is a member.
*/
e = e.next()) {
return (MethodSymbol)e.sym;
}
}
return null;
}
/** Does this symbol override `other' symbol, when both are seen as
* members of class `origin'? It is assumed that _other is a member
* of origin.
*
* It is assumed that both symbols have the same name. The static
* modifier is ignored for this test.
*
* See JLS 8.4.6.1 (without transitivity) and 8.4.6.4
*/
if (this == _other) return true;
// check for a direct implementation
if (!checkResult)
return true;
return true;
}
}
// check for an inherited implementation
return false;
// assert types.asSuper(origin.type, other.owner) != null;
return
}
// JLS 8.4.6.1
return false;
return true;
case 0:
// for package private: can only override in the same
// package
return
default:
return false;
}
}
/** The implementation of this (abstract) symbol in class origin;
* null if none exists. Synthetic methods are not considered
* as possible implementations.
*/
}
// where
}
};
public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
return res;
// if origin is derived from a raw type, we might have missed
// an implementation because we do not know enough about instantiations.
// in this case continue with the supertype as origin.
else
return null;
}
// If ClassReader.saveParameterNames has been set true, then
// savedParameterNames will be set to a list of names that
// matches the types in type.getParameterTypes(). If any names
// were not found in the class file, those names in the list will
// be set to the empty name.
// If ClassReader.saveParameterNames has been set false, then
// savedParameterNames will be null.
// discard the provided names if the list of names is the wrong size.
// assert: remaining and paramNames are both empty or both
// have same cardinality as type.getParameterTypes()
int i = 0;
// no names for any parameters available
} else {
// no name for this specific parameter
}
}
i++;
}
}
return params;
}
// Create a name for the argument at position 'index' that is not in
// the exclude list. In normal use, either no names will have been
// provided, in which case the exclude list is empty, or all the names
// will have been provided, in which case this method will not be called.
while (true) {
return argName;
prefix += "$";
}
}
}
return ElementKind.CONSTRUCTOR;
return ElementKind.STATIC_INIT;
else
return ElementKind.METHOD;
}
public boolean isStaticOrInstanceInit() {
}
return defaultValue;
}
return params();
}
public boolean isVarArgs() {
}
return v.visitExecutable(this, p);
}
return v.visitMethodSymbol(this, p);
}
return asType().getReturnType();
}
return asType().getThrownTypes();
}
}
/** A class for predefined operators.
*/
public int opcode;
}
return v.visitOperatorSymbol(this, p);
}
}
/** Symbol completer interface.
*/
public static interface Completer {
}
/** A diagnostic object describing the failure
*/
/** A localized string describing the failure.
* @deprecated Use {@code getDetail()} or {@code getMessage()}
*/
// this.printStackTrace();//DEBUG
}
// this.printStackTrace();//DEBUG
}
return diag;
}
else
return errmsg;
}
}
return this;
}
}
/**
* A visitor for symbols. A visitor is used to implement operations
* (or relations) on symbols. Most common operations on types are
* binary relations and this interface is designed for binary
* relations, that is, operations on the form
* Symbol × P → R.
* <!-- In plain text: Type x P -> R -->
*
* @param <R> the return type of the operation implemented by this
* visitor; use Void if no return type is needed.
* @param <P> the type of the second argument (the first being the
* symbol itself) of the operation implemented by this visitor; use
* Void if a second argument is not needed.
*/
public interface Visitor<R,P> {
}
}