< prev index next >

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

Print this page
rev 2977 : JDK-8058150

@@ -48,18 +48,20 @@
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.file.JRTIndex;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javac.platform.PlatformProvider;
 import com.sun.tools.javac.util.*;
 
 import static javax.tools.StandardLocation.*;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 
 import static com.sun.tools.javac.main.Option.*;
+
 import com.sun.tools.javac.util.Dependencies.CompletionCause;
 
 /**
  *  This class provides operations to locate class definitions
  *  from the source and class files on the paths provided to javac.

@@ -96,10 +98,15 @@
      * Switch: Search classpath and sourcepath for classes before the
      * bootclasspath
      */
     protected boolean userPathsFirst;
 
+    /**
+     * Switch: should read OTHER classfiles (.sig files) from PLATFORM_CLASS_PATH.
+     */
+    private boolean allowSigFiles;
+
     /** The log to use for verbose output
      */
     final Log log;
 
     /** The symbol table. */

@@ -190,10 +197,11 @@
         Options options = Options.instance(context);
         verbose = options.isSet(VERBOSE);
         cacheCompletionFailure = options.isUnset("dev");
         preferSource = "source".equals(options.get("-Xprefer"));
         userPathsFirst = options.isSet(XXUSERPATHSFIRST);
+        allowSigFiles = context.get(PlatformProvider.class) != null;
 
         completionFailureName =
             options.isSet("failcomplete")
             ? names.fromString(options.get("failcomplete"))
             : null;

@@ -335,11 +343,12 @@
                 }
                 currentClassFile = classfile;
                 if (verbose) {
                     log.printVerbose("loading", currentClassFile.toString());
                 }
-                if (classfile.getKind() == JavaFileObject.Kind.CLASS) {
+                if (classfile.getKind() == JavaFileObject.Kind.CLASS ||
+                    classfile.getKind() == JavaFileObject.Kind.OTHER) {
                     reader.readClassFile(c);
                     c.flags_field |= getSupplementaryFlags(c);
                 } else {
                     if (!sourceCompleter.isTerminal()) {
                         sourceCompleter.complete(c);

@@ -416,11 +425,11 @@
         if ((p.flags_field & EXISTS) == 0)
             for (Symbol q = p; q != null && q.kind == PCK; q = q.owner)
                 q.flags_field |= EXISTS;
         JavaFileObject.Kind kind = file.getKind();
         int seen;
-        if (kind == JavaFileObject.Kind.CLASS)
+        if (kind == JavaFileObject.Kind.CLASS || kind == JavaFileObject.Kind.OTHER)
             seen = CLASS_SEEN;
         else
             seen = SOURCE_SEEN;
         String binaryName = fileManager.inferBinaryName(currentLoc, file);
         int lastDot = binaryName.lastIndexOf(".");

@@ -579,21 +588,33 @@
      */
     private void scanPlatformPath(PackageSymbol p) throws IOException {
         fillIn(p, PLATFORM_CLASS_PATH,
                fileManager.list(PLATFORM_CLASS_PATH,
                                 p.fullname.toString(),
-                                EnumSet.of(JavaFileObject.Kind.CLASS),
+                                allowSigFiles ? EnumSet.of(JavaFileObject.Kind.CLASS,
+                                                           JavaFileObject.Kind.OTHER)
+                                              : EnumSet.of(JavaFileObject.Kind.CLASS),
                                 false));
     }
     // where
+        @SuppressWarnings("fallthrough")
         private void fillIn(PackageSymbol p,
                             Location location,
                             Iterable<JavaFileObject> files)
         {
             currentLoc = location;
             for (JavaFileObject fo : files) {
                 switch (fo.getKind()) {
+                case OTHER:
+                    boolean sigFile = location == PLATFORM_CLASS_PATH &&
+                                      allowSigFiles &&
+                                      fo.getName().endsWith(".sig");
+                    if (!sigFile) {
+                        extraFileActions(p, fo);
+                        break;
+                    }
+                    //intentional fall-through:
                 case CLASS:
                 case SOURCE: {
                     // TODO pass binaryName to includeClassFile
                     String binaryName = fileManager.inferBinaryName(currentLoc, fo);
                     String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
< prev index next >