4833N/A/*
6151N/A * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
4833N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4833N/A *
4833N/A * This code is free software; you can redistribute it and/or modify it
4833N/A * under the terms of the GNU General Public License version 2 only, as
4833N/A * published by the Free Software Foundation.
4833N/A *
4833N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4833N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4833N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4833N/A * version 2 for more details (a copy is included in the LICENSE file that
4833N/A * accompanied this code).
4833N/A *
4833N/A * You should have received a copy of the GNU General Public License version
4833N/A * 2 along with this work; if not, write to the Free Software Foundation,
4833N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4833N/A *
4833N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4833N/A * or visit www.oracle.com if you need additional information or have any
4833N/A * questions.
4833N/A */
4833N/A
4833N/A/*
4833N/A * @test
6151N/A * @bug 7146431 8000450
6151N/A * @summary Test that internal packages cannot be accessed
4833N/A */
4833N/A
4833N/Apublic class CheckPackageAccess {
4833N/A
4833N/A public static void main(String[] args) throws Exception {
4833N/A
4833N/A String[] pkgs = new String[] {
6151N/A "com.sun.corba.se.impl.",
4833N/A "com.sun.org.apache.xerces.internal.utils.",
4833N/A "com.sun.org.apache.xalan.internal.utils." };
4833N/A SecurityManager sm = new SecurityManager();
4833N/A System.setSecurityManager(sm);
4833N/A for (String pkg : pkgs) {
4833N/A System.out.println("Checking package access for " + pkg);
4833N/A try {
4833N/A sm.checkPackageAccess(pkg);
6151N/A throw new Exception("Expected PackageAccess SecurityException not thrown");
6151N/A } catch (SecurityException se) { }
6151N/A try {
6151N/A sm.checkPackageDefinition(pkg);
6151N/A throw new Exception("Expected PackageDefinition SecurityException not thrown");
4833N/A } catch (SecurityException se) { }
4833N/A }
4833N/A }
4833N/A}