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

Java crashes when running with +UseAOT

XMLWordPrintable

    • x86_64
    • windows_7

      ADDITIONAL SYSTEM INFORMATION :
      System:
      Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
      32 GB RAM
      Windows 7 Enterprise Service Pack 1

      java --version
      java 11.0.1 2018-10-16 LTS
      Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      Java crashes during startup of my application when running with AOT enabled on java.base module.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Compile java.base module using jaotc:
      call %JAVA_HOME%\bin\jaotc.exe --compile-for-tiered --info --output libjavabase.so --module java.base

      2) compile simple example given in the source code section, that attempts to load java classes

      call %JAVA_HOME%\bin\javac.exe com\example\Hello.java

      3) Run it few times, crash is not consistently happening on every run, which is why you have to do it a number of times, close and ignore any GUI windows that may be popping up due to class loading. They don't seem to be relevant to the crash.

      FOR /L %%A IN (1,1,2000) DO (
        call %JAVA_HOME%\bin\java.exe -cp . -XX:+UnlockDiagnosticVMOptions -XX:+UseAOT -XX:AOTLibrary=libjavabase.so -XX:+UseAOTStrictLoading com.example.Hello
      )



      ACTUAL -
      Tested on 2 different Windows 7 PCs where a pop-up appears "Javaâ„¢ Platform SE binary has stopped working". Fully runnable script reproducing the above available upon request.


      ---------- BEGIN SOURCE ----------
      package com.example;

      import java.lang.module.ModuleFinder;
      import java.lang.module.ModuleReader;
      import java.lang.module.ModuleReference;
      import java.util.Set;

      public class Hello
      {

          public static void main(String[] args)
          {
              loadClasses();
          }

          private static void loadClasses()

          {
              Set<ModuleReference> modRefs = ModuleFinder.ofSystem().findAll();
              for (ModuleReference mr : modRefs)
              {
                  try
                  {
                      ModuleReader moduleReader = mr.open();
                      moduleReader.list().forEach(name ->
                      {
                          if (!"module-info.class".equals(name) && isValidClassFileName(name))
                          {
                              final String dirName = name.lastIndexOf('/') < 0 ? "" : name.substring(0, name.lastIndexOf('/'));
                              final String packageName = dirName.replace('/', '.');

                              String fileName = name.lastIndexOf('/') < 0 ? name : name.substring(name.lastIndexOf('/') + 1);
                              String classSimpleName = getClassNameFromFileName(fileName);

                              final String fullyQualifiedClassName = packageName + "." + classSimpleName;

                              try
                              {
                                  Class.forName(fullyQualifiedClassName, true, Hello.class.getClassLoader());
                              }
                              catch (ClassNotFoundException e)
                              {
                                  //System.out.println("ERROR: ClassNotFound: " + e.getMessage());
                              }

                          }
                      });
                  }
                  catch (Throwable e)
                  {
                      //System.out.println("ERROR ignored: " + e.getMessage());
                  }
              }

          }

          private static boolean isValidClassFileName(String fileName)
          {
              return fileName.endsWith(".class");
          }

          private static String getClassNameFromFileName(String fileName)
          {
              String className = null;
              if (isValidClassFileName(fileName))
              {
                  className = fileName.substring(0, fileName.length() - 6);
              }
              return className;
          }

      }


      ---------- END SOURCE ----------

      FREQUENCY : often


            kvn Vladimir Kozlov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: