Class MemberDefinition

  • All Implemented Interfaces:
    Constants, RuntimeConstants
    Direct Known Subclasses:
    AsmMemberDefinition, BinaryMember, LocalMember, SourceMember

    public class MemberDefinition
    extends java.lang.Object
    implements Constants
    This class defines a member of a Java class: a variable, a method, or an inner class. 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.
    • Constructor Detail

      • MemberDefinition

        public MemberDefinition​(ClassDefinition innerClass)
        Constructor for an inner class. Inner classes are represented as fields right along with variables and methods for simplicity of data structure, and to reflect properly the textual declaration order.

        This constructor calls the generic constructor for this class, extracting all necessary values from the innerClass.

    • Method Detail

      • makeProxyMember

        public static MemberDefinition makeProxyMember​(MemberDefinition field,
                                                       ClassDefinition classDef,
                                                       Environment env)
        Create a member which is externally the same as `field' but is defined in class `classDef'. This is used by code in org.glassfish.rmic.tools.tree.(MethodExpression,FieldExpression) as part of the fix for bug 4135692. Proxy members should not be added, ala addMember(), to classes. They are merely "stand-ins" to produce modified MethodRef constant pool entries during code generation. We keep a cache of previously created proxy members not to save time or space, but to ensure uniqueness of the proxy member for any (field,classDef) pair. If these are not made unique then we can end up generating duplicate MethodRef constant pool entries during code generation.
      • getWhere

        public final long getWhere()
        Get the position in the input
      • getClassDeclaration

        public final ClassDeclaration getClassDeclaration()
        Get the class declaration
      • resolveTypeStructure

        public void resolveTypeStructure​(Environment env)
        A stub. Subclasses can do more checking.
      • getDefiningClassDeclaration

        public ClassDeclaration getDefiningClassDeclaration()
        Get the class declaration in which the field is actually defined
      • getClassDefinition

        public final ClassDefinition getClassDefinition()
        Get the class definition
      • getTopClass

        public final ClassDefinition getTopClass()
        Get the field's top-level enclosing class
      • getModifiers

        public final int getModifiers()
        Get the field's modifiers
      • subModifiers

        public final void subModifiers​(int mod)
      • addModifiers

        public final void addModifiers​(int mod)
      • getType

        public final Type getType()
        Get the field's type
      • getName

        public final Identifier getName()
        Get the field's name
      • getArguments

        public java.util.Vector<MemberDefinition> getArguments()
        Get arguments (a vector of LocalMember)
      • getInnerClass

        public ClassDefinition getInnerClass()
        Get an inner class.
      • isUplevelValue

        public boolean isUplevelValue()
        Is this a synthetic field which holds a copy of, or reference to, a local variable or enclosing instance?
      • isAccessMethod

        public boolean isAccessMethod()
      • getAccessMethodTarget

        public MemberDefinition getAccessMethodTarget()
        Is this a synthetic method which provides access to a visible private member?
      • setAccessMethodTarget

        public void setAccessMethodTarget​(MemberDefinition target)
      • getAccessUpdateMember

        public MemberDefinition getAccessUpdateMember()
        If this method is a getter for a private field, return the setter.
      • setAccessUpdateMember

        public void setAccessUpdateMember​(MemberDefinition updater)
      • isSuperAccessMethod

        public final boolean isSuperAccessMethod()
        Is this an access method for a field selection or method call of the form '...super.foo' or '...super.foo()'?
      • setIsSuperAccessMethod

        public final void setIsSuperAccessMethod​(boolean b)
        Mark this member as an access method for a field selection or method call via the 'super' keyword.
      • isBlankFinal

        public final boolean isBlankFinal()
        Tell if this is a final variable without an initializer. Such variables are subject to definite single assignment.
      • isNeverNull

        public boolean isNeverNull()
      • getValue

        public final Node getValue()
      • setValue

        public final void setValue​(Node value)
      • getInitialValue

        public java.lang.Object getInitialValue()
      • getNextMember

        public final MemberDefinition getNextMember()
        Get the next field or the next match
      • getDocumentation

        public java.lang.String getDocumentation()
        Get the field's documentation
      • reportDeprecated

        public boolean reportDeprecated​(Environment env)
        Tells whether to report a deprecation error for this field.
      • canReach

        public final boolean canReach​(Environment env,
                                      MemberDefinition f)
        Check if a field can reach another field (only considers forward references, not the access modifiers).
      • getAccessLevel

        private int getAccessLevel()
        Return the access modifier of this member as a number. The idea is that this number may be used to check properties like "the access modifier of x is more restrictive than the access modifier of y" with a simple inequality test: "x.getAccessLevel() > y.getAccessLevel. This is an internal utility method.
      • reportError

        private void reportError​(Environment env,
                                 java.lang.String errorString,
                                 ClassDeclaration clazz,
                                 MemberDefinition method)
        Munge our error message to report whether the override conflict came from an inherited method or a declared method.
      • sameReturnType

        public boolean sameReturnType​(MemberDefinition method)
        Convenience method to see if two methods return the same type
      • checkOverride

        public boolean checkOverride​(Environment env,
                                     MemberDefinition method)
        Check to see if `this' can override/hide `method'. Caller is responsible for verifying that `method' has the same signature as `this'. Caller is also responsible for verifying that `method' is visible to the class where this override is occurring. This method is called for the case when class B extends A and both A and B define some method.
               A - void foo() throws e1
               |
               |
               B - void foo() throws e2
         
      • checkOverride

        private boolean checkOverride​(Environment env,
                                      MemberDefinition method,
                                      ClassDeclaration clazz)
        Checks whether `this' can override `method'. It `clazz' is null, it reports the errors in the class where `this' is declared. If `clazz' is not null, it reports the error in `clazz'.
      • checkMeet

        public boolean checkMeet​(Environment env,
                                 MemberDefinition method,
                                 ClassDeclaration clazz)
        Check to see if two method definitions are compatible, that is do they have a `meet'. The meet of two methods is essentially and `intersection' of two methods. This method is called when some class C inherits declarations for some method foo from two parents (superclass, interfaces) but it does not, itself, have a declaration of foo. Caller is responsible for making sure that both methods are indeed visible in clazz.
             A - void foo() throws e1
              \
               \     B void foo() throws e2
                \   /
                 \ /
                  C
         
      • couldOverride

        public boolean couldOverride​(Environment env,
                                     MemberDefinition method)
        This method is meant to be used to determine if one of two inherited methods could override the other. Unlike checkOverride(), failure is not an error. This method is only meant to be called after checkMeet() has succeeded on the two methods. If you call couldOverride() without doing a checkMeet() first, then you are on your own.
      • exceptionsFit

        private boolean exceptionsFit​(Environment env,
                                      MemberDefinition method)
        Check to see if the exceptions of `this' fit within the exceptions of `method'.
      • isPublic

        public final boolean isPublic()
        Checks
      • isPrivate

        public final boolean isPrivate()
      • isProtected

        public final boolean isProtected()
      • isPackagePrivate

        public final boolean isPackagePrivate()
      • isFinal

        public final boolean isFinal()
      • isStatic

        public final boolean isStatic()
      • isSynchronized

        public final boolean isSynchronized()
      • isAbstract

        public final boolean isAbstract()
      • isNative

        public final boolean isNative()
      • isVolatile

        public final boolean isVolatile()
      • isTransient

        public final boolean isTransient()
      • isMethod

        public final boolean isMethod()
      • isVariable

        public final boolean isVariable()
      • isSynthetic

        public final boolean isSynthetic()
      • isDeprecated

        public final boolean isDeprecated()
      • isStrict

        public final boolean isStrict()
      • isInnerClass

        public final boolean isInnerClass()
      • isInitializer

        public final boolean isInitializer()
      • isConstructor

        public final boolean isConstructor()
      • isLocal

        public boolean isLocal()
      • isConstant

        public boolean isConstant()
        Check if constant: Will it inline away to a constant?
      • toString

        public java.lang.String toString()
        toString
        Overrides:
        toString in class java.lang.Object
      • print

        public void print​(java.io.PrintStream out)
        Print for debugging