--- a/jdk/src/share/classes/java/net/URLPermission.java Mon Oct 14 22:09:15 2013 +0100
+++ b/jdk/src/share/classes/java/net/URLPermission.java Wed Oct 30 18:37:50 2013 +0000
@@ -353,7 +353,7 @@
return getActions().hashCode()
+ scheme.hashCode()
+ authority.hashCode()
- + path == null ? 0 : path.hashCode();
+ + (path == null ? 0 : path.hashCode());
}
--- a/jdk/test/java/net/URLPermission/URLPermissionTest.java Mon Oct 14 22:09:15 2013 +0100
+++ b/jdk/test/java/net/URLPermission/URLPermissionTest.java Wed Oct 30 18:37:50 2013 +0000
@@ -26,7 +26,7 @@
/**
* @test
- * @bug 8010464
+ * @bug 8010464 8027570
*/
public class URLPermissionTest {
@@ -110,6 +110,28 @@
return new ActionImpliesTest(arg1, arg2, expected);
}
+ static class HashCodeTest extends Test {
+ String arg1, arg2;
+ int hash;
+
+ HashCodeTest(String arg1, String arg2, int hash) {
+ this.arg1 = arg1;
+ this.arg2 = arg2;
+ this.hash = hash;
+ }
+
+ @Override
+ boolean execute() {
+ URLPermission p = new URLPermission(arg1, arg2);
+ int h = p.hashCode();
+ return h == hash;
+ }
+ }
+
+ static HashCodeTest hashtest(String arg1, String arg2, int expected) {
+ return new HashCodeTest(arg1, arg2, expected);
+ }
+
static class URLEqualityTest extends Test {
String arg1, arg2;
@@ -178,6 +200,11 @@
extest("http:")
};
+ static Test[] hashTests = {
+ hashtest("http://www.foo.com/path", "GET:X-Foo", 388644203),
+ hashtest("http:*", "*:*", 3255810)
+ };
+
static Test[] pathImplies2 = {
imtest("http://[FE80::]:99", "http://[fe80:0::]:99", true),
@@ -326,6 +353,17 @@
}
+ for (int i=0; i<hashTests.length; i++) {
+ HashCodeTest test = (HashCodeTest)hashTests[i];
+ boolean result = test.execute();
+ if (!result) {
+ System.out.printf ("test failed: %s %s %d\n", test.arg1, test.arg2, test.hash);
+ failed = true;
+ } else {
+ System.out.println ("hash test " + i + " OK");
+ }
+ }
+
for (int i=0; i<exceptionTests.length; i++) {
ExTest test = (ExTest)exceptionTests[i];
boolean result = test.execute();