Merge branch '6.0.x'
This commit is contained in:
@@ -22,6 +22,7 @@ import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -508,14 +509,14 @@ public class ReflectUtils {
|
||||
catch (InvocationTargetException ex) {
|
||||
throw new CodeGenerationException(ex.getTargetException());
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// Fall through if setAccessible fails with InaccessibleObjectException on JDK 9+
|
||||
// (on the module path and/or with a JVM bootstrapped with --illegal-access=deny)
|
||||
if (!ex.getClass().getName().endsWith("InaccessibleObjectException")) {
|
||||
throw new CodeGenerationException(ex);
|
||||
}
|
||||
catch (InaccessibleObjectException ex) {
|
||||
// setAccessible failed with JDK 9+ InaccessibleObjectException -> fall through
|
||||
// Avoid through JVM startup with --add-opens=java.base/java.lang=ALL-UNNAMED
|
||||
t = ex;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new CodeGenerationException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,13 +526,14 @@ public class ReflectUtils {
|
||||
MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(contextClass, MethodHandles.lookup());
|
||||
c = lookup.defineClass(b);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (LinkageError | IllegalAccessException ex) {
|
||||
throw new CodeGenerationException(ex) {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "ClassLoader mismatch for [" + contextClass.getName() +
|
||||
"]: JVM should be started with --add-opens=java.base/java.lang=ALL-UNNAMED " +
|
||||
"for ClassLoader.defineClass to be accessible on " + loader.getClass().getName();
|
||||
"for ClassLoader.defineClass to be accessible on " + loader.getClass().getName() +
|
||||
"; consider co-locating the affected class in that target ClassLoader instead.";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -507,16 +507,8 @@ public abstract class ReflectionUtils {
|
||||
* @see java.lang.Object#equals(Object)
|
||||
*/
|
||||
public static boolean isEqualsMethod(@Nullable Method method) {
|
||||
if (method == null) {
|
||||
return false;
|
||||
}
|
||||
if (method.getParameterCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
if (!method.getName().equals("equals")) {
|
||||
return false;
|
||||
}
|
||||
return method.getParameterTypes()[0] == Object.class;
|
||||
return (method != null && method.getParameterCount() == 1 && method.getName().equals("equals") &&
|
||||
method.getParameterTypes()[0] == Object.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,7 +516,7 @@ public abstract class ReflectionUtils {
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public static boolean isHashCodeMethod(@Nullable Method method) {
|
||||
return method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode");
|
||||
return (method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user