Skip to content

Commit

Permalink
Bug fix for JDK 22
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto-Gentili committed May 1, 2024
1 parent c80f960 commit 2236a3b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion java/src/main/java/io/github/toolfactory/jvm/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
package io.github.toolfactory.jvm;

public interface Info {
public final static int[] CRITICAL_VERSIONS = {7, 9, 14, 17, 20, 21};
public final static int[] CRITICAL_VERSIONS = {7, 9, 14, 17, 20, 21, 22};


public boolean isCompressedOopsOffOn64BitHotspot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,17 @@ public ForJava9(Map<Object, Object> context) throws Throwable {

}

public static class ForJava22 extends Abst {

public ForJava22(Map<Object, Object> context) throws Throwable {
ObjectProvider functionProvider = ObjectProvider.get(context);
Class<?> constructorAccessorImplClass = Class.forName("jdk.internal.reflect.DirectConstructorHandleAccessor$NativeAccessor");
Method method = constructorAccessorImplClass.getDeclaredMethod("newInstance0", Constructor.class, Object[].class);
ConsulterSupplyFunction getConsulterFunction = functionProvider.getOrBuildObject(ConsulterSupplyFunction.class, context);
MethodHandles.Lookup consulter = getConsulterFunction.apply(constructorAccessorImplClass);
methodHandle = consulter.unreflect(method);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,18 @@ public ForJava9(Map<Object, Object> context) throws Throwable {

}

public static class ForJava22 extends Abst {

public ForJava22(Map<Object, Object> context) throws Throwable {
Class<?> nativeMethodAccessorImplClass = Class.forName("jdk.internal.reflect.DirectMethodHandleAccessor$NativeAccessor");
Method invoker = nativeMethodAccessorImplClass.getDeclaredMethod("invoke0", Method.class, Object.class, Object[].class);
ObjectProvider functionProvider = ObjectProvider.get(context);
ConsulterSupplyFunction consulterSupplyFunction = functionProvider.getOrBuildObject(ConsulterSupplyFunction.class, context);
MethodHandles.Lookup consulter = consulterSupplyFunction.apply(nativeMethodAccessorImplClass);
functionProvider.getOrBuildObject(SetAccessibleFunction.class, context).accept(invoker, true);
methodHandle = consulter.unreflect(invoker);
}

}

}

0 comments on commit 2236a3b

Please sign in to comment.