Skip to content

Commit 6dac15d

Browse files
committed
Fix test for JDK 8
1 parent 874b60c commit 6dac15d

File tree

3 files changed

+85
-11
lines changed

3 files changed

+85
-11
lines changed

hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.java renamed to hotspot/test/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGenerated.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,15 +21,7 @@
2121
* questions.
2222
*/
2323

24-
/*
25-
* @test
26-
* @bug 8212155
27-
* @summary Test concurrent enabling and posting of DynamicCodeGenerated events.
28-
* @library /test/lib
29-
* @run main/othervm/native -agentlib:DynamicCodeGenerated DynamicCodeGeneratedTest
30-
*/
31-
32-
public class DynamicCodeGeneratedTest {
24+
public class DynamicCodeGenerated {
3325
static {
3426
System.loadLibrary("DynamicCodeGenerated");
3527
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
4+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
#
6+
# This code is free software; you can redistribute it and/or modify it
7+
# under the terms of the GNU General Public License version 2 only, as
8+
# published by the Free Software Foundation.
9+
#
10+
# This code is distributed in the hope that it will be useful, but WITHOUT
11+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
# version 2 for more details (a copy is included in the LICENSE file that
14+
# accompanied this code).
15+
#
16+
# You should have received a copy of the GNU General Public License version
17+
# 2 along with this work; if not, write to the Free Software Foundation,
18+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
#
20+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
# or visit www.oracle.com if you need additional information or have any
22+
# questions.
23+
24+
# @test DynamicCodeGeneratedTest.sh
25+
# @bug 8212155
26+
# @summary Test concurrent enabling and posting of DynamicCodeGenerated events.
27+
# @run shell DynamicCodeGeneratedTest.sh
28+
29+
if [ "$TESTSRC" = "" ]
30+
then TESTSRC=.
31+
fi
32+
33+
if [ "$TESTJAVA" = "" ]
34+
then
35+
PARENT=$(dirname $(which java))
36+
TESTJAVA=$(dirname $PARENT)
37+
echo "TESTJAVA not set, selecting " $TESTJAVA
38+
echo "If this is incorrect, try setting the variable manually."
39+
fi
40+
41+
# set platform-dependent variables
42+
OS=$(uname -s)
43+
case "$OS" in
44+
Linux )
45+
ARCHFLAG=
46+
$TESTJAVA/bin/java -version 2>&1 | grep '64-Bit' > /dev/null
47+
if [ $? -eq '0' ]
48+
then
49+
ARCH="amd64"
50+
else
51+
ARCH="i386"
52+
ARCHFLAG="-m32 -march=i386"
53+
fi
54+
;;
55+
* )
56+
echo "Test passed, unrecognized system."
57+
exit 0;
58+
;;
59+
esac
60+
61+
echo "OS-ARCH is" linux-$ARCH
62+
$TESTJAVA/jre/bin/java -fullversion 2>&1
63+
64+
which gcc >/dev/null 2>&1
65+
if [ "$?" -ne '0' ]
66+
then
67+
echo "No C compiler found. Test passed."
68+
exit 0
69+
fi
70+
71+
JAVA=$TESTJAVA/jre/bin/java
72+
JAVAC=$TESTJAVA/bin/javac
73+
JAVAH=$TESTJAVA/bin/javah
74+
75+
$JAVAC -d . $TESTSRC/DynamicCodeGenerated.java
76+
$JAVAH -jni -classpath . -d . DynamicCodeGenerated
77+
78+
gcc --shared $ARCHFLAG -fPIC -O -I$TESTJAVA/include -I$TESTJAVA/include/linux -I. -o libDynamicCodeGenerated.so $TESTSRC/libDynamicCodeGenerated.cpp
79+
80+
LD_LIBRARY_PATH=. $JAVA -classpath . -agentlib:DynamicCodeGenerated DynamicCodeGenerated
81+
82+
exit $?

hotspot/test/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern "C" {
3131
#endif
3232

3333
JNIEXPORT
34-
void JNICALL Java_DynamicCodeGeneratedTest_changeEventNotificationMode(JNIEnv* jni, jclass cls) {
34+
void JNICALL Java_DynamicCodeGenerated_changeEventNotificationMode(JNIEnv* jni, jclass cls) {
3535
while (true) {
3636
jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL);
3737
jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL);

0 commit comments

Comments
 (0)