< prev index next >

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

Print this page
@@ -50,10 +50,11 @@
  import com.sun.tools.javac.code.Type.ErrorType;
  import com.sun.tools.javac.code.Type.JCPrimitiveType;
  import com.sun.tools.javac.code.Type.JCVoidType;
  import com.sun.tools.javac.code.Type.MethodType;
  import com.sun.tools.javac.code.Type.UnknownType;
+ import com.sun.tools.javac.code.Type.WildcardType;
  import com.sun.tools.javac.code.Types.UniqueType;
  import com.sun.tools.javac.comp.Modules;
  import com.sun.tools.javac.jvm.Target;
  import com.sun.tools.javac.util.Assert;
  import com.sun.tools.javac.util.Context;

@@ -63,10 +64,11 @@
  import com.sun.tools.javac.util.Iterators;
  import com.sun.tools.javac.util.JavacMessages;
  import com.sun.tools.javac.util.List;
  import com.sun.tools.javac.util.Name;
  import com.sun.tools.javac.util.Names;
+ import com.sun.tools.javac.util.Options;
  
  import static com.sun.tools.javac.code.Flags.*;
  import static com.sun.tools.javac.code.Kinds.Kind.*;
  import static com.sun.tools.javac.code.TypeTag.*;
  

@@ -272,12 +274,21 @@
  
      public VarSymbol getClassField(Type type, Types types) {
          return classFields.computeIfAbsent(
              new UniqueType(type, types), k -> {
                  Type arg = null;
-                 if (type.getTag() == ARRAY || type.getTag() == CLASS)
-                     arg = types.erasure(type);
+                 if (type.getTag() == ARRAY || type.getTag() == CLASS) {
+                     /* Temporary treatment for primitive class: Given a primitive class V that implements
+                        I1, I2, ... In, V.class is typed to be Class<? extends Object & I1 & I2 .. & In>
+                     */
+                     if (type.isPrimitiveClass()) {
+                         List<Type> bounds = List.of(objectType).appendList(((ClassSymbol) type.tsym).getInterfaces());
+                         arg = new WildcardType(bounds.size() > 1 ? types.makeIntersectionType(bounds) : objectType, BoundKind.EXTENDS, boundClass);
+                     } else {
+                         arg = types.erasure(type);
+                     }
+                 }
                  else if (type.isPrimitiveOrVoid())
                      arg = types.boxedClass(type).type;
                  else
                      throw new AssertionError(type);
  

@@ -632,11 +643,13 @@
          // Enter a class for arrays.
          // The class implements java.lang.Cloneable and java.io.Serializable.
          // It has a final length field and a clone method.
          ClassType arrayClassType = (ClassType)arrayClass.type;
          arrayClassType.supertype_field = objectType;
-         arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
+         arrayClassType.interfaces_field =
+                 List.of(cloneableType, serializableType);
+ 
          arrayClass.members_field = WriteableScope.create(arrayClass);
          lengthVar = new VarSymbol(
              PUBLIC | FINAL,
              names.length,
              intType,
< prev index next >