jdk/test/java/lang/instrument/RedefineMethodAddInvoke.sh
author chegar
Tue, 09 Aug 2011 16:39:04 +0100
changeset 10150 dee4cb73adc3
parent 5506 202f599c92aa
child 15254 3997a6f357cb
permissions -rw-r--r--
7073295: TEST_BUG: test/java/lang/instrument/ManifestTest.sh causing havoc (win) Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     1
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 284
diff changeset
     2
# Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     4
#
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     7
# published by the Free Software Foundation.
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     8
#
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    13
# accompanied this code).
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    14
#
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    18
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 284
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 284
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 284
diff changeset
    21
# questions.
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    22
#
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    23
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    24
# @test
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    25
# @bug 6667089
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    26
# @summary Reflexive invocation of newly added methods broken.
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    27
# @author Daniel D. Daugherty
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    28
#
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    29
# @run shell MakeJAR3.sh RedefineMethodAddInvokeAgent 'Can-Redefine-Classes: true'
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    30
# @run build RedefineMethodAddInvokeApp
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    31
# @run shell RedefineMethodAddInvoke.sh
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    32
#
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    33
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    34
if [ "${TESTJAVA}" = "" ]
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    35
then
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    36
  echo "TESTJAVA not set.  Test cannot execute.  Failed."
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    37
  exit 1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    38
fi
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    39
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    40
if [ "${TESTSRC}" = "" ]
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    41
then
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    42
  echo "TESTSRC not set.  Test cannot execute.  Failed."
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    43
  exit 1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    44
fi
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    45
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    46
if [ "${TESTCLASSES}" = "" ]
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    47
then
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    48
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    49
  exit 1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    50
fi
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    51
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    52
JAVAC="${TESTJAVA}"/bin/javac
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    53
JAVA="${TESTJAVA}"/bin/java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    54
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    55
cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_1.java \
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    56
    RedefineMethodAddInvokeTarget.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    57
"${JAVAC}" -d . RedefineMethodAddInvokeTarget.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    58
mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_1.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    59
mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_1.class
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    60
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    61
cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_2.java \
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    62
    RedefineMethodAddInvokeTarget.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    63
"${JAVAC}" -d . RedefineMethodAddInvokeTarget.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    64
mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_2.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    65
mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_2.class
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    66
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    67
"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodAddInvokeAgent.jar \
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    68
    -classpath "${TESTCLASSES}" RedefineMethodAddInvokeApp > output.log 2>&1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    69
cat output.log
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    70
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    71
MESG="Exception"
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    72
grep "$MESG" output.log
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    73
result=$?
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    74
if [ "$result" = 0 ]; then
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    75
    echo "FAIL: found '$MESG' in the test output"
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    76
    result=1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    77
else
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    78
    echo "PASS: did NOT find '$MESG' in the test output"
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    79
    result=0
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    80
fi
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    81
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    82
exit $result