changeset 2959:1421777eadbd

ensure builtin classes are declared in the base module
author jjg
date Wed, 01 Apr 2015 11:59:58 -0700
parents 92a298b8a0d7
children 16938aca9549
files src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java src/jdk.javadoc/share/classes/com/sun/tools/javadoc/DocEnv.java
diffstat 3 files changed, 22 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Tue Mar 31 16:48:55 2015 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Apr 01 11:59:58 2015 -0700
@@ -59,6 +59,7 @@
 import com.sun.tools.javac.util.Log;
 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.*;
@@ -104,10 +105,6 @@
     private final Completer initialCompleter;
     private final Completer moduleCompleter;
 
-    /** A symbol for the root module.
-     */
-//    public final ModuleSymbol rootModule;
-
     /** A symbol for the unnamed module.
      */
     public final ModuleSymbol unnamedModule;
@@ -156,6 +153,10 @@
     /** The builtin type of all methods. */
     public final ClassSymbol methodClass;
 
+    /** A symbol for the java.base module.
+     */
+    public final ModuleSymbol javaBase;
+
     /** Predefined types.
      */
     public final Type objectType;
@@ -224,7 +225,7 @@
      */
     public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
 
-    /** The name of the class that belongs to a basix type tag.
+    /** The name of the class that belongs to a basic type tag.
      */
     public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
 
@@ -259,7 +260,7 @@
 
     public void initType(Type type, String name, String bname) {
         initType(type, name);
-            boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname);
+        boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname);
     }
 
     /** The class symbol that owns all predefined symbols.
@@ -270,7 +271,7 @@
      *  @param s The name of the class.
      */
     private Type enterClass(String s) {
-        return enterClass(names.fromString(s)).type;
+        return enterClass(javaBase, names.fromString(s)).type;
     }
 
     public void synthesizeEmptyInterfaceIfMissing(final Type type) {
@@ -291,7 +292,7 @@
     }
 
     public void synthesizeBoxTypeIfMissing(final Type type) {
-        ClassSymbol sym = enterClass(boxedName[type.getTag().ordinal()]);
+        ClassSymbol sym = enterClass(javaBase, boxedName[type.getTag().ordinal()]);
         final Completer completer = sym.completer;
         if (completer != null) {
             sym.completer = new Completer() {
@@ -352,7 +353,6 @@
         final JavacMessages messages = JavacMessages.instance(context);
 
         // create the basic builtin symbols
-//        rootModule = new ModuleSymbol(names.empty, null);
         unnamedModule = new ModuleSymbol(names.empty, null) {
                 @Override
                 public String toString() {
@@ -438,7 +438,14 @@
 
         classes.put(predefClass.fullname, predefClass);
 
-        // Enter predefined classes.
+        Source source = Source.instance(context);
+        Options options = Options.instance(context);
+        boolean noModules = options.isSet("noModules");
+        javaBase = source.allowModules() && !noModules
+                ? enterModule(names.java_base)
+                : noModule;
+
+        // Enter predefined classes. All are assumed to be in the java.base module.
         objectType = enterClass("java.lang.Object");
         objectsType = enterClass("java.util.Objects");
         classType = enterClass("java.lang.Class");
@@ -464,7 +471,7 @@
         cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
         annotationType = enterClass("java.lang.annotation.Annotation");
         classLoaderType = enterClass("java.lang.ClassLoader");
-        enumSym = enterClass(names.java_lang_Enum);
+        enumSym = enterClass(javaBase, names.java_lang_Enum);
         enumFinalFinalize =
             new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
                              names.finalize,
@@ -645,24 +652,7 @@
             p.completer = initialCompleter;
             packages.put(fullname, p);
         }
-//        if (currModule != null) {
-//            if (p.modle == null) {
-//                p.modle = currModule;
-//            } else if (p.modle != currModule) {
-//                // TODO: changing module?
-//                System.err.println("Package: " + fullname
-//                        + " old:" + p.modle
-//                        + " new:" + currModule
-//                        + " types: " + (p.members_field == null ? "null" : p.getEnclosedElements().size()));
-//            }
-//        }
         if (p.modle == null && currModule != null) {
-//            if (p.modleHint != currModule) {
-//                System.err.println("Package: " + fullname
-//                        + " old:" + p.modleHint
-//                        + " new: " + currModule
-//                        + " comp:" + p.completer);
-//            }
             p.modleHint = currModule;
             if (p.completer == null)
                 p.completer = initialCompleter;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Tue Mar 31 16:48:55 2015 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Wed Apr 01 11:59:58 2015 -0700
@@ -3977,7 +3977,7 @@
      * Return the class that boxes the given primitive.
      */
     public ClassSymbol boxedClass(Type t) {
-        return syms.enterClass(syms.boxedName[t.getTag().ordinal()]);
+        return syms.enterClass(syms.javaBase, syms.boxedName[t.getTag().ordinal()]);
     }
 
     /**
@@ -3996,7 +3996,7 @@
         for (int i=0; i<syms.boxedName.length; i++) {
             Name box = syms.boxedName[i];
             if (box != null &&
-                asSuper(t, syms.enterClass(box)) != null)
+                asSuper(t, syms.enterClass(syms.javaBase, box)) != null)
                 return syms.typeOfTag[i];
         }
         return Type.noType;
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/DocEnv.java	Tue Mar 31 16:48:55 2015 -0700
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/DocEnv.java	Wed Apr 01 11:59:58 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,7 +150,7 @@
         finder = JavadocClassFinder.instance(context);
         enter = JavadocEnter.instance(context);
         names = Names.instance(context);
-        externalizableSym = syms.enterClass(names.fromString("java.io.Externalizable"));
+        externalizableSym = syms.enterClass(syms.javaBase, names.fromString("java.io.Externalizable"));
         chk = Check.instance(context);
         types = Types.instance(context);
         fileManager = context.get(JavaFileManager.class);