0N/A#
3261N/A# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A#!/bin/sh
0N/A# @test
2414N/A# @bug 6473331 6485027 6934615
0N/A# @summary Test handling of the Class-Path attribute in jar file manifests
0N/A# for the rmic tool
0N/A# @author Andrey Ozerov
0N/A#
0N/A# @run shell run.sh
0N/A
0N/A# To run this test manually, simply do ./run.sh
0N/A
0N/A. ${TESTSRC-.}/Util.sh
0N/A
0N/Aset -u
0N/A
0N/ACleanup() {
0N/A Sys rm -rf pkg Main.java MainI.java Main.class MainI.class Main_Stub.class
0N/A Sys rm -rf jars MANIFEST.MF A.jar B.zip
0N/A}
0N/A
0N/ACleanup
0N/ASys mkdir pkg
0N/A
0N/A#----------------------------------------------------------------
0N/A# Create mutually referential jar files
0N/A#----------------------------------------------------------------
0N/Acat >pkg/A.java <<EOF
0N/Apackage pkg;
0N/Apublic class A implements java.io.Serializable {
0N/A public int f(B b) { return b.g(); }
0N/A public int g() { return 0; }
0N/A}
0N/AEOF
0N/A
0N/Acat >pkg/B.java <<EOF
0N/Apackage pkg;
0N/Apublic class B implements java.io.Serializable {
0N/A public int f(A a) { return a.g(); }
0N/A public int g() { return 0; }
0N/A}
0N/AEOF
0N/A
0N/ASys "$javac" pkg/A.java pkg/B.java
0N/A
2414N/A# NOTE: Previously, some lines were commented out and alternative lines
2414N/A# provided, to work around javac bug 6485027. That bug, and related rmic
2414N/A# bug 6934615 have now been fixed, so most of the workarounds have been
2414N/A# removed. However, javac still does not evaluate jar class paths on
2414N/A# the bootclasspath, including -extdirs.
0N/A
2414N/AMkManifestWithClassPath "sub/B.zip"
0N/ASys "$jar" cmf MANIFEST.MF A.jar pkg/A.class
0N/A
2414N/AMkManifestWithClassPath "../A.jar"
0N/ASys "$jar" cmf MANIFEST.MF B.zip pkg/B.class
0N/A
0N/ASys rm -rf pkg
0N/ASys mkdir jars
0N/ASys mv A.jar jars/.
2414N/ASys mkdir jars/sub
2414N/ASys mv B.zip jars/sub/.
0N/A
0N/Acat >MainI.java <<EOF
0N/Aimport pkg.*;
0N/Apublic interface MainI extends java.rmi.Remote {
0N/A public int doIt(A a, B b) throws java.rmi.RemoteException;
0N/A}
0N/AEOF
0N/A
0N/Acat >Main.java <<EOF
0N/Aimport pkg.*;
0N/Aimport java.rmi.server.UnicastRemoteObject;
0N/Apublic class Main implements MainI {
0N/A public int doIt(A a, B b) {
0N/A return a.f(b) + b.f(a);
0N/A }
0N/A public static void main(String args[]) throws Exception {
0N/A Main impl = new Main();
0N/A try {
0N/A MainI stub = (MainI) UnicastRemoteObject.exportObject(impl);
0N/A int result = stub.doIt(new A(), new B());
0N/A System.exit(result);
0N/A } finally {
0N/A try {
0N/A UnicastRemoteObject.unexportObject(impl, true);
0N/A } catch (Exception e) { }
0N/A }
0N/A }
0N/A}
0N/AEOF
0N/A
0N/ASuccess "$javac" -classpath "jars/A.jar" Main.java MainI.java
0N/ASuccess "$rmic" -classpath "jars/A.jar${PS}." Main
0N/ASuccess "$java" -classpath "jars/A.jar${PS}." Main
0N/A
0N/ASys rm -f Main.class MainI.class Main_Stub.class
0N/A
2414N/ASuccess "$javac" -classpath "jars/sub/B.zip" Main.java MainI.java
2414N/ASuccess "$rmic" -classpath "jars/sub/B.zip${PS}." Main
2414N/ASuccess "$java" -classpath "jars/sub/B.zip${PS}." Main
0N/A
0N/A#Sys rm -f Main.class MainI.class Main_Stub.class
2414N/ASys rm -f Main_Stub.class # javac -extdirs workaround
0N/A
0N/A#Success "$javac" -extdirs "jars" -classpath None Main.java MainI.java
0N/ASuccess "$rmic" -extdirs "jars" -classpath . Main
0N/ASuccess "$java" -Djava.ext.dirs="jars" -cp . Main
0N/A
2414N/ASys rm -f Main_Stub.class
2414N/A
0N/A#Success "$javac" -extdirs "jars/sub" -classpath None Main.java MainI.java
2414N/ASuccess "$rmic" -extdirs "jars/sub" -classpath . Main
2414N/ASuccess "$java" -Djava.ext.dirs="jars/sub" -cp . Main
0N/A
0N/ACleanup
0N/A
0N/ABottom Line