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 2019/10/04 11:30:29 UTC
[tomcat] branch master updated: Ensure correct exception with
StaticFieldELResolver and Java 9+
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new ac4a40a Ensure correct exception with StaticFieldELResolver and Java 9+
ac4a40a is described below
commit ac4a40ac84260236f9ce22ac65f4292c569781a1
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 3 23:55:16 2019 +0100
Ensure correct exception with StaticFieldELResolver and Java 9+
---
java/javax/el/LocalStrings.properties | 2 +-
java/javax/el/StaticFieldELResolver.java | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/java/javax/el/LocalStrings.properties b/java/javax/el/LocalStrings.properties
index 4bca364..76e4fb8 100644
--- a/java/javax/el/LocalStrings.properties
+++ b/java/javax/el/LocalStrings.properties
@@ -45,7 +45,7 @@ propertyReadError=Error reading [{1}] on type [{0}]
propertyWriteError=Error writing [{1}] on type [{0}]
staticFieldELResolver.methodNotFound=No matching public static method named [{0}] found on class [{1}]
-staticFieldELResolver.notFound=No public static field named [{0}] was found on class [{1}]
+staticFieldELResolver.notFound=No public static field named [{0}] was found on (exported for Java 9+) class [{1}]
staticFieldELResolver.notWriteable=Writing to static fields (in this case field [{0}] on class [{1}]) is not permitted
util.method.ambiguous=Unable to find unambiguous method: {0}.{1}({2})
diff --git a/java/javax/el/StaticFieldELResolver.java b/java/javax/el/StaticFieldELResolver.java
index e3cc72a..5b3afaf 100644
--- a/java/javax/el/StaticFieldELResolver.java
+++ b/java/javax/el/StaticFieldELResolver.java
@@ -43,8 +43,10 @@ public class StaticFieldELResolver extends ELResolver {
try {
Field field = clazz.getField(name);
int modifiers = field.getModifiers();
+ JreCompat jreCompat = JreCompat.getInstance();
if (Modifier.isStatic(modifiers) &&
- Modifier.isPublic(modifiers)) {
+ Modifier.isPublic(modifiers) &&
+ jreCompat.canAcccess(null, field)) {
return field.get(null);
}
} catch (IllegalArgumentException | IllegalAccessException |
@@ -153,8 +155,10 @@ public class StaticFieldELResolver extends ELResolver {
try {
Field field = clazz.getField(name);
int modifiers = field.getModifiers();
+ JreCompat jreCompat = JreCompat.getInstance();
if (Modifier.isStatic(modifiers) &&
- Modifier.isPublic(modifiers)) {
+ Modifier.isPublic(modifiers) &&
+ jreCompat.canAcccess(null, field)) {
return field.getType();
}
} catch (IllegalArgumentException | NoSuchFieldException |
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org