diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
index ca58ca7968bd1..6cb4803c65f12 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
@@ -45,7 +45,6 @@
import java.io.Serializable;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
-import java.net.URL;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Locale;
@@ -604,55 +603,7 @@ public void load(InputStream input, Class> resourceBase) throws
}
new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
- null, resourceBase, defaultsMap);
- }
-
- /**
- * Loads the set of SynthStyle
s that will be used by
- * this SynthLookAndFeel
. Path based resources are resolved
- * relatively to the specified URL
of the style. For example
- * an Image
would be resolved by
- * new URL(synthFile, path)
. Refer to
- * Synth File Format for more
- * information.
- *
- * Whilst this API may be safe for loading local resources that are
- * delivered with a {@code LookAndFeel} or application, and so have an
- * equal level of trust with application code, using it to load from
- * remote resources, particularly any which may have a lower level of
- * trust, is strongly discouraged.
- * The alternative mechanisms to load styles from an {@code InputStream}
- * {@linkplain #load(InputStream, Class)}
- * using resources co-located with the application or by providing a
- * {@code SynthStyleFactory} to
- * {@linkplain #setStyleFactory setStyleFactory(SynthStyleFactory)}
- * are preferred.
- * Consequently this method is deprecated and will be removed in a future
- * release.
- *
- * @param url the URL
to load the set of
- * SynthStyle
from
- * @throws ParseException if there is an error in parsing
- * @throws IllegalArgumentException if synthSet is null
- * @throws IOException if synthSet cannot be opened as an InputStream
- * @since 1.6
- * @deprecated Use {@link #load(InputStream, Class)} or
- * {@link #setStyleFactory setStyleFactory(SynthStyleFactory)} instead
- */
- @Deprecated(since = "21", forRemoval = true)
- public void load(URL url) throws ParseException, IOException {
- if (url == null) {
- throw new IllegalArgumentException(
- "You must supply a valid Synth set URL");
- }
-
- if (defaultsMap == null) {
- defaultsMap = new HashMap();
- }
-
- InputStream input = url.openStream();
- new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
- url, null, defaultsMap);
+ resourceBase, defaultsMap);
}
/**
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java
index 6334c0649bfd3..869460d59b88c 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java
@@ -34,7 +34,6 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.text.ParseException;
@@ -165,11 +164,6 @@ class SynthParser extends DefaultHandler {
*/
private Map _mapping;
- /**
- * Based URL used to resolve paths.
- */
- private URL _urlResourceBase;
-
/**
* Based class used to resolve paths.
*/
@@ -213,26 +207,21 @@ class SynthParser extends DefaultHandler {
*
* @param inputStream XML document containing the styles to read
* @param factory DefaultSynthStyleFactory that new styles are added to
- * @param urlResourceBase the URL used to resolve any resources, such as Images
* @param classResourceBase the Class used to resolve any resources, such as Images
* @param defaultsMap Map that UIDefaults properties are placed in
*/
public void parse(InputStream inputStream,
DefaultSynthStyleFactory factory,
- URL urlResourceBase, Class> classResourceBase,
+ Class> classResourceBase,
Map defaultsMap)
throws ParseException, IllegalArgumentException {
- if (inputStream == null || factory == null ||
- (urlResourceBase == null && classResourceBase == null)) {
+ if (inputStream == null || factory == null || classResourceBase == null) {
throw new IllegalArgumentException(
- "You must supply an InputStream, StyleFactory and Class or URL");
+ "You must supply an InputStream, StyleFactory and Class");
}
- assert(!(urlResourceBase != null && classResourceBase != null));
-
_factory = factory;
_classResourceBase = classResourceBase;
- _urlResourceBase = urlResourceBase;
_defaultsMap = defaultsMap;
try {
try {
@@ -255,17 +244,7 @@ public void parse(InputStream inputStream,
* Returns the path to a resource.
*/
private URL getResource(String path) {
- if (_classResourceBase != null) {
- return _classResourceBase.getResource(path);
- } else {
- try {
- @SuppressWarnings("deprecation")
- var result = new URL(_urlResourceBase, path);
- return result;
- } catch (MalformedURLException mue) {
- return null;
- }
- }
+ return _classResourceBase.getResource(path);
}
/**
@@ -294,20 +273,7 @@ private boolean isForwarding() {
private DocumentHandler getHandler() {
if (_handler == null) {
_handler = new DocumentHandler();
- if (_urlResourceBase != null) {
- // getHandler() is never called before parse() so it is safe
- // to create a URLClassLoader with _resourceBase.
- //
- // getResource(".") is called to ensure we have the directory
- // containing the resources in the case the resource base is a
- // .class file.
- URL[] urls = new URL[] { getResource(".") };
- ClassLoader parent = Thread.currentThread().getContextClassLoader();
- ClassLoader urlLoader = new URLClassLoader(urls, parent);
- _handler.setClassLoader(urlLoader);
- } else {
- _handler.setClassLoader(_classResourceBase.getClassLoader());
- }
+ _handler.setClassLoader(_classResourceBase.getClassLoader());
for (String key : _mapping.keySet()) {
_handler.setVariable(key, _mapping.get(key));
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html b/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
index b3c8118b40496..87c5e74737482 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html
@@ -53,9 +53,7 @@
necessary to create your own look and feel. A synth file is
loaded by way of the
- SynthLookAndFeel.load(InputStream, Class) or
-
- SynthLookAndFeel.load(URL) methods.
+ SynthLookAndFeel.load(InputStream, Class) method.
The following example uses the load
method to configure
a SynthLookAndFeel
and sets it as the current look
and feel:
@@ -71,36 +69,6 @@
This example loads the look and feel from an input stream, using
the specified class as the resource base to resolve paths.
-
- It is also possible to load a look and feel from an arbitrary URL
- as in the following example.
-
-
-
- SynthLookAndFeel laf = new SynthLookAndFeel();
- laf.load(new URL("file:///C:/java/synth/laf/laf.xml"));
- UIManager.setLookAndFeel(laf);
-
-
-
- The method
- SynthLookAndFeel.load(URL) can be used, for instance, to load a look
- and feel from any of the following:
-
-
- - File, e.g.
file:///C:/java/synth/laf/laf.xml
- - Web server, e.g.
http://host/laf.xml
- - JAR file, e.g.
-
jar:file:///C:/synth-laf.jar!/laf.xml
- - Remote JAR file, e.g.
-
jar:http://host/synth-laf.jar!/laf.xml
-
- Note: Synth's file format allows for the definition of code to be executed.
- Loading any code from a remote location should be used only
- with extreme caution from a trusted source over a secure connection.
- It is strongly discouraged for an application or a LookAndFeel to do so.
-
While the DTD for synth is specified, the parser is not validating.
Parsing will fail only if a necessary attribute is not
@@ -880,10 +848,9 @@
The imagePainter element
a direction or orientation. If this is not specified the image is
used for all directions.
path
- Path to the image. If SynthLookAndFeel.load is
- passed a Class this will use the Class method getResource (with the
- Class supplied to the load method). If load is passed a URL this will use the
- URL constructor URL(context, path) to resolve the path.
+ Path to the image. SynthLookAndFeel.load
+ will use the Class method getResource (with the
+ Class supplied to the load method) to resolve the path.
sourceInsets
Insets on the source image. This is top, left, bottom, right with
each component separated by a space.