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

AOT cache should not contain classes injected into built-in class loaders

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 25
    • 25
    • hotspot
    • b19

      During an application's training run, it's possible to inject classes into the built-in platform/app class loaders with reflection calls. Previously, only the names of these classes were recorded in the AOT config file. When the AOT cache is generated, these classes are automatically filtered out.

      However, since JDK-8348426, these classes are stored as parsed InstanceKlasses in the AOT config file, and will be transferred into the AOT cache.

      The new behavior may cause some applications to fail, as they may inject bytecodes that have environment dependencies. For safety, it's better to filter out such injected classes,

      Example:

      ========================
      Method m = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
           byte[].class, int.class, int.class, ProtectionDomain.class);
      m.setAccessible(true);
      ProtectionDomain pd = MyApp.class.getProtectionDomain();
      ClassLoader appLoader = MyApp.class.getClassLoader();
      byte[] data = Files.readAllBytes(Paths.get("ClassNotInJar2.class"));
      Class c = (Class)m.invoke(appLoader, "ClassNotInJar2", data, 0, data.length, pd);
      ==========================

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: