< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java

Print this page
@@ -35,10 +35,11 @@
  import com.sun.tools.javac.code.Kinds.KindName;
  import com.sun.tools.javac.code.Kinds.KindSelector;
  import com.sun.tools.javac.code.Scope.*;
  import com.sun.tools.javac.code.Symbol.*;
  import com.sun.tools.javac.code.Type.*;
+ import com.sun.tools.javac.code.Type.ClassType.Flavor;
  import com.sun.tools.javac.main.Option.PkgInfo;
  import com.sun.tools.javac.resources.CompilerProperties.Errors;
  import com.sun.tools.javac.resources.CompilerProperties.Warnings;
  import com.sun.tools.javac.tree.*;
  import com.sun.tools.javac.tree.JCTree.*;

@@ -102,10 +103,11 @@
      JavaFileManager fileManager;
      PkgInfo pkginfoOpt;
      TypeEnvs typeEnvs;
      Modules modules;
      JCDiagnostic.Factory diags;
+     boolean allowPrimitiveClasses;
  
      private final Todo todo;
  
      public static Enter instance(Context context) {
          Enter instance = context.get(enterKey);

@@ -142,10 +144,12 @@
          fileManager = context.get(JavaFileManager.class);
  
          Options options = Options.instance(context);
          pkginfoOpt = PkgInfo.get(options);
          typeEnvs = TypeEnvs.instance(context);
+         Source source = Source.instance(context);
+         allowPrimitiveClasses = Source.Feature.PRIMITIVE_CLASSES.allowedInSource(source) && options.isSet("enablePrimitiveClasses");
      }
  
      /** Accessor for typeEnvs
       */
      public Env<AttrContext> getEnv(TypeSymbol sym) {

@@ -503,10 +507,14 @@
          c.members_field = WriteableScope.create(c);
          c.isPermittedExplicit = tree.permitting.nonEmpty();
          c.clearAnnotationMetadata();
  
          ClassType ct = (ClassType)c.type;
+         if (allowPrimitiveClasses) {
+             ct.flavor = ct.flavor.metamorphose((c.flags_field & PRIMITIVE_CLASS) != 0);
+         }
+ 
          if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
              // We are seeing a local or inner class.
              // Set outer_field of this class to closest enclosing class
              // which contains this class in a non-static context
              // (its "enclosing instance class"), provided such a class exists.

@@ -521,10 +529,16 @@
          }
  
          // Enter type parameters.
          ct.typarams_field = classEnter(tree.typarams, localEnv);
          ct.allparams_field = null;
+         if (allowPrimitiveClasses && ct.isPrimitiveClass()) {
+             if (ct.projection != null) {
+                 ct.projection.typarams_field = ct.typarams_field;
+                 ct.projection.allparams_field = ct.allparams_field;
+             }
+         }
  
          // install further completer for this type.
          c.completer = typeEnter;
  
          // Add non-local class to uncompleted, to make sure it will be
< prev index next >