< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/classfile/ClassfileBytecodeProviderTest.java
Print this page
*** 193,221 ****
private static boolean isGSON(String className) {
return className.contains("com.google.gson");
}
protected void checkClass(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, String className) throws ClassNotFoundException {
Class<?> c = Class.forName(className, true, getClass().getClassLoader());
ClassfileBytecodeProvider cbp = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
for (Method method : c.getDeclaredMethods()) {
checkMethod(cbp, metaAccess, method);
}
}
private static void checkMethod(ClassfileBytecodeProvider cbp, MetaAccessProvider metaAccess, Executable executable) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(executable);
if (method.hasBytecodes()) {
- ResolvedJavaMethodBytecode expected = new ResolvedJavaMethodBytecode(method);
Bytecode actual = getBytecode(cbp, method);
! new BytecodeComparer(expected, actual).compare();
}
}
protected static Bytecode getBytecode(ClassfileBytecodeProvider cbp, ResolvedJavaMethod method) {
try {
return cbp.getBytecode(method);
} catch (Throwable e) {
throw new AssertionError(String.format("Error getting bytecode for %s", method.format("%H.%n(%p)")), e);
}
}
--- 193,231 ----
private static boolean isGSON(String className) {
return className.contains("com.google.gson");
}
protected void checkClass(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, String className) throws ClassNotFoundException {
+ if (className.equals("jdk.vm.ci.services.JVMCIClassLoaderFactory")) {
+ // JVMCIClassLoaderFactory must only be initialized by the VM
+ return;
+ }
Class<?> c = Class.forName(className, true, getClass().getClassLoader());
ClassfileBytecodeProvider cbp = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
for (Method method : c.getDeclaredMethods()) {
checkMethod(cbp, metaAccess, method);
}
}
private static void checkMethod(ClassfileBytecodeProvider cbp, MetaAccessProvider metaAccess, Executable executable) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(executable);
if (method.hasBytecodes()) {
Bytecode actual = getBytecode(cbp, method);
! if (actual != null) {
! ResolvedJavaMethodBytecode expected = new ResolvedJavaMethodBytecode(method);
! new BytecodeComparer(expected, actual).compare();
! }
}
}
protected static Bytecode getBytecode(ClassfileBytecodeProvider cbp, ResolvedJavaMethod method) {
try {
return cbp.getBytecode(method);
+ } catch (UnsupportedClassVersionError e) {
+ // This can happen when a library containing old class files
+ // is bundled into a Graal jar (GR-12672).
+ return null;
} catch (Throwable e) {
throw new AssertionError(String.format("Error getting bytecode for %s", method.format("%H.%n(%p)")), e);
}
}
< prev index next >