jdk/test/java/lang/instrument/RedefineMethodWithAnnotations.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:
16022
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     1
#
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 16924
diff changeset
     2
# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
16022
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     4
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     7
# published by the Free Software Foundation.
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     8
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    13
# accompanied this code).
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    14
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    18
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    21
# questions.
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    22
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    23
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    24
# @test
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    25
# @bug 7022100
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    26
# @summary Method annotations are incorrectly set when redefining classes.
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    27
# @author Stefan Karlsson
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    28
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    29
# @run shell MakeJAR3.sh RedefineMethodWithAnnotationsAgent 'Can-Redefine-Classes: true'
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    30
# @run build RedefineMethodWithAnnotationsTarget RedefineMethodWithAnnotationsApp RedefineMethodWithAnnotationsAnnotations
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    31
# @run shell RedefineMethodWithAnnotations.sh
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    32
#
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    33
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    34
if [ "${TESTJAVA}" = "" ]
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    35
then
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    36
  echo "TESTJAVA not set.  Test cannot execute.  Failed."
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    37
  exit 1
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    38
fi
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    39
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    40
if [ "${COMPILEJAVA}" = "" ]
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    41
then
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    42
  COMPILEJAVA="${TESTJAVA}"
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    43
fi
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    44
echo "COMPILEJAVA=${COMPILEJAVA}"
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    45
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    46
if [ "${TESTSRC}" = "" ]
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    47
then
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    48
  echo "TESTSRC not set.  Test cannot execute.  Failed."
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    49
  exit 1
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    50
fi
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    51
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    52
if [ "${TESTCLASSES}" = "" ]
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    53
then
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    54
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    55
  exit 1
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    56
fi
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    57
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    58
JAVAC="${COMPILEJAVA}"/bin/javac
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    59
JAVA="${TESTJAVA}"/bin/java
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    60
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    61
cp "${TESTSRC}"/RedefineMethodWithAnnotationsTarget_2.java \
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    62
    RedefineMethodWithAnnotationsTarget.java
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    63
cp "${TESTSRC}"/RedefineMethodWithAnnotationsAnnotations.java \
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    64
    RedefineMethodWithAnnotationsAnnotations.java
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    65
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    66
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    67
    RedefineMethodWithAnnotationsTarget.java \
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    68
    RedefineMethodWithAnnotationsAnnotations.java
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    69
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    70
"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodWithAnnotationsAgent.jar \
16924
8a86b4fa429b 8009531: Crash when redefining class with annotated method
coleenp
parents: 16022
diff changeset
    71
    -XX:+StressLdcRewrite -XX:+IgnoreUnrecognizedVMOptions \
16022
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    72
    -cp "${TESTCLASSES}" RedefineMethodWithAnnotationsApp > output.log 2>&1
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    73
cat output.log
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    74
16924
8a86b4fa429b 8009531: Crash when redefining class with annotated method
coleenp
parents: 16022
diff changeset
    75
MESG="Exception|fatal"
8a86b4fa429b 8009531: Crash when redefining class with annotated method
coleenp
parents: 16022
diff changeset
    76
egrep "$MESG" output.log
16022
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    77
result=$?
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    78
if [ "$result" = 0 ]; then
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    79
    echo "FAIL: found '$MESG' in the test output"
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    80
    result=1
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    81
else
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    82
    echo "PASS: did NOT find '$MESG' in the test output"
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    83
    result=0
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    84
fi
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    85
3f1545eccc6f 7140852: Add test for 7022100
stefank
parents:
diff changeset
    86
exit $result