blob: 2f194c06123d05b2af699adcac3ca2aaeacff97b [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#
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
33if [ "${TESTJAVA}" = "" ]
34then
35 echo "TESTJAVA not set. Test cannot execute. Failed."
36 exit 1
37fi
38
39
40OS=`uname -s`
41# Need to determine the classpath separator and filepath separator based on the
42# operating system.
43case "$OS" in
44SunOS | Linux )
45 PS=":" ;;
46Windows* )
47 PS=";" ;;
48* )
49 echo "Unrecognized system!"
50 exit 1 ;;
51esac
52
53JAVA=${TESTJAVA}/bin/java
54JAVAC=${TESTJAVA}/bin/javac
55MKDIR=mkdir
56RDEL="rm -r"
57
58if [ -d ${TESTCLASSES}/oclasses ]
59then
60 ${RDEL} ${TESTCLASSES}/oclasses
61fi
62if [ -d ${TESTCLASSES}/nclasses ]
63then
64 ${RDEL} ${TESTCLASSES}/nclasses
65fi
66if [ -d ${TESTCLASSES}/share ]
67then
68 ${RDEL} ${TESTCLASSES}/share
69fi
70if [ -f ${TESTCLASSES}/stream.ser ]
71then
72 ${RDEL} ${TESTCLASSES}/stream.ser
73fi
74
75mkdir ${TESTCLASSES}/oclasses
76mkdir ${TESTCLASSES}/share
77mkdir ${TESTCLASSES}/nclasses
78
79# Build sources
80set -e
81${JAVAC} -d ${TESTCLASSES}/share ${TESTSRC}/extension/ExtendedObjectInputStream.java
82CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
83${JAVAC} -d ${TESTCLASSES}/oclasses ${TESTSRC}/test/SerialDriver.java
84CLASSPATH=${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.
88CLASSPATH=${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
89${JAVA} test.SerialDriver -s
90CLASSPATH=${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
91${JAVA} install.SerialDriver -d
92rm stream.ser
93
94# Run Case 2. Map install.SerialDriver within stream to test.SerialDriver.
95CLASSPATH=${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
96${JAVA} install.SerialDriver -s
97CLASSPATH=${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
98${JAVA} test.SerialDriver -d