TestCrossDelegate.sh revision 5116:d45bc4307996
1# 2# Copyright (c) 2009, 2010, 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# @test 24# @bug 4735126 25# @summary (cl) ClassLoader.loadClass locks all instances in chain 26# when delegating 27# 28# @run shell/timeout=300 TestCrossDelegate.sh 29 30# if running by hand on windows, change TESTSRC and TESTCLASSES to "." 31if [ "${TESTSRC}" = "" ] ; then 32 TESTSRC=`pwd` 33fi 34if [ "${TESTCLASSES}" = "" ] ; then 35 TESTCLASSES=`pwd` 36fi 37 38# if running by hand on windows, change this to appropriate value 39if [ "${TESTJAVA}" = "" ] ; then 40 echo "TESTJAVA not set. Test cannot execute." 41 echo "FAILED!!!" 42 exit 1 43fi 44 45# set platform-specific variables 46OS=`uname -s` 47case "$OS" in 48 SunOS ) 49 FS="/" 50 ;; 51 Linux ) 52 FS="/" 53 ;; 54 Darwin ) 55 FS="/" 56 ;; 57 Windows*) 58 FS="\\" 59 ;; 60 CYGWIN* ) 61 FS="\\" 62 TESTCLASSES=`/usr/bin/cygpath -a -s -m ${TESTCLASSES}` 63 ;; 64esac 65 66echo TESTSRC=${TESTSRC} 67echo TESTCLASSES=${TESTCLASSES} 68echo TESTJAVA=${TESTJAVA} 69echo "" 70 71# compile test 72${TESTJAVA}${FS}bin${FS}javac \ 73 -d ${TESTCLASSES} \ 74 ${TESTSRC}${FS}Starter.java ${TESTSRC}${FS}DelegatingLoader.java 75 76STATUS=$? 77if [ ${STATUS} -ne 0 ] 78then 79 exit ${STATUS} 80fi 81 82# set up test 83${TESTJAVA}${FS}bin${FS}javac \ 84 -d ${TESTCLASSES}${FS} \ 85 ${TESTSRC}${FS}Alice.java ${TESTSRC}${FS}SupBob.java \ 86 ${TESTSRC}${FS}Bob.java ${TESTSRC}${FS}SupAlice.java 87 88cd ${TESTCLASSES} 89DIRS="SA SB" 90for dir in $DIRS 91do 92 if [ -d ${dir} ]; then 93 rm -rf ${dir} 94 fi 95 mkdir ${dir} 96 mv com${dir} ${dir} 97done 98 99# run test 100${TESTJAVA}${FS}bin${FS}java \ 101 -verbose:class -XX:+TraceClassLoading -cp . \ 102 -Dtest.classes=${TESTCLASSES} \ 103 Starter cross 104# -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \ 105 106# save error status 107STATUS=$? 108 109# clean up 110rm -rf ${TESTCLASSES}${FS}SA ${TESTCLASSES}${FS}SB 111 112# return 113exit ${STATUS} 114