30 import java.io.FilePermission; |
30 import java.io.FilePermission; |
31 import java.io.IOException; |
31 import java.io.IOException; |
32 import java.io.InputStream; |
32 import java.io.InputStream; |
33 import java.net.MalformedURLException; |
33 import java.net.MalformedURLException; |
34 import java.net.URL; |
34 import java.net.URL; |
35 import java.security.AccessController; |
|
36 import java.security.Permission; |
35 import java.security.Permission; |
37 import java.security.PrivilegedAction; |
|
38 import java.util.List; |
|
39 |
36 |
40 import jdk.internal.jimage.ImageLocation; |
37 import jdk.internal.jimage.ImageLocation; |
41 import jdk.internal.jimage.ImageReader; |
38 import jdk.internal.jimage.ImageReader; |
42 import jdk.internal.jimage.ImageReaderFactory; |
39 import jdk.internal.jimage.ImageReaderFactory; |
43 |
40 |
44 import jdk.internal.loader.URLClassPath; |
41 import jdk.internal.loader.URLClassPath; |
45 import jdk.internal.loader.Resource; |
42 import jdk.internal.loader.Resource; |
46 import sun.net.www.ParseUtil; |
43 import sun.net.www.ParseUtil; |
47 import sun.net.www.URLConnection; |
44 import sun.net.www.URLConnection; |
|
45 import sun.security.action.GetPropertyAction; |
48 |
46 |
49 /** |
47 /** |
50 * URLConnection implementation that can be used to connect to resources |
48 * URLConnection implementation that can be used to connect to resources |
51 * contained in the runtime image. |
49 * contained in the runtime image. |
52 */ |
50 */ |
161 |
159 |
162 @Override |
160 @Override |
163 public Permission getPermission() throws IOException { |
161 public Permission getPermission() throws IOException { |
164 Permission p = permission; |
162 Permission p = permission; |
165 if (p == null) { |
163 if (p == null) { |
166 // using lambda expression here leads to recursive initialization |
164 String home = GetPropertyAction.getProperty("java.home"); |
167 PrivilegedAction<String> pa = new PrivilegedAction<String>() { |
|
168 public String run() { return System.getProperty("java.home"); } |
|
169 }; |
|
170 String home = AccessController.doPrivileged(pa); |
|
171 p = new FilePermission(home + File.separator + "-", "read"); |
165 p = new FilePermission(home + File.separator + "-", "read"); |
172 permission = p; |
166 permission = p; |
173 } |
167 } |
174 return p; |
168 return p; |
175 } |
169 } |