diff --git a/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java b/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java index c5216d87e6c..8690ed34e12 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java +++ b/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,12 +44,6 @@ import sun.net.www.ParseUtil; /* URL jar file is a common JarFile subtype used for JarURLConnection */ public class URLJarFile extends JarFile { - /* - * Interface to be able to call retrieve() in plugin if - * this variable is set. - */ - private static URLJarFileCallBack callback = null; - /* Controller of the Jar File's closing */ private URLJarFileCloseController closeController = null; @@ -57,10 +51,6 @@ public class URLJarFile extends JarFile { private Attributes superAttr; private Map superEntries; - static JarFile getJarFile(URL url) throws IOException { - return getJarFile(url, null); - } - static JarFile getJarFile(URL url, URLJarFileCloseController closeController) throws IOException { if (isFileURL(url)) { Runtime.Version version = "runtime".equals(url.getRef()) @@ -72,23 +62,6 @@ public class URLJarFile extends JarFile { } } - /* - * Changed modifier from private to public in order to be able - * to instantiate URLJarFile from sun.plugin package. - */ - public URLJarFile(File file) throws IOException { - this(file, null); - } - - /* - * Changed modifier from private to public in order to be able - * to instantiate URLJarFile from sun.plugin package. - */ - public URLJarFile(File file, URLJarFileCloseController closeController) throws IOException { - super(file, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE); - this.closeController = closeController; - } - private URLJarFile(File file, URLJarFileCloseController closeController, Runtime.Version version) throws IOException { super(file, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE, version); @@ -188,63 +161,39 @@ public class URLJarFile extends JarFile { */ @SuppressWarnings("removal") private static JarFile retrieve(final URL url, final URLJarFileCloseController closeController) throws IOException { - /* - * See if interface is set, then call retrieve function of the class - * that implements URLJarFileCallBack interface (sun.plugin - to - * handle the cache failure for JARJAR file.) - */ - if (callback != null) - { - return callback.retrieve(url); - } + JarFile result = null; + Runtime.Version version = "runtime".equals(url.getRef()) + ? JarFile.runtimeVersion() + : JarFile.baseVersion(); - else - { - - JarFile result = null; - Runtime.Version version = "runtime".equals(url.getRef()) - ? JarFile.runtimeVersion() - : JarFile.baseVersion(); - - /* get the stream before asserting privileges */ - try (final InputStream in = url.openConnection().getInputStream()) { - result = AccessController.doPrivileged( - new PrivilegedExceptionAction<>() { - public JarFile run() throws IOException { - Path tmpFile = Files.createTempFile("jar_cache", null); + /* get the stream before asserting privileges */ + try (final InputStream in = url.openConnection().getInputStream()) { + result = AccessController.doPrivileged( + new PrivilegedExceptionAction<>() { + public JarFile run() throws IOException { + Path tmpFile = Files.createTempFile("jar_cache", null); + try { + Files.copy(in, tmpFile, StandardCopyOption.REPLACE_EXISTING); + JarFile jarFile = new URLJarFile(tmpFile.toFile(), closeController, version); + tmpFile.toFile().deleteOnExit(); + return jarFile; + } catch (Throwable thr) { try { - Files.copy(in, tmpFile, StandardCopyOption.REPLACE_EXISTING); - JarFile jarFile = new URLJarFile(tmpFile.toFile(), closeController, version); - tmpFile.toFile().deleteOnExit(); - return jarFile; - } catch (Throwable thr) { - try { - Files.delete(tmpFile); - } catch (IOException ioe) { - thr.addSuppressed(ioe); - } - throw thr; + Files.delete(tmpFile); + } catch (IOException ioe) { + thr.addSuppressed(ioe); } + throw thr; } - }); - } catch (PrivilegedActionException pae) { - throw (IOException) pae.getException(); - } - - return result; + } + }); + } catch (PrivilegedActionException pae) { + throw (IOException) pae.getException(); } - } - /* - * Set the call back interface to call retrieve function in sun.plugin - * package if plugin is running. - */ - public static void setCallBack(URLJarFileCallBack cb) - { - callback = cb; + return result; } - private class URLJarFileEntry extends JarEntry { private final JarEntry je; diff --git a/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFileCallBack.java b/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFileCallBack.java deleted file mode 100644 index d55aeafd051..00000000000 --- a/src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFileCallBack.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.net.www.protocol.jar; - -import java.io.*; -import java.net.*; -import java.util.jar.*; - - -/* - * This interface is used to call back to sun.plugin package. - */ -public interface URLJarFileCallBack -{ - public JarFile retrieve (URL url) throws IOException; -}