< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java

Print this page
*** 50,10 ***
--- 50,11 ---
  import javax.lang.model.element.VariableElement;
  import javax.tools.JavaFileManager;
  import javax.tools.JavaFileObject;
  
  import com.sun.tools.javac.code.Kinds.Kind;
+ import com.sun.tools.javac.code.Type.ClassType.Flavor;
  import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
  import com.sun.tools.javac.code.Type.*;
  import com.sun.tools.javac.comp.Attr;
  import com.sun.tools.javac.comp.AttrContext;
  import com.sun.tools.javac.comp.Env;

*** 413,10 ***
--- 414,22 ---
  
      public boolean isPrivate() {
          return (flags_field & Flags.AccessFlags) == PRIVATE;
      }
  
+     public boolean isSynthetic() {
+         return (flags_field & SYNTHETIC) != 0;
+     }
+ 
+     public boolean isReferenceFavoringPrimitiveClass() {
+         return (flags() & REFERENCE_FAVORING) != 0;  // bit set only for primitive classes
+     }
+ 
+     public boolean isPrimitiveClass() {
+         return (flags() & PRIMITIVE_CLASS) != 0;
+     }
+ 
      public boolean isPublic() {
          return (flags_field & Flags.AccessFlags) == PUBLIC;
      }
  
      public boolean isEnum() {

*** 454,11 ***
      }
  
      /** Is this symbol a constructor?
       */
      public boolean isConstructor() {
!         return name == name.table.names.init;
      }
  
      public boolean isDynamic() {
          return false;
      }
--- 467,17 ---
      }
  
      /** Is this symbol a constructor?
       */
      public boolean isConstructor() {
!         return name == name.table.names.init && (flags() & STATIC) == 0;
+     }
+ 
+     /** Is this symbol a primitive object factory?
+      */
+     public boolean isPrimitiveObjectFactory() {
+         return ((name == name.table.names.init && this.type.getReturnType().tsym == this.owner));
      }
  
      public boolean isDynamic() {
          return false;
      }

*** 1314,11 ***
  
          public ClassSymbol(long flags, Name name, Symbol owner) {
              this(
                  flags,
                  name,
!                 new ClassType(Type.noType, null, null),
                  owner);
              this.type.tsym = this;
          }
  
          /** The Java source which this symbol represents.
--- 1333,11 ---
  
          public ClassSymbol(long flags, Name name, Symbol owner) {
              this(
                  flags,
                  name,
!                 new ClassType(Type.noType, null, null, TypeMetadata.EMPTY, Flavor.X_Typeof_X),
                  owner);
              this.type.tsym = this;
          }
  
          /** The Java source which this symbol represents.

*** 1351,19 ***
  
          public Type erasure(Types types) {
              if (erasure_field == null)
                  erasure_field = new ClassType(types.erasure(type.getEnclosingType()),
                                                List.nil(), this,
!                                               type.getMetadata());
              return erasure_field;
          }
  
          public String className() {
              if (name.isEmpty())
                  return
                      Log.getLocalizedString("anonymous.class", flatname);
!             else
                  return fullname.toString();
          }
  
          @DefinedBy(Api.LANGUAGE_MODEL)
          public Name getQualifiedName() {
--- 1370,20 ---
  
          public Type erasure(Types types) {
              if (erasure_field == null)
                  erasure_field = new ClassType(types.erasure(type.getEnclosingType()),
                                                List.nil(), this,
!                                               type.getMetadata(),
+                                               type.getFlavor());
              return erasure_field;
          }
  
          public String className() {
              if (name.isEmpty())
                  return
                      Log.getLocalizedString("anonymous.class", flatname);
! 
                  return fullname.toString();
          }
  
          @DefinedBy(Api.LANGUAGE_MODEL)
          public Name getQualifiedName() {

*** 1412,10 ***
--- 1432,18 ---
                  ex.dcfh.classSymbolCompleteFailed(this, origCompleter);
                  // quiet error recovery
                  flags_field |= (PUBLIC|STATIC);
                  this.type = new ErrorType(this, Type.noType);
                  throw ex;
+             } finally {
+                 if (this.type != null && this.type.hasTag(CLASS)) {
+                     ClassType ct = (ClassType) this.type;
+                     ct.flavor = ct.flavor.metamorphose(this.flags_field);
+                     if (!this.type.isIntersection() && this.erasure_field != null && this.erasure_field.hasTag(CLASS)) {
+                         ((ClassType) this.erasure_field).flavor = ct.flavor;
+                     }
+                 }
              }
          }
  
          @DefinedBy(Api.LANGUAGE_MODEL)
          public List<Type> getInterfaces() {

*** 1601,10 ***
--- 1629,11 ---
                  classType.typarams_field = null;
                  classType.allparams_field = null;
                  classType.supertype_field = null;
                  classType.interfaces_field = null;
                  classType.all_interfaces_field = null;
+                 classType.flavor = Flavor.X_Typeof_X;
              }
              clearAnnotationMetadata();
          }
  
          public void clearAnnotationMetadata() {

*** 2017,11 ***
              if (this == _other) return true;
              MethodSymbol other = (MethodSymbol)_other;
  
              // check for a direct implementation
              if (other.isOverridableIn((TypeSymbol)owner) &&
!                 types.asSuper(owner.type, other.owner) != null &&
                  types.isSameType(erasure(types), other.erasure(types)))
                  return true;
  
              // check for an inherited implementation
              return
--- 2046,11 ---
              if (this == _other) return true;
              MethodSymbol other = (MethodSymbol)_other;
  
              // check for a direct implementation
              if (other.isOverridableIn((TypeSymbol)owner) &&
!                 types.asSuper(owner.type.referenceProjectionOrSelf(), other.owner) != null &&
                  types.isSameType(erasure(types), other.erasure(types)))
                  return true;
  
              // check for an inherited implementation
              return

*** 2086,11 ***
              if (this == _other) return true;
              MethodSymbol other = (MethodSymbol)_other;
  
              // check for a direct implementation
              if (other.isOverridableIn((TypeSymbol)owner) &&
!                 types.asSuper(owner.type, other.owner) != null) {
                  Type mt = types.memberType(owner.type, this);
                  Type ot = types.memberType(owner.type, other);
                  if (types.isSubSignature(mt, ot)) {
                      if (!checkResult)
                          return true;
--- 2115,11 ---
              if (this == _other) return true;
              MethodSymbol other = (MethodSymbol)_other;
  
              // check for a direct implementation
              if (other.isOverridableIn((TypeSymbol)owner) &&
!                 types.asSuper(owner.type.referenceProjectionOrSelf(), other.owner) != null) {
                  Type mt = types.memberType(owner.type, this);
                  Type ot = types.memberType(owner.type, other);
                  if (types.isSubSignature(mt, ot)) {
                      if (!checkResult)
                          return true;

*** 2135,10 ***
--- 2164,11 ---
              }
          }
  
          @Override
          public boolean isInheritedIn(Symbol clazz, Types types) {
+ 
              switch ((int)(flags_field & Flags.AccessFlags)) {
                  case PUBLIC:
                      return !this.owner.isInterface() ||
                              clazz == owner ||
                              (flags_field & STATIC) == 0;

*** 2441,11 ***
              }
              accessCode = AccessCode.from(tag, opcode);
              return accessCode;
          }
  
!         /** Access codes for dereferencing, assignment,
           *  and pre/post increment/decrement.
  
           *  All access codes for accesses to the current class are even.
           *  If a member of the superclass should be accessed instead (because
           *  access was via a qualified super), add one to the corresponding code
--- 2471,11 ---
              }
              accessCode = AccessCode.from(tag, opcode);
              return accessCode;
          }
  
!         /** Access codes for dereferencing, assignment, withfield
           *  and pre/post increment/decrement.
  
           *  All access codes for accesses to the current class are even.
           *  If a member of the superclass should be accessed instead (because
           *  access was via a qualified super), add one to the corresponding code

*** 2461,11 ***
              ASSIGN(2, Tag.ASSIGN),
              PREINC(4, Tag.PREINC),
              PREDEC(6, Tag.PREDEC),
              POSTINC(8, Tag.POSTINC),
              POSTDEC(10, Tag.POSTDEC),
!             FIRSTASGOP(12, Tag.NO_TAG);
  
              public final int code;
              public final Tag tag;
              public static final int numberOfAccessCodes = (lushrl - ishll + lxor + 2 - iadd) * 2 + FIRSTASGOP.code + 2;
  
--- 2491,12 ---
              ASSIGN(2, Tag.ASSIGN),
              PREINC(4, Tag.PREINC),
              PREDEC(6, Tag.PREDEC),
              POSTINC(8, Tag.POSTINC),
              POSTDEC(10, Tag.POSTDEC),
!             WITHFIELD(12, Tag.WITHFIELD),
+             FIRSTASGOP(14, Tag.NO_TAG);
  
              public final int code;
              public final Tag tag;
              public static final int numberOfAccessCodes = (lushrl - ishll + lxor + 2 - iadd) * 2 + FIRSTASGOP.code + 2;
  

*** 2494,10 ***
--- 2525,12 ---
                          return AccessCode.PREDEC.code;
                      case POSTINC:
                          return AccessCode.POSTINC.code;
                      case POSTDEC:
                          return AccessCode.POSTDEC.code;
+                     case WITHFIELD:
+                         return AccessCode.WITHFIELD.code;
                  }
                  if (iadd <= opcode && opcode <= lxor) {
                      return (opcode - iadd) * 2 + FIRSTASGOP.code;
                  } else if (opcode == string_add) {
                      return (lxor + 1 - iadd) * 2 + FIRSTASGOP.code;
< prev index next >