diff --git a/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java b/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java
index eaf13e52a64a..dcdac85af037 100644
--- a/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java
+++ b/jetty-core/jetty-ee/src/main/java/org/eclipse/jetty/ee/WebAppClassLoading.java
@@ -169,8 +169,9 @@ public static void addHiddenClasses(String... patterns)
* Add a hidden (server) Class pattern to use for all WebAppContexts of a given {@link Server}.
* @param attributes The {@link Attributes} instance to add classes to
* @param patterns the patterns to use
+ * @deprecated use {@link #addHiddenClasses(Server, String...)} instead
*/
- @Deprecated (forRemoval = true)
+ @Deprecated (since = "12.0.9", forRemoval = true)
public static void addHiddenClasses(Attributes attributes, String... patterns)
{
if (patterns != null && patterns.length > 0)
diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ClassVisibilityChecker.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ClassVisibilityChecker.java
index 12bfaec2322f..e9d273a7e5ed 100644
--- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ClassVisibilityChecker.java
+++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/ClassVisibilityChecker.java
@@ -21,7 +21,7 @@ public interface ClassVisibilityChecker
{
/**
* Is the class a Protected (System) Class.
- * A System class is a class that is visible to a webapplication,
+ * A System class is a class that is visible to a web application,
* but that cannot be overridden by the contents of WEB-INF/lib or
* WEB-INF/classes
*
@@ -33,8 +33,8 @@ public interface ClassVisibilityChecker
/**
* Is the class a Hidden (Server) Class.
* A Server class is a class that is part of the implementation of
- * the server and is NIT visible to a webapplication. The web
- * application may provide it's own implementation of the class,
+ * the server and is NOT visible to a web application. The web
+ * application may provide its own implementation of the class,
* to be loaded from WEB-INF/lib or WEB-INF/classes
*
* @param clazz The fully qualified name of the class.
@@ -44,7 +44,7 @@ public interface ClassVisibilityChecker
/**
* Is the class a System Class.
- * A System class is a class that is visible to a webapplication,
+ * A System class is a class that is visible to a web application,
* but that cannot be overridden by the contents of WEB-INF/lib or
* WEB-INF/classes
*
@@ -61,8 +61,8 @@ default boolean isSystemClass(Class> clazz)
/**
* Is the class a Server Class.
* A Server class is a class that is part of the implementation of
- * the server and is NIT visible to a webapplication. The web
- * application may provide it's own implementation of the class,
+ * the server and is NOT visible to a web application. The web
+ * application may provide its own implementation of the class,
* to be loaded from WEB-INF/lib or WEB-INF/classes
*
* @param clazz The fully qualified name of the class.
diff --git a/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java b/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java
index 07370998d8d1..32ed6ef47c4f 100644
--- a/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java
+++ b/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiConfiguration.java
@@ -13,8 +13,6 @@
package org.eclipse.jetty.ee10.cdi;
-import java.util.function.Predicate;
-
import org.eclipse.jetty.ee10.annotations.AnnotationConfiguration;
import org.eclipse.jetty.ee10.plus.webapp.PlusConfiguration;
import org.eclipse.jetty.ee10.webapp.AbstractConfiguration;
@@ -33,11 +31,11 @@ public CdiConfiguration()
{
super(new Builder()
.protectAndExpose("org.eclipse.jetty.ee10.cdi.CdiServletContainerInitializer")
- .hide(getHiddenClasses())
+ .hide(getCdiHiddenClasses())
.addDependents(AnnotationConfiguration.class, PlusConfiguration.class));
}
- private static String[] getHiddenClasses()
+ private static String[] getCdiHiddenClasses()
{
//Only hide the cdi api classes if there is not also an impl on the
//environment classpath - vital for embedded uses.
@@ -45,4 +43,4 @@ private static String[] getHiddenClasses()
return new String[]{"jakarta.enterprise.", "jakarta.decorator."};
return new String[0];
}
-}
\ No newline at end of file
+}
diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java
index 2db4056c8bd9..ae04963208c2 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/AbstractConfiguration.java
@@ -19,13 +19,15 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.jetty.util.ClassMatcher;
+
public class AbstractConfiguration implements Configuration
{
private final boolean _enabledByDefault;
private final List
Also since Jetty-9.4, Configurations are responsible for providing {@link #getServerClasses()} and - * {@link #getSystemClasses()} to configure the {@link WebAppClassLoader} for each context. + *
Also since Jetty-9.4, Configurations are responsible for providing {@link #getHiddenClasses()} and + * {@link #getProtectedClasses()} to configure the {@link WebAppClassLoader} for each context. *
*/ public interface Configuration @@ -93,25 +94,43 @@ default Collection
diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java
index a1ad3d32d9af..a2bbd6aab13a 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoader.java
@@ -20,28 +20,24 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Stream;
import org.eclipse.jetty.util.ClassVisibilityChecker;
import org.eclipse.jetty.util.FileID;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil;
-import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollators;
import org.eclipse.jetty.util.resource.ResourceFactory;
@@ -115,9 +111,33 @@ public interface Context extends ClassVisibilityChecker
List
- * These classes/packages are used to implement the server and are hiddenClasses
+ * These classes/packages are used to implement the server and are hidden
* from the context. If the context needs to load these classes, it must have its
* own copy of them in WEB-INF/lib or WEB-INF/classes.
*
@@ -635,7 +635,7 @@ public void setHiddenClassMatcher(ClassMatcher hiddenClasses)
}
/**
- * Set the protected (aka system) classes patterns.
+ * Set the protected (system) classes patterns.
*
* These classes/packages are provided by the JVM and
* cannot be replaced by classes of the same name from WEB-INF,
@@ -680,7 +680,7 @@ public ClassMatcher getProtectedClassMatcher()
}
/**
- * @return The ClassMatcher used to match Server (hiddenClasses) classes
+ * @return The ClassMatcher used to match Server (hidden) classes
*/
public ClassMatcher getHiddenClassMatcher()
{
@@ -693,7 +693,7 @@ public String[] getProtectedClasses()
return _protectedClasses.getPatterns();
}
- @ManagedAttribute(value = "classes and packages hiddenClasses by the context classloader", readonly = true)
+ @ManagedAttribute(value = "classes and packages hidden by the context classloader", readonly = true)
public String[] getHiddenClasses()
{
return _hiddenClasses.getPatterns();
@@ -727,56 +727,54 @@ public boolean isProtectedResource(String name, URL url)
* @deprecated use {@link #setHiddenClassMatcher(ClassMatcher)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
- public void setServerClassMatcher(ClassMatcher serverClasses)
+ public void setServerClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher serverClasses)
{
- _hiddenClasses.clear();
- _hiddenClasses.add(serverClasses.getPatterns());
+ setHiddenClassMatcher(serverClasses);
}
/**
* @deprecated use {@link #setProtectedClassMatcher(ClassMatcher)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
- public void setSystemClassMatcher(ClassMatcher systemClasses)
+ public void setSystemClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher systemClasses)
{
- _protectedClasses.clear();
- _protectedClasses.add(systemClasses.getPatterns());
+ setProtectedClassMatcher(systemClasses);
}
/**
* @deprecated use {@link #addHiddenClassMatcher(ClassMatcher)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
- public void addServerClassMatcher(ClassMatcher serverClasses)
+ public void addServerClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher serverClasses)
{
- _hiddenClasses.add(serverClasses.getPatterns());
+ addHiddenClassMatcher(serverClasses);
}
/**
* @deprecated use {@link #addProtectedClassMatcher(ClassMatcher)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
- public void addSystemClassMatcher(ClassMatcher systemClasses)
+ public void addSystemClassMatcher(org.eclipse.jetty.ee10.webapp.ClassMatcher systemClasses)
{
- _protectedClasses.add(systemClasses.getPatterns());
+ addProtectedClassMatcher(systemClasses);
}
/**
* @deprecated use {@link #getProtectedClassMatcher()}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
- public ClassMatcher getSystemClassMatcher()
+ public org.eclipse.jetty.ee10.webapp.ClassMatcher getSystemClassMatcher()
{
- return _protectedClasses;
+ return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getProtectedClassMatcher());
}
/**
* @deprecated use {@link #getHiddenClassMatcher()}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
- public ClassMatcher getServerClassMatcher()
+ public org.eclipse.jetty.ee10.webapp.ClassMatcher getServerClassMatcher()
{
- return _hiddenClasses;
+ return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getHiddenClassMatcher());
}
/**
@@ -785,7 +783,7 @@ public ClassMatcher getServerClassMatcher()
@Deprecated(since = "12.0.8", forRemoval = true)
public String[] getSystemClasses()
{
- return _protectedClasses.getPatterns();
+ return getProtectedClasses();
}
/**
@@ -794,7 +792,7 @@ public String[] getSystemClasses()
@Deprecated(since = "12.0.8", forRemoval = true)
public String[] getServerClasses()
{
- return _hiddenClasses.getPatterns();
+ return getHiddenClasses();
}
/**
@@ -803,7 +801,7 @@ public String[] getServerClasses()
@Deprecated(since = "12.0.8", forRemoval = true)
public boolean isServerClass(Class> clazz)
{
- return _hiddenClasses.match(clazz);
+ return isHiddenClass(clazz);
}
/**
@@ -812,25 +810,7 @@ public boolean isServerClass(Class> clazz)
@Deprecated(since = "12.0.8", forRemoval = true)
public boolean isSystemClass(Class> clazz)
{
- return _protectedClasses.match(clazz);
- }
-
- /**
- * @deprecated use {@link #isHiddenResource(String, URL)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public boolean isServerResource(String name, URL url)
- {
- return _hiddenClasses.match(name, url);
- }
-
- /**
- * @deprecated use {@link #isProtectedResource(String, URL)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public boolean isSystemResource(String name, URL url)
- {
- return _protectedClasses.match(name, url);
+ return isProtectedClass(clazz);
}
@Override
diff --git a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java
index c08c71724ea8..b3a55912f23b 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/WebAppClassLoaderTest.java
@@ -75,7 +75,7 @@ public void init() throws Exception
}
@AfterEach
- public void afterEach() throws Exception
+ public void afterEach()
{
IO.close(_loader);
LifeCycle.stop(_server);
@@ -315,7 +315,6 @@ public void testResources() throws Exception
resources = Collections.list(_loader.getResources("org/acme/resource.txt"));
- expected.clear();
expected.add(webappWebInfLibAcme);
expected.add(webappWebInfClasses);
expected.add(targetTestClasses);
diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java
index d382b4cf4ac1..58ac7a04cadb 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java
@@ -18,11 +18,6 @@
import org.eclipse.jetty.util.IncludeExcludeSet;
-/**
- * @deprecated Use org.eclipse.jetty.util.ClassMatcher
- */
-
-@Deprecated(since = "12.0.8", forRemoval = true)
public class ClassMatcher extends org.eclipse.jetty.util.ClassMatcher
{
public ClassMatcher()
diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java
index bc0b23f3a682..39fa82a0c5c0 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java
@@ -104,7 +104,7 @@ default ClassMatcher getSystemClasses()
}
/**
- * Get the system classes associated with this Configuration.
+ * Get the server classes associated with this Configuration.
*
* @return ClassMatcher of server classes.
*/
diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java
index f474fa96ceda..01e809657285 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoader.java
@@ -20,28 +20,24 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Stream;
import org.eclipse.jetty.util.ClassVisibilityChecker;
import org.eclipse.jetty.util.FileID;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil;
-import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollators;
import org.eclipse.jetty.util.resource.ResourceFactory;
@@ -530,7 +526,6 @@ protected Class> loadAsResource(final String name, boolean checkSystemResource
if (webappUrl != null && (!checkSystemResource || !_context.isSystemResource(name, webappUrl)))
{
-
webappClass = this.foundClass(name, webappUrl);
resolveClass(webappClass);
if (LOG.isDebugEnabled())
diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java
index 574cd0969a6e..6e63474b41ba 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java
@@ -55,7 +55,6 @@
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.Attributes;
-import org.eclipse.jetty.util.ClassMatcher;
import org.eclipse.jetty.util.ExceptionUtil;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
@@ -673,7 +672,7 @@ public PermissionCollection getPermissions()
/**
* Set the server classes patterns.
*
- * Server classes/packages are classes used to implement the server and are hidden
+ * These classes/packages are used to implement the server and are hidden
* from the context. If the context needs to load these classes, it must have its
* own copy of them in WEB-INF/lib or WEB-INF/classes.
*
@@ -688,7 +687,7 @@ public void setServerClassMatcher(ClassMatcher serverClasses)
/**
* Set the system classes patterns.
*
- * System classes/packages are classes provided by the JVM and that
+ * These classes/packages are provided by the JVM and
* cannot be replaced by classes of the same name from WEB-INF,
* regardless of the value of {@link #setParentLoaderPriority(boolean)}.
*
@@ -753,11 +752,23 @@ public String[] getServerClasses()
@Override
public boolean isHiddenClass(Class> clazz)
{
- return _serverClasses.match(clazz);
+ return isServerClass(clazz);
}
@Override
public boolean isProtectedClass(Class> clazz)
+ {
+ return isSystemClass(clazz);
+ }
+
+ @Override
+ public boolean isServerClass(Class> clazz)
+ {
+ return _serverClasses.match(clazz);
+ }
+
+ @Override
+ public boolean isSystemClass(Class> clazz)
{
return _systemClasses.match(clazz);
}
diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java
index af4e50031f41..6ab704340a11 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppClassLoaderTest.java
@@ -26,7 +26,6 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
-import org.eclipse.jetty.util.ClassMatcher;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.resource.Resource;
@@ -75,7 +74,7 @@ public void init() throws Exception
}
@AfterEach
- public void afterEach() throws Exception
+ public void afterEach()
{
IO.close(_loader);
LifeCycle.stop(_server);
@@ -315,7 +314,6 @@ public void testResources() throws Exception
resources = Collections.list(_loader.getResources("org/acme/resource.txt"));
- expected.clear();
expected.add(webappWebInfLibAcme);
expected.add(webappWebInfClasses);
expected.add(targetTestClasses);