Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/rmic/manifestClassPath/run.sh
38855 views
#!/bin/sh1#2# Copyright (c) 2007, 2010, 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 it6# under the terms of the GNU General Public License version 2 only, as7# published by the Free Software Foundation.8#9# This code is distributed in the hope that it will be useful, but WITHOUT10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12# version 2 for more details (a copy is included in the LICENSE file that13# accompanied this code).14#15# You should have received a copy of the GNU General Public License version16# 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 USA20# or visit www.oracle.com if you need additional information or have any21# questions.22#2324# @test25# @bug 6473331 6485027 693461526# @summary Test handling of the Class-Path attribute in jar file manifests27# for the rmic tool28# @author Andrey Ozerov29#30# @run shell run.sh3132# To run this test manually, simply do ./run.sh3334. ${TESTSRC-.}/Util.sh3536set -u3738Cleanup() {39Sys rm -rf pkg Main.java MainI.java Main.class MainI.class Main_Stub.class40Sys rm -rf jars MANIFEST.MF A.jar B.zip41}4243Cleanup44Sys mkdir pkg4546#----------------------------------------------------------------47# Create mutually referential jar files48#----------------------------------------------------------------49cat >pkg/A.java <<EOF50package pkg;51public class A implements java.io.Serializable {52public int f(B b) { return b.g(); }53public int g() { return 0; }54}55EOF5657cat >pkg/B.java <<EOF58package pkg;59public class B implements java.io.Serializable {60public int f(A a) { return a.g(); }61public int g() { return 0; }62}63EOF6465Sys "$javac" pkg/A.java pkg/B.java6667# NOTE: Previously, some lines were commented out and alternative lines68# provided, to work around javac bug 6485027. That bug, and related rmic69# bug 6934615 have now been fixed, so most of the workarounds have been70# removed. However, javac still does not evaluate jar class paths on71# the bootclasspath, including -extdirs.7273MkManifestWithClassPath "sub/B.zip"74Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class7576MkManifestWithClassPath "../A.jar"77Sys "$jar" cmf MANIFEST.MF B.zip pkg/B.class7879Sys rm -rf pkg80Sys mkdir jars81Sys mv A.jar jars/.82Sys mkdir jars/sub83Sys mv B.zip jars/sub/.8485cat >MainI.java <<EOF86import pkg.*;87public interface MainI extends java.rmi.Remote {88public int doIt(A a, B b) throws java.rmi.RemoteException;89}90EOF9192cat >Main.java <<EOF93import pkg.*;94import java.rmi.server.UnicastRemoteObject;95public class Main implements MainI {96public int doIt(A a, B b) {97return a.f(b) + b.f(a);98}99public static void main(String args[]) throws Exception {100Main impl = new Main();101try {102MainI stub = (MainI) UnicastRemoteObject.exportObject(impl);103int result = stub.doIt(new A(), new B());104System.exit(result);105} finally {106try {107UnicastRemoteObject.unexportObject(impl, true);108} catch (Exception e) { }109}110}111}112EOF113114Success "$javac" -classpath "jars/A.jar" Main.java MainI.java115Success "$rmic" -classpath "jars/A.jar${PS}." Main116Success "$java" ${TESTVMOPTS} -classpath "jars/A.jar${PS}." Main117118Sys rm -f Main.class MainI.class Main_Stub.class119120Success "$javac" -classpath "jars/sub/B.zip" Main.java MainI.java121Success "$rmic" -classpath "jars/sub/B.zip${PS}." Main122Success "$java" ${TESTVMOPTS} -classpath "jars/sub/B.zip${PS}." Main123124#Sys rm -f Main.class MainI.class Main_Stub.class125Sys rm -f Main_Stub.class # javac -extdirs workaround126127#Success "$javac" -extdirs "jars" -classpath None Main.java MainI.java128Success "$rmic" -extdirs "jars" -classpath . Main129Success "$java" ${TESTVMOPTS} -Djava.ext.dirs="jars" -cp . Main130131Sys rm -f Main_Stub.class132133#Success "$javac" -extdirs "jars/sub" -classpath None Main.java MainI.java134Success "$rmic" -extdirs "jars/sub" -classpath . Main135Success "$java" ${TESTVMOPTS} -Djava.ext.dirs="jars/sub" -cp . Main136137Cleanup138139Bottom Line140141142