< prev index next >

src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs

*** 30,52 **** import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; - import java.security.AccessController; import java.security.Permission; - import java.security.PrivilegedAction; - import java.util.List; import jdk.internal.jimage.ImageLocation; import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReaderFactory; import jdk.internal.loader.URLClassPath; import jdk.internal.loader.Resource; import sun.net.www.ParseUtil; import sun.net.www.URLConnection; /** * URLConnection implementation that can be used to connect to resources * contained in the runtime image. */ --- 30,50 ---- import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.security.Permission; import jdk.internal.jimage.ImageLocation; import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReaderFactory; import jdk.internal.loader.URLClassPath; import jdk.internal.loader.Resource; import sun.net.www.ParseUtil; import sun.net.www.URLConnection; + import sun.security.action.GetPropertyAction; /** * URLConnection implementation that can be used to connect to resources * contained in the runtime image. */
*** 161,175 **** @Override public Permission getPermission() throws IOException { Permission p = permission; if (p == null) { ! // using lambda expression here leads to recursive initialization ! PrivilegedAction<String> pa = new PrivilegedAction<String>() { ! public String run() { return System.getProperty("java.home"); } ! }; ! String home = AccessController.doPrivileged(pa); p = new FilePermission(home + File.separator + "-", "read"); permission = p; } return p; } --- 159,169 ---- @Override public Permission getPermission() throws IOException { Permission p = permission; if (p == null) { ! String home = GetPropertyAction.getProperty("java.home"); p = new FilePermission(home + File.separator + "-", "read"); permission = p; } return p; }
< prev index next >