-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method open() throws IllegalAccessException #92
Comments
I join the message above - I start the project using maven from the command line (mvn clean test) and get an IllegalAccessException error. |
@PavelSukh, it seems ...
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@HandleWith(DefaultMethod.Extension.class)
public @interface DefaultMethod {
class Extension implements MethodHandler {
@Override
public Object handle(Context context, Object proxy, Method method, Object[] args) throws Throwable {
Class<?> declaringClass = method.getDeclaringClass();
if (isJava8()) {
Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class
.getDeclaredConstructor(Class.class, int.class);
constructor.setAccessible(true);
return constructor.newInstance(declaringClass, MethodHandles.Lookup.PRIVATE)
.unreflectSpecial(method, declaringClass)
.bindTo(proxy)
.invokeWithArguments(args);
} else {
MethodType rt = MethodType.methodType(method.getReturnType(), method.getParameterTypes());
return MethodHandles.lookup()
.findSpecial(declaringClass, method.getName(), rt, declaringClass)
.bindTo(proxy)
.invokeWithArguments(args);
}
}
private static boolean isJava8() {
String version = ManagementFactory.getRuntimeMXBean().getSpecVersion();
return version.startsWith("1.8");
}
}
} |
@rgrigoryev thank you for your help. I was deleted JDK 11 from my pc and use the JDK 8 on default, it solved my problem. |
Solved the same problem using the same way |
Please find the code from example bellow:
test.zip
The text was updated successfully, but these errors were encountered: