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 2022/08/25 15:14:46 UTC
[tomcat] branch 10.0.x updated: Simplifying ImportHandler to not test class presence with getResource (no more perf boost from it on modern JRE)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new 1321709431 Simplifying ImportHandler to not test class presence with getResource (no more perf boost from it on modern JRE)
1321709431 is described below
commit 1321709431d067b29c42536d2ab9bf60a83fbd16
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Wed Aug 24 15:39:16 2022 +0200
Simplifying ImportHandler to not test class presence with getResource (no more perf boost from it on modern JRE)
---
java/jakarta/el/ImportHandler.java | 50 --------------------------------------
webapps/docs/changelog.xml | 6 +++++
2 files changed, 6 insertions(+), 50 deletions(-)
diff --git a/java/jakarta/el/ImportHandler.java b/java/jakarta/el/ImportHandler.java
index 6ab3ad2574..bda701decd 100644
--- a/java/jakarta/el/ImportHandler.java
+++ b/java/jakarta/el/ImportHandler.java
@@ -19,8 +19,6 @@ package jakarta.el;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -33,8 +31,6 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ImportHandler {
- private static final boolean IS_SECURITY_ENABLED = (System.getSecurityManager() != null);
-
private static final Map<String,Set<String>> standardPackages = new HashMap<>();
static {
@@ -453,31 +449,6 @@ public class ImportHandler {
private Class<?> findClass(String name, boolean throwException) {
Class<?> clazz;
ClassLoader cl = Util.getContextClassLoader();
- String path = name.replace('.', '/') + ".class";
- try {
- /* Given that findClass() has to be called for every imported
- * package and that getResource() is a lot faster then loadClass()
- * for resources that don't exist, the overhead of the getResource()
- * for the case where the class does exist is a lot less than the
- * overhead we save by not calling loadClass().
- */
- if (IS_SECURITY_ENABLED) {
- // Webapps don't have read permission for JAVA_HOME (and
- // possibly other sources of classes). Only need to know if the
- // class exists at this point. Class loading occurs with
- // standard SecurityManager policy next.
- if (!AccessController.doPrivileged(new PrivilegedResourceExists(cl, path)).booleanValue()) {
- return null;
- }
- } else {
- if (cl.getResource(path) == null) {
- return null;
- }
- }
- } catch (ClassCircularityError cce) {
- // May happen under a security manager. Ignore it and try loading
- // the class normally.
- }
try {
clazz = cl.loadClass(name);
} catch (ClassNotFoundException e) {
@@ -508,25 +479,4 @@ public class ImportHandler {
*/
private static class NotFound {
}
-
-
- private static class PrivilegedResourceExists implements PrivilegedAction<Boolean> {
-
- private final ClassLoader cl;
- private final String name;
-
- public PrivilegedResourceExists(ClassLoader cl, String name) {
- this.cl = cl;
- this.name = name;
- }
-
- @Override
- public Boolean run() {
- if (cl.getResource(name) == null) {
- return Boolean.FALSE;
- } else {
- return Boolean.TRUE;
- }
- }
- }
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 523ea03d30..f525c1a945 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -220,6 +220,12 @@
<bug>66235</bug>: Fix various issues with the bean resolver used for
Graal. (remm)
</fix>
+ <fix>
+ Improve the performance of the <code>ImportHandler</code> in the
+ Expression Language implementation. This removes a previous optimisation
+ that is now detrimental rather than helpful. Pull request <pr>547</pr>
+ provided by rmannibucau. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Cluster">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org