This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 35bd877 Add more generics to EL API to align with spec project 35bd877 is described below commit 35bd87789017661b599f18ce33529ba544b81a06 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jul 7 16:55:30 2021 +0100 Add more generics to EL API to align with spec project --- java/jakarta/el/ELProcessor.java | 6 ++++-- test/jakarta/el/TestELProcessor.java | 11 +++++------ test/jakarta/el/TestUtil.java | 2 +- test/org/apache/el/TestMethodExpressionImpl.java | 6 +++--- test/org/apache/el/lang/TestELArithmetic.java | 12 ++++++------ test/org/apache/el/parser/TestAstAnd.java | 8 ++++---- test/org/apache/el/parser/TestAstChoice.java | 2 +- test/org/apache/el/parser/TestAstNot.java | 6 +++--- test/org/apache/el/parser/TestAstOr.java | 8 ++++---- webapps/docs/changelog.xml | 8 ++++++++ 10 files changed, 39 insertions(+), 30 deletions(-) diff --git a/java/jakarta/el/ELProcessor.java b/java/jakarta/el/ELProcessor.java index 98ff6a3..aea604a 100644 --- a/java/jakarta/el/ELProcessor.java +++ b/java/jakarta/el/ELProcessor.java @@ -50,8 +50,10 @@ public class ELProcessor { } - public Object eval(String expression) { - return getValue(expression, Object.class); + public <T> T eval(String expression) { + @SuppressWarnings("unchecked") + T result = (T) getValue(expression, Object.class); + return result; } diff --git a/test/jakarta/el/TestELProcessor.java b/test/jakarta/el/TestELProcessor.java index 4bf6673..644a557 100644 --- a/test/jakarta/el/TestELProcessor.java +++ b/test/jakarta/el/TestELProcessor.java @@ -47,7 +47,7 @@ public class TestELProcessor { public void testEval03() { ELProcessor elp = new ELProcessor(); // Note \ is escaped as \\ in Java source code - String result = (String) elp.eval("'\\\\'"); + String result = elp.eval("'\\\\'"); Assert.assertEquals("\\", result); } @@ -200,12 +200,11 @@ public class TestELProcessor { elp.defineBean("bean01", bean01); elp.defineBean("bean02", new TesterBean("bean02")); - Object result = elp.eval("bean02.setValueC(bean01.valueB);bean02.valueC"); + Integer[] result = elp.eval("bean02.setValueC(bean01.valueB);bean02.valueC"); - Integer[] resultArray = (Integer[]) result; - Assert.assertEquals(bean01.getValueB().length, resultArray.length); - for (int i = 0; i < resultArray.length; i++) { - Assert.assertEquals(bean01.getValueB()[i], resultArray[i].intValue()); + Assert.assertEquals(bean01.getValueB().length, result.length); + for (int i = 0; i < result.length; i++) { + Assert.assertEquals(bean01.getValueB()[i], result[i].intValue()); } } } diff --git a/test/jakarta/el/TestUtil.java b/test/jakarta/el/TestUtil.java index dc2a5ed..3ed53f5 100644 --- a/test/jakarta/el/TestUtil.java +++ b/test/jakarta/el/TestUtil.java @@ -35,7 +35,7 @@ public class TestUtil { public void test02() { ELProcessor processor = new ELProcessor(); processor.getELManager().importClass("java.util.Date"); - Date result = (Date) processor.eval("Date(86400)"); + Date result = processor.eval("Date(86400)"); Assert.assertEquals(86400, result.getTime()); } diff --git a/test/org/apache/el/TestMethodExpressionImpl.java b/test/org/apache/el/TestMethodExpressionImpl.java index 103f400..3339d01 100644 --- a/test/org/apache/el/TestMethodExpressionImpl.java +++ b/test/org/apache/el/TestMethodExpressionImpl.java @@ -606,7 +606,7 @@ public class TestMethodExpressionImpl { ELProcessor elp = new ELProcessor(); elp.defineBean("apple", TesterEnum.APPLE); elp.defineBean("beanF", new TesterBeanF()); - String elResult = (String) elp.eval(expression); + String elResult = elp.eval(expression); String javaResult = func.apply(new TesterBeanF()); Assert.assertEquals(javaResult, elResult); } @@ -676,7 +676,7 @@ public class TestMethodExpressionImpl { ELProcessor elp = new ELProcessor(); elp.defineBean("apple", TesterEnum.APPLE); elp.defineBean("beanG", new TesterBeanG()); - String elResult = (String) elp.eval(expression); + String elResult = elp.eval(expression); String javaResult = func.apply(new TesterBeanG()); Assert.assertEquals(javaResult, elResult); } @@ -745,7 +745,7 @@ public class TestMethodExpressionImpl { ELProcessor elp = new ELProcessor(); elp.defineBean("apple", TesterEnum.APPLE); elp.defineBean("beanH", new TesterBeanH()); - String elResult = (String) elp.eval(expression); + String elResult = elp.eval(expression); String javaResult = func.apply(new TesterBeanH()); Assert.assertEquals(javaResult, elResult); } diff --git a/test/org/apache/el/lang/TestELArithmetic.java b/test/org/apache/el/lang/TestELArithmetic.java index 6c4e80c..800d8ea 100644 --- a/test/org/apache/el/lang/TestELArithmetic.java +++ b/test/org/apache/el/lang/TestELArithmetic.java @@ -38,7 +38,7 @@ public class TestELArithmetic { @Test public void testAdd02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null + null"); + Long result = processor.eval("null + null"); Assert.assertEquals(Long.valueOf(0), result); } @@ -51,7 +51,7 @@ public class TestELArithmetic { @Test public void testSubtract02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null - null"); + Long result = processor.eval("null - null"); Assert.assertEquals(Long.valueOf(0), result); } @@ -64,7 +64,7 @@ public class TestELArithmetic { @Test public void testMultiply02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null * null"); + Long result = processor.eval("null * null"); Assert.assertEquals(Long.valueOf(0), result); } @@ -77,7 +77,7 @@ public class TestELArithmetic { @Test public void testDivide02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null / null"); + Long result = processor.eval("null / null"); Assert.assertEquals(Long.valueOf(0), result); } @@ -90,14 +90,14 @@ public class TestELArithmetic { @Test public void testMod02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null % null"); + Long result = processor.eval("null % null"); Assert.assertEquals(Long.valueOf(0), result); } @Test public void testUnaryMinus01() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("-null"); + Long result = processor.eval("-null"); Assert.assertEquals(Long.valueOf(0), result); } diff --git a/test/org/apache/el/parser/TestAstAnd.java b/test/org/apache/el/parser/TestAstAnd.java index 040717f..8303eaf 100644 --- a/test/org/apache/el/parser/TestAstAnd.java +++ b/test/org/apache/el/parser/TestAstAnd.java @@ -26,28 +26,28 @@ public class TestAstAnd { @Test public void test01() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("true && true"); + Boolean result = processor.eval("true && true"); Assert.assertEquals(Boolean.TRUE, result); } @Test public void test02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("true && null"); + Boolean result = processor.eval("true && null"); Assert.assertEquals(Boolean.FALSE, result); } @Test public void test03() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null && true"); + Boolean result = processor.eval("null && true"); Assert.assertEquals(Boolean.FALSE, result); } @Test public void test04() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null && null"); + Boolean result = processor.eval("null && null"); Assert.assertEquals(Boolean.FALSE, result); } } diff --git a/test/org/apache/el/parser/TestAstChoice.java b/test/org/apache/el/parser/TestAstChoice.java index 0eaa9f4..23e8fdd 100644 --- a/test/org/apache/el/parser/TestAstChoice.java +++ b/test/org/apache/el/parser/TestAstChoice.java @@ -26,7 +26,7 @@ public class TestAstChoice { @Test public void test01() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null?1:2"); + Long result = processor.eval("null?1:2"); Assert.assertEquals(Long.valueOf(2), result); } } diff --git a/test/org/apache/el/parser/TestAstNot.java b/test/org/apache/el/parser/TestAstNot.java index f6b859d..11f53f3 100644 --- a/test/org/apache/el/parser/TestAstNot.java +++ b/test/org/apache/el/parser/TestAstNot.java @@ -26,21 +26,21 @@ public class TestAstNot { @Test public void test01() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("!null"); + Boolean result = processor.eval("!null"); Assert.assertEquals(Boolean.TRUE, result); } @Test public void test02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("!true"); + Boolean result = processor.eval("!true"); Assert.assertEquals(Boolean.FALSE, result); } @Test public void test03() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("!false"); + Boolean result = processor.eval("!false"); Assert.assertEquals(Boolean.TRUE, result); } } diff --git a/test/org/apache/el/parser/TestAstOr.java b/test/org/apache/el/parser/TestAstOr.java index 46a30d0..bb7a2bd 100644 --- a/test/org/apache/el/parser/TestAstOr.java +++ b/test/org/apache/el/parser/TestAstOr.java @@ -26,28 +26,28 @@ public class TestAstOr { @Test public void test01() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("true || true"); + Boolean result = processor.eval("true || true"); Assert.assertEquals(Boolean.TRUE, result); } @Test public void test02() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("true || null"); + Boolean result = processor.eval("true || null"); Assert.assertEquals(Boolean.TRUE, result); } @Test public void test03() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null || true"); + Boolean result = processor.eval("null || true"); Assert.assertEquals(Boolean.TRUE, result); } @Test public void test04() { ELProcessor processor = new ELProcessor(); - Object result = processor.eval("null || null"); + Boolean result = processor.eval("null || null"); Assert.assertEquals(Boolean.FALSE, result); } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 41766a3..2e78aa9 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -142,6 +142,14 @@ </fix> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <scode> + Add additional generics to the EL API to align with the latest changes + in the EL specification project. (markt) + </scode> + </changelog> + </subsection> <subsection name="Web applications"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org