Use new Java features (switch expressions, text blocks, new JDK methods)

Closes gh-29747
This commit is contained in:
Krzysztof Krason
2022-12-28 08:59:08 +01:00
committed by Sam Brannen
parent 48abd493fe
commit afb8a0d1b1
53 changed files with 498 additions and 552 deletions

View File

@@ -274,7 +274,7 @@ public class MethodReference extends SpelNodeImpl {
public boolean isCompilable() {
CachedMethodExecutor executorToCheck = this.cachedExecutor;
if (executorToCheck == null || executorToCheck.hasProxyTarget() ||
!(executorToCheck.get() instanceof ReflectiveMethodExecutor)) {
!(executorToCheck.get() instanceof ReflectiveMethodExecutor executor)) {
return false;
}
@@ -284,26 +284,20 @@ public class MethodReference extends SpelNodeImpl {
}
}
ReflectiveMethodExecutor executor = (ReflectiveMethodExecutor) executorToCheck.get();
if (executor.didArgumentConversionOccur()) {
return false;
}
Class<?> clazz = executor.getMethod().getDeclaringClass();
if (!Modifier.isPublic(clazz.getModifiers()) && executor.getPublicDeclaringClass() == null) {
return false;
}
return true;
return Modifier.isPublic(clazz.getModifiers()) || executor.getPublicDeclaringClass() != null;
}
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
CachedMethodExecutor executorToCheck = this.cachedExecutor;
if (executorToCheck == null || !(executorToCheck.get() instanceof ReflectiveMethodExecutor)) {
if (executorToCheck == null || !(executorToCheck.get() instanceof ReflectiveMethodExecutor methodExecutor)) {
throw new IllegalStateException("No applicable cached executor found: " + executorToCheck);
}
ReflectiveMethodExecutor methodExecutor = (ReflectiveMethodExecutor) executorToCheck.get();
Method method = methodExecutor.getMethod();
boolean isStaticMethod = Modifier.isStatic(method.getModifiers());
String descriptor = cf.lastDescriptor();