1 # 2 # Copyright (c) 2014, 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 6760902 26 # @summary Empty path on bootclasspath is not default to current working 27 # directory for both class lookup and resource lookup whereas 28 # empty path on classpath is default to current working directory. 29 # 30 # @run shell GetResource.sh 31 32 if [ "${TESTSRC}" = "" ] ; then 33 TESTSRC=`pwd` 34 fi 35 if [ "${TESTCLASSES}" = "" ] ; then 36 TESTCLASSES=`pwd` 37 fi 38 39 if [ "${TESTJAVA}" = "" ] ; then 40 echo "TESTJAVA not set. Test cannot execute." 41 echo "FAILED!!!" 42 exit 1 43 fi 44 45 if [ "${COMPILEJAVA}" = "" ] ; then 46 COMPILEJAVA="${TESTJAVA}" 47 fi 48 49 # set platform-specific variables 50 OS=`uname -s` 51 case "$OS" in 52 Windows*) 53 PS=";" 54 ;; 55 CYGWIN* ) 56 PS=";" 57 TESTCLASSES=`/usr/bin/cygpath -a -s -m ${TESTCLASSES}` 58 ;; 59 * ) 60 PS=":" 61 ;; 62 esac 63 64 echo TESTSRC=${TESTSRC} 65 echo TESTCLASSES=${TESTCLASSES} 66 echo TESTJAVA=${TESTJAVA} 67 echo "" 68 69 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ 70 -d ${TESTCLASSES} \ 71 ${TESTSRC}/GetResource.java || exit 10 72 73 setup() { 74 dest=${TESTCLASSES}/$1 75 rm -rf $dest 76 mkdir $dest 77 cp ${TESTSRC}/test.properties $dest 78 cp ${TESTCLASSES}/GetResource.class $dest 79 } 80 81 82 count=0 83 runTest() { 84 expected=$1; 85 vmoption=$2; shift; shift 86 count=$((count+1)) 87 echo "Test $count : $vmoption $@" 88 ${TESTJAVA}/bin/java ${TESTVMOPTS} "$vmoption" $@ \ 89 GetResource $expected || exit 10 90 } 91 92 # run test 93 setup "a" 94 setup "b" 95 96 cd ${TESTCLASSES} 97 DIR=`pwd` 98 99 # Expected -Xbootclasspath 100 # Location or -classpath 101 runTest "a" "-Xbootclasspath/p:a" 102 runTest "a" "-Xbootclasspath/p:a${PS}b" 103 runTest "b" "-Xbootclasspath/p:b" 104 runTest "b" "-Xbootclasspath/p:b${PS}a" 105 runTest "a" -cp a 106 runTest "a" -cp "a${PS}b" 107 runTest "b" -cp b 108 runTest "b" -cp "b${PS}a" 109 110 cd ${DIR}/a 111 112 runTest "a" "-Xbootclasspath/p:." 113 runTest "b" "-Xbootclasspath/p:../b" 114 115 # no -classpath 116 runTest "a" -cp "${PS}" 117 runTest "b" -cp "../b" 118 119 # Test empty path in bootclasspath not default to current working directory 120 runTest "b" "-Xbootclasspath/p:${PS}../b" 121 122 # Test empty path in classpath default to current working directory 123 runTest "a" -cp "${PS}../b" 124