19
19
import java .lang .reflect .Array ;
20
20
import java .lang .reflect .Field ;
21
21
import java .lang .reflect .Method ;
22
+ import java .nio .charset .Charset ;
22
23
import java .util .ArrayList ;
23
24
import java .util .Arrays ;
24
25
import java .util .Collection ;
@@ -1836,26 +1837,36 @@ public void SPR11609() {
1836
1837
}
1837
1838
1838
1839
@ Test
1839
- public void SPR12502 () throws Exception {
1840
+ public void SPR12502 () {
1840
1841
SpelExpressionParser parser = new SpelExpressionParser ();
1841
1842
Expression expression = parser .parseExpression ("#root.getClass().getName()" );
1842
1843
assertEquals (UnnamedUser .class .getName (), expression .getValue (new UnnamedUser ()));
1843
1844
assertEquals (NamedUser .class .getName (), expression .getValue (new NamedUser ()));
1844
1845
}
1845
1846
1846
1847
@ Test
1847
- public void SPR12803 () throws Exception {
1848
+ public void SPR12803 () {
1848
1849
StandardEvaluationContext sec = new StandardEvaluationContext ();
1849
1850
sec .setVariable ("iterable" , Collections .emptyList ());
1850
1851
SpelExpressionParser parser = new SpelExpressionParser ();
1851
1852
Expression expression = parser .parseExpression ("T(org.springframework.expression.spel.SpelReproTests.GuavaLists).newArrayList(#iterable)" );
1852
1853
assertTrue (expression .getValue (sec ) instanceof ArrayList );
1853
1854
}
1854
1855
1856
+ @ Test
1857
+ public void SPR13918 () {
1858
+ EvaluationContext context = new StandardEvaluationContext ();
1859
+ context .setVariable ("encoding" , "UTF-8" );
1860
+
1861
+ Expression ex = parser .parseExpression ("T(java.nio.charset.Charset).forName(#encoding)" );
1862
+ Object result = ex .getValue (context );
1863
+ assertEquals (Charset .forName ("UTF-8" ), result );
1864
+ }
1865
+
1855
1866
1856
- private static enum ABC { A , B , C }
1867
+ private enum ABC { A , B , C }
1857
1868
1858
- private static enum XYZ { X , Y , Z }
1869
+ private enum XYZ { X , Y , Z }
1859
1870
1860
1871
1861
1872
public static class BooleanHolder {
@@ -1882,7 +1893,7 @@ public boolean isPrimitiveProperty() {
1882
1893
}
1883
1894
1884
1895
1885
- private static interface GenericInterface <T extends Number > {
1896
+ private interface GenericInterface <T extends Number > {
1886
1897
1887
1898
public T getProperty ();
1888
1899
}
@@ -1909,9 +1920,9 @@ public static class OnlyBridgeMethod extends PackagePrivateClassWithGetter {
1909
1920
}
1910
1921
1911
1922
1912
- public static interface StaticFinal {
1923
+ public interface StaticFinal {
1913
1924
1914
- public static final String VALUE = "interfaceValue" ;
1925
+ String VALUE = "interfaceValue" ;
1915
1926
}
1916
1927
1917
1928
@@ -1988,6 +1999,7 @@ public Object resolve(EvaluationContext context, String beanName) throws AccessE
1988
1999
}
1989
2000
1990
2001
2002
+ @ SuppressWarnings ({"rawtypes" , "serial" })
1991
2003
public static class MapWithConstant extends HashMap {
1992
2004
1993
2005
public static final int X = 1 ;
0 commit comments