@@ -286,6 +286,11 @@ static class TestProperties {
286
286
287
287
static class MapAccessor implements PropertyAccessor {
288
288
289
+ @ Override
290
+ public Class <?>[] getSpecificTargetClasses () {
291
+ return new Class <?>[] {Map .class };
292
+ }
293
+
289
294
@ Override
290
295
public boolean canRead (EvaluationContext context , Object target , String name ) throws AccessException {
291
296
return (((Map <?, ?>) target ).containsKey (name ));
@@ -306,11 +311,6 @@ public boolean canWrite(EvaluationContext context, Object target, String name) t
306
311
public void write (EvaluationContext context , Object target , String name , Object newValue ) throws AccessException {
307
312
((Map <String , Object >) target ).put (name , newValue );
308
313
}
309
-
310
- @ Override
311
- public Class <?>[] getSpecificTargetClasses () {
312
- return new Class [] { Map .class };
313
- }
314
314
}
315
315
316
316
@@ -1774,18 +1774,18 @@ public TypedValue execute(EvaluationContext context, Object target, Object... ar
1774
1774
public void SPR10486 () throws Exception {
1775
1775
SpelExpressionParser parser = new SpelExpressionParser ();
1776
1776
StandardEvaluationContext context = new StandardEvaluationContext ();
1777
- SPR10486 rootObject = new SPR10486 ();
1777
+ Spr10486 rootObject = new Spr10486 ();
1778
1778
Expression classNameExpression = parser .parseExpression ("class.name" );
1779
1779
Expression nameExpression = parser .parseExpression ("name" );
1780
- assertThat (classNameExpression .getValue (context , rootObject ), equalTo ((Object ) SPR10486 .class .getName ()));
1780
+ assertThat (classNameExpression .getValue (context , rootObject ), equalTo ((Object ) Spr10486 .class .getName ()));
1781
1781
assertThat (nameExpression .getValue (context , rootObject ), equalTo ((Object ) "name" ));
1782
1782
}
1783
1783
1784
1784
@ Test
1785
1785
public void SPR11142 () throws Exception {
1786
1786
SpelExpressionParser parser = new SpelExpressionParser ();
1787
1787
StandardEvaluationContext context = new StandardEvaluationContext ();
1788
- SPR11142 rootObject = new SPR11142 ();
1788
+ Spr11142 rootObject = new Spr11142 ();
1789
1789
Expression expression = parser .parseExpression ("something" );
1790
1790
thrown .expect (SpelEvaluationException .class );
1791
1791
thrown .expectMessage ("'something' cannot be found" );
@@ -1837,33 +1837,22 @@ public void SPR11445_beanReference() {
1837
1837
assertEquals (1 , expr .getValue (context ));
1838
1838
}
1839
1839
1840
-
1841
- static class Spr11445Class implements BeanResolver {
1842
-
1843
- private final AtomicInteger counter = new AtomicInteger ();
1844
-
1845
- public int echo (int invocation ) {
1846
- return invocation ;
1847
- }
1848
-
1849
- public int parameter () {
1850
- return counter .incrementAndGet ();
1851
- }
1852
-
1853
- @ Override
1854
- public Object resolve (EvaluationContext context , String beanName ) throws AccessException {
1855
- return beanName .equals ("bean" ) ? this : null ;
1856
- }
1857
- }
1858
-
1859
-
1860
1840
@ Test
1861
1841
public void SPR11494 () {
1862
1842
Expression exp = new SpelExpressionParser ().parseExpression ("T(java.util.Arrays).asList('a','b')" );
1863
1843
List <String > list = (List <String >) exp .getValue ();
1864
1844
assertThat (list .size (), is (2 ));
1865
1845
}
1866
1846
1847
+ @ Test
1848
+ public void SPR11609 () {
1849
+ StandardEvaluationContext sec = new StandardEvaluationContext ();
1850
+ sec .addPropertyAccessor (new MapAccessor ());
1851
+ Expression exp = new SpelExpressionParser ().parseExpression (
1852
+ "T(org.springframework.expression.spel.SpelReproTests$MapWithConstant).X" );
1853
+ assertEquals (1 , exp .getValue (sec ));
1854
+ }
1855
+
1867
1856
1868
1857
private static enum ABC { A , B , C }
1869
1858
@@ -1939,7 +1928,7 @@ public static class StaticFinalImpl2 extends AbstractStaticFinal {
1939
1928
}
1940
1929
1941
1930
1942
- public static class SPR10486 {
1931
+ public static class Spr10486 {
1943
1932
1944
1933
private String name = "name" ;
1945
1934
@@ -1953,7 +1942,7 @@ public void setName(String name) {
1953
1942
}
1954
1943
1955
1944
1956
- static class SPR11142 {
1945
+ static class Spr11142 {
1957
1946
1958
1947
public String isSomething () {
1959
1948
return "" ;
@@ -1983,4 +1972,29 @@ public boolean equals(Object o) {
1983
1972
}
1984
1973
}
1985
1974
1975
+
1976
+ static class Spr11445Class implements BeanResolver {
1977
+
1978
+ private final AtomicInteger counter = new AtomicInteger ();
1979
+
1980
+ public int echo (int invocation ) {
1981
+ return invocation ;
1982
+ }
1983
+
1984
+ public int parameter () {
1985
+ return counter .incrementAndGet ();
1986
+ }
1987
+
1988
+ @ Override
1989
+ public Object resolve (EvaluationContext context , String beanName ) throws AccessException {
1990
+ return beanName .equals ("bean" ) ? this : null ;
1991
+ }
1992
+ }
1993
+
1994
+
1995
+ public static class MapWithConstant extends HashMap {
1996
+
1997
+ public static final int X = 1 ;
1998
+ }
1999
+
1986
2000
}
0 commit comments