8155090: String concatenation fails with a custom SecurityManager that uses concatenation
Reviewed-by: redestad, chegar
This commit is contained in:
parent
46e74c829b
commit
a6f2cdbb0f
@ -123,7 +123,7 @@ public final class StringConcatFactory {
|
||||
* Concatenation strategy to use. See {@link Strategy} for possible options.
|
||||
* This option is controllable with -Djava.lang.invoke.stringConcat JDK option.
|
||||
*/
|
||||
private static final Strategy STRATEGY;
|
||||
private static Strategy STRATEGY;
|
||||
|
||||
/**
|
||||
* Default strategy to use for concatenation.
|
||||
@ -187,6 +187,16 @@ public final class StringConcatFactory {
|
||||
private static final ProxyClassesDumper DUMPER;
|
||||
|
||||
static {
|
||||
// In case we need to double-back onto the StringConcatFactory during this
|
||||
// static initialization, make sure we have the reasonable defaults to complete
|
||||
// the static initialization properly. After that, actual users would use the
|
||||
// the proper values we have read from the the properties.
|
||||
STRATEGY = DEFAULT_STRATEGY;
|
||||
// CACHE_ENABLE = false; // implied
|
||||
// CACHE = null; // implied
|
||||
// DEBUG = false; // implied
|
||||
// DUMPER = null; // implied
|
||||
|
||||
Properties props = GetPropertyAction.getProperties();
|
||||
final String strategy =
|
||||
props.getProperty("java.lang.invoke.stringConcat");
|
||||
|
53
jdk/test/java/lang/String/concat/WithSecurityManager.java
Normal file
53
jdk/test/java/lang/String/concat/WithSecurityManager.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.security.Permission;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary String concatenation fails with a custom SecurityManager that uses concatenation
|
||||
* @bug 8155090
|
||||
*
|
||||
* @compile WithSecurityManager.java
|
||||
*
|
||||
* @run main/othervm -Xverify:all WithSecurityManager
|
||||
* @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB WithSecurityManager
|
||||
* @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB_SIZED WithSecurityManager
|
||||
* @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED WithSecurityManager
|
||||
* @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT WithSecurityManager
|
||||
* @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT WithSecurityManager
|
||||
* @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT WithSecurityManager
|
||||
*/
|
||||
public class WithSecurityManager {
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SecurityManager sm = new SecurityManager() {
|
||||
@Override
|
||||
public void checkPermission(Permission perm) {
|
||||
String abc = "abc";
|
||||
String full = abc + "def";
|
||||
}
|
||||
};
|
||||
System.setSecurityManager(sm);
|
||||
ClassLoader cl = new ClassLoader() {};
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user