From 8f4fe8fd57e4f8623679cf8d78668891226a1e1f Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 30 Apr 2024 17:33:50 +0200
Subject: [PATCH 1/3] Addendum to #11566.
Restored methods that were removed in WebAppClassLoader.Context.
Fixed method signatures for deprecated method -- they must take the deprecated ClassMatcher, not the newly introduced one.
Signed-off-by: Simone Bordet
---
.../eclipse/jetty/ee/WebAppClassLoading.java | 3 +-
.../jetty/ee10/cdi/CdiConfiguration.java | 8 +-
.../ee10/webapp/AbstractConfiguration.java | 28 +--
.../jetty/ee10/webapp/ClassMatcher.java | 1 -
.../jetty/ee10/webapp/Configuration.java | 31 ++-
.../jetty/ee10/webapp/WebAppClassLoader.java | 32 ++-
.../jetty/ee10/webapp/WebAppContext.java | 68 +++----
.../jetty/ee9/demos/ProxyWebAppTest.java | 2 +-
.../webapp/PlusDescriptorProcessorTest.java | 2 +-
.../jetty/ee9/quickstart/TestQuickStart.java | 8 +-
.../jetty/ee9/cdi/tests/EmbeddedWeldTest.java | 8 +-
.../ee9/webapp/AbstractConfiguration.java | 34 ++--
.../jetty/ee9/webapp/ClassMatcher.java | 1 -
.../jetty/ee9/webapp/Configuration.java | 31 ++-
.../jetty/ee9/webapp/WebAppClassLoader.java | 44 ++--
.../jetty/ee9/webapp/WebAppContext.java | 188 +++++++++++++-----
.../ee9/webapp/WebAppClassLoaderTest.java | 44 ++--
.../jetty/ee9/webapp/WebAppContextTest.java | 4 +-
18 files changed, 343 insertions(+), 194 deletions(-)
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-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..5929ce18aa1e 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 _after;
private final List _before;
- private final ClassMatcher _system;
- private final ClassMatcher _server;
+ private final ClassMatcher _protected;
+ private final ClassMatcher _hidden;
public static class Builder
{
@@ -88,7 +90,7 @@ public Builder addDependents(Class>... classes)
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getSystemClasses()}
+ * to the {@link WebAppConfiguration#getProtectedClasses()}
*
* @param classes classname or package pattern
*/
@@ -100,7 +102,7 @@ public Builder protect(String... classes)
/**
* Hide classes from the web application by adding them
- * to the {@link WebAppConfiguration#getServerClasses()}
+ * to the {@link WebAppConfiguration#getHiddenClasses()}
*
* @param classes classname or package pattern
*/
@@ -112,7 +114,7 @@ public Builder hide(String... classes)
/**
* Expose classes to the web application by adding them
- * as exclusions to the {@link WebAppConfiguration#getServerClasses()}
+ * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
*
* @param classes classname or package pattern
*/
@@ -129,9 +131,9 @@ public Builder expose(String... classes)
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getSystemClasses()} and
+ * to the {@link WebAppConfiguration#getHiddenClasses()} and
* expose them to the web application by adding them
- * as exclusions to the {@link WebAppConfiguration#getServerClasses()}
+ * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
*
* @param classes classname or package pattern
*/
@@ -154,8 +156,8 @@ protected AbstractConfiguration(Builder builder)
_enabledByDefault = builder._enabledByDefault;
_after = List.copyOf(builder._after);
_before = List.copyOf(builder._before);
- _system = new ClassMatcher(builder._system).asImmutable();
- _server = new ClassMatcher(builder._server).asImmutable();
+ _protected = new ClassMatcher(builder._system).asImmutable();
+ _hidden = new ClassMatcher(builder._server).asImmutable();
}
@Override
@@ -171,15 +173,15 @@ public Collection getDependencies()
}
@Override
- public ClassMatcher getSystemClasses()
+ public ClassMatcher getProtectedClasses()
{
- return _system;
+ return _protected;
}
@Override
- public ClassMatcher getServerClasses()
+ public ClassMatcher getHiddenClasses()
{
- return _server;
+ return _hidden;
}
@Override
diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java
index 23a625dcd1c3..3eb611146b6f 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java
@@ -21,7 +21,6 @@
/**
* @deprecated Use org.eclipse.jetty.util.ClassMatcher
*/
-
@Deprecated(since = "12.0.8", forRemoval = true)
public class ClassMatcher extends org.eclipse.jetty.util.ClassMatcher
{
diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java
index ca8e4934ecdb..1e92b56f68d9 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java
@@ -17,6 +17,7 @@
import java.util.Collections;
import java.util.ServiceLoader;
+import org.eclipse.jetty.util.ClassMatcher;
import org.eclipse.jetty.util.TopologicalSort;
/**
@@ -43,8 +44,8 @@
* (eg {@link JndiConfiguration}, {@link JaasConfiguration}} etc.) can be added or removed without concern
* for ordering.
*
- * 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 #getHiddenClasses()} to configure the {@link WebAppClassLoader} for each context.
*
*/
public interface Configuration
@@ -93,25 +94,43 @@ default Collection getDependents()
}
/**
- * Get the system classes associated with this Configuration.
+ * Get the system (protected) classes associated with this Configuration.
*
* @return ClassMatcher of system classes.
*/
- default ClassMatcher getSystemClasses()
+ default ClassMatcher getProtectedClasses()
{
return new ClassMatcher();
}
/**
- * Get the system classes associated with this Configuration.
+ * Get the system (hidden) classes associated with this Configuration.
*
* @return ClassMatcher of server classes.
*/
- default ClassMatcher getServerClasses()
+ default ClassMatcher getHiddenClasses()
{
return new ClassMatcher();
}
+ /**
+ * @deprecated use {@link #getProtectedClasses()} instead
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default org.eclipse.jetty.ee10.webapp.ClassMatcher getSystemClasses()
+ {
+ return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getProtectedClasses());
+ }
+
+ /**
+ * @deprecated use {@link #getHiddenClasses()} instead
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default org.eclipse.jetty.ee10.webapp.ClassMatcher getServerClasses()
+ {
+ return new org.eclipse.jetty.ee10.webapp.ClassMatcher(getHiddenClasses());
+ }
+
/**
* Set up for configuration.
*
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..82e14887a483 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 getExtraClasspath();
- boolean isHiddenResource(String name, URL parentUrl);
+ /**
+ * @deprecated use {@link #isHiddenResource(String, URL)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default boolean isServerResource(String name, URL parentUrl)
+ {
+ return isHiddenResource(name, parentUrl);
+ }
+
+ /**
+ * @deprecated use {@link #isProtectedResource(String, URL)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default boolean isSystemResource(String name, URL webappUrl)
+ {
+ return isProtectedResource(name, webappUrl);
+ }
- boolean isProtectedResource(String name, URL webappUrl);
+ default boolean isHiddenResource(String name, URL parentUrl)
+ {
+ return false;
+ }
+
+ default boolean isProtectedResource(String name, URL webappUrl)
+ {
+ return false;
+ }
}
/**
diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java
index 473eca9595b0..53081d51dc39 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java
@@ -425,7 +425,7 @@ public void preConfigure() throws Exception
// Add the known server class inclusions for all known configurations
for (Configuration configuration : Configurations.getKnown())
{
- _hiddenClasses.include(configuration.getServerClasses().getInclusions());
+ _hiddenClasses.include(configuration.getHiddenClasses().getInclusions());
}
// Setup Configuration classes for this webapp!
@@ -433,8 +433,8 @@ public void preConfigure() throws Exception
_configurations.sort();
for (Configuration configuration : _configurations)
{
- _protectedClasses.add(configuration.getSystemClasses().getPatterns());
- _hiddenClasses.exclude(configuration.getServerClasses().getExclusions());
+ _protectedClasses.add(configuration.getProtectedClasses().getPatterns());
+ _hiddenClasses.exclude(configuration.getHiddenClasses().getExclusions());
}
// Configure classloader
@@ -620,9 +620,9 @@ public PermissionCollection getPermissions()
}
/**
- * Set the hidden (aka server) classes patterns.
+ * Set the hidden (server) classes patterns.
*
- * 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-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java
index 78ec5592f3b9..0848380e77b1 100644
--- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java
+++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java
@@ -57,7 +57,7 @@ public void setup() throws Exception
// This is a pieced together WebApp.
// We don't have a valid WEB-INF/lib to rely on at this point.
// So, open up server classes here, for purposes of this testcase.
- webapp.getServerClassMatcher().add("-org.eclipse.jetty.ee9.proxy.");
+ webapp.getHiddenClassMatcher().add("-org.eclipse.jetty.ee9.proxy.");
// Default location (EE9)
Path webappDir = MavenTestingUtils.getBasePath().resolve("src/main/webapp");
if (!Files.exists(webappDir))
diff --git a/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java b/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java
index 4a84332199da..6892cbc29f0b 100644
--- a/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java
+++ b/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java
@@ -129,7 +129,7 @@ public void setUp() throws Exception
context.setConfigurations(new Configuration[]{new PlusConfiguration(), new EnvConfiguration()});
context.preConfigure();
context.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), context));
- context.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.plus.webapp."); //need visbility of the TestInjections class
+ context.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.plus.webapp."); //need visbility of the TestInjections class
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(context.getClassLoader());
Context icontext = new InitialContext();
diff --git a/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java b/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java
index 1040160a5ebf..4a58dc4e3acd 100644
--- a/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java
+++ b/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java
@@ -89,7 +89,7 @@ public void testProgrammaticOverrideOfDefaultServletMapping() throws Exception
WebAppContext webapp = new WebAppContext();
webapp.setResourceBase(testDir.getAbsolutePath());
webapp.addConfiguration(new QuickStartConfiguration());
- webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART);
//add in the servlet
webapp.getServletHandler().addServlet(fooHolder);
@@ -139,7 +139,7 @@ public void testDefaultContextPath() throws Exception
webapp.addConfiguration(new QuickStartConfiguration());
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART);
webapp.setResourceBase(testDir.getAbsolutePath());
- webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
server.setHandler(webapp);
server.setDryRun(false);
@@ -180,7 +180,7 @@ public void testDefaultRequestAndResponseEncodings() throws Exception
webapp.addConfiguration(new QuickStartConfiguration());
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART);
webapp.setResourceBase(testDir.getAbsolutePath());
- webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
server.setHandler(webapp);
server.setDryRun(false);
@@ -255,7 +255,7 @@ public void testDuplicateGenerationFromContextXml() throws Exception
//a freshly applied context xml
quickstart = new WebAppContext();
//need visibility of FooServlet, FooFilter, FooContextListener when we quickstart
- quickstart.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ quickstart.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
quickstart.addConfiguration(new QuickStartConfiguration());
quickstart.setWar(testDir.toURI().toURL().toExternalForm());
quickstart.setDescriptor(MavenTestingUtils.getTargetFile("test-classes/web.xml").getAbsolutePath());
diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java
index c9978cbec67d..b5e8c07b852e 100644
--- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java
+++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java
@@ -202,8 +202,8 @@ public void testWebappContext() throws Exception
webapp.addBean(new ServletContextHandler.Initializer(webapp, new org.jboss.weld.environment.servlet.EnhancedListener()));
String pkg = EmbeddedWeldTest.class.getPackage().getName();
- webapp.getServerClassMatcher().add("-" + pkg + ".");
- webapp.getSystemClassMatcher().add(pkg + ".");
+ webapp.getHiddenClassMatcher().add("-" + pkg + ".");
+ webapp.getProtectedClassMatcher().add(pkg + ".");
webapp.addServlet(GreetingsServlet.class, "/greet");
webapp.addFilter(MyFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
@@ -238,8 +238,8 @@ public void testWebappContextDiscovered() throws Exception
// This is ugly but needed for maven for testing in a overlaid war pom
String pkg = EmbeddedWeldTest.class.getPackage().getName();
- webapp.getServerClassMatcher().add("-" + pkg + ".");
- webapp.getSystemClassMatcher().add(pkg + ".");
+ webapp.getHiddenClassMatcher().add("-" + pkg + ".");
+ webapp.getProtectedClassMatcher().add(pkg + ".");
webapp.getServletHandler().addListener(new ListenerHolder(MyContextListener.class));
webapp.addFilter(MyFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java
index 2d5db6c60989..d49b379fe05c 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java
@@ -19,13 +19,15 @@
import java.util.List;
import java.util.stream.Collectors;
+import org.eclipse.jetty.util.ClassMatcher;
+
public class AbstractConfiguration implements Configuration
{
private final boolean _enabledByDefault;
private final List _after = new ArrayList<>();
private final List _beforeThis = new ArrayList<>();
- private final ClassMatcher _system = new ClassMatcher();
- private final ClassMatcher _server = new ClassMatcher();
+ private final ClassMatcher _protected = new ClassMatcher();
+ private final ClassMatcher _hidden = new ClassMatcher();
protected AbstractConfiguration()
{
@@ -85,29 +87,29 @@ protected void addDependents(Class>... classes)
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getSystemClasses()}
+ * to the {@link WebAppConfiguration#getProtectedClasses()}
*
* @param classes classname or package pattern
*/
protected void protect(String... classes)
{
- _system.add(classes);
+ _protected.add(classes);
}
/**
* Hide classes from the web application by adding them
- * to the {@link WebAppConfiguration#getServerClasses()}
+ * to the {@link WebAppConfiguration#getHiddenClasses()}
*
* @param classes classname or package pattern
*/
protected void hide(String... classes)
{
- _server.add(classes);
+ _hidden.add(classes);
}
/**
* Expose classes to the web application by adding them
- * as exclusions to the {@link WebAppConfiguration#getServerClasses()}
+ * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
*
* @param classes classname or package pattern
*/
@@ -117,15 +119,15 @@ protected void expose(String... classes)
{
if (c.startsWith("-"))
throw new IllegalArgumentException();
- _server.add("-" + c);
+ _hidden.add("-" + c);
}
}
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getSystemClasses()} and
+ * to the {@link WebAppConfiguration#getProtectedClasses()} and
* expose them to the web application by adding them
- * as exclusions to the {@link WebAppConfiguration#getServerClasses()}
+ * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
*
* @param classes classname or package pattern
*/
@@ -136,8 +138,8 @@ protected void protectAndExpose(String... classes)
if (c.startsWith("-"))
throw new IllegalArgumentException();
- _system.add(c);
- _server.add("-" + c);
+ _protected.add(c);
+ _hidden.add("-" + c);
}
}
@@ -154,15 +156,15 @@ public Collection getDependencies()
}
@Override
- public ClassMatcher getSystemClasses()
+ public ClassMatcher getProtectedClasses()
{
- return _system;
+ return _protected;
}
@Override
- public ClassMatcher getServerClasses()
+ public ClassMatcher getHiddenClasses()
{
- return _server;
+ return _hidden;
}
@Override
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..733f559c296a 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
@@ -21,7 +21,6 @@
/**
* @deprecated Use org.eclipse.jetty.util.ClassMatcher
*/
-
@Deprecated(since = "12.0.8", forRemoval = true)
public class ClassMatcher extends org.eclipse.jetty.util.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..41e8dc12e599 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
@@ -17,6 +17,7 @@
import java.util.Collections;
import java.util.ServiceLoader;
+import org.eclipse.jetty.util.ClassMatcher;
import org.eclipse.jetty.util.TopologicalSort;
/**
@@ -42,8 +43,8 @@
* (eg {@link JndiConfiguration}, {@link JaasConfiguration}} etc.) can be added or removed without concern
* for ordering.
*
- * 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 #getHiddenClasses()} to configure the {@link WebAppClassLoader} for each context.
*
*/
public interface Configuration
@@ -94,25 +95,43 @@ default Collection getDependents()
}
/**
- * Get the system classes associated with this Configuration.
+ * Get the system (protected) classes associated with this Configuration.
*
* @return ClassMatcher of system classes.
*/
- default ClassMatcher getSystemClasses()
+ default ClassMatcher getProtectedClasses()
{
return new ClassMatcher();
}
/**
- * Get the system classes associated with this Configuration.
+ * Get the system (hidden) classes associated with this Configuration.
*
* @return ClassMatcher of server classes.
*/
- default ClassMatcher getServerClasses()
+ default ClassMatcher getHiddenClasses()
{
return new ClassMatcher();
}
+ /**
+ * @deprecated use {@link #getProtectedClasses()} instead
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default org.eclipse.jetty.ee9.webapp.ClassMatcher getSystemClasses()
+ {
+ return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getProtectedClasses());
+ }
+
+ /**
+ * @deprecated use {@link #getHiddenClasses()} instead
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default org.eclipse.jetty.ee9.webapp.ClassMatcher getServerClasses()
+ {
+ return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getHiddenClasses());
+ }
+
/**
* Set up for configuration.
*
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..4bcdfdb926ee 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;
@@ -115,9 +111,33 @@ public interface Context extends ClassVisibilityChecker
List getExtraClasspath();
- boolean isServerResource(String name, URL parentUrl);
+ /**
+ * @deprecated use {@link #isHiddenResource(String, URL)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default boolean isServerResource(String name, URL parentUrl)
+ {
+ return isHiddenResource(name, parentUrl);
+ }
+
+ /**
+ * @deprecated use {@link #isProtectedResource(String, URL)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ default boolean isSystemResource(String name, URL webappUrl)
+ {
+ return isProtectedResource(name, webappUrl);
+ }
- boolean isSystemResource(String name, URL webappUrl);
+ default boolean isHiddenResource(String name, URL parentUrl)
+ {
+ return false;
+ }
+
+ default boolean isProtectedResource(String name, URL webappUrl)
+ {
+ return false;
+ }
}
/**
@@ -306,7 +326,7 @@ public Enumeration getResources(String name) throws IOException
while (urls != null && urls.hasMoreElements())
{
URL url = urls.nextElement();
- if (Boolean.TRUE.equals(__loadServerClasses.get()) || !_context.isServerResource(name, url))
+ if (Boolean.TRUE.equals(__loadServerClasses.get()) || !_context.isHiddenResource(name, url))
fromParent.add(url);
}
@@ -314,7 +334,7 @@ public Enumeration getResources(String name) throws IOException
while (urls != null && urls.hasMoreElements())
{
URL url = urls.nextElement();
- if (!_context.isSystemResource(name, url) || fromParent.isEmpty())
+ if (!_context.isProtectedResource(name, url) || fromParent.isEmpty())
fromWebapp.add(url);
}
@@ -355,7 +375,7 @@ public URL getResource(String name)
// return if we have a url the webapp is allowed to see
if (parentUrl != null &&
(Boolean.TRUE.equals(__loadServerClasses.get()) ||
- !_context.isServerResource(name, parentUrl)))
+ !_context.isHiddenResource(name, parentUrl)))
resource = parentUrl;
else
{
@@ -374,7 +394,7 @@ public URL getResource(String name)
{
URL webappUrl = this.findResource(name);
- if (webappUrl != null && !_context.isSystemResource(name, webappUrl))
+ if (webappUrl != null && !_context.isProtectedResource(name, webappUrl))
resource = webappUrl;
else
{
@@ -383,7 +403,7 @@ public URL getResource(String name)
URL parentUrl = _parent.getResource(name);
if (parentUrl != null &&
(Boolean.TRUE.equals(__loadServerClasses.get()) ||
- !_context.isServerResource(name, parentUrl)))
+ !_context.isHiddenResource(name, parentUrl)))
resource = parentUrl;
// We couldn't find a parent resource, so OK to return a webapp one if it exists
// and we just couldn't see it before
@@ -528,7 +548,7 @@ protected Class> loadAsResource(final String name, boolean checkSystemResource
String path = TypeUtil.toClassReference(name);
URL webappUrl = findResource(path);
- if (webappUrl != null && (!checkSystemResource || !_context.isSystemResource(name, webappUrl)))
+ if (webappUrl != null && (!checkSystemResource || !_context.isProtectedResource(name, webappUrl)))
{
webappClass = this.foundClass(name, webappUrl);
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..79af73cd1f54 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
@@ -116,8 +116,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
public static final org.eclipse.jetty.ee9.webapp.ClassMatcher __dftServerClasses =
new org.eclipse.jetty.ee9.webapp.ClassMatcher(WebAppClassLoading.DEFAULT_HIDDEN_CLASSES);
- private final ClassMatcher _systemClasses = new ClassMatcher(WebAppClassLoading.getProtectedClasses(ServletContextHandler.ENVIRONMENT));
- private final ClassMatcher _serverClasses = new ClassMatcher(WebAppClassLoading.getHiddenClasses(ServletContextHandler.ENVIRONMENT));
+ private final ClassMatcher _protectedClasses = new ClassMatcher(WebAppClassLoading.getProtectedClasses(ServletContextHandler.ENVIRONMENT));
+ private final ClassMatcher _hiddenClasses = new ClassMatcher(WebAppClassLoading.getHiddenClasses(ServletContextHandler.ENVIRONMENT));
private Configurations _configurations;
private String _defaultsDescriptor = WEB_DEFAULTS_XML;
@@ -461,7 +461,7 @@ public void preConfigure() throws Exception
// Add the known server class inclusions for all known configurations
for (Configuration configuration : Configurations.getKnown())
{
- _serverClasses.include(configuration.getServerClasses().getInclusions());
+ _hiddenClasses.include(configuration.getHiddenClasses().getInclusions());
}
// Setup Configuration classes for this webapp!
@@ -469,8 +469,8 @@ public void preConfigure() throws Exception
_configurations.sort();
for (Configuration configuration : _configurations)
{
- _systemClasses.add(configuration.getSystemClasses().getPatterns());
- _serverClasses.exclude(configuration.getServerClasses().getExclusions());
+ _protectedClasses.add(configuration.getProtectedClasses().getPatterns());
+ _hiddenClasses.exclude(configuration.getHiddenClasses().getExclusions());
}
// Configure classloader
@@ -671,107 +671,197 @@ public PermissionCollection getPermissions()
}
/**
- * Set the server classes patterns.
+ * Set the hidden (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.
*
- * @param serverClasses the server classes pattern
+ * @param hiddenClasses the server classes pattern
*/
- public void setServerClassMatcher(ClassMatcher serverClasses)
+ public void setHiddenClassMatcher(ClassMatcher hiddenClasses)
{
- _serverClasses.clear();
- _serverClasses.add(serverClasses.getPatterns());
+ _hiddenClasses.clear();
+ _hiddenClasses.add(hiddenClasses.getPatterns());
}
/**
- * Set the system classes patterns.
+ * Set the protected (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)}.
*
- * @param systemClasses the system classes pattern
+ * @param protectedClasses the system classes pattern
*/
- public void setSystemClassMatcher(ClassMatcher systemClasses)
+ public void setProtectedClassMatcher(ClassMatcher protectedClasses)
{
- _systemClasses.clear();
- _systemClasses.add(systemClasses.getPatterns());
+ _protectedClasses.clear();
+ _protectedClasses.add(protectedClasses.getPatterns());
}
/**
- * Add a ClassMatcher for server classes by combining with
+ * Add a ClassMatcher for hidden (server) classes by combining with
* any existing matcher.
*
- * @param serverClasses The class matcher of patterns to add to the server ClassMatcher
+ * @param hiddenClasses The class matcher of patterns to add to the server ClassMatcher
*/
- public void addServerClassMatcher(ClassMatcher serverClasses)
+ public void addHiddenClassMatcher(ClassMatcher hiddenClasses)
{
- _serverClasses.add(serverClasses.getPatterns());
+ _hiddenClasses.add(hiddenClasses.getPatterns());
}
/**
- * Add a ClassMatcher for system classes by combining with
+ * Add a ClassMatcher for protected (system) classes by combining with
* any existing matcher.
*
- * @param systemClasses The class matcher of patterns to add to the system ClassMatcher
+ * @param protectedClasses The class matcher of patterns to add to the system ClassMatcher
*/
- public void addSystemClassMatcher(ClassMatcher systemClasses)
+ public void addProtectedClassMatcher(ClassMatcher protectedClasses)
{
- _systemClasses.add(systemClasses.getPatterns());
+ _protectedClasses.add(protectedClasses.getPatterns());
}
/**
* @return The ClassMatcher used to match System (protected) classes
*/
- public ClassMatcher getSystemClassMatcher()
+ public ClassMatcher getProtectedClassMatcher()
{
- return _systemClasses;
+ return _protectedClasses;
}
/**
* @return The ClassMatcher used to match Server (hidden) classes
*/
- public ClassMatcher getServerClassMatcher()
+ public ClassMatcher getHiddenClassMatcher()
{
- return _serverClasses;
+ return _hiddenClasses;
}
@ManagedAttribute(value = "classes and packages protected by context classloader", readonly = true)
- public String[] getSystemClasses()
+ public String[] getProtectedClasses()
{
- return _systemClasses.getPatterns();
+ return _protectedClasses.getPatterns();
}
@ManagedAttribute(value = "classes and packages hidden by the context classloader", readonly = true)
- public String[] getServerClasses()
+ public String[] getHiddenClasses()
{
- return _serverClasses.getPatterns();
+ return _hiddenClasses.getPatterns();
}
@Override
public boolean isHiddenClass(Class> clazz)
{
- return _serverClasses.match(clazz);
+ return _hiddenClasses.match(clazz);
}
@Override
public boolean isProtectedClass(Class> clazz)
{
- return _systemClasses.match(clazz);
+ return _protectedClasses.match(clazz);
}
@Override
- public boolean isServerResource(String name, URL url)
+ public boolean isHiddenResource(String name, URL url)
{
- return _serverClasses.match(name, url);
+ return _hiddenClasses.match(name, url);
}
@Override
- public boolean isSystemResource(String name, URL url)
+ public boolean isProtectedResource(String name, URL url)
+ {
+ return _protectedClasses.match(name, url);
+ }
+
+ /**
+ * @deprecated use {@link #setHiddenClassMatcher(ClassMatcher)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public void setServerClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher serverClasses)
+ {
+ setHiddenClassMatcher(serverClasses);
+ }
+
+ /**
+ * @deprecated use {@link #setProtectedClassMatcher(ClassMatcher)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public void setSystemClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher systemClasses)
+ {
+ setProtectedClassMatcher(systemClasses);
+ }
+
+ /**
+ * @deprecated use {@link #addHiddenClassMatcher(ClassMatcher)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public void addServerClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher serverClasses)
+ {
+ addHiddenClassMatcher(serverClasses);
+ }
+
+ /**
+ * @deprecated use {@link #addProtectedClassMatcher(ClassMatcher)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public void addSystemClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher systemClasses)
+ {
+ addProtectedClassMatcher(systemClasses);
+ }
+
+ /**
+ * @deprecated use {@link #getProtectedClassMatcher()}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public org.eclipse.jetty.ee9.webapp.ClassMatcher getSystemClassMatcher()
+ {
+ return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getProtectedClassMatcher());
+ }
+
+ /**
+ * @deprecated use {@link #getHiddenClassMatcher()}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public org.eclipse.jetty.ee9.webapp.ClassMatcher getServerClassMatcher()
+ {
+ return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getHiddenClassMatcher());
+ }
+
+ /**
+ * @deprecated use {@link #getProtectedClasses()}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public String[] getSystemClasses()
+ {
+ return getProtectedClasses();
+ }
+
+ /**
+ * @deprecated use {@link #getHiddenClasses()}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public String[] getServerClasses()
+ {
+ return getHiddenClasses();
+ }
+
+ /**
+ * @deprecated use {@link #isHiddenClass(Class)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public boolean isServerClass(Class> clazz)
+ {
+ return isHiddenClass(clazz);
+ }
+
+ /**
+ * @deprecated use {@link #isProtectedClass(Class)}
+ */
+ @Deprecated(since = "12.0.8", forRemoval = true)
+ public boolean isSystemClass(Class> clazz)
{
- return _systemClasses.match(name, url);
+ return isProtectedClass(clazz);
}
@Override
@@ -780,8 +870,8 @@ public void setServer(Server server)
super.setServer(server);
if (server != null)
{
- _systemClasses.add(WebAppClassLoading.getProtectedClasses(server).getPatterns());
- _serverClasses.add(WebAppClassLoading.getHiddenClasses(server).getPatterns());
+ _protectedClasses.add(WebAppClassLoading.getProtectedClasses(server).getPatterns());
+ _hiddenClasses.add(WebAppClassLoading.getHiddenClasses(server).getPatterns());
}
}
@@ -893,16 +983,16 @@ public String toString()
public void dump(Appendable out, String indent) throws IOException
{
List systemClasses = null;
- if (_systemClasses != null)
+ if (_protectedClasses != null)
{
- systemClasses = new ArrayList<>(_systemClasses);
+ systemClasses = new ArrayList<>(_protectedClasses);
Collections.sort(systemClasses);
}
List serverClasses = null;
- if (_serverClasses != null)
+ if (_hiddenClasses != null)
{
- serverClasses = new ArrayList<>(_serverClasses);
+ serverClasses = new ArrayList<>(_hiddenClasses);
Collections.sort(serverClasses);
}
@@ -1480,8 +1570,8 @@ public MetaData getMetaData()
* Add a Server Class pattern to use for all ee9 WebAppContexts.
* @param attributes The {@link Server} instance to add classes to
* @param patterns the patterns to use
- * @see #getServerClassMatcher()
- * @see #getServerClasses()
+ * @see #getHiddenClassMatcher()
+ * @see #getHiddenClasses()
* @deprecated use {@link WebAppClassLoading#addProtectedClasses(Server, String...)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
@@ -1494,8 +1584,8 @@ public static void addServerClasses(Attributes attributes, String... patterns)
* Add a System Class pattern to use for all ee9 WebAppContexts.
* @param attributes The {@link Server} instance to add classes to
* @param patterns the patterns to use
- * @see #getSystemClassMatcher()
- * @see #getSystemClasses()
+ * @see #getProtectedClassMatcher()
+ * @see #getProtectedClasses()
* @deprecated use {@link WebAppClassLoading#addHiddenClasses(Server, String...)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
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..64baae738836 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
@@ -210,11 +210,11 @@ public byte[] transform(ClassLoader loader, String className, Class> classBein
@Test
public void testExposedClassDeprecated() throws Exception
{
- String[] oldSC = _context.getServerClasses();
+ String[] oldSC = _context.getHiddenClasses();
String[] newSC = new String[oldSC.length + 1];
newSC[0] = "-org.eclipse.jetty.ee9.webapp.Configuration";
System.arraycopy(oldSC, 0, newSC, 1, oldSC.length);
- _context.setServerClassMatcher(new ClassMatcher(newSC));
+ _context.setHiddenClassMatcher(new ClassMatcher(newSC));
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -227,7 +227,7 @@ public void testExposedClassDeprecated() throws Exception
@Test
public void testExposedClass() throws Exception
{
- _context.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.webapp.Configuration");
+ _context.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.webapp.Configuration");
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -240,18 +240,18 @@ public void testExposedClass() throws Exception
@Test
public void testSystemServerClassDeprecated() throws Exception
{
- String[] oldServC = _context.getServerClasses();
+ String[] oldServC = _context.getHiddenClasses();
String[] newServC = new String[oldServC.length + 1];
newServC[0] = "org.eclipse.jetty.ee9.webapp.Configuration";
System.arraycopy(oldServC, 0, newServC, 1, oldServC.length);
- _context.setServerClassMatcher(new ClassMatcher(newServC));
+ _context.setHiddenClassMatcher(new ClassMatcher(newServC));
- String[] oldSysC = _context.getSystemClasses();
+ String[] oldSysC = _context.getProtectedClasses();
String[] newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.eclipse.jetty.ee9.webapp.";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setSystemClassMatcher(new ClassMatcher(newSysC));
+ _context.setHiddenClassMatcher(new ClassMatcher(newSysC));
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -259,28 +259,28 @@ public void testSystemServerClassDeprecated() throws Exception
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.Configuration");
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.JarScanner");
- oldSysC = _context.getSystemClasses();
+ oldSysC = _context.getProtectedClasses();
newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.acme.webapp.ClassInJarA";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setSystemClassMatcher(new ClassMatcher(newSysC));
+ _context.setProtectedClassMatcher(new ClassMatcher(newSysC));
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
- _context.setSystemClassMatcher(new ClassMatcher(oldSysC));
+ _context.setProtectedClassMatcher(new ClassMatcher(oldSysC));
- oldServC = _context.getServerClasses();
+ oldServC = _context.getHiddenClasses();
newServC = new String[oldServC.length + 1];
newServC[0] = "org.acme.webapp.ClassInJarA";
System.arraycopy(oldServC, 0, newServC, 1, oldServC.length);
- _context.setServerClassMatcher(new ClassMatcher(newServC));
+ _context.setHiddenClassMatcher(new ClassMatcher(newServC));
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
}
@Test
public void testSystemServerClass() throws Exception
{
- _context.getServerClassMatcher().add("org.eclipse.jetty.ee9.webapp.Configuration");
- _context.getSystemClassMatcher().add("org.eclipse.jetty.ee9.webapp.");
+ _context.getHiddenClassMatcher().add("org.eclipse.jetty.ee9.webapp.Configuration");
+ _context.getProtectedClassMatcher().add("org.eclipse.jetty.ee9.webapp.");
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -288,11 +288,11 @@ public void testSystemServerClass() throws Exception
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.Configuration");
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.JarScanner");
- _context.getSystemClassMatcher().add("org.acme.webapp.ClassInJarA");
+ _context.getProtectedClassMatcher().add("org.acme.webapp.ClassInJarA");
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
- _context.getSystemClassMatcher().remove("org.acme.webapp.ClassInJarA");
+ _context.getProtectedClassMatcher().remove("org.acme.webapp.ClassInJarA");
- _context.getServerClassMatcher().add("org.acme.webapp.ClassInJarA");
+ _context.getHiddenClassMatcher().add("org.acme.webapp.ClassInJarA");
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
}
@@ -339,11 +339,11 @@ public void testResources() throws Exception
// assertEquals(0,resources.get(1).toString().indexOf("jar:file:"));
// assertEquals(-1,resources.get(2).toString().indexOf("test-classes"));
- String[] oldServC = _context.getServerClasses();
+ String[] oldServC = _context.getHiddenClasses();
String[] newServC = new String[oldServC.length + 1];
newServC[0] = "org.acme.";
System.arraycopy(oldServC, 0, newServC, 1, oldServC.length);
- _context.setServerClassMatcher(new ClassMatcher(newServC));
+ _context.setHiddenClassMatcher(new ClassMatcher(newServC));
_context.setParentLoaderPriority(true);
// dump(_context);
@@ -360,12 +360,12 @@ public void testResources() throws Exception
// assertEquals(0,resources.get(0).toString().indexOf("jar:file:"));
// assertEquals(0,resources.get(1).toString().indexOf("file:"));
- _context.setServerClassMatcher(new ClassMatcher(oldServC));
- String[] oldSysC = _context.getSystemClasses();
+ _context.setHiddenClassMatcher(new ClassMatcher(oldServC));
+ String[] oldSysC = _context.getProtectedClasses();
String[] newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.acme.";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setSystemClassMatcher(new ClassMatcher(newSysC));
+ _context.setProtectedClassMatcher(new ClassMatcher(newSysC));
_context.setParentLoaderPriority(true);
// dump(_context);
diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
index 9e9ee0bd01b3..ad3bcc434464 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
@@ -870,7 +870,7 @@ public void testAddServerClasses() throws Exception
server.setHandler(context);
server.start();
- List serverClasses = List.of(context.getServerClasses());
+ List serverClasses = List.of(context.getHiddenClasses());
assertThat("Should have environment specific test pattern", serverClasses, hasItem(testPattern));
assertThat("Should have pattern from defaults", serverClasses, hasItem("org.eclipse.jetty."));
assertThat("Should have pattern from JaasConfiguration", serverClasses, hasItem("-org.eclipse.jetty.security.jaas."));
@@ -898,7 +898,7 @@ public void testAddSystemClasses() throws Exception
server.setHandler(context);
server.start();
- List systemClasses = List.of(context.getSystemClasses());
+ List systemClasses = List.of(context.getProtectedClasses());
assertThat("Should have environment specific test pattern", systemClasses, hasItem(testPattern));
assertThat("Should have pattern from defaults", systemClasses, hasItem("javax."));
assertThat("Should have pattern from defaults", systemClasses, hasItem("jakarta."));
From e325a8f82dca9766c34dad6c48bb561eed783d0a Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 30 Apr 2024 21:17:30 +0200
Subject: [PATCH 2/3] More fixes.
Signed-off-by: Simone Bordet
---
.../eclipse/jetty/util/ClassVisibilityChecker.java | 12 ++++++------
.../jetty/ee10/webapp/AbstractConfiguration.java | 2 +-
.../org/eclipse/jetty/ee10/webapp/Configuration.java | 4 ++--
.../eclipse/jetty/ee10/webapp/WebAppClassLoader.java | 1 -
.../jetty/ee10/webapp/WebAppClassLoaderTest.java | 3 +--
.../org/eclipse/jetty/ee9/webapp/Configuration.java | 4 ++--
.../eclipse/jetty/ee9/webapp/WebAppClassLoader.java | 1 -
.../jetty/ee9/webapp/WebAppClassLoaderTest.java | 5 ++---
8 files changed, 14 insertions(+), 18 deletions(-)
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-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 5929ce18aa1e..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
@@ -131,7 +131,7 @@ public Builder expose(String... classes)
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getHiddenClasses()} and
+ * to the {@link WebAppConfiguration#getProtectedClasses()} and
* expose them to the web application by adding them
* as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
*
diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java
index 1e92b56f68d9..1f172c43fe31 100644
--- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java
+++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/Configuration.java
@@ -45,7 +45,7 @@
* for ordering.
*
* Also since Jetty-9.4, Configurations are responsible for providing {@link #getHiddenClasses()} and
- * {@link #getHiddenClasses()} to configure the {@link WebAppClassLoader} for each context.
+ * {@link #getProtectedClasses()} to configure the {@link WebAppClassLoader} for each context.
*
*/
public interface Configuration
@@ -104,7 +104,7 @@ default ClassMatcher getProtectedClasses()
}
/**
- * Get the system (hidden) classes associated with this Configuration.
+ * Get the server (hidden) classes associated with this Configuration.
*
* @return ClassMatcher of server classes.
*/
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 82e14887a483..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
@@ -546,7 +546,6 @@ protected Class> loadAsResource(final String name, boolean checkSystemResource
if (webappUrl != null && (!checkSystemResource || !_context.isProtectedResource(name, webappUrl)))
{
-
webappClass = this.foundClass(name, webappUrl);
resolveClass(webappClass);
if (LOG.isDebugEnabled())
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/Configuration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/Configuration.java
index 41e8dc12e599..ef7ef7aa4207 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
@@ -44,7 +44,7 @@
* for ordering.
*
* Also since Jetty-9.4, Configurations are responsible for providing {@link #getHiddenClasses()} and
- * {@link #getHiddenClasses()} to configure the {@link WebAppClassLoader} for each context.
+ * {@link #getProtectedClasses()} to configure the {@link WebAppClassLoader} for each context.
*
*/
public interface Configuration
@@ -105,7 +105,7 @@ default ClassMatcher getProtectedClasses()
}
/**
- * Get the system (hidden) classes associated with this Configuration.
+ * Get the server (hidden) 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 4bcdfdb926ee..3b480039e271 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
@@ -550,7 +550,6 @@ protected Class> loadAsResource(final String name, boolean checkSystemResource
if (webappUrl != null && (!checkSystemResource || !_context.isProtectedResource(name, webappUrl)))
{
-
webappClass = this.foundClass(name, webappUrl);
resolveClass(webappClass);
if (LOG.isDebugEnabled())
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 64baae738836..db27339d91c1 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
@@ -75,7 +75,7 @@ public void init() throws Exception
}
@AfterEach
- public void afterEach() throws Exception
+ public void afterEach()
{
IO.close(_loader);
LifeCycle.stop(_server);
@@ -251,7 +251,7 @@ public void testSystemServerClassDeprecated() throws Exception
String[] newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.eclipse.jetty.ee9.webapp.";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setHiddenClassMatcher(new ClassMatcher(newSysC));
+ _context.setProtectedClassMatcher(new ClassMatcher(newSysC));
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -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);
From b0bade10f312edeeb45e34b4f573ee5d3a993528 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Wed, 1 May 2024 20:07:07 +0200
Subject: [PATCH 3/3] Reverted changes to ee9 as per review.
Signed-off-by: Simone Bordet
---
.../jetty/ee9/demos/ProxyWebAppTest.java | 2 +-
.../webapp/PlusDescriptorProcessorTest.java | 2 +-
.../jetty/ee9/quickstart/TestQuickStart.java | 8 +-
.../jetty/ee9/cdi/tests/EmbeddedWeldTest.java | 8 +-
.../ee9/webapp/AbstractConfiguration.java | 34 ++--
.../jetty/ee9/webapp/ClassMatcher.java | 4 -
.../jetty/ee9/webapp/Configuration.java | 31 +--
.../jetty/ee9/webapp/WebAppClassLoader.java | 40 +---
.../jetty/ee9/webapp/WebAppContext.java | 185 +++++-------------
.../ee9/webapp/WebAppClassLoaderTest.java | 45 +++--
.../jetty/ee9/webapp/WebAppContextTest.java | 4 +-
11 files changed, 117 insertions(+), 246 deletions(-)
diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java
index 0848380e77b1..78ec5592f3b9 100644
--- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java
+++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-proxy-webapp/src/test/java/org/eclipse/jetty/ee9/demos/ProxyWebAppTest.java
@@ -57,7 +57,7 @@ public void setup() throws Exception
// This is a pieced together WebApp.
// We don't have a valid WEB-INF/lib to rely on at this point.
// So, open up server classes here, for purposes of this testcase.
- webapp.getHiddenClassMatcher().add("-org.eclipse.jetty.ee9.proxy.");
+ webapp.getServerClassMatcher().add("-org.eclipse.jetty.ee9.proxy.");
// Default location (EE9)
Path webappDir = MavenTestingUtils.getBasePath().resolve("src/main/webapp");
if (!Files.exists(webappDir))
diff --git a/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java b/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java
index 6892cbc29f0b..4a84332199da 100644
--- a/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java
+++ b/jetty-ee9/jetty-ee9-plus/src/test/java/org/eclipse/jetty/ee9/plus/webapp/PlusDescriptorProcessorTest.java
@@ -129,7 +129,7 @@ public void setUp() throws Exception
context.setConfigurations(new Configuration[]{new PlusConfiguration(), new EnvConfiguration()});
context.preConfigure();
context.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), context));
- context.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.plus.webapp."); //need visbility of the TestInjections class
+ context.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.plus.webapp."); //need visbility of the TestInjections class
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(context.getClassLoader());
Context icontext = new InitialContext();
diff --git a/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java b/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java
index 4a58dc4e3acd..1040160a5ebf 100644
--- a/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java
+++ b/jetty-ee9/jetty-ee9-quickstart/src/test/java/org/eclipse/jetty/ee9/quickstart/TestQuickStart.java
@@ -89,7 +89,7 @@ public void testProgrammaticOverrideOfDefaultServletMapping() throws Exception
WebAppContext webapp = new WebAppContext();
webapp.setResourceBase(testDir.getAbsolutePath());
webapp.addConfiguration(new QuickStartConfiguration());
- webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART);
//add in the servlet
webapp.getServletHandler().addServlet(fooHolder);
@@ -139,7 +139,7 @@ public void testDefaultContextPath() throws Exception
webapp.addConfiguration(new QuickStartConfiguration());
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART);
webapp.setResourceBase(testDir.getAbsolutePath());
- webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
server.setHandler(webapp);
server.setDryRun(false);
@@ -180,7 +180,7 @@ public void testDefaultRequestAndResponseEncodings() throws Exception
webapp.addConfiguration(new QuickStartConfiguration());
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.QUICKSTART);
webapp.setResourceBase(testDir.getAbsolutePath());
- webapp.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ webapp.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
server.setHandler(webapp);
server.setDryRun(false);
@@ -255,7 +255,7 @@ public void testDuplicateGenerationFromContextXml() throws Exception
//a freshly applied context xml
quickstart = new WebAppContext();
//need visibility of FooServlet, FooFilter, FooContextListener when we quickstart
- quickstart.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
+ quickstart.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.quickstart.");
quickstart.addConfiguration(new QuickStartConfiguration());
quickstart.setWar(testDir.toURI().toURL().toExternalForm());
quickstart.setDescriptor(MavenTestingUtils.getTargetFile("test-classes/web.xml").getAbsolutePath());
diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java
index b5e8c07b852e..c9978cbec67d 100644
--- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java
+++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-cdi/src/test/java/org/eclipse/jetty/ee9/cdi/tests/EmbeddedWeldTest.java
@@ -202,8 +202,8 @@ public void testWebappContext() throws Exception
webapp.addBean(new ServletContextHandler.Initializer(webapp, new org.jboss.weld.environment.servlet.EnhancedListener()));
String pkg = EmbeddedWeldTest.class.getPackage().getName();
- webapp.getHiddenClassMatcher().add("-" + pkg + ".");
- webapp.getProtectedClassMatcher().add(pkg + ".");
+ webapp.getServerClassMatcher().add("-" + pkg + ".");
+ webapp.getSystemClassMatcher().add(pkg + ".");
webapp.addServlet(GreetingsServlet.class, "/greet");
webapp.addFilter(MyFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
@@ -238,8 +238,8 @@ public void testWebappContextDiscovered() throws Exception
// This is ugly but needed for maven for testing in a overlaid war pom
String pkg = EmbeddedWeldTest.class.getPackage().getName();
- webapp.getHiddenClassMatcher().add("-" + pkg + ".");
- webapp.getProtectedClassMatcher().add(pkg + ".");
+ webapp.getServerClassMatcher().add("-" + pkg + ".");
+ webapp.getSystemClassMatcher().add(pkg + ".");
webapp.getServletHandler().addListener(new ListenerHolder(MyContextListener.class));
webapp.addFilter(MyFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java
index d49b379fe05c..2d5db6c60989 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/AbstractConfiguration.java
@@ -19,15 +19,13 @@
import java.util.List;
import java.util.stream.Collectors;
-import org.eclipse.jetty.util.ClassMatcher;
-
public class AbstractConfiguration implements Configuration
{
private final boolean _enabledByDefault;
private final List _after = new ArrayList<>();
private final List _beforeThis = new ArrayList<>();
- private final ClassMatcher _protected = new ClassMatcher();
- private final ClassMatcher _hidden = new ClassMatcher();
+ private final ClassMatcher _system = new ClassMatcher();
+ private final ClassMatcher _server = new ClassMatcher();
protected AbstractConfiguration()
{
@@ -87,29 +85,29 @@ protected void addDependents(Class>... classes)
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getProtectedClasses()}
+ * to the {@link WebAppConfiguration#getSystemClasses()}
*
* @param classes classname or package pattern
*/
protected void protect(String... classes)
{
- _protected.add(classes);
+ _system.add(classes);
}
/**
* Hide classes from the web application by adding them
- * to the {@link WebAppConfiguration#getHiddenClasses()}
+ * to the {@link WebAppConfiguration#getServerClasses()}
*
* @param classes classname or package pattern
*/
protected void hide(String... classes)
{
- _hidden.add(classes);
+ _server.add(classes);
}
/**
* Expose classes to the web application by adding them
- * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
+ * as exclusions to the {@link WebAppConfiguration#getServerClasses()}
*
* @param classes classname or package pattern
*/
@@ -119,15 +117,15 @@ protected void expose(String... classes)
{
if (c.startsWith("-"))
throw new IllegalArgumentException();
- _hidden.add("-" + c);
+ _server.add("-" + c);
}
}
/**
* Protect classes from modification by the web application by adding them
- * to the {@link WebAppConfiguration#getProtectedClasses()} and
+ * to the {@link WebAppConfiguration#getSystemClasses()} and
* expose them to the web application by adding them
- * as exclusions to the {@link WebAppConfiguration#getHiddenClasses()}
+ * as exclusions to the {@link WebAppConfiguration#getServerClasses()}
*
* @param classes classname or package pattern
*/
@@ -138,8 +136,8 @@ protected void protectAndExpose(String... classes)
if (c.startsWith("-"))
throw new IllegalArgumentException();
- _protected.add(c);
- _hidden.add("-" + c);
+ _system.add(c);
+ _server.add("-" + c);
}
}
@@ -156,15 +154,15 @@ public Collection getDependencies()
}
@Override
- public ClassMatcher getProtectedClasses()
+ public ClassMatcher getSystemClasses()
{
- return _protected;
+ return _system;
}
@Override
- public ClassMatcher getHiddenClasses()
+ public ClassMatcher getServerClasses()
{
- return _hidden;
+ return _server;
}
@Override
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 733f559c296a..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,10 +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 ef7ef7aa4207..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
@@ -17,7 +17,6 @@
import java.util.Collections;
import java.util.ServiceLoader;
-import org.eclipse.jetty.util.ClassMatcher;
import org.eclipse.jetty.util.TopologicalSort;
/**
@@ -43,8 +42,8 @@
* (eg {@link JndiConfiguration}, {@link JaasConfiguration}} etc.) can be added or removed without concern
* for ordering.
*
- * Also since Jetty-9.4, Configurations are responsible for providing {@link #getHiddenClasses()} and
- * {@link #getProtectedClasses()} to configure the {@link WebAppClassLoader} for each context.
+ *
Also since Jetty-9.4, Configurations are responsible for providing {@link #getServerClasses()} and
+ * {@link #getSystemClasses()} to configure the {@link WebAppClassLoader} for each context.
*
*/
public interface Configuration
@@ -95,43 +94,25 @@ default Collection getDependents()
}
/**
- * Get the system (protected) classes associated with this Configuration.
+ * Get the system classes associated with this Configuration.
*
* @return ClassMatcher of system classes.
*/
- default ClassMatcher getProtectedClasses()
+ default ClassMatcher getSystemClasses()
{
return new ClassMatcher();
}
/**
- * Get the server (hidden) classes associated with this Configuration.
+ * Get the server classes associated with this Configuration.
*
* @return ClassMatcher of server classes.
*/
- default ClassMatcher getHiddenClasses()
+ default ClassMatcher getServerClasses()
{
return new ClassMatcher();
}
- /**
- * @deprecated use {@link #getProtectedClasses()} instead
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- default org.eclipse.jetty.ee9.webapp.ClassMatcher getSystemClasses()
- {
- return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getProtectedClasses());
- }
-
- /**
- * @deprecated use {@link #getHiddenClasses()} instead
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- default org.eclipse.jetty.ee9.webapp.ClassMatcher getServerClasses()
- {
- return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getHiddenClasses());
- }
-
/**
* Set up for configuration.
*
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 3b480039e271..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
@@ -111,33 +111,9 @@ public interface Context extends ClassVisibilityChecker
List getExtraClasspath();
- /**
- * @deprecated use {@link #isHiddenResource(String, URL)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- default boolean isServerResource(String name, URL parentUrl)
- {
- return isHiddenResource(name, parentUrl);
- }
-
- /**
- * @deprecated use {@link #isProtectedResource(String, URL)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- default boolean isSystemResource(String name, URL webappUrl)
- {
- return isProtectedResource(name, webappUrl);
- }
+ boolean isServerResource(String name, URL parentUrl);
- default boolean isHiddenResource(String name, URL parentUrl)
- {
- return false;
- }
-
- default boolean isProtectedResource(String name, URL webappUrl)
- {
- return false;
- }
+ boolean isSystemResource(String name, URL webappUrl);
}
/**
@@ -326,7 +302,7 @@ public Enumeration getResources(String name) throws IOException
while (urls != null && urls.hasMoreElements())
{
URL url = urls.nextElement();
- if (Boolean.TRUE.equals(__loadServerClasses.get()) || !_context.isHiddenResource(name, url))
+ if (Boolean.TRUE.equals(__loadServerClasses.get()) || !_context.isServerResource(name, url))
fromParent.add(url);
}
@@ -334,7 +310,7 @@ public Enumeration getResources(String name) throws IOException
while (urls != null && urls.hasMoreElements())
{
URL url = urls.nextElement();
- if (!_context.isProtectedResource(name, url) || fromParent.isEmpty())
+ if (!_context.isSystemResource(name, url) || fromParent.isEmpty())
fromWebapp.add(url);
}
@@ -375,7 +351,7 @@ public URL getResource(String name)
// return if we have a url the webapp is allowed to see
if (parentUrl != null &&
(Boolean.TRUE.equals(__loadServerClasses.get()) ||
- !_context.isHiddenResource(name, parentUrl)))
+ !_context.isServerResource(name, parentUrl)))
resource = parentUrl;
else
{
@@ -394,7 +370,7 @@ public URL getResource(String name)
{
URL webappUrl = this.findResource(name);
- if (webappUrl != null && !_context.isProtectedResource(name, webappUrl))
+ if (webappUrl != null && !_context.isSystemResource(name, webappUrl))
resource = webappUrl;
else
{
@@ -403,7 +379,7 @@ public URL getResource(String name)
URL parentUrl = _parent.getResource(name);
if (parentUrl != null &&
(Boolean.TRUE.equals(__loadServerClasses.get()) ||
- !_context.isHiddenResource(name, parentUrl)))
+ !_context.isServerResource(name, parentUrl)))
resource = parentUrl;
// We couldn't find a parent resource, so OK to return a webapp one if it exists
// and we just couldn't see it before
@@ -548,7 +524,7 @@ protected Class> loadAsResource(final String name, boolean checkSystemResource
String path = TypeUtil.toClassReference(name);
URL webappUrl = findResource(path);
- if (webappUrl != null && (!checkSystemResource || !_context.isProtectedResource(name, webappUrl)))
+ if (webappUrl != null && (!checkSystemResource || !_context.isSystemResource(name, webappUrl)))
{
webappClass = this.foundClass(name, webappUrl);
resolveClass(webappClass);
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 79af73cd1f54..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;
@@ -116,8 +115,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
public static final org.eclipse.jetty.ee9.webapp.ClassMatcher __dftServerClasses =
new org.eclipse.jetty.ee9.webapp.ClassMatcher(WebAppClassLoading.DEFAULT_HIDDEN_CLASSES);
- private final ClassMatcher _protectedClasses = new ClassMatcher(WebAppClassLoading.getProtectedClasses(ServletContextHandler.ENVIRONMENT));
- private final ClassMatcher _hiddenClasses = new ClassMatcher(WebAppClassLoading.getHiddenClasses(ServletContextHandler.ENVIRONMENT));
+ private final ClassMatcher _systemClasses = new ClassMatcher(WebAppClassLoading.getProtectedClasses(ServletContextHandler.ENVIRONMENT));
+ private final ClassMatcher _serverClasses = new ClassMatcher(WebAppClassLoading.getHiddenClasses(ServletContextHandler.ENVIRONMENT));
private Configurations _configurations;
private String _defaultsDescriptor = WEB_DEFAULTS_XML;
@@ -461,7 +460,7 @@ public void preConfigure() throws Exception
// Add the known server class inclusions for all known configurations
for (Configuration configuration : Configurations.getKnown())
{
- _hiddenClasses.include(configuration.getHiddenClasses().getInclusions());
+ _serverClasses.include(configuration.getServerClasses().getInclusions());
}
// Setup Configuration classes for this webapp!
@@ -469,8 +468,8 @@ public void preConfigure() throws Exception
_configurations.sort();
for (Configuration configuration : _configurations)
{
- _protectedClasses.add(configuration.getProtectedClasses().getPatterns());
- _hiddenClasses.exclude(configuration.getHiddenClasses().getExclusions());
+ _systemClasses.add(configuration.getSystemClasses().getPatterns());
+ _serverClasses.exclude(configuration.getServerClasses().getExclusions());
}
// Configure classloader
@@ -671,197 +670,119 @@ public PermissionCollection getPermissions()
}
/**
- * Set the hidden (server) classes patterns.
+ * Set the server classes patterns.
*
* 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.
*
- * @param hiddenClasses the server classes pattern
+ * @param serverClasses the server classes pattern
*/
- public void setHiddenClassMatcher(ClassMatcher hiddenClasses)
+ public void setServerClassMatcher(ClassMatcher serverClasses)
{
- _hiddenClasses.clear();
- _hiddenClasses.add(hiddenClasses.getPatterns());
+ _serverClasses.clear();
+ _serverClasses.add(serverClasses.getPatterns());
}
/**
- * Set the protected (system) classes patterns.
+ * Set the system classes patterns.
*
* 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)}.
*
- * @param protectedClasses the system classes pattern
+ * @param systemClasses the system classes pattern
*/
- public void setProtectedClassMatcher(ClassMatcher protectedClasses)
+ public void setSystemClassMatcher(ClassMatcher systemClasses)
{
- _protectedClasses.clear();
- _protectedClasses.add(protectedClasses.getPatterns());
+ _systemClasses.clear();
+ _systemClasses.add(systemClasses.getPatterns());
}
/**
- * Add a ClassMatcher for hidden (server) classes by combining with
+ * Add a ClassMatcher for server classes by combining with
* any existing matcher.
*
- * @param hiddenClasses The class matcher of patterns to add to the server ClassMatcher
+ * @param serverClasses The class matcher of patterns to add to the server ClassMatcher
*/
- public void addHiddenClassMatcher(ClassMatcher hiddenClasses)
+ public void addServerClassMatcher(ClassMatcher serverClasses)
{
- _hiddenClasses.add(hiddenClasses.getPatterns());
+ _serverClasses.add(serverClasses.getPatterns());
}
/**
- * Add a ClassMatcher for protected (system) classes by combining with
+ * Add a ClassMatcher for system classes by combining with
* any existing matcher.
*
- * @param protectedClasses The class matcher of patterns to add to the system ClassMatcher
+ * @param systemClasses The class matcher of patterns to add to the system ClassMatcher
*/
- public void addProtectedClassMatcher(ClassMatcher protectedClasses)
+ public void addSystemClassMatcher(ClassMatcher systemClasses)
{
- _protectedClasses.add(protectedClasses.getPatterns());
+ _systemClasses.add(systemClasses.getPatterns());
}
/**
* @return The ClassMatcher used to match System (protected) classes
*/
- public ClassMatcher getProtectedClassMatcher()
+ public ClassMatcher getSystemClassMatcher()
{
- return _protectedClasses;
+ return _systemClasses;
}
/**
* @return The ClassMatcher used to match Server (hidden) classes
*/
- public ClassMatcher getHiddenClassMatcher()
+ public ClassMatcher getServerClassMatcher()
{
- return _hiddenClasses;
+ return _serverClasses;
}
@ManagedAttribute(value = "classes and packages protected by context classloader", readonly = true)
- public String[] getProtectedClasses()
+ public String[] getSystemClasses()
{
- return _protectedClasses.getPatterns();
+ return _systemClasses.getPatterns();
}
@ManagedAttribute(value = "classes and packages hidden by the context classloader", readonly = true)
- public String[] getHiddenClasses()
+ public String[] getServerClasses()
{
- return _hiddenClasses.getPatterns();
+ return _serverClasses.getPatterns();
}
@Override
public boolean isHiddenClass(Class> clazz)
{
- return _hiddenClasses.match(clazz);
+ return isServerClass(clazz);
}
@Override
public boolean isProtectedClass(Class> clazz)
{
- return _protectedClasses.match(clazz);
+ return isSystemClass(clazz);
}
@Override
- public boolean isHiddenResource(String name, URL url)
+ public boolean isServerClass(Class> clazz)
{
- return _hiddenClasses.match(name, url);
+ return _serverClasses.match(clazz);
}
@Override
- public boolean isProtectedResource(String name, URL url)
- {
- return _protectedClasses.match(name, url);
- }
-
- /**
- * @deprecated use {@link #setHiddenClassMatcher(ClassMatcher)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public void setServerClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher serverClasses)
- {
- setHiddenClassMatcher(serverClasses);
- }
-
- /**
- * @deprecated use {@link #setProtectedClassMatcher(ClassMatcher)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public void setSystemClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher systemClasses)
- {
- setProtectedClassMatcher(systemClasses);
- }
-
- /**
- * @deprecated use {@link #addHiddenClassMatcher(ClassMatcher)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public void addServerClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher serverClasses)
- {
- addHiddenClassMatcher(serverClasses);
- }
-
- /**
- * @deprecated use {@link #addProtectedClassMatcher(ClassMatcher)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public void addSystemClassMatcher(org.eclipse.jetty.ee9.webapp.ClassMatcher systemClasses)
- {
- addProtectedClassMatcher(systemClasses);
- }
-
- /**
- * @deprecated use {@link #getProtectedClassMatcher()}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public org.eclipse.jetty.ee9.webapp.ClassMatcher getSystemClassMatcher()
- {
- return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getProtectedClassMatcher());
- }
-
- /**
- * @deprecated use {@link #getHiddenClassMatcher()}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public org.eclipse.jetty.ee9.webapp.ClassMatcher getServerClassMatcher()
- {
- return new org.eclipse.jetty.ee9.webapp.ClassMatcher(getHiddenClassMatcher());
- }
-
- /**
- * @deprecated use {@link #getProtectedClasses()}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public String[] getSystemClasses()
- {
- return getProtectedClasses();
- }
-
- /**
- * @deprecated use {@link #getHiddenClasses()}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public String[] getServerClasses()
+ public boolean isSystemClass(Class> clazz)
{
- return getHiddenClasses();
+ return _systemClasses.match(clazz);
}
- /**
- * @deprecated use {@link #isHiddenClass(Class)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public boolean isServerClass(Class> clazz)
+ @Override
+ public boolean isServerResource(String name, URL url)
{
- return isHiddenClass(clazz);
+ return _serverClasses.match(name, url);
}
- /**
- * @deprecated use {@link #isProtectedClass(Class)}
- */
- @Deprecated(since = "12.0.8", forRemoval = true)
- public boolean isSystemClass(Class> clazz)
+ @Override
+ public boolean isSystemResource(String name, URL url)
{
- return isProtectedClass(clazz);
+ return _systemClasses.match(name, url);
}
@Override
@@ -870,8 +791,8 @@ public void setServer(Server server)
super.setServer(server);
if (server != null)
{
- _protectedClasses.add(WebAppClassLoading.getProtectedClasses(server).getPatterns());
- _hiddenClasses.add(WebAppClassLoading.getHiddenClasses(server).getPatterns());
+ _systemClasses.add(WebAppClassLoading.getProtectedClasses(server).getPatterns());
+ _serverClasses.add(WebAppClassLoading.getHiddenClasses(server).getPatterns());
}
}
@@ -983,16 +904,16 @@ public String toString()
public void dump(Appendable out, String indent) throws IOException
{
List systemClasses = null;
- if (_protectedClasses != null)
+ if (_systemClasses != null)
{
- systemClasses = new ArrayList<>(_protectedClasses);
+ systemClasses = new ArrayList<>(_systemClasses);
Collections.sort(systemClasses);
}
List serverClasses = null;
- if (_hiddenClasses != null)
+ if (_serverClasses != null)
{
- serverClasses = new ArrayList<>(_hiddenClasses);
+ serverClasses = new ArrayList<>(_serverClasses);
Collections.sort(serverClasses);
}
@@ -1570,8 +1491,8 @@ public MetaData getMetaData()
* Add a Server Class pattern to use for all ee9 WebAppContexts.
* @param attributes The {@link Server} instance to add classes to
* @param patterns the patterns to use
- * @see #getHiddenClassMatcher()
- * @see #getHiddenClasses()
+ * @see #getServerClassMatcher()
+ * @see #getServerClasses()
* @deprecated use {@link WebAppClassLoading#addProtectedClasses(Server, String...)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
@@ -1584,8 +1505,8 @@ public static void addServerClasses(Attributes attributes, String... patterns)
* Add a System Class pattern to use for all ee9 WebAppContexts.
* @param attributes The {@link Server} instance to add classes to
* @param patterns the patterns to use
- * @see #getProtectedClassMatcher()
- * @see #getProtectedClasses()
+ * @see #getSystemClassMatcher()
+ * @see #getSystemClasses()
* @deprecated use {@link WebAppClassLoading#addHiddenClasses(Server, String...)}
*/
@Deprecated(since = "12.0.8", forRemoval = true)
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 db27339d91c1..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;
@@ -210,11 +209,11 @@ public byte[] transform(ClassLoader loader, String className, Class> classBein
@Test
public void testExposedClassDeprecated() throws Exception
{
- String[] oldSC = _context.getHiddenClasses();
+ String[] oldSC = _context.getServerClasses();
String[] newSC = new String[oldSC.length + 1];
newSC[0] = "-org.eclipse.jetty.ee9.webapp.Configuration";
System.arraycopy(oldSC, 0, newSC, 1, oldSC.length);
- _context.setHiddenClassMatcher(new ClassMatcher(newSC));
+ _context.setServerClassMatcher(new ClassMatcher(newSC));
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -227,7 +226,7 @@ public void testExposedClassDeprecated() throws Exception
@Test
public void testExposedClass() throws Exception
{
- _context.getHiddenClassMatcher().exclude("org.eclipse.jetty.ee9.webapp.Configuration");
+ _context.getServerClassMatcher().exclude("org.eclipse.jetty.ee9.webapp.Configuration");
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -240,18 +239,18 @@ public void testExposedClass() throws Exception
@Test
public void testSystemServerClassDeprecated() throws Exception
{
- String[] oldServC = _context.getHiddenClasses();
+ String[] oldServC = _context.getServerClasses();
String[] newServC = new String[oldServC.length + 1];
newServC[0] = "org.eclipse.jetty.ee9.webapp.Configuration";
System.arraycopy(oldServC, 0, newServC, 1, oldServC.length);
- _context.setHiddenClassMatcher(new ClassMatcher(newServC));
+ _context.setServerClassMatcher(new ClassMatcher(newServC));
- String[] oldSysC = _context.getProtectedClasses();
+ String[] oldSysC = _context.getSystemClasses();
String[] newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.eclipse.jetty.ee9.webapp.";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setProtectedClassMatcher(new ClassMatcher(newSysC));
+ _context.setSystemClassMatcher(new ClassMatcher(newSysC));
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -259,28 +258,28 @@ public void testSystemServerClassDeprecated() throws Exception
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.Configuration");
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.JarScanner");
- oldSysC = _context.getProtectedClasses();
+ oldSysC = _context.getSystemClasses();
newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.acme.webapp.ClassInJarA";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setProtectedClassMatcher(new ClassMatcher(newSysC));
+ _context.setSystemClassMatcher(new ClassMatcher(newSysC));
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
- _context.setProtectedClassMatcher(new ClassMatcher(oldSysC));
+ _context.setSystemClassMatcher(new ClassMatcher(oldSysC));
- oldServC = _context.getHiddenClasses();
+ oldServC = _context.getServerClasses();
newServC = new String[oldServC.length + 1];
newServC[0] = "org.acme.webapp.ClassInJarA";
System.arraycopy(oldServC, 0, newServC, 1, oldServC.length);
- _context.setHiddenClassMatcher(new ClassMatcher(newServC));
+ _context.setServerClassMatcher(new ClassMatcher(newServC));
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
}
@Test
public void testSystemServerClass() throws Exception
{
- _context.getHiddenClassMatcher().add("org.eclipse.jetty.ee9.webapp.Configuration");
- _context.getProtectedClassMatcher().add("org.eclipse.jetty.ee9.webapp.");
+ _context.getServerClassMatcher().add("org.eclipse.jetty.ee9.webapp.Configuration");
+ _context.getSystemClassMatcher().add("org.eclipse.jetty.ee9.webapp.");
assertCanLoadClass("org.acme.webapp.ClassInJarA");
assertCanLoadClass("org.acme.webapp.ClassInJarB");
@@ -288,11 +287,11 @@ public void testSystemServerClass() throws Exception
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.Configuration");
assertCantLoadClass("org.eclipse.jetty.ee9.webapp.JarScanner");
- _context.getProtectedClassMatcher().add("org.acme.webapp.ClassInJarA");
+ _context.getSystemClassMatcher().add("org.acme.webapp.ClassInJarA");
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
- _context.getProtectedClassMatcher().remove("org.acme.webapp.ClassInJarA");
+ _context.getSystemClassMatcher().remove("org.acme.webapp.ClassInJarA");
- _context.getHiddenClassMatcher().add("org.acme.webapp.ClassInJarA");
+ _context.getServerClassMatcher().add("org.acme.webapp.ClassInJarA");
assertCanLoadResource("org/acme/webapp/ClassInJarA.class");
}
@@ -338,11 +337,11 @@ public void testResources() throws Exception
// assertEquals(0,resources.get(1).toString().indexOf("jar:file:"));
// assertEquals(-1,resources.get(2).toString().indexOf("test-classes"));
- String[] oldServC = _context.getHiddenClasses();
+ String[] oldServC = _context.getServerClasses();
String[] newServC = new String[oldServC.length + 1];
newServC[0] = "org.acme.";
System.arraycopy(oldServC, 0, newServC, 1, oldServC.length);
- _context.setHiddenClassMatcher(new ClassMatcher(newServC));
+ _context.setServerClassMatcher(new ClassMatcher(newServC));
_context.setParentLoaderPriority(true);
// dump(_context);
@@ -359,12 +358,12 @@ public void testResources() throws Exception
// assertEquals(0,resources.get(0).toString().indexOf("jar:file:"));
// assertEquals(0,resources.get(1).toString().indexOf("file:"));
- _context.setHiddenClassMatcher(new ClassMatcher(oldServC));
- String[] oldSysC = _context.getProtectedClasses();
+ _context.setServerClassMatcher(new ClassMatcher(oldServC));
+ String[] oldSysC = _context.getSystemClasses();
String[] newSysC = new String[oldSysC.length + 1];
newSysC[0] = "org.acme.";
System.arraycopy(oldSysC, 0, newSysC, 1, oldSysC.length);
- _context.setProtectedClassMatcher(new ClassMatcher(newSysC));
+ _context.setSystemClassMatcher(new ClassMatcher(newSysC));
_context.setParentLoaderPriority(true);
// dump(_context);
diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
index ad3bcc434464..9e9ee0bd01b3 100644
--- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
+++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java
@@ -870,7 +870,7 @@ public void testAddServerClasses() throws Exception
server.setHandler(context);
server.start();
- List serverClasses = List.of(context.getHiddenClasses());
+ List serverClasses = List.of(context.getServerClasses());
assertThat("Should have environment specific test pattern", serverClasses, hasItem(testPattern));
assertThat("Should have pattern from defaults", serverClasses, hasItem("org.eclipse.jetty."));
assertThat("Should have pattern from JaasConfiguration", serverClasses, hasItem("-org.eclipse.jetty.security.jaas."));
@@ -898,7 +898,7 @@ public void testAddSystemClasses() throws Exception
server.setHandler(context);
server.start();
- List systemClasses = List.of(context.getProtectedClasses());
+ List systemClasses = List.of(context.getSystemClasses());
assertThat("Should have environment specific test pattern", systemClasses, hasItem(testPattern));
assertThat("Should have pattern from defaults", systemClasses, hasItem("javax."));
assertThat("Should have pattern from defaults", systemClasses, hasItem("jakarta."));