diff --git a/src/java.base/share/classes/sun/net/util/SocketExceptions.java b/src/java.base/share/classes/sun/net/util/SocketExceptions.java index ee70c58b9ba0a..1198898edcb3f 100644 --- a/src/java.base/share/classes/sun/net/util/SocketExceptions.java +++ b/src/java.base/share/classes/sun/net/util/SocketExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -30,8 +30,6 @@ import java.net.InetSocketAddress; import java.net.UnixDomainSocketAddress; import java.net.SocketAddress; -import java.security.AccessController; -import java.security.PrivilegedAction; import sun.security.util.SecurityProperties; @@ -83,22 +81,16 @@ private static IOException ofUnixDomain(IOException e, UnixDomainSocketAddress a // return a new instance of the same type with the given detail // msg, or if the type doesn't support detail msgs, return given // instance. - - @SuppressWarnings("removal") - private static IOException create(IOException e, String msg) { - return AccessController.doPrivileged(new PrivilegedAction<IOException>() { - public IOException run() { - try { - Class<?> clazz = e.getClass(); - Constructor<?> ctor = clazz.getConstructor(String.class); - IOException e1 = (IOException)(ctor.newInstance(msg)); - e1.setStackTrace(e.getStackTrace()); - return e1; - } catch (Exception e0) { - // Some eg AsynchronousCloseException have no detail msg - return e; - } - } - }); + private static IOException create(final IOException e, final String msg) { + try { + Class<?> clazz = e.getClass(); + Constructor<?> ctor = clazz.getConstructor(String.class); + IOException e1 = (IOException)(ctor.newInstance(msg)); + e1.setStackTrace(e.getStackTrace()); + return e1; + } catch (Exception e0) { + // Some eg AsynchronousCloseException have no detail msg + return e; + } } } 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 8690ed34e1295..b3d4a2231964b 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 @@ -36,9 +36,6 @@ import java.util.zip.ZipEntry; import java.security.CodeSigner; import java.security.cert.Certificate; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; -import java.security.PrivilegedActionException; import sun.net.www.ParseUtil; /* URL jar file is a common JarFile subtype used for JarURLConnection */ @@ -159,39 +156,26 @@ private synchronized boolean isSuperMan() throws IOException { * Given a URL, retrieves a JAR file, caches it to disk, and creates a * cached JAR file object. */ - @SuppressWarnings("removal") private static JarFile retrieve(final URL url, final URLJarFileCloseController closeController) throws IOException { - 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); - 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; - } - } - }); - } catch (PrivilegedActionException pae) { - throw (IOException) pae.getException(); + 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.delete(tmpFile); + } catch (IOException ioe) { + thr.addSuppressed(ioe); + } + throw thr; + } } - - return result; } private class URLJarFileEntry extends JarEntry {