New test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh (original) (raw)

1 # 2 # Copyright (c) 2013, 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 # @test 25 # @bug 7182152 26 # @summary Redefining a subclass that implements two interfaces is broken. 27 # @author Daniel D. Daugherty 28 # 29 # @run shell MakeJAR3.sh RedefineSubclassWithTwoInterfacesAgent 'Can-Redefine-Classes: true' 30 # @run build RedefineSubclassWithTwoInterfacesApp 31 # @run shell RedefineSubclassWithTwoInterfaces.sh 32 # 33 34 if [ "${TESTJAVA}" = "" ] 35 then 36 echo "TESTJAVA not set. Test cannot execute. Failed." 37 exit 1 38 fi 39 40 if [ "${TESTSRC}" = "" ] 41 then 42 echo "TESTSRC not set. Test cannot execute. Failed." 43 exit 1 44 fi 45 46 if [ "${TESTCLASSES}" = "" ] 47 then 48 echo "TESTCLASSES not set. Test cannot execute. Failed." 49 exit 1 50 fi 51 52 JAVAC="${TESTJAVA}"/bin/javac 53 JAVA="${TESTJAVA}"/bin/java 54 55 echo "INFO: building the replacement classes." 56 57 cp "${TESTSRC}"/RedefineSubclassWithTwoInterfacesTarget_1.java
58 RedefineSubclassWithTwoInterfacesTarget.java 59 cp "${TESTSRC}"/RedefineSubclassWithTwoInterfacesImpl_1.java
60 RedefineSubclassWithTwoInterfacesImpl.java 61 "${JAVAC}" -cp "${TESTCLASSES}" -d .
62 RedefineSubclassWithTwoInterfacesTarget.java
63 RedefineSubclassWithTwoInterfacesImpl.java 64 status="$?" 65 if [ "$status" != 0 ]; then 66 echo "FAIL: compile of *_1.java files failed." 67 exit "$status" 68 fi 69 70 mv RedefineSubclassWithTwoInterfacesTarget.java
71 RedefineSubclassWithTwoInterfacesTarget_1.java 72 mv RedefineSubclassWithTwoInterfacesTarget.class
73 RedefineSubclassWithTwoInterfacesTarget_1.class 74 mv RedefineSubclassWithTwoInterfacesImpl.java
75 RedefineSubclassWithTwoInterfacesImpl_1.java 76 mv RedefineSubclassWithTwoInterfacesImpl.class
77 RedefineSubclassWithTwoInterfacesImpl_1.class 78 79 echo "INFO: launching RedefineSubclassWithTwoInterfacesApp" 80 81 # TraceRedefineClasses options: 82 # 83 # 0x00000001 | 1 - name each target class before loading, after 84 # loading and after redefinition is completed 85 # 0x00000002 | 2 - print info if parsing, linking or 86 # verification throws an exception 87 # 0x00000004 | 4 - print timer info for the VM operation 88 # 0x00001000 | 4096 - detect calls to obsolete methods 89 # 0x00002000 | 8192 - fail a guarantee() in addition to detection 90 # 0x00004000 | 16384 - detect old/obsolete methods in metadata 91 # 0x00100000 | 1048576 - impl details: vtable updates 92 # 0x00200000 | 2097152 - impl details: itable updates 93 # 94 # 1+2+4+4096+8192+16384+1048576+2097152 == 3174407 95 96 "${JAVA}" ${TESTVMOPTS}
97 -XX:TraceRedefineClasses=3174407
98 -javaagent:RedefineSubclassWithTwoInterfacesAgent.jar
99 -classpath "${TESTCLASSES}"
100 RedefineSubclassWithTwoInterfacesApp > output.log 2>&1 101 status="$?" 102 cat output.log 103 if [ "$status" != 0 ]; then 104 echo "FAIL: RedefineSubclassWithTwoInterfacesApp failed." 105 exit "$status" 106 fi 107 108 MESG="guarantee" 109 grep "$MESG" output.log 110 result=$? 111 if [ "$result" = 0 ]; then 112 echo "FAIL: found '$MESG' in the test output" 113 result=1 114 else 115 echo "PASS: did NOT find '$MESG' in the test output" 116 result=0 117 fi 118 119 exit $result