1/* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24import java.security.Permission; 25 26/** 27 * @test 28 * @summary String concatenation fails with a custom SecurityManager that uses concatenation 29 * @bug 8155090 8158851 30 * 31 * @compile WithSecurityManager.java 32 * 33 * @run main/othervm -Xverify:all WithSecurityManager 34 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB WithSecurityManager 35 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB_SIZED WithSecurityManager 36 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED WithSecurityManager 37 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT WithSecurityManager 38 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT WithSecurityManager 39 * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT WithSecurityManager 40 * 41 * @run main/othervm -Xverify:all --limit-modules=java.base WithSecurityManager 42 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB WithSecurityManager 43 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED WithSecurityManager 44 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED WithSecurityManager 45 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT WithSecurityManager 46 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT WithSecurityManager 47 * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT WithSecurityManager 48*/ 49public class WithSecurityManager { 50 public static void main(String[] args) throws Throwable { 51 // First time should succeed to bootstrap everything 52 { 53 SecurityManager sm = new SecurityManager() { 54 @Override 55 public void checkPermission(Permission perm) { 56 String abc = "abc"; 57 String full = abc + "def"; 58 } 59 }; 60 System.setSecurityManager(sm); 61 ClassLoader cl = new ClassLoader() { 62 }; 63 } 64 65 // Second time should succeed to run after bootstrapping 66 { 67 SecurityManager sm = new SecurityManager() { 68 @Override 69 public void checkPermission(Permission perm) { 70 String abc = "abc"; 71 String full = abc + "def"; 72 } 73 }; 74 System.setSecurityManager(sm); 75 ClassLoader cl = new ClassLoader() { 76 }; 77 } 78 } 79} 80