Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187047

[AOT] jaotc --ignore-errors flag is ignored in several exceptions cases

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      generic
    • OS:
      generic

      Description

      jaotc will exit with java.lang.ClassNotFoundException when referenced class not found regardless --ignore-errors flag.

      > $JAVA_HOME/bin/jaotc --info Test.class --ignore-errors
      Compiling unnamed.so...
       (27 ms)
      Exception in thread "main" java.lang.NoClassDefFoundError: ref/TestClass
      at java.base/java.lang.ClassLoader.defineClass1(Native Method)
      ...
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:495)
      at jdk.aot/jdk.tools.jaotc.collect.classname.ClassNameSourceProvider.findSource(ClassNameSourceProvider.java:63)
      at jdk.aot/jdk.tools.jaotc.collect.ClassSearch.findSource(ClassSearch.java:99)
      at jdk.aot/jdk.tools.jaotc.collect.ClassSearch.search(ClassSearch.java:55)
      at jdk.aot/jdk.tools.jaotc.Collector.collectClassesToCompile(Collector.java:64)
      at jdk.aot/jdk.tools.jaotc.Main.run(Main.java:133)
      at jdk.aot/jdk.tools.jaotc.Main.run(Main.java:100)
      at jdk.aot/jdk.tools.jaotc.Main.main(Main.java:79)
      Caused by: java.lang.ClassNotFoundException: ref.TestClass
      at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:562)
      at java.base/java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:890)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:495)
      ... 19 more
      >

      > cat Test.java
      import ref.TestClass;
      public class Test extends TestClass {
          public static void main(String[] args) { }
      }

      > cat ref/TestClass.java
      package ref;
      public class TestClass {
      }

      TestClass.class is in jar file:

      > $JAVA_HOME/bin/javac Test.java
      > $JAVA_HOME/bin/jar -c -f testClass.jar ref/
      > rm ref/TestClass.class

      > java -cp .:testClass.jar Test

      Note, to avoid CNFE you need put TestClass on class path:

      > $JAVA_HOME/bin/jaotc --info Test.class -J-cp -J.:testClass.jar

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kvn Vladimir Kozlov
                Reporter:
                kvn Vladimir Kozlov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: