1 # 2 # Copyright (c) 2009, 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 25 # @test Test6842838.sh 26 # @bug 6842838 27 # @summary Test 6842838 64-bit launcher failure due to corrupt jar 28 # @compile CreateBadJar.java 29 # @run shell Test6842838.sh 30 31 set -x 32 33 if [ "${TESTJAVA}" = "" ]; then 34 PARENT=`dirname \`which java\`` 35 TESTJAVA=`dirname ${PARENT}` 36 printf "TESTJAVA not set. Test cannot execute. Failed.\n" 37 fi 38 39 if [ "${TESTCLASSES}" = "" ]; then 40 printf "TESTCLASSES not set. Test cannot execute. Failed.\n" 41 exit 1 42 fi 43 44 # set platform-dependent variables 45 OS=`uname -s` 46 case "$OS" in 47 SunOS ) 48 NULL=/dev/null 49 PS=":" 50 FS="/" 51 JAVA_EXE=${TESTJAVA}${FS}bin${FS}java 52 ;; 53 * ) 54 printf "Only testing on solaris 64-bit (use libumem to reliably catch buffer overrun)\n" 55 exit 0; 56 ;; 57 esac 58 59 if [ ! -x ${JAVA_EXE} ]; then 60 printf "Warning: 64-bit components not installed - skipping test.\n" 61 exit 0 62 fi 63 64 LIBUMEM=/lib/64/libumem.so 65 if [ ! -x ${LIBUMEM} ]; then 66 printf "Warning: libumem not installed - skipping test.\n" 67 exit 0 68 fi 69 70 BADFILE=newbadjar.jar 71 ${JAVA_EXE} ${TESTVMOPTS} -version 72 ${JAVA_EXE} ${TESTVMOPTS} -cp ${TESTCLASSES} CreateBadJar ${BADFILE} "META-INF/MANIFEST.MF" 73 LD_PRELOAD=${LIBUMEM} ${JAVA_EXE} -jar ${BADFILE} > test.out 2>&1 74 75 grep "Invalid or corrupt jarfile" test.out 76 exit $?