You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/01/17 17:41:05 UTC
(tomcat) branch main updated: Improve EL Identifier tests
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 e0da738a9a Improve EL Identifier tests
e0da738a9a is described below
commit e0da738a9afbfd85d407bb0b7759f85a5ba087b2
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jan 17 17:40:52 2025 +0000
Improve EL Identifier tests
Test valid and non-valid characters.
Tests can only run on versions of Java that have the same definition of
identifier as Java 21 (Java 21 to Java 23).
---
test/org/apache/el/parser/TestAstIdentifier.java | 34 +++++++++++++++++++++-
.../el/parser/TesterGenerateIdentifierRanges.java | 5 ++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/test/org/apache/el/parser/TestAstIdentifier.java b/test/org/apache/el/parser/TestAstIdentifier.java
index 584325d4b6..5d94478624 100644
--- a/test/org/apache/el/parser/TestAstIdentifier.java
+++ b/test/org/apache/el/parser/TestAstIdentifier.java
@@ -17,14 +17,17 @@
package org.apache.el.parser;
import jakarta.el.ELContext;
+import jakarta.el.ELException;
import jakarta.el.ELProcessor;
import jakarta.el.ExpressionFactory;
import jakarta.el.ValueExpression;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Test;
import org.apache.jasper.el.ELContextImpl;
+import org.apache.tomcat.util.compat.JreCompat;
public class TestAstIdentifier {
@@ -52,9 +55,24 @@ public class TestAstIdentifier {
@Test
public void testIdentifierStart() {
+ /*
+ * This test only works on Java 21 to Java 23.
+ *
+ * Java 21 is the minimum Java version for Tomcat 12.
+ *
+ * In Java 24, the definition of Java Letter and/or Java Digit has changed.
+ */
+ Assume.assumeFalse(JreCompat.isJre24Available());
for (int i = 0; i < 0xFFFF; i++) {
if (Character.isJavaIdentifierStart(i)) {
testIdentifier((char) i, 'b');
+ } else {
+ try {
+ testIdentifier((char) i, 'b');
+ } catch (ELException e) {
+ continue;
+ }
+ Assert.fail("Expected EL exception for [" + i + "], [" + (char) i + "]");
}
}
}
@@ -62,9 +80,24 @@ public class TestAstIdentifier {
@Test
public void testIdentifierPart() {
+ /*
+ * This test only works on Java 21 to Java 23.
+ *
+ * Java 21 is the minimum Java version for Tomcat 12.
+ *
+ * In Java 24, the definition of Java Letter and/or Java Digit has changed.
+ */
+ Assume.assumeFalse(JreCompat.isJre24Available());
for (int i = 0; i < 0xFFFF; i++) {
if (Character.isJavaIdentifierPart(i)) {
testIdentifier('b', (char) i);
+ } else {
+ try {
+ testIdentifier((char) i, 'b');
+ } catch (ELException e) {
+ continue;
+ }
+ Assert.fail("Expected EL exception for [" + i + "], [" + (char) i + "]");
}
}
}
@@ -84,7 +117,6 @@ public class TestAstIdentifier {
try {
ve = factory.createValueExpression(context, "${" + identifier + "}", String.class);
} catch (Exception e) {
- System.out.println("" + (int) one + " " + (int) two);
throw e;
}
diff --git a/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java b/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java
index f692344e3f..6ac9bd7adc 100644
--- a/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java
+++ b/test/org/apache/el/parser/TesterGenerateIdentifierRanges.java
@@ -21,6 +21,11 @@ import org.junit.Test;
/*
* The purpose of this class is to generate the ranges used in the JavaCC grammar for EL parsing.
*
+ * The ranges for Tomcat 12 were generated with Java 21.
+ *
+ * The generated ranges are unchanged from Java 21 to Java 23.
+ *
+ * The generated ranges change in Java 24 (somewhere between EA 22 and EA 31).
*/
public class TesterGenerateIdentifierRanges {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Improve EL Identifier tests
Posted by Mark Thomas <ma...@apache.org>.
On 17/01/2025 17:41, markt@apache.org wrote:
> 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 e0da738a9a Improve EL Identifier tests
> e0da738a9a is described below
>
> commit e0da738a9afbfd85d407bb0b7759f85a5ba087b2
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Fri Jan 17 17:40:52 2025 +0000
>
> Improve EL Identifier tests
>
> Test valid and non-valid characters.
> Tests can only run on versions of Java that have the same definition of
> identifier as Java 21 (Java 21 to Java 23).
FYI.
My plan is to configure the EL parser to allow identifiers as defined by
the minimum version of Java supported by that version of Tomcat. I'll
then figure out the range of Java versions that supports that definition
and limit the tests to just that version range.
It is possible that the Jakarta EL team takes a different view and
decides that Identifier is whatever the current version of Java says it
is. I think that is the wrong choice for various reasons not least the
interoperability issues it would introduce. But, if the decision goes
that way I'll update Tomcat accordingly.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org