test/java/lang/SecurityManager/CheckPackageAccess.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2012, 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.
--- 1,7 ----
/*
! * Copyright (c) 2012, 2013, 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.
*** 21,47 ****
* questions.
*/
/*
* @test
! * @bug 7146431
! * @summary Test that internal JAXP packages cannot be accessed
*/
public class CheckPackageAccess {
public static void main(String[] args) throws Exception {
String[] pkgs = new String[] {
"com.sun.org.apache.xerces.internal.utils.",
"com.sun.org.apache.xalan.internal.utils." };
SecurityManager sm = new SecurityManager();
System.setSecurityManager(sm);
for (String pkg : pkgs) {
System.out.println("Checking package access for " + pkg);
try {
sm.checkPackageAccess(pkg);
! throw new Exception("Expected SecurityException not thrown");
} catch (SecurityException se) { }
}
}
}
--- 21,52 ----
* questions.
*/
/*
* @test
! * @bug 7146431 8000450
! * @summary Test that internal packages cannot be accessed
*/
public class CheckPackageAccess {
public static void main(String[] args) throws Exception {
String[] pkgs = new String[] {
+ "com.sun.corba.se.impl.",
"com.sun.org.apache.xerces.internal.utils.",
"com.sun.org.apache.xalan.internal.utils." };
SecurityManager sm = new SecurityManager();
System.setSecurityManager(sm);
for (String pkg : pkgs) {
System.out.println("Checking package access for " + pkg);
try {
sm.checkPackageAccess(pkg);
! throw new Exception("Expected PackageAccess SecurityException not thrown");
} catch (SecurityException se) { }
+ try {
+ sm.checkPackageDefinition(pkg);
+ throw new Exception("Expected PackageDefinition SecurityException not thrown");
+ } catch (SecurityException se) { }
}
}
}