src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java
changeset 51218 bfcdf06f97fa
parent 47216 71c04702a3d5
child 51436 091c0d22e735
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java	Fri Jul 20 10:12:34 2018 -0700
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java	Fri Jul 20 11:39:37 2018 -0700
@@ -61,7 +61,7 @@
 
         List<LoadedClass> foundClasses = null;
         try {
-            foundClasses = lookup.search(main.options.files, main.options.searchPath);
+            foundClasses = lookup.search(main.options.files, main.options.searchPath, this::handleLoadingError);
         } catch (InternalError e) {
             main.printer.reportError(e);
             return null;
@@ -118,12 +118,7 @@
                     addMethods(aotClass, ctors, compilationRestrictions);
                     total += ctors.length;
                 } catch (Throwable e) {
-                    // If we are running in JCK mode we ignore all exceptions.
-                    if (main.options.ignoreClassLoadingErrors) {
-                        main.printer.printError(c.getName() + ": " + e);
-                    } else {
-                        throw new InternalError(e);
-                    }
+                    handleLoadingError(c.getName(), e);
                 }
 
                 // Methods
@@ -132,12 +127,7 @@
                     addMethods(aotClass, methods, compilationRestrictions);
                     total += methods.length;
                 } catch (Throwable e) {
-                    // If we are running in JCK mode we ignore all exceptions.
-                    if (main.options.ignoreClassLoadingErrors) {
-                        main.printer.printError(c.getName() + ": " + e);
-                    } else {
-                        throw new InternalError(e);
-                    }
+                    handleLoadingError(c.getName(), e);
                 }
 
                 // Class initializer
@@ -148,12 +138,7 @@
                         total++;
                     }
                 } catch (Throwable e) {
-                    // If we are running in JCK mode we ignore all exceptions.
-                    if (main.options.ignoreClassLoadingErrors) {
-                        main.printer.printError(c.getName() + ": " + e);
-                    } else {
-                        throw new InternalError(e);
-                    }
+                    handleLoadingError(c.getName(), e);
                 }
 
                 // Found any methods to compile? Add the class.
@@ -215,4 +200,11 @@
         return compilationRestrictions;
     }
 
+    private void handleLoadingError(String name, Throwable t) {
+        if (main.options.ignoreClassLoadingErrors) {
+            main.printer.printError(name + ": " + t);
+        } else {
+            throw new InternalError(t);
+        }
+    }
 }