test/jdk/java/lang/String/concat/WithSecurityManager.java
author kvn
Wed, 13 Dec 2017 11:59:55 -0800
changeset 48397 ead47ddf5844
parent 48023 4b7462e3b552
child 54677 beca9f8524c1
permissions -rw-r--r--
8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line Summary: skip tests which use --limit-modules when Graal is used as JIT compiler. Reviewed-by: alanb, mchung, dholmes, ccheung, dnsimon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     1
/*
48397
ead47ddf5844 8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line
kvn
parents: 48023
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     4
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     7
 * published by the Free Software Foundation.
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     8
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    13
 * accompanied this code).
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    14
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    18
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    21
 * questions.
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    22
 */
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    23
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    24
import java.security.Permission;
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    25
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    26
/**
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    27
 * @test
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    28
 * @summary String concatenation fails with a custom SecurityManager that uses concatenation
38861
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    29
 * @bug 8155090 8158851
48397
ead47ddf5844 8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line
kvn
parents: 48023
diff changeset
    30
 * @requires !vm.graal.enabled
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    31
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    32
 * @compile WithSecurityManager.java
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    33
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    34
 * @run main/othervm -Xverify:all WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    35
 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB                  WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    36
 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB_SIZED            WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    37
 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED            WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    38
 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT      WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    39
 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT      WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    40
 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT  WithSecurityManager
38861
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    41
 *
48023
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    42
 * @run main/othervm -Xverify:all --limit-modules=java.base WithSecurityManager
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    43
 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB                  WithSecurityManager
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    44
 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED            WithSecurityManager
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    45
 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED            WithSecurityManager
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    46
 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT      WithSecurityManager
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    47
 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT      WithSecurityManager
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    48
 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT  WithSecurityManager
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    49
*/
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    50
public class WithSecurityManager {
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    51
    public static void main(String[] args) throws Throwable {
38861
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    52
        // First time should succeed to bootstrap everything
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    53
        {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    54
            SecurityManager sm = new SecurityManager() {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    55
                @Override
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    56
                public void checkPermission(Permission perm) {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    57
                    String abc = "abc";
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    58
                    String full = abc + "def";
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    59
                }
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    60
            };
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    61
            System.setSecurityManager(sm);
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    62
            ClassLoader cl = new ClassLoader() {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    63
            };
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    64
        }
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    65
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    66
        // Second time should succeed to run after bootstrapping
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    67
        {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    68
            SecurityManager sm = new SecurityManager() {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    69
                @Override
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    70
                public void checkPermission(Permission perm) {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    71
                    String abc = "abc";
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    72
                    String full = abc + "def";
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    73
                }
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    74
            };
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    75
            System.setSecurityManager(sm);
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    76
            ClassLoader cl = new ClassLoader() {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    77
            };
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    78
        }
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    79
    }
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    80
}