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);
==========================