1 #
   2 # Copyright 1998-2004 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20 # CA 95054 USA or visit www.sun.com if you need additional information or
  21 # have any questions.
  22 #
  23 
  24 # @test
  25 # @bug 4087295 4785472
  26 # @summary Enable resolveClass() to accommodate package renaming.
  27 # This fix enables one to implement a resolveClass method that maps a
  28 # Serialiazable class within a serialization stream to the same class
  29 # in a different package within the JVM runtime. See run shell script
  30 # for instructions on how to run this test.
  31 
  32 
  33 if [ "${TESTJAVA}" = "" ]
  34 then
  35   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  36   exit 1
  37 fi
  38 
  39 
  40 OS=`uname -s`
  41 # Need to determine the classpath separator and filepath separator based on the
  42 # operating system.
  43 case "$OS" in
  44 SunOS | Linux )
  45   PS=":"  ;;
  46 Windows* )
  47   PS=";"  ;;
  48 * )
  49   echo "Unrecognized system!"
  50   exit 1  ;;
  51 esac
  52 
  53 JAVA=${TESTJAVA}/bin/java
  54 JAVAC=${TESTJAVA}/bin/javac
  55 MKDIR=mkdir
  56 RDEL="rm -r"
  57 
  58 if [ -d ${TESTCLASSES}/oclasses ] 
  59 then
  60    ${RDEL} ${TESTCLASSES}/oclasses 
  61 fi
  62 if [ -d ${TESTCLASSES}/nclasses ] 
  63 then
  64    ${RDEL} ${TESTCLASSES}/nclasses 
  65 fi
  66 if [ -d ${TESTCLASSES}/share ] 
  67 then
  68    ${RDEL} ${TESTCLASSES}/share 
  69 fi
  70 if [ -f ${TESTCLASSES}/stream.ser ] 
  71 then
  72    ${RDEL} ${TESTCLASSES}/stream.ser
  73 fi
  74 
  75 mkdir ${TESTCLASSES}/oclasses
  76 mkdir ${TESTCLASSES}/share
  77 mkdir ${TESTCLASSES}/nclasses
  78 
  79 # Build sources
  80 set -e 
  81 ${JAVAC} -d ${TESTCLASSES}/share ${TESTSRC}/extension/ExtendedObjectInputStream.java
  82 CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
  83 ${JAVAC} -d ${TESTCLASSES}/oclasses ${TESTSRC}/test/SerialDriver.java
  84 CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
  85 ${JAVAC} -d ${TESTCLASSES}/nclasses ${TESTSRC}/install/SerialDriver.java
  86 
  87 # Run Case 1. Map test.SerialDriver within stream to install.SerialDriver.
  88 CLASSPATH=${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
  89 ${JAVA} test.SerialDriver -s
  90 CLASSPATH=${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
  91 ${JAVA} install.SerialDriver -d
  92 rm stream.ser
  93 
  94 # Run Case 2. Map install.SerialDriver within stream to test.SerialDriver.
  95 CLASSPATH=${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
  96 ${JAVA} install.SerialDriver -s
  97 CLASSPATH=${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
  98 ${JAVA} test.SerialDriver -d