jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
author mullan
Fri, 11 Oct 2013 08:43:07 -0400
changeset 20774 330ea6efa3fd
parent 19600 fce5c0729a1c
child 20874 3d0974c9a59e
permissions -rw-r--r--
8007292: Add JavaFX internal packages to package.access Summary: build hooks to allow closed restricted packages to be added to java.security file Reviewed-by: erikj, dholmes, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     1
/*
18138
02cb2d482ed0 8000450: Restrict access to com/sun/corba/se/impl package
coffeys
parents: 12446
diff changeset
     2
 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     4
 *
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     8
 *
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    13
 * accompanied this code).
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    14
 *
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    18
 *
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    21
 * questions.
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    22
 */
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    23
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    24
/*
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    25
 *  @test
19600
fce5c0729a1c 8019830: Add com.sun.media.sound to the list of restricted package
mullan
parents: 18828
diff changeset
    26
 *  @bug 6741606 7146431 8000450 8019830
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    27
 *  @summary Make sure all restricted packages listed in the package.access
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    28
 *           property in the java.security file are blocked
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    29
 *  @run main/othervm CheckPackageAccess
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    30
 */
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    31
20774
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
    32
import java.io.File;
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
    33
import java.nio.charset.StandardCharsets;
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
    34
import java.nio.file.Files;
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    35
import java.security.Security;
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    36
import java.util.Collections;
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    37
import java.util.Arrays;
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    38
import java.util.ArrayList;
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    39
import java.util.List;
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    40
import java.util.StringTokenizer;
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    41
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    42
/*
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    43
 * The main benefit of this test is to catch merge errors or other types
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    44
 * of issues where one or more of the packages are accidentally
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    45
 * removed. This is why the packages that are known to be restricted have to
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    46
 * be explicitly listed below.
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    47
 */
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    48
public class CheckPackageAccess {
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    49
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    50
    /*
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    51
     * This array should be updated whenever new packages are added to the
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    52
     * package.access property in the java.security file
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    53
     */
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    54
    private static final String[] packages = {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    55
        "sun.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    56
        "com.sun.xml.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    57
        "com.sun.imageio.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    58
        "com.sun.istack.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    59
        "com.sun.jmx.",
19600
fce5c0729a1c 8019830: Add com.sun.media.sound to the list of restricted package
mullan
parents: 18828
diff changeset
    60
        "com.sun.media.sound.",
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    61
        "com.sun.proxy.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    62
        "com.sun.org.apache.bcel.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    63
        "com.sun.org.apache.regexp.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    64
        "com.sun.org.apache.xerces.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    65
        "com.sun.org.apache.xpath.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    66
        "com.sun.org.apache.xalan.internal.extensions.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    67
        "com.sun.org.apache.xalan.internal.lib.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    68
        "com.sun.org.apache.xalan.internal.res.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    69
        "com.sun.org.apache.xalan.internal.templates.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    70
        "com.sun.org.apache.xalan.internal.utils.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    71
        "com.sun.org.apache.xalan.internal.xslt.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    72
        "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    73
        "com.sun.org.apache.xalan.internal.xsltc.compiler.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    74
        "com.sun.org.apache.xalan.internal.xsltc.trax.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    75
        "com.sun.org.apache.xalan.internal.xsltc.util.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    76
        "com.sun.org.apache.xml.internal.res.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    77
        "com.sun.org.apache.xml.internal.security.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    78
        "com.sun.org.apache.xml.internal.serializer.utils.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    79
        "com.sun.org.apache.xml.internal.utils.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    80
        "com.sun.org.glassfish.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    81
        "com.oracle.xmlns.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    82
        "com.oracle.webservices.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    83
        "oracle.jrockit.jfr.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    84
        "org.jcp.xml.dsig.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    85
        "jdk.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    86
        "jdk.nashorn.internal.",
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    87
        "jdk.nashorn.tools."
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    88
    };
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    89
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    90
    public static void main(String[] args) throws Exception {
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    91
        List<String> pkgs = new ArrayList<>(Arrays.asList(packages));
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    92
        String osName = System.getProperty("os.name");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    93
        if (osName.contains("OS X")) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    94
            pkgs.add("apple.");  // add apple package for OS X
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    95
        } else if (osName.startsWith("Windows")) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    96
            pkgs.add("com.sun.java.accessibility.");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    97
        }
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
    98
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
    99
        List<String> jspkgs =
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   100
            getPackages(Security.getProperty("package.access"));
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   101
20774
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   102
        // get closed restricted packages
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   103
        File f = new File(System.getProperty("test.src"),
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   104
            "../../../../src/closed/share/lib/security/restricted.pkgs");
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   105
        if (f.exists()) {
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   106
            List<String> ipkgs = Files.readAllLines(f.toPath(),
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   107
                                                    StandardCharsets.UTF_8);
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   108
            // Remove any closed packages from list before comparing
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   109
            jspkgs.removeAll(ipkgs);
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   110
        }
330ea6efa3fd 8007292: Add JavaFX internal packages to package.access
mullan
parents: 19600
diff changeset
   111
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   112
        // Sort to ensure lists are comparable
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   113
        Collections.sort(pkgs);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   114
        Collections.sort(jspkgs);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   115
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   116
        if (!pkgs.equals(jspkgs)) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   117
            for (String p : pkgs)
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   118
                if (!jspkgs.contains(p))
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   119
                    System.out.println("In golden set, but not in j.s file: " + p);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   120
            for (String p : jspkgs)
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   121
                if (!pkgs.contains(p))
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   122
                    System.out.println("In j.s file, but not in golden set: " + p);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   123
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   124
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   125
            throw new RuntimeException("restricted packages are not " +
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   126
                                       "consistent with java.security file");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   127
        }
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   128
        System.setSecurityManager(new SecurityManager());
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   129
        SecurityManager sm = System.getSecurityManager();
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   130
        for (String pkg : packages) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   131
            String subpkg = pkg + "foo";
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   132
            try {
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   133
                sm.checkPackageAccess(pkg);
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   134
                throw new RuntimeException("Able to access " + pkg +
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   135
                                           " package");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   136
            } catch (SecurityException se) { }
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   137
            try {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   138
                sm.checkPackageAccess(subpkg);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   139
                throw new RuntimeException("Able to access " + subpkg +
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   140
                                           " package");
18138
02cb2d482ed0 8000450: Restrict access to com/sun/corba/se/impl package
coffeys
parents: 12446
diff changeset
   141
            } catch (SecurityException se) { }
02cb2d482ed0 8000450: Restrict access to com/sun/corba/se/impl package
coffeys
parents: 12446
diff changeset
   142
            try {
02cb2d482ed0 8000450: Restrict access to com/sun/corba/se/impl package
coffeys
parents: 12446
diff changeset
   143
                sm.checkPackageDefinition(pkg);
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   144
                throw new RuntimeException("Able to define class in " + pkg +
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   145
                                           " package");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   146
            } catch (SecurityException se) { }
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   147
            try {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   148
                sm.checkPackageDefinition(subpkg);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   149
                throw new RuntimeException("Able to define class in " + subpkg +
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   150
                                           " package");
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   151
            } catch (SecurityException se) { }
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   152
        }
18791
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   153
        System.out.println("Test passed");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   154
    }
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   155
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   156
    private static List<String> getPackages(String p) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   157
        List<String> packages = new ArrayList<>();
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   158
        if (p != null && !p.equals("")) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   159
            StringTokenizer tok = new StringTokenizer(p, ",");
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   160
            while (tok.hasMoreElements()) {
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   161
                String s = tok.nextToken().trim();
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   162
                packages.add(s);
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   163
            }
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   164
        }
1973449fc9d9 8019979: Replace CheckPackageAccess test with better one from closed repo
coffeys
parents: 18138
diff changeset
   165
        return packages;
12446
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   166
    }
69b93f3b9f85 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents:
diff changeset
   167
}