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:01:56 UTC
[tomcat] branch main 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 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 a908486e0c Simplifying ImportHandler to not test class presence with getResource (no more perf boost from it on modern JRE)
a908486e0c is described below
commit a908486e0c7cdc0802de5bb58a8eda396f6a6e91
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 --------------------------------------
1 file changed, 50 deletions(-)
diff --git a/java/jakarta/el/ImportHandler.java b/java/jakarta/el/ImportHandler.java
index e9f0d41fea..93f1052a26 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 {
@@ -452,31 +448,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) {
@@ -513,25 +484,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;
- }
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org