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