1 # 2 # Copyright (c) 2004, 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 4811968 6908628 25 # @summary Serialization compatibility with old versions (and fix) 26 # @author Weijun Wang 27 # 28 # set a few environment variables so that the shell-script can run stand-alone 29 # in the source directory 30 31 if [ "${TESTSRC}" = "" ] ; then 32 TESTSRC="." 33 fi 34 if [ "${TESTCLASSES}" = "" ] ; then 35 TESTCLASSES="." 36 fi 37 if [ "${TESTJAVA}" = "" ] ; then 38 echo "TESTJAVA not set. Test cannot execute." 39 echo "FAILED!!!" 40 exit 1 41 fi 42 if [ "${COMPILEJAVA}" = "" ]; then 43 COMPILEJAVA="${TESTJAVA}" 44 fi 45 46 # set platform-dependent variables 47 PF="" 48 49 OS=`uname -s` 50 case "$OS" in 51 SunOS ) 52 FS="/" 53 ARCH=`isainfo` 54 case "$ARCH" in 55 sparc* ) 56 PF="solaris-sparc" 57 ;; 58 i[3-6]86 ) 59 PF="solaris-i586" 60 ;; 61 amd64* ) 62 PF="solaris-amd64" 63 ;; 64 * ) 65 echo "Unsupported System: Solaris ${ARCH}" 66 exit 0; 67 ;; 68 esac 69 ;; 70 Linux ) 71 ARCH=`uname -m` 72 FS="/" 73 case "$ARCH" in 74 i[3-6]86 ) 75 PF="linux-i586" 76 ;; 77 amd64* | x86_64 ) 78 PF="linux-amd64" 79 ;; 80 * ) 81 echo "Unsupported System: Linux ${ARCH}" 82 exit 0; 83 ;; 84 esac 85 ;; 86 Windows* ) 87 FS="\\" 88 PF="windows-i586" 89 90 # 'uname -m' does not give us enough information - 91 # should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk), 92 # but JTREG does not pass this env variable when executing a shell script. 93 # 94 # execute test program - rely on it to exit if platform unsupported 95 96 ;; 97 * ) 98 echo "Unsupported System: ${OS}" 99 exit 0; 100 ;; 101 esac 102 103 echo "===================================================" 104 echo "Try to set ALT_JAVA_RE_JDK if you see timeout error" 105 echo "===================================================" 106 107 # the test code 108 109 ${COMPILEJAVA}${FS}bin${FS}javac -target 1.4 -source 1.4 \ 110 -d . ${TESTSRC}${FS}SerialTest.java || exit 10 111 112 # You can set ALT_JAVA_RE_JDK to another location that contains the 113 # binaries for older JDK releases. You can set it to a non-existent 114 # directory to skip the interop tests between different versions. 115 116 if [ "$ALT_JAVA_RE_JDK" = "" ]; then 117 JAVA_RE_JDK=/java/re/j2se 118 else 119 JAVA_RE_JDK=$ALT_JAVA_RE_JDK 120 fi 121 122 OLDJAVA=" 123 $JAVA_RE_JDK/1.6.0/latest/binaries/${PF} 124 $JAVA_RE_JDK/1.5.0/latest/binaries/${PF} 125 $JAVA_RE_JDK/1.4.2/latest/binaries/${PF} 126 " 127 128 SMALL=" 129 0.0 130 1.1 131 2.2 132 1.2.3456 133 1.2.2147483647.4 134 1.2.268435456.4 135 " 136 137 HUGE=" 138 2.16.764.1.3101555394.1.0.100.2.1 139 1.2.2147483648.4 140 2.3.4444444444444444444444 141 1.2.888888888888888888.111111111111111.2222222222222.33333333333333333.44444444444444 142 " 143 144 for oid in ${SMALL}; do 145 echo ${oid} 146 # new -> 147 ${TESTJAVA}${FS}bin${FS}java SerialTest out ${oid} > tmp.oid.serial || exit 1 148 # -> new 149 ${TESTJAVA}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial || exit 2 150 for oldj in ${OLDJAVA}; do 151 if [ -d ${oldj} ]; then 152 echo ${oldj} 153 # -> old 154 ${oldj}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial || exit 3 155 # old -> 156 ${oldj}${FS}bin${FS}java SerialTest out ${oid} > tmp.oid.serial.old || exit 4 157 # -> new 158 ${TESTJAVA}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial.old || exit 5 159 fi 160 done 161 done 162 163 for oid in ${HUGE}; do 164 echo ${oid} 165 # new -> 166 ${TESTJAVA}${FS}bin${FS}java SerialTest out ${oid} > tmp.oid.serial || exit 1 167 # -> new 168 ${TESTJAVA}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial || exit 2 169 for oldj in ${OLDJAVA}; do 170 if [ -d ${oldj} ]; then 171 echo ${oldj} 172 # -> old 173 ${oldj}${FS}bin${FS}java SerialTest badin < tmp.oid.serial || exit 3 174 fi 175 done 176 done 177 178 rm -f tmp.oid.serial 179 rm -f tmp.oid.serial.old 180 rm -f SerialTest.class 181 182 for oldj in ${OLDJAVA}; do 183 if [ ! -d ${oldj} ]; then 184 echo WARNING: ${oldj} is missing. Test incomplete! > /dev/stderr 185 fi 186 done 187 188 exit 0