8333130: MakeJAR2.sh uses hard-coded JDK version
Reviewed-by: lancea, darcy, sspitsyn, amenkov
This commit is contained in:
parent
1f09467230
commit
4369856c6d
@ -1,105 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2005, 2023, 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.
|
||||
#
|
||||
|
||||
|
||||
AGENT="$1"
|
||||
APP="$2"
|
||||
|
||||
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 [ "${COMPILEJAVA}" = "" ]
|
||||
then
|
||||
COMPILEJAVA="${TESTJAVA}"
|
||||
fi
|
||||
echo "COMPILEJAVA=${COMPILEJAVA}"
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
Linux )
|
||||
PATHSEP=":"
|
||||
;;
|
||||
|
||||
Windows* | CYGWIN*)
|
||||
PATHSEP=";"
|
||||
;;
|
||||
|
||||
# catch all other OSs
|
||||
* )
|
||||
echo "Unrecognized system! $OS"
|
||||
fail "Unrecognized system! $OS"
|
||||
;;
|
||||
esac
|
||||
|
||||
JAVAC="${COMPILEJAVA}/bin/javac -g"
|
||||
JAR="${COMPILEJAVA}/bin/jar"
|
||||
|
||||
cp ${TESTSRC}/${AGENT}.java .
|
||||
cp ${TESTSRC}/${APP}.java .
|
||||
rm -rf asmlib
|
||||
mkdir asmlib
|
||||
cp ${TESTSRC}/asmlib/*.java asmlib
|
||||
rm -rf bootpath
|
||||
mkdir -p bootpath/bootreporter
|
||||
cp ${TESTSRC}/bootreporter/*.java bootpath/bootreporter
|
||||
|
||||
cd bootpath
|
||||
${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} bootreporter/*.java
|
||||
cd ..
|
||||
|
||||
${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
|
||||
--enable-preview --release 23 \
|
||||
${AGENT}.java asmlib/*.java
|
||||
${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath .${PATHSEP}bootpath ${APP}.java
|
||||
|
||||
echo "Manifest-Version: 1.0" > ${AGENT}.mf
|
||||
echo Premain-Class: ${AGENT} >> ${AGENT}.mf
|
||||
echo Boot-Class-Path: bootpath >> ${AGENT}.mf
|
||||
shift 2
|
||||
while [ $# != 0 ] ; do
|
||||
echo $1 >> ${AGENT}.mf
|
||||
shift
|
||||
done
|
||||
|
||||
${JAR} ${TESTTOOLVMOPTS} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class asmlib/*.class
|
||||
|
||||
# rm -rf ${AGENT}.java asmlib ${AGENT}.mf ${AGENT}*.class
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2024, 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,20 +21,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6263319
|
||||
* @requires ((vm.opt.StartFlightRecording == null) | (vm.opt.StartFlightRecording == false)) & ((vm.opt.FlightRecorder == null) | (vm.opt.FlightRecorder == false))
|
||||
* @summary test setNativeMethodPrefix
|
||||
* @author Robert Field, Sun Microsystems
|
||||
*
|
||||
* @enablePreview
|
||||
* @modules java.management
|
||||
* java.instrument
|
||||
* @run shell/timeout=240 MakeJAR2.sh NativeMethodPrefixAgent NativeMethodPrefixApp 'Can-Retransform-Classes: true' 'Can-Set-Native-Method-Prefix: true'
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-CheckIntrinsics -javaagent:NativeMethodPrefixAgent.jar NativeMethodPrefixApp
|
||||
*/
|
||||
|
||||
import asmlib.Instrumentor;
|
||||
|
||||
import java.lang.constant.ClassDesc;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2024, 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,11 +22,30 @@
|
||||
*/
|
||||
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.lang.management.*;
|
||||
import bootreporter.*;
|
||||
|
||||
import bootreporter.*;
|
||||
import jdk.test.lib.helpers.ClassFileInstaller;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6263319
|
||||
* @summary test setNativeMethodPrefix
|
||||
* @requires ((vm.opt.StartFlightRecording == null) | (vm.opt.StartFlightRecording == false)) & ((vm.opt.FlightRecorder == null) | (vm.opt.FlightRecorder == false))
|
||||
* @modules java.management
|
||||
* java.instrument
|
||||
* @library /test/lib
|
||||
* @build bootreporter.StringIdCallback bootreporter.StringIdCallbackReporter
|
||||
* asmlib.Instrumentor NativeMethodPrefixAgent
|
||||
* @enablePreview
|
||||
* @comment The test uses asmlib/Instrumentor.java which relies on ClassFile API PreviewFeature.
|
||||
* @run driver/timeout=240 NativeMethodPrefixApp roleDriver
|
||||
* @comment The test uses a higher timeout to prevent test timeouts noted in JDK-6528548
|
||||
*/
|
||||
public class NativeMethodPrefixApp implements StringIdCallback {
|
||||
|
||||
// This test is fragile like a golden file test.
|
||||
@ -34,13 +53,56 @@ public class NativeMethodPrefixApp implements StringIdCallback {
|
||||
// native method. The below may need to be updated based on library changes.
|
||||
static String goldenNativeMethodName = "getStartupTime";
|
||||
|
||||
static boolean gotIt[] = {false, false, false};
|
||||
static boolean[] gotIt = {false, false, false};
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
(new NativeMethodPrefixApp()).run(args, System.err);
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length == 1) {
|
||||
if (!"roleDriver".equals(args[0])) {
|
||||
throw new Exception("unexpected program argument: " + args[0]);
|
||||
}
|
||||
// launch the NativeMethodPrefixApp java process after creating the necessary
|
||||
// infrastructure
|
||||
System.out.println("creating agent jar");
|
||||
final Path agentJar = createAgentJar();
|
||||
System.out.println("launching app, with javaagent jar: " + agentJar);
|
||||
launchApp(agentJar);
|
||||
} else {
|
||||
System.err.println("running app");
|
||||
new NativeMethodPrefixApp().run();
|
||||
}
|
||||
}
|
||||
|
||||
public void run(String args[], PrintStream out) throws Exception {
|
||||
private static Path createAgentJar() throws Exception {
|
||||
final String testClassesDir = System.getProperty("test.classes");
|
||||
final Path agentJar = Path.of("NativeMethodPrefixAgent.jar");
|
||||
final String manifest = """
|
||||
Manifest-Version: 1.0
|
||||
Premain-Class: NativeMethodPrefixAgent
|
||||
Can-Retransform-Classes: true
|
||||
Can-Set-Native-Method-Prefix: true
|
||||
"""
|
||||
+ "Boot-Class-Path: " + testClassesDir.replace(File.separatorChar, '/') + "/"
|
||||
+ "\n";
|
||||
System.out.println("Manifest is:\n" + manifest);
|
||||
// create the agent jar
|
||||
ClassFileInstaller.writeJar(agentJar.getFileName().toString(),
|
||||
ClassFileInstaller.Manifest.fromString(manifest),
|
||||
"NativeMethodPrefixAgent",
|
||||
"asmlib.Instrumentor");
|
||||
return agentJar;
|
||||
}
|
||||
|
||||
private static void launchApp(final Path agentJar) throws Exception {
|
||||
final OutputAnalyzer oa = ProcessTools.executeTestJava(
|
||||
"--enable-preview", // due to usage of ClassFile API PreviewFeature in the agent
|
||||
"-javaagent:" + agentJar.toString(),
|
||||
NativeMethodPrefixApp.class.getName());
|
||||
oa.shouldHaveExitValue(0);
|
||||
// make available stdout/stderr in the logs, even in case of successful completion
|
||||
oa.reportDiagnosticSummary();
|
||||
}
|
||||
|
||||
private void run() throws Exception {
|
||||
StringIdCallbackReporter.registerCallback(this);
|
||||
System.err.println("start");
|
||||
|
||||
@ -57,6 +119,7 @@ public class NativeMethodPrefixApp implements StringIdCallback {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tracker(String name, int id) {
|
||||
if (name.endsWith(goldenNativeMethodName)) {
|
||||
System.err.println("Tracked #" + id + ": MATCHED -- " + name);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2024, 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,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6274264 6274241 5070281
|
||||
* @summary test retransformClasses
|
||||
* @author Robert Field, Sun Microsystems
|
||||
*
|
||||
* @enablePreview
|
||||
* @modules java.instrument
|
||||
* @run shell/timeout=240 MakeJAR2.sh RetransformAgent RetransformApp 'Can-Retransform-Classes: true'
|
||||
* @run main/othervm -javaagent:RetransformAgent.jar RetransformApp
|
||||
*/
|
||||
|
||||
import java.lang.constant.ClassDesc;
|
||||
import java.lang.constant.MethodTypeDesc;
|
||||
import java.lang.instrument.*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2024, 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
|
||||
@ -23,19 +23,74 @@
|
||||
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.helpers.ClassFileInstaller;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6274264 6274241 5070281
|
||||
* @summary test retransformClasses
|
||||
*
|
||||
* @modules java.instrument
|
||||
* @library /test/lib
|
||||
* @build RetransformAgent asmlib.Instrumentor
|
||||
* @enablePreview
|
||||
* @comment The test uses asmlib/Instrumentor.java which relies on ClassFile API PreviewFeature.
|
||||
* @run driver/timeout=240 RetransformApp roleDriver
|
||||
* @comment The test uses a higher timeout to prevent test timeouts noted in JDK-6528548
|
||||
*/
|
||||
public class RetransformApp {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
(new RetransformApp()).run(args, System.out);
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length == 1) {
|
||||
if (!"roleDriver".equals(args[0])) {
|
||||
throw new Exception("unexpected program argument: " + args[0]);
|
||||
}
|
||||
// launch the RetransformApp java process after creating the necessary
|
||||
// infrastructure
|
||||
System.out.println("creating agent jar");
|
||||
final Path agentJar = createAgentJar();
|
||||
System.out.println("launching app, with javaagent jar: " + agentJar);
|
||||
launchApp(agentJar);
|
||||
} else {
|
||||
System.err.println("running app");
|
||||
new RetransformApp().run(System.out);
|
||||
}
|
||||
}
|
||||
|
||||
private static Path createAgentJar() throws Exception {
|
||||
Path agentJar = Path.of("RetransformAgent.jar");
|
||||
final String manifest = """
|
||||
Manifest-Version: 1.0
|
||||
Premain-Class: RetransformAgent
|
||||
Can-Retransform-Classes: true
|
||||
""";
|
||||
System.out.println("Manifest is:\n" + manifest);
|
||||
ClassFileInstaller.writeJar(agentJar.getFileName().toString(),
|
||||
ClassFileInstaller.Manifest.fromString(manifest),
|
||||
"RetransformAgent",
|
||||
"asmlib.Instrumentor");
|
||||
return agentJar;
|
||||
}
|
||||
|
||||
private static void launchApp(final Path agentJar) throws Exception {
|
||||
final OutputAnalyzer oa = ProcessTools.executeTestJava(
|
||||
"--enable-preview", // due to usage of ClassFile API PreviewFeature in the agent
|
||||
"-javaagent:" + agentJar.toString(),
|
||||
RetransformApp.class.getName());
|
||||
oa.shouldHaveExitValue(0);
|
||||
// make available stdout/stderr in the logs, even in case of successful completion
|
||||
oa.reportDiagnosticSummary();
|
||||
}
|
||||
|
||||
int foo(int x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
public void run(String args[], PrintStream out) throws Exception {
|
||||
public void run(PrintStream out) throws Exception {
|
||||
out.println("start");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (foo(3) != 9) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user