Skip to content

Commit

Permalink
8319578: Few java/lang/instrument ignore test.java.opts and accept te…
Browse files Browse the repository at this point in the history
…st.vm.opts only

Reviewed-by: kevinw, cjplummer
  • Loading branch information
lmesnik committed Feb 9, 2024
1 parent d39b7ba commit 3ebe6c1
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004, 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
Expand Down Expand Up @@ -74,7 +74,7 @@ case ${OS} in
;;
esac

"$JAVA" ${TESTVMOPTS} -classpath "${TESTCLASSES}" Setup "${TESTCLASSES}" Agent "${CYGWIN}"
"$JAVA" ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath "${TESTCLASSES}" Setup "${TESTCLASSES}" Agent "${CYGWIN}"

BOOTDIR=`cat ${TESTCLASSES}/boot.dir`

Expand All @@ -94,13 +94,13 @@ echo "Creating agent jar file..."

echo "Running test..."

"${JAVA}" ${TESTVMOPTS} -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
result=$?

echo "Cleanup..."

"$JAVAC" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" \
"${TESTSRC}"/Cleanup.java
"$JAVA" ${TESTVMOPTS} -classpath "${TESTCLASSES}" Cleanup "${BOOTDIR}"
"$JAVA" ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath "${TESTCLASSES}" Cleanup "${BOOTDIR}"

exit $result
4 changes: 2 additions & 2 deletions test/jdk/java/lang/instrument/ManifestTest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2008, 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
Expand Down Expand Up @@ -380,7 +380,7 @@ while read token; do
echo "===== begin test case: $token ====="
make_a_JAR "$token"

"${JAVA}" ${TESTVMOPTS} -javaagent:${AGENT}.jar \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:${AGENT}.jar \
-classpath "${TESTCLASSES}" ManifestTestApp > output.log 2>&1
result=$?

Expand Down
6 changes: 3 additions & 3 deletions test/jdk/java/lang/instrument/RedefineBigClass.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
Expand Down Expand Up @@ -62,14 +62,14 @@ JAVAC="${COMPILEJAVA}"/bin/javac
JAVA="${TESTJAVA}"/bin/java

# Does this VM support the 'detail' level of NMT?
"${JAVA}" ${TESTVMOPTS} -XX:NativeMemoryTracking=detail -version
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -XX:NativeMemoryTracking=detail -version
if [ "$?" = 0 ]; then
NMT=-XX:NativeMemoryTracking=detail
else
NMT=-XX:NativeMemoryTracking=summary
fi

"${JAVA}" ${TESTVMOPTS} \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} \
-Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \
-javaagent:RedefineBigClassAgent.jar=BigClass.class \
-classpath "${TESTCLASSES}" RedefineBigClassApp \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2008, 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
Expand Down Expand Up @@ -58,7 +58,7 @@ fi
JAVAC="${COMPILEJAVA}"/bin/javac
JAVA="${TESTJAVA}"/bin/java

"${JAVA}" ${TESTVMOPTS} \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} \
-javaagent:RedefineClassWithNativeMethodAgent.jar=java/lang/Thread.class \
-classpath "${TESTCLASSES}" RedefineClassWithNativeMethodApp \
> output.log 2>&1
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/lang/instrument/RedefineMethodAddInvoke.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2008, 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
Expand Down Expand Up @@ -70,7 +70,7 @@ cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_2.java \
mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_2.java
mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_2.class

"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodAddInvokeAgent.jar \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:RedefineMethodAddInvokeAgent.jar \
-XX:+AllowRedefinitionToAddDeleteMethods \
-classpath "${TESTCLASSES}" RedefineMethodAddInvokeApp > output.log 2>&1
cat output.log
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/lang/instrument/RedefineMethodDelInvoke.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 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
Expand Down Expand Up @@ -71,7 +71,7 @@ cp "${TESTSRC}"/RedefineMethodDelInvokeTarget_2.java \
mv RedefineMethodDelInvokeTarget.java RedefineMethodDelInvokeTarget_2.java
mv RedefineMethodDelInvokeTarget.class RedefineMethodDelInvokeTarget_2.class

"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodDelInvokeAgent.jar \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:RedefineMethodDelInvokeAgent.jar \
-XX:+AllowRedefinitionToAddDeleteMethods \
-classpath "${TESTCLASSES}" RedefineMethodDelInvokeApp > output.log 2>&1

Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/lang/instrument/RedefineMethodInBacktrace.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 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
Expand Down Expand Up @@ -68,7 +68,7 @@ cp "${TESTSRC}"/RedefineMethodInBacktraceTargetB_2.java \
RedefineMethodInBacktraceTargetB.java
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . RedefineMethodInBacktraceTargetB.java

"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodInBacktraceAgent.jar \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:RedefineMethodInBacktraceAgent.jar \
-XX:+AllowRedefinitionToAddDeleteMethods \
-classpath "${TESTCLASSES}" RedefineMethodInBacktraceApp > output.log 2>&1
RUN_RESULT=$?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 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
Expand Down Expand Up @@ -67,7 +67,7 @@ cp "${TESTSRC}"/RedefineMethodWithAnnotationsAnnotations.java \
RedefineMethodWithAnnotationsTarget.java \
RedefineMethodWithAnnotationsAnnotations.java

"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodWithAnnotationsAgent.jar \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:RedefineMethodWithAnnotationsAgent.jar \
-XX:+UnlockDiagnosticVMOptions -XX:+StressLdcRewrite -XX:+IgnoreUnrecognizedVMOptions \
-cp "${TESTCLASSES}" RedefineMethodWithAnnotationsApp > output.log 2>&1
cat output.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 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
Expand Down Expand Up @@ -69,7 +69,7 @@ cp "${TESTSRC}"/RedefineSubclassWithTwoInterfacesImpl_1.java \
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
-cp "${TESTCLASSES}" -d . \
RedefineSubclassWithTwoInterfacesTarget.java \
RedefineSubclassWithTwoInterfacesImpl.java
RedefineSubclassWithTwoInterfacesImpl.java
status="$?"
if [ "$status" != 0 ]; then
echo "FAIL: compile of *_1.java files failed."
Expand All @@ -87,7 +87,7 @@ mv RedefineSubclassWithTwoInterfacesImpl.class \

echo "INFO: launching RedefineSubclassWithTwoInterfacesApp"

"${JAVA}" ${TESTVMOPTS} \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} \
-Xlog:redefine+class+load=trace,redefine+class+load+exceptions=trace,redefine+class+timer=trace,redefine+class+obsolete=trace,redefine+class+obsolete+metadata=trace,redefine+class+constantpool=trace \
-javaagent:RedefineSubclassWithTwoInterfacesAgent.jar \
-classpath "${TESTCLASSES}" \
Expand Down
6 changes: 3 additions & 3 deletions test/jdk/java/lang/instrument/RetransformBigClass.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
Expand Down Expand Up @@ -62,14 +62,14 @@ JAVAC="${COMPILEJAVA}"/bin/javac
JAVA="${TESTJAVA}"/bin/java

# Does this VM support the 'detail' level of NMT?
"${JAVA}" ${TESTVMOPTS} -XX:NativeMemoryTracking=detail -version
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -XX:NativeMemoryTracking=detail -version
if [ "$?" = 0 ]; then
NMT=-XX:NativeMemoryTracking=detail
else
NMT=-XX:NativeMemoryTracking=summary
fi

"${JAVA}" ${TESTVMOPTS} \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} \
-Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \
-javaagent:RetransformBigClassAgent.jar=BigClass.class \
-classpath "${TESTCLASSES}" RetransformBigClassApp \
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/lang/instrument/StressGetObjectSizeTest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2008, 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
Expand Down Expand Up @@ -51,7 +51,7 @@ fi

JAVA="${TESTJAVA}"/bin/java

"${JAVA}" ${TESTVMOPTS} -javaagent:basicAgent.jar \
"${JAVA}" ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:basicAgent.jar \
-classpath "${TESTCLASSES}" StressGetObjectSizeApp StressGetObjectSizeApp \
> output.log 2>&1
cat output.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2015, 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
Expand Down Expand Up @@ -77,4 +77,4 @@ $JAR ${TESTTOOLVMOPTS} -cfm "${TESTCLASSES}"/CircularityErrorTest.jar "${MANIFES

# Finally we run the test
(cd "${TESTCLASSES}";
$JAVA ${TESTVMOPTS} -javaagent:CircularityErrorTest.jar CircularityErrorTest)
$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:CircularityErrorTest.jar CircularityErrorTest)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2019, 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
Expand Down Expand Up @@ -80,5 +80,5 @@ $JAR ${TESTTOOLVMOPTS} -cfm "${TESTCLASSES}"/ClassUnloadTest.jar "${MANIFEST}" \

# Finally we run the test
(cd "${TESTCLASSES}"; \
$JAVA ${TESTVMOPTS} -Xlog:class+unload \
$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -Xlog:class+unload \
-javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright (c) 2005, 2015, 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
Expand Down Expand Up @@ -56,7 +56,7 @@ failures=0

go() {
echo ''
sh -xc "$JAVA ${TESTVMOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1
sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
}

Expand Down Expand Up @@ -85,11 +85,11 @@ mv Application.class InstrumentedApplication.bytes
cp "${TESTSRC}"/Application.java .
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . Application.java

sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1
sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi

# Repeat test with security manager
sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1
sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi

#
Expand Down

3 comments on commit 3ebe6c1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 3ebe6c1 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 3ebe6c1 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-3ebe6c19 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 3ebe6c19 from the openjdk/jdk repository.

The commit being backported was authored by Leonid Mesnik on 9 Feb 2024 and was reviewed by Kevin Walls and Chris Plummer.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-3ebe6c19:backport-GoeLin-3ebe6c19
$ git checkout backport-GoeLin-3ebe6c19
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-3ebe6c19

Please sign in to comment.