This commit is contained in:
Jesper Wilhelmsson 2016-03-19 01:23:44 +01:00
commit 74c006ac7f
12 changed files with 117 additions and 62 deletions

View File

@ -227,8 +227,7 @@ SUNWprivate_1.1 {
Java_java_lang_System_setOut0;
Java_java_lang_Thread_registerNatives;
Java_java_lang_Throwable_fillInStackTrace;
Java_java_lang_Throwable_getStackTraceDepth;
Java_java_lang_Throwable_getStackTraceElement;
Java_java_lang_Throwable_getStackTraceElements;
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2;
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;

View File

@ -78,8 +78,7 @@ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_Pri
text: .text%JNU_GetEnv;
text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_java_lang_reflect_Array_newArray;
text: .text%Java_java_lang_Throwable_getStackTraceDepth;
text: .text%Java_java_lang_Throwable_getStackTraceElement;
text: .text%Java_java_lang_Throwable_getStackTraceElements;
text: .text%throwFileNotFoundException;
text: .text%JNU_NotifyAll;
# Test LoadFrame

View File

@ -74,8 +74,7 @@ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_Pri
text: .text%JNU_GetEnv;
text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_java_lang_reflect_Array_newArray;
text: .text%Java_java_lang_Throwable_getStackTraceDepth;
text: .text%Java_java_lang_Throwable_getStackTraceElement;
text: .text%Java_java_lang_Throwable_getStackTraceElements;
text: .text%throwFileNotFoundException: OUTPUTDIR/io_util.o;
text: .text%JNU_NotifyAll;
# Test LoadFrame

View File

@ -78,8 +78,7 @@ text: .text%Java_java_io_UnixFileSystem_checkAccess;
text: .text%Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
text: .text%Java_java_io_FileInputStream_available;
text: .text%Java_java_lang_reflect_Array_newArray;
text: .text%Java_java_lang_Throwable_getStackTraceDepth;
text: .text%Java_java_lang_Throwable_getStackTraceElement;
text: .text%Java_java_lang_Throwable_getStackTraceElements;
text: .text%Java_java_lang_System_identityHashCode;
text: .text%JNU_NotifyAll;
# Test LoadFrame

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -74,6 +74,12 @@ public final class StackTraceElement implements java.io.Serializable {
this.lineNumber = lineNumber;
}
/**
* Creates an empty stack frame element to be filled in by Throwable.
*/
StackTraceElement() { }
/**
* Returns the name of the source file containing the execution point
* represented by this stack trace element. Generally, this corresponds

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
@ -118,7 +118,7 @@ public class Throwable implements Serializable {
private static final long serialVersionUID = -3042686055658047285L;
/**
* Native code saves some indication of the stack backtrace in this slot.
* The JVM saves some indication of the stack backtrace in this slot.
*/
private transient Object backtrace;
@ -211,6 +211,11 @@ public class Throwable implements Serializable {
*/
private StackTraceElement[] stackTrace = UNASSIGNED_STACK;
/**
* The JVM code sets the depth of the backtrace for later retrieval
*/
private transient int depth;
// Setting this static field introduces an acceptable
// initialization dependency on a few java.util classes.
private static final List<Throwable> SUPPRESSED_SENTINEL = Collections.emptyList();
@ -828,10 +833,11 @@ public class Throwable implements Serializable {
if (backtrace instanceof StackStreamFactory.StackTrace) {
stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements();
} else {
int depth = getStackTraceDepth();
stackTrace = new StackTraceElement[depth];
for (int i = 0; i < depth; i++)
stackTrace[i] = getStackTraceElement(i);
for (int i = 0; i < depth; i++) {
stackTrace[i] = new StackTraceElement();
}
getStackTraceElements(stackTrace);
}
} else if (stackTrace == null) {
return UNASSIGNED_STACK;
@ -884,23 +890,11 @@ public class Throwable implements Serializable {
}
/**
* Returns the number of elements in the stack trace (or 0 if the stack
* trace is unavailable).
*
* package-protection for use by SharedSecrets.
* Gets the stack trace elements.
* @param elements
* @throws IndexOutOfBoundsException if {@code elements.length != depth }
*/
native int getStackTraceDepth();
/**
* Returns the specified element of the stack trace.
*
* package-protection for use by SharedSecrets.
*
* @param index index of the element to return.
* @throws IndexOutOfBoundsException if {@code index < 0 ||
* index >= getStackTraceDepth() }
*/
native StackTraceElement getStackTraceElement(int index);
private native void getStackTraceElements(StackTraceElement[] elements);
/**
* Reads a {@code Throwable} from a stream, enforcing

View File

@ -34,11 +34,11 @@ import jdk.internal.misc.Unsafe;
import java.lang.invoke.MethodHandles.Lookup;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
import sun.security.action.GetPropertyAction;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
@ -188,20 +188,14 @@ public final class StringConcatFactory {
private static final ProxyClassesDumper DUMPER;
static {
// Poke the privileged block once, taking everything we need:
final Object[] values = new Object[4];
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
values[0] = System.getProperty("java.lang.invoke.stringConcat");
values[1] = Boolean.getBoolean("java.lang.invoke.stringConcat.cache");
values[2] = Boolean.getBoolean("java.lang.invoke.stringConcat.debug");
values[3] = System.getProperty("java.lang.invoke.stringConcat.dumpClasses");
return null;
});
final String strategy = (String) values[0];
CACHE_ENABLE = (Boolean) values[1];
DEBUG = (Boolean) values[2];
final String dumpPath = (String) values[3];
final String strategy = AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat"));
CACHE_ENABLE = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat.cache")));
DEBUG = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat.debug")));
final String dumpPath = AccessController.doPrivileged(
new GetPropertyAction("java.lang.invoke.stringConcat.dumpClasses"));
STRATEGY = (strategy == null) ? DEFAULT_STRATEGY : Strategy.valueOf(strategy);
CACHE = CACHE_ENABLE ? new ConcurrentHashMap<>() : null;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -171,11 +171,8 @@ JVM_IsSupportedJNIVersion(jint version);
JNIEXPORT void JNICALL
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
JNIEXPORT jint JNICALL
JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
JNIEXPORT jobject JNICALL
JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
JNIEXPORT void JNICALL
JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements);
/*
* java.lang.StackWalker

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
@ -50,15 +50,9 @@ Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject throwable, jint d
return throwable;
}
JNIEXPORT jint JNICALL
Java_java_lang_Throwable_getStackTraceDepth(JNIEnv *env, jobject throwable)
JNIEXPORT void JNICALL
Java_java_lang_Throwable_getStackTraceElements(JNIEnv *env,
jobject throwable, jobjectArray elements)
{
return JVM_GetStackTraceDepth(env, throwable);
}
JNIEXPORT jobject JNICALL
Java_java_lang_Throwable_getStackTraceElement(JNIEnv *env,
jobject throwable, jint index)
{
return JVM_GetStackTraceElement(env, throwable, index);
JVM_GetStackTraceElements(env, throwable, elements);
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 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.
*/
/*
* @test
* @bug 8087104
* @summary Make sure that clone() method is not called from DateFormatSymbols constructor.
*/
import java.text.DateFormatSymbols;
public class DFSymbolsCloneTest extends DateFormatSymbols {
private Foo foo;
public DFSymbolsCloneTest(Foo fooObj) {
if (fooObj == null) {
this.foo = new Foo();
} else {
this.foo = fooObj;
}
}
@Override
public Object clone() {
DFSymbolsCloneTest dfsclone = (DFSymbolsCloneTest) super.clone();
if (this.foo == null) {
throw new RuntimeException("Clone method should not be called from "
+ " Superclass(DateFormatSymbols) Constructor...");
} else {
dfsclone.foo = (Foo) this.foo.clone();
}
return dfsclone;
}
public static void main(String[] args) {
DFSymbolsCloneTest dfsctest = new DFSymbolsCloneTest(new Foo());
}
}
class Foo {
public Foo() {
}
@Override
protected Object clone() {
return new Foo();
}
}

View File

@ -143,6 +143,7 @@ public class BasicLauncherTest {
launch("No deadlocks found", "jstack");
launch("compiler detected", "jmap");
launch("Java System Properties", "jinfo");
launch("java.threads", "jsnap");
// The test throws RuntimeException on error.
// IOException is thrown if LingeredApp can't start because of some bad

View File

@ -152,5 +152,8 @@ public class SAGetoptTest {
String[] optionSet6 = {"--exe", "--core", "bla_core"};
badOptionsTest(6, optionSet6, "Argument is expected for 'exe'");
String[] optionSet7 = {"--exe"};
badOptionsTest(7, optionSet7, "Argument is expected for 'exe'");
}
}