author | mockner |
Tue, 02 Feb 2016 17:14:00 -0500 | |
changeset 35960 | fa7c192f3df9 |
parent 33402 | 1156d495a525 |
child 38345 | c4e8f0e57f7b |
permissions | -rw-r--r-- |
2 | 1 |
# |
35960
fa7c192f3df9
8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents:
33402
diff
changeset
|
2 |
# Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
# |
|
5 |
# This code is free software; you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
|
7 |
# published by the Free Software Foundation. |
|
8 |
# |
|
9 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
# accompanied this code). |
|
14 |
# |
|
15 |
# You should have received a copy of the GNU General Public License version |
|
16 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
# |
|
5506 | 19 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
# or visit www.oracle.com if you need additional information or have any |
|
21 |
# questions. |
|
2 | 22 |
# |
23 |
||
24 |
# @test |
|
25 |
# @bug 6173575 |
|
26 |
# @summary Unit tests for appendToBootstrapClassLoaderSearch and |
|
27 |
# appendToSystemClasLoaderSearch methods. |
|
28 |
# |
|
29 |
# @build ClassUnloadTest |
|
30 |
# @run shell ClassUnloadTest.sh |
|
31 |
||
32 |
if [ "${TESTSRC}" = "" ] |
|
33 |
then |
|
34 |
echo "TESTSRC not set. Test cannot execute. Failed." |
|
35 |
exit 1 |
|
36 |
fi |
|
276
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
37 |
|
2 | 38 |
. ${TESTSRC}/CommonSetup.sh |
39 |
||
40 |
# Create Foo and Bar |
|
276
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
41 |
# Foo has a reference to Bar but we deleted Bar so that |
2 | 42 |
# a NoClassDefFoundError will be thrown when Foo tries to |
43 |
# resolve the reference to Bar |
|
44 |
||
45 |
OTHERDIR="${TESTCLASSES}"/other |
|
46 |
mkdir "${OTHERDIR}" |
|
47 |
||
48 |
FOO="${OTHERDIR}"/Foo.java |
|
49 |
BAR="${OTHERDIR}"/Bar.java |
|
50 |
rm -f "${FOO}" "${BAR}" |
|
51 |
||
52 |
cat << EOF > "${FOO}" |
|
53 |
public class Foo { |
|
54 |
public static boolean doSomething() { |
|
55 |
try { |
|
276
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
56 |
Bar b = new Bar(); |
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
57 |
return true; |
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
58 |
} catch (NoClassDefFoundError x) { |
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
59 |
return false; |
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
60 |
} |
2 | 61 |
} |
62 |
} |
|
63 |
EOF |
|
64 |
||
65 |
echo "public class Bar { }" > "${BAR}" |
|
66 |
||
67 |
(cd "${OTHERDIR}"; \ |
|
15254
3997a6f357cb
8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents:
5506
diff
changeset
|
68 |
$JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Foo.java Bar.java; \ |
3997a6f357cb
8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents:
5506
diff
changeset
|
69 |
$JAR ${TESTTOOLVMOPTS} cf "${OTHERDIR}"/Bar.jar Bar.class; \ |
2 | 70 |
rm -f Bar.class) |
71 |
||
72 |
# Create the manifest |
|
73 |
MANIFEST="${TESTCLASSES}"/agent.mf |
|
74 |
rm -f "${MANIFEST}" |
|
75 |
echo "Premain-Class: ClassUnloadTest" > "${MANIFEST}" |
|
76 |
||
77 |
# Setup test case as an agent |
|
15254
3997a6f357cb
8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents:
5506
diff
changeset
|
78 |
$JAR ${TESTTOOLVMOPTS} -cfm "${TESTCLASSES}"/ClassUnloadTest.jar "${MANIFEST}" \ |
2 | 79 |
-C "${TESTCLASSES}" ClassUnloadTest.class |
80 |
||
81 |
# Finally we run the test |
|
82 |
(cd "${TESTCLASSES}"; \ |
|
35960
fa7c192f3df9
8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents:
33402
diff
changeset
|
83 |
$JAVA ${TESTVMOPTS} -Xverify:none -Xlog:classunload \ |
276
57cf064fc997
6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents:
2
diff
changeset
|
84 |
-javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar) |