8178823: Unable to initialize HijrahCalendar: Hijrah-umalqura when running with a security manager

Reviewed-by: lancea, rriggs
This commit is contained in:
Naoto Sato 2017-04-20 14:09:35 -07:00
parent d87636bed7
commit e4e2e277fc
6 changed files with 52 additions and 8 deletions

View File

@ -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 @@ public final class HijrahChronology extends AbstractChronology implements Serial
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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -0,0 +1 @@
// Empty policy file for Bug8178823

View File

@ -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

View File

@ -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