Consistent resolution of Class methods and static methods
Issue: SPR-12502
This commit is contained in:
@@ -1208,7 +1208,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Override
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return new Class[] { ContextObject.class };
|
||||
return new Class<?>[] {ContextObject.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1278,7 +1278,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
protected Method[] getMethods(Class<?> type) {
|
||||
try {
|
||||
return new Method[] {
|
||||
Integer.class.getDeclaredMethod("parseInt", new Class[] { String.class, Integer.TYPE }) };
|
||||
Integer.class.getDeclaredMethod("parseInt", new Class<?>[] {String.class, Integer.TYPE})};
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
return new Method[0];
|
||||
@@ -1878,6 +1878,14 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
assertEquals("child1", exp.getValue(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPR12502() throws Exception {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("#root.getClass().getName()");
|
||||
assertEquals(UnnamedUser.class.getName(), expression.getValue(new UnnamedUser()));
|
||||
assertEquals(NamedUser.class.getName(), expression.getValue(new NamedUser()));
|
||||
}
|
||||
|
||||
|
||||
private static enum ABC { A, B, C }
|
||||
|
||||
@@ -2151,4 +2159,16 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class UnnamedUser {
|
||||
}
|
||||
|
||||
|
||||
public static class NamedUser {
|
||||
|
||||
public String getName() {
|
||||
return "foo";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user