test/jdk/java/lang/String/concat/WithSecurityManager.java
author ccheung
Wed, 22 Nov 2017 16:08:39 -0800
changeset 48023 4b7462e3b552
parent 48004 8deb7919d118
child 48397 ead47ddf5844
permissions -rw-r--r--
8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module Summary: backout the fix for 8190975 Reviewed-by: iklam, kvn
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
/*
40684
2e37c119dc2a 8164982: Fix legal notices in java/lang, java/net, java/util tests.
shurailine
parents: 40261
diff changeset
     2
 * Copyright (c) 2016, 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
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    30
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    31
 * @compile WithSecurityManager.java
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    32
 *
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    33
 * @run main/othervm -Xverify:all WithSecurityManager
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    34
 * @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
    35
 * @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
    36
 * @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
    37
 * @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
    38
 * @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
    39
 * @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
    40
 *
48023
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
    41
 * @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
    42
 * @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
    43
 * @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
    44
 * @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
    45
 * @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
    46
 * @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
    47
 * @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
    48
*/
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    49
public class WithSecurityManager {
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    50
    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
    51
        // 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
    52
        {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    53
            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
    54
                @Override
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    55
                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
    56
                    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
    57
                    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
    58
                }
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
            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
    61
            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
    62
            };
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
        // 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
    66
        {
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    67
            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
    68
                @Override
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    69
                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
    70
                    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
    71
                    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
    72
                }
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
            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
    75
            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
    76
            };
e567cc17866d 8158851: MH.publicLookup() init circularity, triggered by custom SecurityManager with String concat and -limitmods java.base
shade
parents: 37684
diff changeset
    77
        }
37684
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    78
    }
38b7cb606a05 8155090: String concatenation fails with a custom SecurityManager that uses concatenation
shade
parents:
diff changeset
    79
}