Consistent resolution of Class methods and static methods

Issue: SPR-12502
This commit is contained in:
Juergen Hoeller
2014-12-03 23:03:24 +01:00
parent 1de71511f0
commit 9ef0bdcb17
2 changed files with 39 additions and 10 deletions

View File

@@ -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";
}
}
}