Injected class bytes are java8 compat. Added more detailed comments
This commit is contained in:
parent
60956481f4
commit
9238065445
@ -147,26 +147,32 @@ public class ClassUtils {
|
|||||||
// we do not have a dependency on javassist simply because we ALREADY know what the generated class bytes are (so there's no need)
|
// we do not have a dependency on javassist simply because we ALREADY know what the generated class bytes are (so there's no need)
|
||||||
|
|
||||||
|
|
||||||
// CtClass dynamicClass = pool.makeClass("java.lang.ClassLoaderAccessor");
|
// try {
|
||||||
// CtMethod method = CtNewMethod.make("public static Class findLoadedClass(ClassLoader classLoader, String className) { " +
|
// ClassPool pool = ClassPool.getDefault();
|
||||||
// "return classLoader.findLoadedClass(className);" +
|
// CtClass dynamicClass = pool.makeClass("java.lang.ClassLoaderAccessor");
|
||||||
// "}", dynamicClass);
|
// CtMethod method = CtNewMethod.make("public static Class findLoadedClass(ClassLoader classLoader, String className) { " +
|
||||||
// dynamicClass.addMethod(method);
|
// "return classLoader.findLoadedClass(className);" +
|
||||||
// dynamicClass.setModifiers(dynamicClass.getModifiers() & ~Modifier.STATIC);
|
// "}", dynamicClass);
|
||||||
|
// dynamicClass.addMethod(method);
|
||||||
|
// dynamicClass.setModifiers(dynamicClass.getModifiers() & ~Modifier.STATIC);
|
||||||
|
//
|
||||||
|
// final byte[] classLoaderAccessorBytes = dynamicClass.toBytecode();
|
||||||
|
// Sys.printArray(classLoaderAccessorBytes);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// final byte[] classLoaderAccessorBytes = dynamicClass.toBytecode();
|
|
||||||
|
|
||||||
byte[] classLoaderAccessorBytes = {
|
byte[] classLoaderAccessorBytes = {
|
||||||
-54,-2,-70,-66,0,0,0,55,0,19,1,0,29,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,
|
-54,-2,-70,-66,0,0,0,52,0,19,1,0,29,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,
|
||||||
114,7,0,1,1,0,16,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,7,0,3,1,0,10,83,111,117,114,99,101,70,105,108,101,1,
|
114,7,0,1,1,0,16,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,7,0,3,1,0,10,83,111,117,114,99,101,70,105,108,101,1,
|
||||||
0,24,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,114,46,106,97,118,97,1,0,15,102,105,110,100,76,111,97,100,101,100,67,
|
0,24,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,114,46,106,97,118,97,1,0,15,102,105,110,100,76,111,97,100,101,100,67,
|
||||||
108,97,115,115,1,0,60,40,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,76,111,97,100,101,114,59,76,106,97,118,97,47,108,97,110,
|
108,97,115,115,1,0,60,40,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,76,111,97,100,101,114,59,76,106,97,118,97,47,108,97,110,
|
||||||
103,47,83,116,114,105,110,103,59,41,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,59,1,0,21,106,97,118,97,47,108,97,110,103,47,
|
103,47,83,116,114,105,110,103,59,41,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,59,1,0,21,106,97,118,97,47,108,97,110,103,47,
|
||||||
67,108,97,115,115,76,111,97,100,101,114,7,0,9,1,0,37,40,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,41,76,106,97,
|
67,108,97,115,115,76,111,97,100,101,114,7,0,9,1,0,37,40,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,41,76,106,97,
|
||||||
118,97,47,108,97,110,103,47,67,108,97,115,115,59,12,0,7,0,11,10,0,10,0,12,1,0,4,67,111,100,101,1,0,6,60,105,110,105,116,62,
|
118,97,47,108,97,110,103,47,67,108,97,115,115,59,12,0,7,0,11,10,0,10,0,12,1,0,4,67,111,100,101,1,0,6,60,105,110,105,116,62,
|
||||||
1,0,3,40,41,86,12,0,15,0,16,10,0,4,0,17,0,33,0,2,0,4,0,0,0,0,0,2,0,9,0,7,0,8,0,1,0,14,0,0,
|
1,0,3,40,41,86,12,0,15,0,16,10,0,4,0,17,0,33,0,2,0,4,0,0,0,0,0,2,0,9,0,7,0,8,0,1,0,14,0,0,
|
||||||
0,18,0,2,0,2,0,0,0,6,42,43,-74,0,13,-80,0,0,0,0,0,1,0,15,0,16,0,1,0,14,0,0,0,17,0,1,0,1,0,0,
|
0,18,0,2,0,2,0,0,0,6,42,43,-74,0,13,-80,0,0,0,0,0,1,0,15,0,16,0,1,0,14,0,0,0,17,0,1,0,1,0,0,
|
||||||
0,5,42,-73,0,18,-79,0,0,0,0,0,1,0,5,0,0,0,2,0,6};
|
0,5,42,-73,0,18,-79,0,0,0,0,0,1,0,5,0,0,0,2,0,6};
|
||||||
try {
|
try {
|
||||||
ClassUtils.defineClass(null, classLoaderAccessorBytes);
|
ClassUtils.defineClass(null, classLoaderAccessorBytes);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -175,30 +181,35 @@ public class ClassUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CtClass classFixer = pool.get("dorkbox.jna.ClassLoaderAccessory");
|
// try {
|
||||||
// CtMethod ctMethod = classFixer.getDeclaredMethod("findLoadedClass");
|
// ClassPool pool = ClassPool.getDefault();
|
||||||
// ctMethod.setBody("{" +
|
// CtClass classFixer = pool.get("dorkbox.jna.ClassLoaderAccessory");
|
||||||
// "return java.lang.ClassLoaderAccessor.findLoadedClass($1, $2);" +
|
// CtMethod ctMethod = classFixer.getDeclaredMethod("findLoadedClass");
|
||||||
// "}");
|
// ctMethod.setBody("{" +
|
||||||
|
// "return java.lang.ClassLoaderAccessor.findLoadedClass($1, $2);" +
|
||||||
|
// "}");
|
||||||
//
|
//
|
||||||
// // perform pre-verification for the modified method
|
// // perform pre-verification for the modified method
|
||||||
// ctMethod.getMethodInfo().rebuildStackMapForME(pool);
|
// ctMethod.getMethodInfo().rebuildStackMapForME(pool);
|
||||||
//
|
//
|
||||||
// final byte[] classFixerBytes = classFixer.toBytecode();
|
// final byte[] classFixerBytes = classFixer.toBytecode();
|
||||||
|
// Sys.printArray(classFixerBytes);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
byte[] classFixerBytes = {
|
byte[] classFixerBytes = {
|
||||||
-54,-2,-70,-66,0,0,0,52,0,22,1,0,32,100,111,114,107,98,111,120,47,106,110,97,47,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,
|
-54,-2,-70,-66,0,0,0,52,0,22,1,0,32,100,111,114,107,98,111,120,47,106,110,97,47,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,
|
||||||
115,111,114,121,7,0,1,1,0,16,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,7,0,3,1,0,6,60,105,110,105,116,62,1,0,
|
115,111,114,121,7,0,1,1,0,16,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,7,0,3,1,0,6,60,105,110,105,116,62,1,0,
|
||||||
3,40,41,86,1,0,4,67,111,100,101,1,0,15,76,105,110,101,78,117,109,98,101,114,84,97,98,108,101,1,0,18,76,111,99,97,108,86,97,114,
|
3,40,41,86,1,0,4,67,111,100,101,1,0,15,76,105,110,101,78,117,109,98,101,114,84,97,98,108,101,1,0,18,76,111,99,97,108,86,97,114,
|
||||||
105,97,98,108,101,84,97,98,108,101,1,0,4,116,104,105,115,1,0,34,76,100,111,114,107,98,111,120,47,106,110,97,47,67,108,97,115,115,76,111,
|
105,97,98,108,101,84,97,98,108,101,1,0,4,116,104,105,115,1,0,34,76,100,111,114,107,98,111,120,47,106,110,97,47,67,108,97,115,115,76,111,
|
||||||
97,100,101,114,65,99,99,101,115,115,111,114,121,59,12,0,5,0,6,10,0,4,0,12,1,0,15,102,105,110,100,76,111,97,100,101,100,67,108,97,
|
97,100,101,114,65,99,99,101,115,115,111,114,121,59,12,0,5,0,6,10,0,4,0,12,1,0,15,102,105,110,100,76,111,97,100,101,100,67,108,97,
|
||||||
115,115,1,0,60,40,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,76,111,97,100,101,114,59,76,106,97,118,97,47,108,97,110,103,47,
|
115,115,1,0,60,40,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,76,111,97,100,101,114,59,76,106,97,118,97,47,108,97,110,103,47,
|
||||||
83,116,114,105,110,103,59,41,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,59,1,0,29,106,97,118,97,47,108,97,110,103,47,67,108,
|
83,116,114,105,110,103,59,41,76,106,97,118,97,47,108,97,110,103,47,67,108,97,115,115,59,1,0,29,106,97,118,97,47,108,97,110,103,47,67,108,
|
||||||
97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,114,7,0,16,12,0,14,0,15,10,0,17,0,18,1,0,10,83,111,117,114,99,101,70,
|
97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,114,7,0,16,12,0,14,0,15,10,0,17,0,18,1,0,10,83,111,117,114,99,101,70,
|
||||||
105,108,101,1,0,25,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,114,121,46,106,97,118,97,0,32,0,2,0,4,0,0,0,
|
105,108,101,1,0,25,67,108,97,115,115,76,111,97,100,101,114,65,99,99,101,115,115,111,114,121,46,106,97,118,97,0,32,0,2,0,4,0,0,0,
|
||||||
0,0,2,0,0,0,5,0,6,0,1,0,7,0,0,0,47,0,1,0,1,0,0,0,5,42,-73,0,13,-79,0,0,0,2,0,8,0,0,0,6,
|
0,0,2,0,0,0,5,0,6,0,1,0,7,0,0,0,47,0,1,0,1,0,0,0,5,42,-73,0,13,-79,0,0,0,2,0,8,0,0,0,6,
|
||||||
0,1,0,0,0,3,0,9,0,0,0,12,0,1,0,0,0,5,0,10,0,11,0,0,0,12,0,14,0,15,0,1,0,7,0,0,0,18,0,2,
|
0,1,0,0,0,3,0,9,0,0,0,12,0,1,0,0,0,5,0,10,0,11,0,0,0,12,0,14,0,15,0,1,0,7,0,0,0,18,0,2,
|
||||||
0,2,0,0,0,6,42,43,-72,0,19,-80,0,0,0,0,0,1,0,20,0,0,0,2,0,21};
|
0,2,0,0,0,6,42,43,-72,0,19,-80,0,0,0,0,0,1,0,20,0,0,0,2,0,21};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// specifically not in the bootstrap classloader -- but instead in the classloader initially searched (which might be the wrong one)
|
// specifically not in the bootstrap classloader -- but instead in the classloader initially searched (which might be the wrong one)
|
||||||
|
Loading…
Reference in New Issue
Block a user