Deadlock2.sh revision 4638
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#!/bin/sh
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington
ae871ebb28959bed920cc96cd9e91063b6625b78Mark Andrews#
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
ae871ebb28959bed920cc96cd9e91063b6625b78Mark Andrews# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington#
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# This code is free software; you can redistribute it and/or modify it
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# under the terms of the GNU General Public License version 2 only, as
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# published by the Free Software Foundation.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# This code is distributed in the hope that it will be useful, but WITHOUT
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# version 2 for more details (a copy is included in the LICENSE file that
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# accompanied this code).
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# You should have received a copy of the GNU General Public License version
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# 2 along with this work; if not, write to the Free Software Foundation,
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# or visit www.oracle.com if you need additional information or have any
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# questions.
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews#
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# @test
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews# @bug 6440846
6d100ee72e4a47dd9855d7a7d7d4509c5cd88c65Bob Halley# @summary make sure we do not deadlock between ExtClassLoader and AppClassLoader
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# @author Valerie Peng
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# @run shell/timeout=20 Deadlock2.sh
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# set a few environment variables so that the shell-script can run stand-alone
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# in the source directory
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrewsif [ "${TESTSRC}" = "" ] ; then
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews TESTSRC="."
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyfi
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyif [ "${TESTCLASSES}" = "" ] ; then
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley TESTCLASSES="."
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyfi
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyif [ "${TESTJAVA}" = "" ] ; then
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley echo "TESTJAVA not set. Test cannot execute."
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley echo "FAILED!!!"
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley exit 1
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyfi
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# set platform-dependent variables
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob HalleyOS=`uname -s`
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleycase "$OS" in
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington SunOS )
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley PATHSEP=":"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington FILESEP="/"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ;;
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington Linux )
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington PATHSEP=":"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington FILESEP="/"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ;;
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington Darwin )
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington PATHSEP=":"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington FILESEP="/"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ;;
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington Windows* )
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington PATHSEP=";"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington FILESEP="\\"
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ;;
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington * )
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington echo "Unrecognized system!"
ae871ebb28959bed920cc96cd9e91063b6625b78Mark Andrews exit 1;
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ;;
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonesac
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington# remove old class files
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtoncd ${TESTCLASSES}
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonif [ -d testlib ] ; then
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington rm -rf testlib
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonfi
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonif [ -d ${TESTJAVA}${FILESEP}lib${FILESEP}ext ] ; then
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington cp -r ${TESTJAVA}${FILESEP}lib${FILESEP}ext testlib
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonelse
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews cp -r ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext testlib
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonfi
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington# compile and package the test program
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews${TESTJAVA}${FILESEP}bin${FILESEP}javac \
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington -d ${TESTCLASSES} \
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ${TESTSRC}${FILESEP}CreateSerialized.java \
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington ${TESTSRC}${FILESEP}Deadlock2.java
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington${TESTJAVA}${FILESEP}bin${FILESEP}jar \
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington -cvf testlib${FILESEP}Deadlock2.jar \
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington Deadlock2*.class
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonrm Deadlock2*.class
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington# create serialized object and run the test
beb12aad6bebb0d6891613e65a4e19a42e6e3f8eMark Andrews${TESTJAVA}${FILESEP}bin${FILESEP}java CreateSerialized
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington${TESTJAVA}${FILESEP}bin${FILESEP}java -Djava.ext.dirs=${TESTCLASSES}${FILESEP}testlib Deadlock2
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian WellingtonSTATUS=$?
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington# clean up
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonrm object.tmp CreateSerialized.class
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonrm -rf testlib
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellingtonexit ${STATUS}
1812c92e63f4f84f1111cc2ef9cda53fd6009981Brian Wellington