提交 ba590c19 编写于 作者: L lana

Merge

...@@ -460,15 +460,13 @@ public interface Path ...@@ -460,15 +460,13 @@ public interface Path
/** /**
* Returns a URI to represent this path. * Returns a URI to represent this path.
* *
* <p> This method constructs a hierarchical {@link URI} that is absolute * <p> This method constructs an absolute {@link URI} with a {@link
* with a non-empty path component. Its {@link URI#getScheme() scheme} is * URI#getScheme() scheme} equal to the URI scheme that identifies the
* equal to the URI scheme that identifies the provider. The exact form of * provider. The exact form of the scheme specific part is highly provider
* the other URI components is highly provider dependent. In particular, it * dependent.
* is implementation dependent if its query, fragment, and authority *
* components are defined or undefined. * <p> In the case of the default provider, the URI is hierarchical with
* * a {@link URI#getPath() path} component that is absolute. The query and
* <p> For the default provider the {@link URI#getPath() path} component
* will represent the {@link #toAbsolutePath absolute} path; the query,
* fragment components are undefined. Whether the authority component is * fragment components are undefined. Whether the authority component is
* defined or not is implementation dependent. There is no guarantee that * defined or not is implementation dependent. There is no guarantee that
* the {@code URI} may be used to construct a {@link java.io.File java.io.File}. * the {@code URI} may be used to construct a {@link java.io.File java.io.File}.
...@@ -497,7 +495,7 @@ public interface Path ...@@ -497,7 +495,7 @@ public interface Path
* A format for compound URIs is not defined in this release; such a scheme * A format for compound URIs is not defined in this release; such a scheme
* may be added in a future release. * may be added in a future release.
* *
* @return an absolute, hierarchical URI with a non-empty path component * @return the URI representing this path
* *
* @throws java.io.IOError * @throws java.io.IOError
* if an I/O error occurs obtaining the absolute path, or where a * if an I/O error occurs obtaining the absolute path, or where a
......
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
/* /*
* @test * @test
* @bug 7044443 * @bug 7044443 7050329
* @run main/othervm/policy=JarURL.policy JarURL
* @summary Permissions resolved incorrectly for jar protocol * @summary Permissions resolved incorrectly for jar protocol
*/ */
import java.net.URL; import java.net.URL;
import java.io.File;
import java.security.AllPermission; import java.security.AllPermission;
import java.security.CodeSource; import java.security.CodeSource;
import java.security.PermissionCollection; import java.security.PermissionCollection;
...@@ -35,11 +37,11 @@ import java.security.Policy; ...@@ -35,11 +37,11 @@ import java.security.Policy;
import java.security.cert.Certificate; import java.security.cert.Certificate;
public class JarURL { public class JarURL {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
URL codeSourceURL String userDir = System.getProperty("user.dir");
= new URL("jar:file:" String jarURL = "jar:file:" + userDir + File.separator + "foo.jar!/";
+ System.getProperty("java.ext.dirs").split(":")[0] URL codeSourceURL = new URL(jarURL);
+ "/foo.jar!/");
CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]); CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]);
PermissionCollection perms = Policy.getPolicy().getPermissions(cs); PermissionCollection perms = Policy.getPolicy().getPermissions(cs);
if (!perms.implies(new AllPermission())) if (!perms.implies(new AllPermission()))
......
grant codeBase "file:${user.dir}/*" {
permission java.security.AllPermission;
};
grant {
permission java.util.PropertyPermission "user.dir", "read";
permission java.security.SecurityPermission "getPolicy";
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册