hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java
author cjplummer
Thu, 29 Oct 2015 12:04:04 -0700
changeset 33730 30e064828045
parent 33183 1ee801e82dda
child 33813 4f376e851453
permissions -rw-r--r--
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests Summary: Use new external.lib.roots property in TEST.ROOT so /../../test/lib is not needed. Reviewed-by: mseledtsov, sla, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    25
/**
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
 * @test
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    27
 * @bug 8136421
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
33730
30e064828045 8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents: 33183
diff changeset
    29
 * @library /testlibrary /test/lib /
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    30
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
 *      compiler.jvmci.SecurityRestrictionsTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    32
 *      NO_SEC_MAN
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    33
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    34
 *      compiler.jvmci.SecurityRestrictionsTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    35
 *      NO_PERM
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    36
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    37
 *      compiler.jvmci.SecurityRestrictionsTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    38
 *      ALL_PERM
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    39
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    40
 *      compiler.jvmci.SecurityRestrictionsTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
 *      NO_JVMCI_ACCESS_PERM
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    42
 * @run main/othervm -XX:+UnlockExperimentalVMOptions
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
 *      compiler.jvmci.SecurityRestrictionsTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    44
 *      NO_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    45
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    46
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    47
package compiler.jvmci;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    48
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    49
import jdk.vm.ci.hotspot.CompilerToVM;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    50
import jdk.test.lib.Utils;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    51
import java.lang.InternalError;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    52
import java.security.AccessControlException;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    53
import java.security.Permission;
33183
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
    54
import java.util.PropertyPermission;
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
    55
import java.util.function.Consumer;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    56
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    57
public class SecurityRestrictionsTest {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    59
    public static void main(String[] args) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    60
        try {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
            // to init Utils before call SecurityManager
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
            Class.forName(Utils.class.getName(), true,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
                    Utils.class.getClassLoader());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
        } catch (ClassNotFoundException e) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    65
            throw new Error("[TEST BUG]: jdk.test.lib.Utils not found", e);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    66
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    67
        try {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    68
            TestCase mode = TestCase.valueOf(args[0]);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
            mode.run();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    70
        } catch (IllegalArgumentException e) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    71
            throw new Error("[TEST BUG]: Unknown mode " + args[0], e);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    73
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    74
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    75
    private enum TestCase {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    76
        NO_SEC_MAN,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    77
        NO_JVMCI {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    78
            @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    79
            public Class<? extends Throwable> getExpectedException() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    80
                return InternalError.class;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    81
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    82
        },
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    83
        ALL_PERM {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    84
            @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    85
            public SecurityManager getSecurityManager() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    86
                return new SecurityManager() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    87
                    @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    88
                    public void checkPermission(Permission perm) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    89
                    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    90
                };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    91
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    92
        },
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    93
        NO_PERM {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    94
            @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
            public SecurityManager getSecurityManager() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
                return new SecurityManager();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    99
            @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
            public Class<? extends Throwable> getExpectedException() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
                return AccessControlException.class;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   102
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
        },
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   104
        NO_JVMCI_ACCESS_PERM {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   105
            @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
            public SecurityManager getSecurityManager() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   107
                return new SecurityManager() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
                    @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
                    public void checkPermission(Permission perm) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   110
                        if (isJvmciPermission(perm)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
                            super.checkPermission(perm);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   112
                        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   113
                    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   114
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   115
                    @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   116
                    public void checkPropertyAccess(String key) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   117
                        if (key.startsWith(JVMCI_PROP_START)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   118
                            super.checkPropertyAccess(key);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   119
                        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   120
                    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   121
                };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   122
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   123
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   124
            private boolean isJvmciPermission(Permission perm) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   125
                String name = perm.getName();
33183
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   126
                boolean isJvmciRuntime = perm instanceof RuntimePermission
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   127
                        && (JVMCI_SERVICES.equals(name)
33183
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   128
                            || name.startsWith(JVMCI_RT_PERM_START));
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   129
                boolean isJvmciProperty = perm instanceof PropertyPermission
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   130
                        && name.startsWith(JVMCI_PROP_START);
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   131
                return isJvmciRuntime || isJvmciProperty;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   132
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   133
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   134
            @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   135
            public Class<? extends Throwable> getExpectedException() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   136
                return AccessControlException.class;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   137
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   138
        };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   139
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   140
        public void run() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   141
            System.setSecurityManager(getSecurityManager());
33183
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   142
            Consumer<Throwable> exceptionCheck = e -> {
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   143
                if (e == null) {
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   144
                    if (getExpectedException() != null) {
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   145
                        String message = name() + ": Didn't get expected exception "
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   146
                                + getExpectedException();
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   147
                        throw new AssertionError(message);
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   148
                    }
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   149
                } else {
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   150
                    String message = name() + ": Got unexpected exception "
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   151
                            + e.getClass().getSimpleName();
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   152
                    if (getExpectedException() == null){
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   153
                        throw new AssertionError(message, e);
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   154
                    }
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   155
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   156
                    Throwable t = e;
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   157
                    while (t.getCause() != null) {
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   158
                        t = t.getCause();
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   159
                    }
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   160
                    if (!getExpectedException().isAssignableFrom(t.getClass())) {
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   161
                        message += " instead of " + getExpectedException()
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   162
                                .getSimpleName();
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   163
                        throw new AssertionError(message, e);
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   164
                    }
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   165
                }
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   166
            };
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   167
            Utils.runAndCheckException(CompilerToVM::new, exceptionCheck);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   168
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   169
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   170
        public SecurityManager getSecurityManager() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   171
            return null;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   172
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   173
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   174
        public Class<? extends Throwable> getExpectedException() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   175
            return null;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   176
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   177
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   178
        private static final String JVMCI_RT_PERM_START
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   179
                = "accessClassInPackage.jdk.vm.ci";
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   180
        private static final String JVMCI_SERVICES = "jvmciServices";
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   181
        private static final String JVMCI_PROP_START = "jvmci.";
33183
1ee801e82dda 8139375: [TESTBUG] compiler/jvmci/SecurityRestrictionsTest checks are too tight
tpivovarova
parents: 33160
diff changeset
   182
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   183
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   184
}