VerifyLocalVariableTableOnRetransformTest.sh revision 12973:2e63fa2efdb1
1#
2# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
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#
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.
22#
23
24#
25
26# @test
27# @bug 7064927
28# @summary Verify LocalVariableTable (LVT) exists when passed to
29# transform() on a retransform operation.
30# @author Daniel D. Daugherty
31#
32# @run build VerifyLocalVariableTableOnRetransformTest
33# @run compile -g DummyClassWithLVT.java
34# @run shell MakeJAR.sh retransformAgent
35# @run shell VerifyLocalVariableTableOnRetransformTest.sh
36
37
38if [ "${TESTJAVA}" = "" ]
39then
40  echo "TESTJAVA not set.  Test cannot execute.  Failed."
41  exit 1
42fi
43
44if [ "${TESTSRC}" = "" ]
45then
46  echo "TESTSRC not set.  Test cannot execute.  Failed."
47  exit 1
48fi
49
50if [ "${TESTCLASSES}" = "" ]
51then
52  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
53  exit 1
54fi
55
56JAVA="${TESTJAVA}"/bin/java
57
58"${JAVA}" ${TESTVMOPTS} -Dtest.classes="${TESTCLASSES}" \
59    -javaagent:retransformAgent.jar \
60    -classpath "${TESTCLASSES}" \
61    VerifyLocalVariableTableOnRetransformTest \
62    VerifyLocalVariableTableOnRetransformTest \
63    > output.log 2>&1
64cat output.log
65
66MESG="did not match .class file"
67grep "$MESG" output.log
68result=$?
69if [ "$result" = 0 ]; then
70    echo "FAIL: found '$MESG' in the test output"
71
72    echo "INFO: 'javap -v' comparison between the .class files:"
73    ${JAVA}p -v -classpath "${TESTCLASSES}" DummyClassWithLVT > orig.javap
74    ${JAVA}p -v DummyClassWithLVT > mismatched.javap
75    diff orig.javap mismatched.javap
76
77    result=1
78else
79    echo "PASS: did NOT find '$MESG' in the test output"
80    result=0
81fi
82
83exit $result
84