8203928: [Test] Convert non-JDB scaffolding serviceability shell script tests to java
Reviewed-by: jcbeyler, cjplummer
This commit is contained in:
parent
2ae27da3bc
commit
d5062c82af
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
@ -21,18 +21,18 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 6287579
|
||||
* @summary SubClasses of ListResourceBundle should fix getContents()
|
||||
*
|
||||
* @modules jdk.jdi/com.sun.tools.example.debug.tty
|
||||
*
|
||||
* This isn't the test case: ImmutableResourceTest.sh is.
|
||||
* Refer to ImmutableResourceTest.sh when running this test.
|
||||
*
|
||||
* @bug 6287579
|
||||
* @summary SubClasses of ListResourceBundle should fix getContents()
|
||||
*
|
||||
* @author Tim Bell
|
||||
* @compile --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED -g ImmutableResourceTest.java
|
||||
*
|
||||
* @run main/othervm --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED ImmutableResourceTest
|
||||
*/
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ImmutableResourceTest {
|
||||
|
@ -1,116 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2005, 2012, 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 6287579
|
||||
# @summary SubClasses of ListResourceBundle should fix getContents()
|
||||
# @author Tim Bell
|
||||
#
|
||||
# @modules jdk.jdi/com.sun.tools.example.debug.tty
|
||||
#
|
||||
# @run shell ImmutableResourceTest.sh
|
||||
#
|
||||
|
||||
# Beginning of subroutines:
|
||||
status=1
|
||||
|
||||
#Call this from anywhere to fail the test with an error message
|
||||
# usage: fail "reason why the test failed"
|
||||
fail()
|
||||
{ echo "The test failed :-("
|
||||
echo "$*" 1>&2
|
||||
echo "exit status was $status"
|
||||
exit $status
|
||||
} #end of fail()
|
||||
|
||||
#Call this from anywhere to pass the test with a message
|
||||
# usage: pass "reason why the test passed if applicable"
|
||||
pass()
|
||||
{ echo "The test passed!!!"
|
||||
echo "$*" 1>&2
|
||||
exit 0
|
||||
} #end of pass()
|
||||
|
||||
# end of subroutines
|
||||
|
||||
# The beginning of the script proper
|
||||
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS | Linux | Darwin | AIX )
|
||||
PATHSEP=":"
|
||||
;;
|
||||
|
||||
Windows* | CYGWIN*)
|
||||
PATHSEP=";"
|
||||
;;
|
||||
|
||||
# catch all other OSs
|
||||
* )
|
||||
echo "Unrecognized system! $OS"
|
||||
fail "Unrecognized system! $OS"
|
||||
;;
|
||||
esac
|
||||
|
||||
TARGETCLASS="ImmutableResourceTest"
|
||||
if [ -z "${TESTJAVA}" ] ; then
|
||||
# TESTJAVA is not set, so the test is running stand-alone.
|
||||
# TESTJAVA holds the path to the root directory of the build of the JDK
|
||||
# to be tested. That is, any java files run explicitly in this shell
|
||||
# should use TESTJAVA in the path to the java interpreter.
|
||||
# So, we'll set this to the JDK spec'd on the command line. If none
|
||||
# is given on the command line, tell the user that and use a default.
|
||||
# THIS IS THE JDK BEING TESTED.
|
||||
if [ -n "$1" ] ; then
|
||||
TESTJAVA=$1
|
||||
else
|
||||
TESTJAVA=$JAVA_HOME
|
||||
fi
|
||||
TESTSRC=.
|
||||
TESTCLASSES=.
|
||||
#Deal with .class files:
|
||||
fi
|
||||
#
|
||||
echo "JDK under test is: $TESTJAVA"
|
||||
#
|
||||
CP="-classpath ${TESTCLASSES}"
|
||||
#
|
||||
env
|
||||
#
|
||||
set -vx
|
||||
#
|
||||
# Compile test class
|
||||
${TESTJAVA}/bin/javac --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \
|
||||
-d "${TESTCLASSES}" ${CP} -g "${TESTSRC}"/"${TARGETCLASS}".java
|
||||
#
|
||||
# Run the test class, again with the classpath we need:
|
||||
${TESTJAVA}/bin/java --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \
|
||||
${CP} ${TARGETCLASS}
|
||||
status=$?
|
||||
echo "test status was: $status"
|
||||
if [ $status -eq "0" ];
|
||||
then pass ""
|
||||
|
||||
else fail "unspecified test failure"
|
||||
fi
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, 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
|
||||
@ -22,37 +22,27 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note 1: JITDebug.java is no longer a standalone regression test,
|
||||
* due to chronic test failures on win32 platforms. When testing,
|
||||
* use the wrapper script (JITDebug.sh) instead, which will in turn
|
||||
* invoke this program.
|
||||
* Note: What seems to be an excessive use of System.xxx.flush();
|
||||
* is actually necessary to combat lost output on win32 systems.
|
||||
*
|
||||
* The problems are related to inconsistent use of "SystemRoot"
|
||||
* versus "SYSTEMROOT" environment variables in different win32 O/S
|
||||
* installations. Refer to the Comments and Evaluation on bugs
|
||||
* 4522770 and 4461673 for more information.
|
||||
* @test
|
||||
* @bug 4291701 4376819 4422312 4522770
|
||||
* @summary Test JIT debugging -
|
||||
* assure that launching on uncaught exception works
|
||||
*
|
||||
* Undefined SystemRoot in a win32 environment causes the O/S socket()
|
||||
* layer to fail with WSAEPROVIDERFAILEDINIT. The workaround used by
|
||||
* JITDebug.sh and JITDebug.java is to select the dt_shmem transport
|
||||
* on any win32 platform where SystemRoot is not found.
|
||||
* @library /test/lib
|
||||
*
|
||||
* Note 2: What seems to be an excessive use of System.xxx.flush();
|
||||
* is actually necessary to combat lost output on win32 systems.
|
||||
*
|
||||
* @t e s t
|
||||
* @bug 4291701 4376819 4422312 4522770
|
||||
* @summary Test JIT debugging -
|
||||
* assure that launching on uncaught exception works
|
||||
*
|
||||
* @author Robert Field
|
||||
* @run driver JITDebug
|
||||
* @author Robert Field
|
||||
* @run main/othervm JITDebug
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.connect.*;
|
||||
import jdk.test.lib.JDKToolFinder;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
/*
|
||||
* This class implements three separate small programs, each
|
||||
@ -97,7 +87,13 @@ public class JITDebug {
|
||||
}
|
||||
case 3:
|
||||
if (args[0].equals("DEBUGGER")) {
|
||||
trivialDebugger(args[2]);
|
||||
// launched by using "-agentlib:" "launch" sub-option:
|
||||
// The following strings are appended to the string given in this argument (space-delimited).
|
||||
// They can aid the launched debugger in establishing a connection with this VM.
|
||||
// The resulting string is executed.
|
||||
// - The value of the transport sub-option.
|
||||
// - The value of the address sub-option (or the generated address if one is not given)
|
||||
trivialDebugger(args[1], args[2]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -108,70 +104,24 @@ public class JITDebug {
|
||||
}
|
||||
|
||||
void testLaunch() {
|
||||
class DisplayOutput extends Thread {
|
||||
InputStream in;
|
||||
|
||||
DisplayOutput(InputStream in) {
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
transfer();
|
||||
} catch (IOException exc) {
|
||||
new RuntimeException("Unexpected exception: " + exc);
|
||||
}
|
||||
}
|
||||
|
||||
void transfer() throws IOException {
|
||||
int ch;
|
||||
while ((ch = in.read()) != -1) {
|
||||
System.out.print((char)ch);
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
String transportMethod = System.getProperty("TRANSPORT_METHOD");
|
||||
if (transportMethod == null) {
|
||||
transportMethod = "dt_socket"; //Default to socket transport.
|
||||
}
|
||||
String javaExe = System.getProperty("java.home") +
|
||||
File.separator + "bin" + File.separator +"java";
|
||||
List largs = new ArrayList();
|
||||
largs.add(javaExe);
|
||||
largs.add("-agentlib:jdwp=transport=" + transportMethod + ",server=y,onuncaught=y," +
|
||||
"launch=" +
|
||||
javaExe + " -DTRANSPORT_METHOD=" + transportMethod + " " +
|
||||
this.getClass().getName() + " DEBUGGER ");
|
||||
largs.add("JITDebug");
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true);
|
||||
List largs = pb.command();
|
||||
largs.add("-classpath");
|
||||
largs.add(Utils.TEST_CLASSES);
|
||||
String javaExe = JDKToolFinder.getJDKTool("java");
|
||||
largs.add("-agentlib:jdwp=transport=dt_socket,server=y,onuncaught=y," +
|
||||
"launch=" + javaExe + " " + this.getClass().getName() + " DEBUGGER ");
|
||||
largs.add(this.getClass().getName());
|
||||
largs.add("TARGET");
|
||||
System.out.println("Launching: " + largs);
|
||||
String[] sargs = (String[])largs.toArray(new String[largs.size()]);
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
try {
|
||||
Process proc = rt.exec(VMConnection.insertDebuggeeVMOptions(sargs));
|
||||
DisplayOutput inThread = new DisplayOutput(proc.getInputStream());
|
||||
DisplayOutput erThread = new DisplayOutput(proc.getErrorStream());
|
||||
inThread.start(); // transfer all in&err
|
||||
erThread.start();
|
||||
inThread.join(); // make sure they are done
|
||||
erThread.join();
|
||||
int exitValue = proc.waitFor();
|
||||
if (exitValue != 0) {
|
||||
throw new RuntimeException("Failure exit status: " +
|
||||
exitValue);
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
ProcessTools.executeCommand(pb)
|
||||
.shouldHaveExitValue(0);
|
||||
} catch (Throwable exc) {
|
||||
throw new RuntimeException("Unexpected exception: " + exc);
|
||||
}
|
||||
System.out.println("JIT Debugging test PASSED");
|
||||
}
|
||||
|
||||
void displayOutput(InputStream in) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Target VM code
|
||||
void debugTarget() {
|
||||
System.out.flush();
|
||||
@ -180,9 +130,8 @@ public class JITDebug {
|
||||
throw new RuntimeException("Start-up onuncaught handling");
|
||||
}
|
||||
|
||||
void trivialDebugger(String transportAddress) {
|
||||
void trivialDebugger(String transportMethod, String transportAddress) {
|
||||
System.out.println("trivial debugger started");
|
||||
String transportMethod = System.getProperty("TRANSPORT_METHOD");
|
||||
String connectorName = null;
|
||||
if ("dt_shmem".equals(transportMethod)) {
|
||||
connectorName = "com.sun.jdi.SharedMemoryAttach";
|
||||
@ -209,7 +158,7 @@ public class JITDebug {
|
||||
}
|
||||
|
||||
void doAttach(String connectorName, AttachingConnector conn, String transportAddress) {
|
||||
Map connArgs = conn.defaultArguments();
|
||||
Map<String, Connector.Argument> connArgs = conn.defaultArguments();
|
||||
if ("com.sun.jdi.SharedMemoryAttach".equals(connectorName)) {
|
||||
Connector.Argument portArg = (Connector.Argument)connArgs.get("name");
|
||||
portArg.setValue(transportAddress);
|
||||
@ -234,7 +183,7 @@ public class JITDebug {
|
||||
void hang() {
|
||||
try {
|
||||
// ten minute nap
|
||||
Thread.currentThread().sleep(10 * 60 * 1000);
|
||||
Thread.sleep(10 * 60 * 1000);
|
||||
} catch (InterruptedException exc) {
|
||||
// shouldn't happen
|
||||
}
|
||||
|
@ -1,142 +0,0 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# Copyright (c) 2002, 2015, 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 JITDebug.sh 1.7 03/09/05
|
||||
# @bug 4291701 4376819 4422312 4522770 4913748
|
||||
# @summary Test JIT debugging - assure that launching on
|
||||
# uncaught exception works
|
||||
# @author Tim Bell
|
||||
# Based on test/java/awt/TEMPLATE/AutomaticShellTest.sh
|
||||
#
|
||||
# @run build TestScaffold VMConnection TargetListener TargetAdapter
|
||||
# @run compile -g JITDebug.java
|
||||
# @run shell JITDebug.sh
|
||||
|
||||
# Beginning of subroutines:
|
||||
status=1
|
||||
|
||||
#Call this from anywhere to fail the test with an error message
|
||||
# usage: fail "reason why the test failed"
|
||||
fail()
|
||||
{ echo "The test failed :-("
|
||||
echo "$*" 1>&2
|
||||
echo "exit status was $status"
|
||||
exit $status
|
||||
} #end of fail()
|
||||
|
||||
#Call this from anywhere to pass the test with a message
|
||||
# usage: pass "reason why the test passed if applicable"
|
||||
pass()
|
||||
{ echo "The test passed!!!"
|
||||
echo "$*" 1>&2
|
||||
exit 0
|
||||
} #end of pass()
|
||||
|
||||
# end of subroutines
|
||||
|
||||
|
||||
# The beginning of the script proper
|
||||
|
||||
OS=`uname -s`
|
||||
export TRANSPORT_METHOD
|
||||
case "$OS" in
|
||||
SunOS | Linux | Darwin | AIX )
|
||||
PATHSEP=":"
|
||||
TRANSPORT_METHOD=dt_socket
|
||||
;;
|
||||
|
||||
Windows* | CYGWIN*)
|
||||
PATHSEP=";"
|
||||
TRANSPORT_METHOD=dt_shmem
|
||||
;;
|
||||
|
||||
# catch all other OSs
|
||||
* )
|
||||
echo "Unrecognized system! $OS"
|
||||
fail "Unrecognized system! $OS"
|
||||
;;
|
||||
esac
|
||||
#
|
||||
# Want this test to run standalone as well as in the harness, so do the
|
||||
# following to copy the test's directory into the harness's scratch directory
|
||||
# and set all appropriate variables:
|
||||
|
||||
if [ -z "${TESTJAVA}" ] ; then
|
||||
# TESTJAVA is not set, so the test is running stand-alone.
|
||||
# TESTJAVA holds the path to the root directory of the build of the JDK
|
||||
# to be tested. That is, any java files run explicitly in this shell
|
||||
# should use TESTJAVA in the path to the java interpreter.
|
||||
# So, we'll set this to the JDK spec'd on the command line. If none
|
||||
# is given on the command line, tell the user that and use a default.
|
||||
# THIS IS THE JDK BEING TESTED.
|
||||
if [ -n "$1" ] ; then
|
||||
TESTJAVA=$1
|
||||
else
|
||||
TESTJAVA=$JAVA_HOME
|
||||
fi
|
||||
TESTSRC=.
|
||||
TESTCLASSES=.
|
||||
#Deal with .class files:
|
||||
#if running standalone (no test harness of any kind), compile the
|
||||
#support files and the test case
|
||||
${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
|
||||
-classpath "${TESTSRC}" \
|
||||
TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java
|
||||
${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
|
||||
-classpath "${TESTSRC}" -g \
|
||||
JITDebug.java
|
||||
fi
|
||||
echo "JDK under test is: $TESTJAVA"
|
||||
#
|
||||
CLASSPATH="${TESTCLASSES}"
|
||||
export CLASSPATH
|
||||
CP="-classpath \"${CLASSPATH}\""
|
||||
#
|
||||
TARGETCLASS=JITDebug
|
||||
RUNFLAGS='-showversion -DTRANSPORT_METHOD="${TRANSPORT_METHOD}"'
|
||||
RUNFLAGS="-Dtest.classes=${TESTCLASSES} ${RUNFLAGS}"
|
||||
#
|
||||
echo ""
|
||||
echo "Environment variable definitions are:"
|
||||
echo ""
|
||||
env | sort
|
||||
echo ""
|
||||
echo ""
|
||||
#
|
||||
echo "Starting test:"
|
||||
echo ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${RUNFLAGS} ${CP} ${TARGETCLASS}
|
||||
eval ${TESTJAVA}/bin/java -DHANGINGJAVA_DEB ${RUNFLAGS} ${CP} ${TARGETCLASS}
|
||||
status=$?
|
||||
if [ $status -ne "0" ];
|
||||
then fail "test failed for class=$TARGETCLASS!"
|
||||
fi
|
||||
#
|
||||
# pass or fail the test based on status of the command
|
||||
if [ $status -eq "0" ];
|
||||
then pass ""
|
||||
|
||||
else fail "unspecified test failure"
|
||||
fi
|
108
test/jdk/com/sun/jdi/PrivateTransportTest.java
Normal file
108
test/jdk/com/sun/jdi/PrivateTransportTest.java
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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 6225664 6220618
|
||||
* @summary Test for when private transport library outside jdk
|
||||
* @comment converted from test/jdk/com/sun/jdi/PrivateTransportTest.sh
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run compile -g HelloWorld.java
|
||||
* @build PrivateTransportTest
|
||||
* @run main/othervm PrivateTransportTest
|
||||
*/
|
||||
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PrivateTransportTest {
|
||||
|
||||
public static void main(String argv[]) throws Throwable {
|
||||
new PrivateTransportTest()
|
||||
.test();
|
||||
}
|
||||
|
||||
private final Path transportLib;
|
||||
private final String pathEnvVar;
|
||||
private final String pathSep;
|
||||
|
||||
private static boolean isTransportLib(Path path) {
|
||||
String fileName = path.getFileName().toString().toLowerCase();
|
||||
return fileName.equals("dt_socket.dll")
|
||||
|| fileName.equals("libdt_socket.so")
|
||||
|| fileName.equals("libdt_socket.dylib");
|
||||
}
|
||||
|
||||
private PrivateTransportTest() throws IOException {
|
||||
Path jdkRoot = Paths.get(Utils.TEST_JDK);
|
||||
try (Stream<Path> files = Files.find(jdkRoot, 5, (path, attr) -> isTransportLib(path.getFileName()))) {
|
||||
Optional<Path> foundLib = files.findAny();
|
||||
if (!foundLib.isPresent()) {
|
||||
throw new RuntimeException("cannot find dt_socket lib");
|
||||
}
|
||||
transportLib = foundLib.get();
|
||||
}
|
||||
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||
pathSep = ";";
|
||||
pathEnvVar = "PATH";
|
||||
} else {
|
||||
pathSep = ":";
|
||||
if (System.getProperty("os.name").equals("AIX")) {
|
||||
pathEnvVar = "LIBPATH";
|
||||
} else {
|
||||
pathEnvVar = "LD_LIBRARY_PATH";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void test() throws Throwable {
|
||||
// copy existing dt_socket lib to <CLASSES>/private_dt_socket
|
||||
String libName = transportLib.getFileName().toString().replace("dt_socket", "private_dt_socket");
|
||||
Files.copy(transportLib, Paths.get(Utils.TEST_CLASSES).resolve(libName));
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
|
||||
"-agentlib:jdwp=transport=private_dt_socket,server=y,suspend=n",
|
||||
"-classpath", Utils.TEST_CLASSES,
|
||||
"HelloWorld");
|
||||
Map<String, String> env = pb.environment();
|
||||
String pathValue = env.get(pathEnvVar);
|
||||
if (pathValue == null) {
|
||||
pathValue = Utils.TEST_CLASSES;
|
||||
} else {
|
||||
pathValue = pathValue + pathSep + Utils.TEST_CLASSES;
|
||||
}
|
||||
env.put(pathEnvVar, pathValue);
|
||||
|
||||
ProcessTools.executeCommand(pb)
|
||||
.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# Copyright (c) 2005, 2013, 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 PrivateTransportTest.sh
|
||||
# @bug 6225664 6220618
|
||||
# @summary Test for when private transport library outside jdk
|
||||
# @author Kelly O'Hair
|
||||
#
|
||||
# @run compile -g HelloWorld.java
|
||||
# @run shell PrivateTransportTest.sh
|
||||
#
|
||||
|
||||
# Beginning of subroutines:
|
||||
status=1
|
||||
|
||||
#Call this from anywhere to fail the test with an error message
|
||||
# usage: fail "reason why the test failed"
|
||||
fail()
|
||||
{ echo "The test failed :-("
|
||||
echo "$*" 1>&2
|
||||
echo "exit status was $status"
|
||||
exit $status
|
||||
} #end of fail()
|
||||
|
||||
#Call this from anywhere to pass the test with a message
|
||||
# usage: pass "reason why the test passed if applicable"
|
||||
pass()
|
||||
{ echo "The test passed!!!"
|
||||
echo "$*" 1>&2
|
||||
exit 0
|
||||
} #end of pass()
|
||||
|
||||
# end of subroutines
|
||||
|
||||
# The beginning of the script proper
|
||||
|
||||
TARGETCLASS="HelloWorld"
|
||||
if [ -z "${TESTJAVA}" ] ; then
|
||||
# TESTJAVA is not set, so the test is running stand-alone.
|
||||
# TESTJAVA holds the path to the root directory of the build of the JDK
|
||||
# to be tested. That is, any java files run explicitly in this shell
|
||||
# should use TESTJAVA in the path to the java interpreter.
|
||||
# So, we'll set this to the JDK spec'd on the command line. If none
|
||||
# is given on the command line, tell the user that and use a default.
|
||||
# THIS IS THE JDK BEING TESTED.
|
||||
if [ -n "$1" ] ; then
|
||||
TESTJAVA=$1
|
||||
else
|
||||
TESTJAVA=$JAVA_HOME
|
||||
fi
|
||||
TESTSRC=.
|
||||
TESTCLASSES=.
|
||||
#Deal with .class files:
|
||||
${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
|
||||
-classpath "${TESTCLASSES}" -g \
|
||||
${TARGETCLASS}.java
|
||||
fi
|
||||
#
|
||||
echo "JDK under test is: $TESTJAVA"
|
||||
|
||||
# Get flags being sent to debuggee
|
||||
DEBUGGEEFLAGS=$TESTVMOPTS $TESTJAVAOPTS
|
||||
|
||||
# Figure out what the libarch path is
|
||||
os=`uname -s`
|
||||
|
||||
jreloc=${TESTJAVA}/jre
|
||||
if [ ! -d ${jreloc} ] ; then
|
||||
jreloc=${TESTJAVA}
|
||||
fi
|
||||
|
||||
libdir=${TESTCLASSES}
|
||||
|
||||
is_windows=false
|
||||
is_cygwin=false
|
||||
case `uname -s` in
|
||||
SunOS|Linux|AIX)
|
||||
xx=`find ${jreloc}/lib -name libdt_socket.so`
|
||||
libloc=`dirname ${xx}`
|
||||
;;
|
||||
Darwin)
|
||||
libloc=${jreloc}/lib
|
||||
;;
|
||||
Windows*)
|
||||
is_windows=true
|
||||
libloc=${jreloc}/bin
|
||||
sep=';'
|
||||
;;
|
||||
CYGWIN*)
|
||||
is_windows=true
|
||||
is_cygwin=true
|
||||
libloc=${jreloc}/bin
|
||||
sep=':'
|
||||
|
||||
# This is going onto PATH and cygwin needs the form
|
||||
# /cygdrive/j/x..... for that.
|
||||
libdir=`cygpath -u "$TESTCLASSES"`
|
||||
;;
|
||||
*)
|
||||
echo "FAILURE: Unknown uname -s: " `uname -s`
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create private transport library
|
||||
echo "Setup private transport library by copying an existing one and renaming"
|
||||
private_transport=private_dt_socket
|
||||
if [ -f ${libloc}/dt_socket.dll ] ; then
|
||||
fullpath=${libdir}/${private_transport}.dll
|
||||
rm -f ${fullpath}
|
||||
echo cp ${libloc}/dt_socket.dll ${fullpath}
|
||||
cp ${libloc}/dt_socket.dll ${fullpath}
|
||||
# make sure we can find libraries in current directory
|
||||
PATH="${PATH}${sep}${libdir}"
|
||||
export PATH
|
||||
echo PATH=${PATH}
|
||||
elif [ -f ${libloc}/libdt_socket.dylib ]; then
|
||||
fullpath=${libdir}/lib${private_transport}.dylib
|
||||
rm -f ${fullpath}
|
||||
echo cp ${libloc}/libdt_socket.dylib ${fullpath}
|
||||
cp ${libloc}/libdt_socket.dylib ${fullpath}
|
||||
# make sure we can find libraries in current directory
|
||||
if [ "${LD_LIBRARY_PATH}" = "" ] ; then
|
||||
LD_LIBRARY_PATH=${libdir}
|
||||
else
|
||||
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${libdir}
|
||||
fi
|
||||
export LD_LIBRARY_PATH
|
||||
echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
|
||||
elif [ -f ${libloc}/libdt_socket.so ] ; then
|
||||
fullpath=${libdir}/lib${private_transport}.so
|
||||
rm -f ${fullpath}
|
||||
echo cp ${libloc}/libdt_socket.so ${fullpath}
|
||||
cp ${libloc}/libdt_socket.so ${fullpath}
|
||||
# make sure we can find libraries in current directory
|
||||
if [ "$os" = "AIX" ] ; then
|
||||
if [ "${LIBPATH}" = "" ] ; then
|
||||
LIBPATH=${libdir}
|
||||
else
|
||||
LIBPATH=${LIBPATH}:${libdir}
|
||||
fi
|
||||
export LIBPATH
|
||||
echo LIBPATH=${LIBPATH}
|
||||
else
|
||||
if [ "${LD_LIBRARY_PATH}" = "" ] ; then
|
||||
LD_LIBRARY_PATH=${libdir}
|
||||
else
|
||||
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${libdir}
|
||||
fi
|
||||
export LD_LIBRARY_PATH
|
||||
echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
|
||||
fi
|
||||
else
|
||||
echo "cannot find dt_socket in ${libloc} for ${private_transport}"
|
||||
fail "cannot find dt_socket in ${libloc} for ${private_transport}"
|
||||
fi
|
||||
|
||||
#
|
||||
CP="-classpath \"${TESTCLASSES}\""
|
||||
#
|
||||
if [ "$is_windows" = "true" ]; then
|
||||
if [ "$is_cygwin" = "true" ]; then
|
||||
win_fullpath=`cygpath -m "$fullpath" \
|
||||
| sed -e 's#/#\\\\\\\\#g' -e 's/\.dll//'`
|
||||
else
|
||||
win_fullpath=`echo "$fullpath" \
|
||||
| sed -e 's#/#\\\\\\\\#g' -e 's/\.dll//'`
|
||||
fi
|
||||
DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${win_fullpath},server=y,suspend=n"
|
||||
else
|
||||
DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${private_transport},server=y,suspend=n"
|
||||
fi
|
||||
|
||||
echo ${TESTJAVA}/bin/java ${DEBUGGEEFLAGS} ${CP} ${TARGETCLASS}
|
||||
eval ${TESTJAVA}/bin/java ${DEBUGGEEFLAGS} ${CP} ${TARGETCLASS}
|
||||
status=$?
|
||||
echo "test status for ${DEBUGGERFLAGS} was: $status"
|
||||
if [ $status -ne 0 ] ; then
|
||||
fail "unspecified test failure"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pass "found private transport library"
|
||||
exit 0
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2018, 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
|
||||
@ -21,6 +21,16 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 5055681
|
||||
* @summary Test loading JDI classes via custom class loader
|
||||
*
|
||||
* @library /test/lib
|
||||
* @build JdiLoadedByCustomLoader
|
||||
* @run main/othervm JdiLoadedByCustomLoader
|
||||
*/
|
||||
|
||||
/*
|
||||
* Creates a URLClassLoader from a file URL. The file URL
|
||||
* is constructed from the given argument. Once created the test
|
||||
@ -28,16 +38,33 @@
|
||||
* using the class loader and then it invokes the list()
|
||||
* method.
|
||||
*/
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.compiler.CompilerUtils;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class JdiLoadedByCustomLoader {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
// Compile the list connectors class into a directory that isn't on
|
||||
// any class path.
|
||||
Path src = Paths.get(Utils.TEST_SRC).toAbsolutePath().resolve("ListConnectors.java");
|
||||
Path newClassDir = Paths.get(Utils.TEST_CLASSES).toAbsolutePath().resolve("someotherdir");
|
||||
if (!CompilerUtils.compile(src, newClassDir, false, "-classpath", Utils.TEST_CLASSES)) {
|
||||
throw new RuntimeException("failed to compile " + src);
|
||||
}
|
||||
|
||||
test(newClassDir.toString());
|
||||
}
|
||||
|
||||
private static void test(String classPath) throws Exception {
|
||||
// create files from given arguments and tools.jar
|
||||
File f1 = new File(args[0]);
|
||||
File f1 = new File(classPath);
|
||||
|
||||
// create class loader
|
||||
URL[] urls = { f1.toURL() };
|
||||
|
@ -1,77 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2004, 2015, 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 5055681
|
||||
# @summary Test loading JDI classes via custom class loader
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS | Linux | Darwin | AIX )
|
||||
PS=":"
|
||||
;;
|
||||
Windows* | CYGWIN*)
|
||||
PS=";"
|
||||
;;
|
||||
* )
|
||||
echo "Unrecognized system!"
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
JAVAC="${TESTJAVA}"/bin/javac
|
||||
JAVA="${TESTJAVA}"/bin/java
|
||||
SOMEOTHERDIR="${TESTCLASSES}"/someotherdir
|
||||
|
||||
# Compile test into the classes directory
|
||||
# Compile the list connectors class into a directory that isn't on
|
||||
# any class path.
|
||||
|
||||
$JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/JdiLoadedByCustomLoader.java
|
||||
|
||||
mkdir "${SOMEOTHERDIR}"
|
||||
$JAVAC -d "${SOMEOTHERDIR}" -classpath "${TESTSRC}" \
|
||||
"${TESTSRC}"/ListConnectors.java
|
||||
|
||||
# Run the test
|
||||
|
||||
"${JAVA}" -classpath "${TESTCLASSES}" JdiLoadedByCustomLoader \
|
||||
"${SOMEOTHERDIR}"
|
@ -1,68 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2001, 2002, 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.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTJAVA=${TESTJAVA}"
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "TESTCLASSES=${TESTCLASSES}"
|
||||
echo "CLASSPATH=${CLASSPATH}"
|
||||
|
||||
JAVAC="${TESTJAVA}/bin/javac -g"
|
||||
|
||||
cp ${TESTSRC}/Different_RedefineSubTarg.java RedefineSubTarg.java
|
||||
${JAVAC} RedefineSubTarg.java
|
||||
mv RedefineSubTarg.class Different_RedefineSubTarg.class
|
||||
rm -f RedefineSubTarg.java
|
||||
|
||||
cp ${TESTSRC}/SchemaChange_RedefineSubTarg.java RedefineSubTarg.java
|
||||
${JAVAC} RedefineSubTarg.java
|
||||
mv RedefineSubTarg.class SchemaChange_RedefineSubTarg.class
|
||||
rm -f RedefineSubTarg.java
|
||||
|
||||
cp ${TESTSRC}/RedefineSubTarg.java RedefineSubTarg.java
|
||||
${JAVAC} RedefineSubTarg.java
|
||||
rm -f RedefineSubTarg.java
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2018, 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
|
||||
@ -31,15 +31,22 @@
|
||||
* @author Robert Field
|
||||
*
|
||||
* @library ..
|
||||
* @library /test/lib
|
||||
*
|
||||
* @run build TestScaffold VMConnection TargetListener TargetAdapter
|
||||
* @run compile -g RedefineTest.java
|
||||
* @run shell RedefineSetUp.sh
|
||||
* @run driver RedefineTest
|
||||
*/
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.*;
|
||||
import com.sun.jdi.request.*;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
@ -268,9 +275,25 @@ public class RedefineTest extends TestScaffold {
|
||||
return;
|
||||
}
|
||||
|
||||
// prepares .class file for redefined RedefineSubTarg class:
|
||||
// - compiles <fileName>.java from test source dir;
|
||||
// - saves compiled class <fileName>.class.
|
||||
protected void prepareRedefinedClass(String fileName) throws Exception {
|
||||
Path srcJavaFile = Paths.get(Utils.TEST_SRC).resolve(fileName + ".java");
|
||||
Path dstClassFile = Paths.get(".").resolve(fileName + ".class");
|
||||
byte[] compiledData = InMemoryJavaCompiler.compile("RedefineSubTarg",
|
||||
new String(Files.readAllBytes(srcJavaFile), StandardCharsets.UTF_8),
|
||||
"-g");
|
||||
Files.write(dstClassFile, compiledData);
|
||||
}
|
||||
|
||||
/********** test core **********/
|
||||
|
||||
protected void runTests() throws Exception {
|
||||
// prepare redefined .class files
|
||||
prepareRedefinedClass("Different_RedefineSubTarg");
|
||||
prepareRedefinedClass("SchemaChange_RedefineSubTarg");
|
||||
prepareRedefinedClass("RedefineSubTarg");
|
||||
|
||||
BreakpointEvent bpe = startToMain("RedefineTarg");
|
||||
targetClass = bpe.location().declaringType();
|
||||
|
@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2002, 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.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTJAVA=${TESTJAVA}"
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTCLASSES=${TESTCLASSES}"
|
||||
echo "CLASSPATH=${CLASSPATH}"
|
||||
|
||||
JAVAC="${TESTJAVA}/bin/javac"
|
||||
|
||||
cp ${TESTSRC}/Different_RedefineSubTarg.java RedefineSubTarg.java
|
||||
${JAVAC} -g RedefineSubTarg.java
|
||||
mv RedefineSubTarg.class Different_RedefineSubTarg.class
|
||||
rm -f RedefineSubTarg.java
|
||||
|
||||
cp ${TESTSRC}/RedefineSubTarg.java RedefineSubTarg.java
|
||||
${JAVAC} -g RedefineSubTarg.java
|
||||
rm -f RedefineSubTarg.java
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2018, 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
|
||||
@ -28,16 +28,23 @@
|
||||
* @author Robert Field
|
||||
*
|
||||
* @library ..
|
||||
* @library /test/lib
|
||||
*
|
||||
* @run build TestScaffold VMConnection TargetListener TargetAdapter
|
||||
* @run compile -g RedefineTest.java
|
||||
* @run shell RedefineSetUp.sh
|
||||
* @run driver RedefineTest -repeat 3
|
||||
* @run driver RedefineTest
|
||||
*/
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.*;
|
||||
import com.sun.jdi.request.*;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
@ -205,15 +212,9 @@ public class RedefineTest extends TestScaffold {
|
||||
}
|
||||
|
||||
|
||||
void doRedefine(String fileName) throws Exception {
|
||||
File phyl = new File(fileName);
|
||||
byte[] bytes = new byte[(int)phyl.length()];
|
||||
InputStream in = new FileInputStream(phyl);
|
||||
in.read(bytes);
|
||||
in.close();
|
||||
|
||||
void doRedefine(byte[] compiledClass) throws Exception {
|
||||
Map map = new HashMap();
|
||||
map.put(findReferenceType("RedefineSubTarg"), bytes);
|
||||
map.put(findReferenceType("RedefineSubTarg"), compiledClass);
|
||||
|
||||
try {
|
||||
for (int i = 0; i < redefineRepeat; ++i) {
|
||||
@ -240,9 +241,18 @@ public class RedefineTest extends TestScaffold {
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] compileRedefinedClass(String srcJavaFile) throws Exception {
|
||||
Path src = Paths.get(Utils.TEST_SRC).resolve(srcJavaFile);
|
||||
return InMemoryJavaCompiler.compile("RedefineSubTarg",
|
||||
new String(Files.readAllBytes(src), StandardCharsets.UTF_8),
|
||||
"-g", "-classpath", Utils.TEST_CLASSES);
|
||||
}
|
||||
|
||||
/********** test core **********/
|
||||
|
||||
protected void runTests() throws Exception {
|
||||
byte[] compiled_Different_RedefineSubTarg = compileRedefinedClass("Different_RedefineSubTarg.java");
|
||||
byte[] compiled_RedefineSubTarg = compileRedefinedClass("RedefineSubTarg.java");
|
||||
|
||||
startToMain("RedefineTarg");
|
||||
|
||||
@ -252,7 +262,7 @@ public class RedefineTest extends TestScaffold {
|
||||
checkFrames(thread, before);
|
||||
|
||||
println("------ After Redefine ------");
|
||||
doRedefine("Different_RedefineSubTarg.class");
|
||||
doRedefine(compiled_Different_RedefineSubTarg);
|
||||
checkFrames(thread, after);
|
||||
|
||||
println("------ Static 2 ------");
|
||||
@ -268,7 +278,7 @@ public class RedefineTest extends TestScaffold {
|
||||
checkFrames(thread, refresh);
|
||||
|
||||
println("------ Breakpoints ------");
|
||||
doRedefine("RedefineSubTarg.class");
|
||||
doRedefine(compiled_RedefineSubTarg);
|
||||
for (int i = 0; i < bps.length; ++i) {
|
||||
setBP(bps[i]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user