Merge branch '6.2.x'
# Conflicts: # spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java # spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java
This commit is contained in:
@@ -527,15 +527,26 @@ public class ReflectUtils {
|
||||
c = lookup.defineClass(b);
|
||||
}
|
||||
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() +
|
||||
"; consider co-locating the affected class in that target ClassLoader instead.";
|
||||
if (ex instanceof LinkageError) {
|
||||
// Could be a ClassLoader mismatch with the class pre-existing in a
|
||||
// parent ClassLoader -> try loadClass before giving up completely.
|
||||
try {
|
||||
c = contextClass.getClassLoader().loadClass(className);
|
||||
}
|
||||
};
|
||||
catch (ClassNotFoundException cnfe) {
|
||||
}
|
||||
}
|
||||
if (c == null) {
|
||||
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() +
|
||||
"; consider co-locating the affected class in that target ClassLoader instead.";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new CodeGenerationException(ex);
|
||||
|
||||
@@ -117,7 +117,18 @@ public final class SpringProperties {
|
||||
* @param key the property key
|
||||
*/
|
||||
public static void setFlag(String key) {
|
||||
localProperties.put(key, Boolean.TRUE.toString());
|
||||
localProperties.setProperty(key, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatically set a local flag to the given value, overriding
|
||||
* an entry in the {@code spring.properties} file (if any).
|
||||
* @param key the property key
|
||||
* @param value the associated boolean value
|
||||
* @since 6.2.6
|
||||
*/
|
||||
public static void setFlag(String key, boolean value) {
|
||||
localProperties.setProperty(key, Boolean.toString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,4 +141,19 @@ public final class SpringProperties {
|
||||
return Boolean.parseBoolean(getProperty(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the flag for the given property key, returning {@code null}
|
||||
* instead of {@code false} in case of no actual flag set.
|
||||
* @param key the property key
|
||||
* @return {@code true} if the property is set to the string "true"
|
||||
* (ignoring case), {@code} false if it is set to any other value,
|
||||
* {@code null} if it is not set at all
|
||||
* @since 6.2.6
|
||||
*/
|
||||
@Nullable
|
||||
public static Boolean checkFlag(String key) {
|
||||
String flag = getProperty(key);
|
||||
return (flag != null ? Boolean.valueOf(flag) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user