This commit is contained in:
Daniel D. Daugherty 2016-04-07 10:03:48 -07:00
commit 3115b36c77
21 changed files with 222 additions and 122 deletions
jdk
make/mapfiles/libjava
src
java.base/share
java.management/share/classes
javax/management/remote
sun/management/jdp
test

@ -224,8 +224,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;

@ -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

@ -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

@ -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

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2015, 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
@ -112,6 +112,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

@ -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

@ -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;

@ -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

@ -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);
}

@ -34,10 +34,15 @@ import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.BitSet;
import java.util.Enumeration;
import java.util.Locale;
import java.util.StringTokenizer;
@ -236,10 +241,13 @@ public class JMXServiceURL implements Serializable {
* @param protocol the protocol part of the URL. If null, defaults
* to <code>jmxmp</code>.
*
* @param host the host part of the URL. If null, defaults to the
* local host name, as determined by
* <code>InetAddress.getLocalHost().getHostName()</code>. If it
* is a numeric IPv6 address, it can optionally be enclosed in
* @param host the host part of the URL. If host is null and if
* local host name can be resolved to an IP, then host defaults
* to local host name as determined by
* <code>InetAddress.getLocalHost().getHostName()</code>. If host is null
* and if local host name cannot be resolved to an IP, then host
* defaults to numeric IP address of one of the active network interfaces.
* If host is a numeric IPv6 address, it can optionally be enclosed in
* square brackets <code>[]</code>.
*
* @param port the port part of the URL.
@ -260,10 +268,13 @@ public class JMXServiceURL implements Serializable {
* @param protocol the protocol part of the URL. If null, defaults
* to <code>jmxmp</code>.
*
* @param host the host part of the URL. If null, defaults to the
* local host name, as determined by
* <code>InetAddress.getLocalHost().getHostName()</code>. If it
* is a numeric IPv6 address, it can optionally be enclosed in
* @param host the host part of the URL. If host is null and if
* local host name can be resolved to an IP, then host defaults
* to local host name as determined by
* <code>InetAddress.getLocalHost().getHostName()</code>. If host is null
* and if local host name cannot be resolved to an IP, then host
* defaults to numeric IP address of one of the active network interfaces.
* If host is a numeric IPv6 address, it can optionally be enclosed in
* square brackets <code>[]</code>.
*
* @param port the port part of the URL.
@ -286,32 +297,45 @@ public class JMXServiceURL implements Serializable {
InetAddress local;
try {
local = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
throw new MalformedURLException("Local host name unknown: " +
e);
}
host = local.getHostName();
host = local.getHostName();
/* We might have a hostname that violates DNS naming
rules, for example that contains an `_'. While we
could be strict and throw an exception, this is rather
user-hostile. Instead we use its numerical IP address.
We can only reasonably do this for the host==null case.
If we're given an explicit host name that is illegal we
have to reject it. (Bug 5057532.) */
try {
validateHost(host, port);
} catch (MalformedURLException e) {
if (logger.fineOn()) {
/* We might have a hostname that violates DNS naming
rules, for example that contains an `_'. While we
could be strict and throw an exception, this is rather
user-hostile. Instead we use its numerical IP address.
We can only reasonably do this for the host==null case.
If we're given an explicit host name that is illegal we
have to reject it. (Bug 5057532.) */
try {
validateHost(host, port);
} catch (MalformedURLException e) {
if (logger.fineOn()) {
logger.fine("JMXServiceURL",
"Replacing illegal local host name " +
host + " with numeric IP address " +
"(see RFC 1034)", e);
}
host = local.getHostAddress();
/* Use the numeric address, which could be either IPv4
or IPv6. validateHost will accept either. */
}
} catch (UnknownHostException e) {
try {
/*
If hostname cannot be resolved, we will try and use numeric
IPv4/IPv6 address. If host=null while starting agent,
we know that it will be started on all interfaces - 0.0.0.0.
Hence we will use IP address of first active non-loopback
interface
*/
host = getActiveNetworkInterfaceIP();
if (host == null) {
throw new MalformedURLException("Unable"
+ " to resolve hostname or "
+ "get valid IP address");
}
} catch (SocketException ex) {
throw new MalformedURLException("Unable"
+ " to resolve hostname or get valid IP address");
}
}
}
@ -340,6 +364,33 @@ public class JMXServiceURL implements Serializable {
validate();
}
private String getActiveNetworkInterfaceIP() throws SocketException {
Enumeration<NetworkInterface>
networkInterface = NetworkInterface.getNetworkInterfaces();
String ipv6AddrStr = null;
while (networkInterface.hasMoreElements()) {
NetworkInterface nic = networkInterface.nextElement();
if (nic.isUp() && !nic.isLoopback()) {
Enumeration<InetAddress> inet = nic.getInetAddresses();
while (inet.hasMoreElements()) {
InetAddress addr = inet.nextElement();
if (addr instanceof Inet4Address
&& !addr.isLinkLocalAddress()) {
return addr.getHostAddress();
}else if (addr instanceof Inet6Address
&& !addr.isLinkLocalAddress()) {
/*
We save last seen IPv6 address which we will return
if we do not find any interface with IPv4 address.
*/
ipv6AddrStr = addr.getHostAddress();
}
}
}
}
return ipv6AddrStr;
}
private static final String INVALID_INSTANCE_MSG =
"Trying to deserialize an invalid instance of JMXServiceURL";
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
@ -540,7 +591,9 @@ public class JMXServiceURL implements Serializable {
* constructor that takes a separate host parameter, the result is
* the string that was specified. If that string was null, the
* result is
* <code>InetAddress.getLocalHost().getHostName()</code>.</p>
* <code>InetAddress.getLocalHost().getHostName()</code> if local host name
* can be resolved to an IP. Else numeric IP address of an active
* network interface will be used.</p>
*
* <p>In either case, if the host was specified using the
* <code>[...]</code> syntax for numeric IPv6 addresses, the

@ -99,30 +99,7 @@ public final class JdpBroadcaster {
throw new JdpException("Unable to bind to source address");
}
channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
} else {
Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
boolean succeed = false;
while (nics.hasMoreElements()) {
NetworkInterface nic = nics.nextElement();
if (nic.isUp() && nic.supportsMulticast()) {
try {
channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, nic);
succeed = true;
} catch (IOException ex) {
// pass
}
}
}
if (!succeed) {
throw new JdpException("Unable to bind to any interfaces.");
}
}
}
/**

@ -153,8 +153,6 @@ javax/management/MBeanServer/OldMBeanServerTest.java 8030957 aix-all
javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215 generic-all
sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java 8147985 generic-all
############################################################################
# jdk_net
@ -335,6 +333,10 @@ com/sun/jdi/CatchPatternTest.sh 8068645 generic-
com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-all
com/sun/jdi/InterfaceMethodsTest.java 8152586 generic-all
com/sun/jdi/InvokeTest.java 8152586 generic-all
############################################################################
# jdk_util

@ -153,14 +153,17 @@ public class InterruptHangTest extends TestScaffold {
timerThread = new Thread("test timer") {
public void run() {
int mySteps = 0;
float timeoutFactor = Float.parseFloat(System.getProperty("test.timeout.factor", "1.0"));
long sleepSeconds = (long)(20 * timeoutFactor);
println("Timer watching for steps every " + sleepSeconds + " seconds");
while (true) {
try {
Thread.sleep(20000);
Thread.sleep(sleepSeconds * 1000);
synchronized(sync) {
System.out.println("steps = " + nSteps);
println("steps = " + nSteps);
if (mySteps == nSteps) {
// no step for 10 secs
failure("failure: Debuggee appears to be hung");
// no step for a long time
failure("failure: Debuggee appears to be hung (no steps for " + sleepSeconds + "s)");
vm().exit(-1);
break;
}

@ -131,6 +131,9 @@ killcmd=kill
# This can be increased if timing seems to be an issue.
sleep_seconds=1
if [ -n "$TIMEOUT_FACTOR" ] ; then
sleep_seconds=$(echo $TIMEOUT_FACTOR $sleep_seconds | awk '{printf "%d\n", int($1 * $2)}')
fi
echo "ShellScaffold.sh: Version" >& 2
topPid=$$

@ -64,6 +64,7 @@ abstract public class TestScaffold extends TargetAdapter {
boolean vmDisconnected = false;
final String[] args;
protected boolean testFailed = false;
protected long startTime;
static private class ArgInfo {
String targetVMArgs = "";
@ -425,6 +426,7 @@ abstract public class TestScaffold extends TargetAdapter {
abstract protected void runTests() throws Exception;
final public void startTests() throws Exception {
startTime = System.currentTimeMillis();
try {
runTests();
} finally {
@ -433,7 +435,8 @@ abstract public class TestScaffold extends TargetAdapter {
}
protected void println(String str) {
System.err.println(str);
long elapsed = System.currentTimeMillis() - startTime;
System.err.println("[" + elapsed + "ms] " + str);
}
protected void print(String str) {

@ -35,6 +35,11 @@ import java.util.Map;
public class ThreadLists {
public static void main(String args[]) {
// Bug id : JDK-8151797
// Use a lambda expression so that call-site cleaner thread is started
Runnable printLambda = () -> {System.out.println("Starting Test");};
printLambda.run();
// get top-level thread group
ThreadGroup top = Thread.currentThread().getThreadGroup();
ThreadGroup parent;

@ -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();
}
}

@ -57,7 +57,6 @@ public class JdpDefaultsTest extends DynamicLauncher {
"-Dcom.sun.management.jmxremote.autodiscovery=true",
"-Dcom.sun.management.jdp.pause=1",
"-Dcom.sun.management.jdp.name=" + jdpName,
"-Dcom.sun.management.jdp.address=224.0.23.178",
"-Djava.util.logging.SimpleFormatter.format='%1$tF %1$tT %4$-7s %5$s %n'",
testName
};

@ -122,7 +122,7 @@ public abstract class JdpTestCase {
*/
private void jdpPacketReceived(Map<String, String> payload) throws Exception {
final String instanceName = payload.get("INSTANCE_NAME");
if (instanceName.equals(connection.instanceName)) {
if (instanceName != null && instanceName.equals(connection.instanceName)) {
packetFromThisVMReceived(payload);
} else {
packetFromOtherVMReceived(payload);

@ -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

@ -153,5 +153,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'");
}
}