jdk/test/java/lang/instrument/RetransformBigClass.sh
author dcubed
Thu, 22 Dec 2011 18:35:48 -0800
changeset 11359 9e53808b2128
child 15254 3997a6f357cb
permissions -rw-r--r--
7121600: Instrumentation.redefineClasses() leaks class bytes Summary: Call JNI ReleaseByteArrayElements() on memory returned by JNI GetByteArrayElements(). Also push test for 7122253. Reviewed-by: acorn, poonam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11359
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     1
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     2
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     4
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     7
# published by the Free Software Foundation.
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     8
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    13
# accompanied this code).
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    14
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    18
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    21
# questions.
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    22
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    23
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    24
# @test
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    25
# @bug 7122253
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    26
# @ignore until the fix for 7122253 (from HotSpot) is in a promoted build
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    27
# @summary Retransform a big class.
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    28
# @author Daniel D. Daugherty
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    29
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    30
# @run shell MakeJAR4.sh RetransformBigClassAgent SimpleIdentityTransformer 'Can-Retransform-Classes: true'
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    31
# @run build BigClass RetransformBigClassApp
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    32
# @run shell/timeout=600 RetransformBigClass.sh
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    33
#
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    34
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    35
if [ "${TESTJAVA}" = "" ]
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    36
then
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    37
  echo "TESTJAVA not set.  Test cannot execute.  Failed."
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    38
  exit 1
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    39
fi
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    40
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    41
if [ "${TESTSRC}" = "" ]
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    42
then
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    43
  echo "TESTSRC not set.  Test cannot execute.  Failed."
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    44
  exit 1
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    45
fi
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    46
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    47
if [ "${TESTCLASSES}" = "" ]
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    48
then
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    49
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    50
  exit 1
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    51
fi
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    52
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    53
JAVAC="${TESTJAVA}"/bin/javac
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    54
JAVA="${TESTJAVA}"/bin/java
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    55
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    56
"${JAVA}" ${TESTVMOPTS} \
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    57
    -XX:TraceRedefineClasses=3 \
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    58
    -javaagent:RetransformBigClassAgent.jar=BigClass.class \
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    59
    -classpath "${TESTCLASSES}" RetransformBigClassApp \
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    60
    > output.log 2>&1
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    61
result=$?
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    62
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    63
cat output.log
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    64
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    65
if [ "$result" = 0 ]; then
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    66
    echo "PASS: RetransformBigClassApp exited with status of 0."
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    67
else
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    68
    echo "FAIL: RetransformBigClassApp exited with status of $result"
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    69
    exit "$result"
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    70
fi
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    71
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    72
MESG="Exception"
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    73
grep "$MESG" output.log
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    74
result=$?
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    75
if [ "$result" = 0 ]; then
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    76
    echo "FAIL: found '$MESG' in the test output"
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    77
    result=1
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    78
else
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    79
    echo "PASS: did NOT find '$MESG' in the test output"
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    80
    result=0
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    81
fi
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    82
9e53808b2128 7121600: Instrumentation.redefineClasses() leaks class bytes
dcubed
parents:
diff changeset
    83
exit $result