mirror of https://github.com/apache/druid.git
Fix monomorphic processing code running on JDK8 since it references a non-existing method (#15092)
Code relying on monomorphic processing on JDK8 doesn't work correctly, since it tries to reference getArrayLength using method handles, which might have been accidentally removed here since it seems unused. This PR adds the method back as is.
This commit is contained in:
parent
b4bc9b6950
commit
2c286d6f42
|
@ -95,7 +95,7 @@ public class DefineClassUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Compile" a MethodHandle that is equilavent to:
|
* "Compile" a MethodHandle that is equivalent to:
|
||||||
*
|
*
|
||||||
* Class<?> defineClass(Class targetClass, byte[] byteCode, String className) {
|
* Class<?> defineClass(Class targetClass, byte[] byteCode, String className) {
|
||||||
* return Unsafe.defineClass(
|
* return Unsafe.defineClass(
|
||||||
|
@ -147,7 +147,7 @@ public class DefineClassUtils
|
||||||
// defineClass(className, byteCode, 0, length, targetClass)
|
// defineClass(className, byteCode, 0, length, targetClass)
|
||||||
defineClass = MethodHandles.insertArguments(defineClass, 2, (int) 0);
|
defineClass = MethodHandles.insertArguments(defineClass, 2, (int) 0);
|
||||||
|
|
||||||
// JDK8 does not implement MethodHandles.arrayLength so we have to roll our own
|
// JDK8 does not implement MethodHandles.arrayLength, so we have to roll our own
|
||||||
MethodHandle arrayLength = lookup.findStatic(
|
MethodHandle arrayLength = lookup.findStatic(
|
||||||
lookup.lookupClass(),
|
lookup.lookupClass(),
|
||||||
"getArrayLength",
|
"getArrayLength",
|
||||||
|
@ -171,6 +171,16 @@ public class DefineClassUtils
|
||||||
return defineClass;
|
return defineClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is referenced in Java 8 using method handle, therefore it is not actually unused, and shouldn't be
|
||||||
|
* removed (till Java 8 is supported)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused") // method is referenced and used in defineClassJava8
|
||||||
|
static int getArrayLength(byte[] bytes)
|
||||||
|
{
|
||||||
|
return bytes.length;
|
||||||
|
}
|
||||||
|
|
||||||
public static Class defineClass(
|
public static Class defineClass(
|
||||||
Class<?> targetClass,
|
Class<?> targetClass,
|
||||||
byte[] byteCode,
|
byte[] byteCode,
|
||||||
|
|
Loading…
Reference in New Issue