jdk/test/java/lang/instrument/RedefineMethodAddInvoke.sh
author shurailine
Tue, 27 Oct 2015 20:06:02 -0700
changeset 33402 1156d495a525
parent 30376 2ccf2cf7ea48
permissions -rw-r--r--
8140336: Add @modules for exported dependencies to jdk_core tests Reviewed-by: alanb, 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
#
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 23010
diff changeset
     2
# Copyright (c) 2008, 2015, 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
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    40
if [ "${COMPILEJAVA}" = "" ]
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    41
then
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    42
  COMPILEJAVA="${TESTJAVA}"
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    43
fi
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    44
echo "COMPILEJAVA=${COMPILEJAVA}"
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    45
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    46
if [ "${TESTSRC}" = "" ]
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 "TESTSRC 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
if [ "${TESTCLASSES}" = "" ]
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    53
then
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    54
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    55
  exit 1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    56
fi
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    57
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    58
JAVAC="${COMPILEJAVA}"/bin/javac
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    59
JAVA="${TESTJAVA}"/bin/java
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_1.java \
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    62
    RedefineMethodAddInvokeTarget.java
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    63
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . RedefineMethodAddInvokeTarget.java
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    64
mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_1.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    65
mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_1.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
cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_2.java \
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    68
    RedefineMethodAddInvokeTarget.java
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    69
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . RedefineMethodAddInvokeTarget.java
284
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    70
mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_2.java
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    71
mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_2.class
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    72
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    73
"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodAddInvokeAgent.jar \
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    74
    -classpath "${TESTCLASSES}" RedefineMethodAddInvokeApp > output.log 2>&1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    75
cat output.log
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    76
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    77
MESG="Exception"
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    78
grep "$MESG" output.log
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    79
result=$?
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    80
if [ "$result" = 0 ]; then
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    81
    echo "FAIL: found '$MESG' in the test output"
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    82
    result=1
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    83
else
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    84
    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
    85
    result=0
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    86
fi
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    87
14672d061f7a 6667089: 3/3 multiple redefinitions of a class break reflection
dcubed
parents:
diff changeset
    88
exit $result