changeset 17046:0a701ba4c306

8178823: Unable to initialize HijrahCalendar: Hijrah-umalqura when running with a security manager Reviewed-by: lancea, rriggs
author naoto
date Thu, 20 Apr 2017 14:09:35 -0700
parents 533d7278264b
children 83ec9920d373
files src/java.base/share/classes/java/time/chrono/HijrahChronology.java test/java/time/TEST.properties test/java/time/nontestng/java/time/chrono/Bug8178823.java test/java/time/nontestng/java/time/chrono/bug8178823.policy test/java/time/tck/TEST.properties test/java/time/test/TEST.properties
diffstat 6 files changed, 52 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/time/chrono/HijrahChronology.java	Thu Apr 20 11:40:57 2017 -0700
+++ b/src/java.base/share/classes/java/time/chrono/HijrahChronology.java	Thu Apr 20 14:09:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -813,8 +813,9 @@
     private Properties readConfigProperties(final String calendarType) throws Exception {
         String resourceName = RESOURCE_PREFIX + calendarType + RESOURCE_SUFFIX;
         PrivilegedAction<InputStream> getResourceAction =  () -> HijrahChronology.class.getResourceAsStream(resourceName);
-        FilePermission perm = new FilePermission("<<ALL FILES>>", "read");
-        try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm)) {
+        FilePermission perm1 = new FilePermission("<<ALL FILES>>", "read");
+        RuntimePermission perm2 = new RuntimePermission("accessSystemModules");
+        try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) {
             if (is == null) {
                 throw new RuntimeException("Hijrah calendar resource not found: /java/time/chrono/" + resourceName);
             }
--- a/test/java/time/TEST.properties	Thu Apr 20 11:40:57 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# java.time tests use TestNG
-TestNG.dirs = .
-othervm.dirs = tck/java/time/chrono test/java/time/chrono test/java/time/format
-lib.dirs = ../../lib/testlibrary
-lib.build = jdk.testlibrary.RandomFactory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/time/nontestng/java/time/chrono/Bug8178823.java	Thu Apr 20 14:09:35 2017 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package nontestng.java.time.chrono;
+
+import java.time.chrono.HijrahChronology;
+
+/* @test
+ * @bug 8178823
+ * @build Bug8178823
+ * @run main/othervm/policy=bug8178823.policy -Djava.security.manager nontestng.java.time.chrono.Bug8178823
+ * @summary Test Hijrah calendar is initialized with the security manager.
+ */
+public class Bug8178823 {
+    public static void main(String[] args) {
+        HijrahChronology.INSTANCE.isLeapYear(2017);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/time/nontestng/java/time/chrono/bug8178823.policy	Thu Apr 20 14:09:35 2017 -0700
@@ -0,0 +1,1 @@
+// Empty policy file for Bug8178823
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/time/tck/TEST.properties	Thu Apr 20 14:09:35 2017 -0700
@@ -0,0 +1,5 @@
+# java.time tests use TestNG
+TestNG.dirs = ..
+othervm.dirs = java/time/chrono
+lib.dirs = ../../../lib/testlibrary
+lib.build = jdk.testlibrary.RandomFactory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/time/test/TEST.properties	Thu Apr 20 14:09:35 2017 -0700
@@ -0,0 +1,5 @@
+# java.time tests use TestNG
+TestNG.dirs = ..
+othervm.dirs = java/time/chrono java/time/format
+lib.dirs = ../../../lib/testlibrary
+lib.build = jdk.testlibrary.RandomFactory