langtools/src/jdk.compiler/share/classes/com/sun/tools/javap/JavapTask.java
changeset 27858 443efec4bf09
parent 27579 d1a63c99cdd5
parent 27852 2e6ad0e4fe20
child 29291 076c277565f7
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javap/JavapTask.java	Wed Jul 05 20:08:43 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javap/JavapTask.java	Wed Dec 03 19:28:40 2014 +0000
@@ -36,6 +36,10 @@
 import java.io.StringWriter;
 import java.io.Writer;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.NoSuchFileException;
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -61,10 +65,6 @@
 import javax.tools.StandardLocation;
 
 import com.sun.tools.classfile.*;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
 
@@ -568,7 +568,7 @@
             } catch (EOFException e) {
                 reportError("err.end.of.file", className);
                 result = EXIT_ERROR;
-            } catch (FileNotFoundException e) {
+            } catch (FileNotFoundException | NoSuchFileException e) {
                 reportError("err.file.not.found", e.getLocalizedMessage());
                 result = EXIT_ERROR;
             } catch (IOException e) {
@@ -668,9 +668,12 @@
 
         if (fileManager instanceof StandardJavaFileManager) {
             StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
-            fo = sfm.getJavaFileObjects(className).iterator().next();
-            if (fo != null && fo.getLastModified() != 0) {
-                return fo;
+            try {
+                fo = sfm.getJavaFileObjects(className).iterator().next();
+                if (fo != null && fo.getLastModified() != 0) {
+                    return fo;
+                }
+            } catch (IllegalArgumentException ignore) {
             }
         }
 
@@ -860,11 +863,15 @@
     }
 
     private JavaFileObject getClassFileObject(String className) throws IOException {
-        JavaFileObject fo;
-        fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
-        if (fo == null)
-            fo = fileManager.getJavaFileForInput(StandardLocation.CLASS_PATH, className, JavaFileObject.Kind.CLASS);
-        return fo;
+        try {
+            JavaFileObject fo;
+            fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
+            if (fo == null)
+                fo = fileManager.getJavaFileForInput(StandardLocation.CLASS_PATH, className, JavaFileObject.Kind.CLASS);
+            return fo;
+        } catch (IllegalArgumentException e) {
+            return null;
+        }
     }
 
     private void showHelp() {