873N/A#!/bin/sh
873N/A#
873N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
873N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
873N/A#
873N/A# This code is free software; you can redistribute it and/or modify it
873N/A# under the terms of the GNU General Public License version 2 only, as
873N/A# published by the Free Software Foundation.
873N/A#
873N/A# This code is distributed in the hope that it will be useful, but WITHOUT
873N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
873N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
873N/A# version 2 for more details (a copy is included in the LICENSE file that
873N/A# accompanied this code).
873N/A#
873N/A# You should have received a copy of the GNU General Public License version
873N/A# 2 along with this work; if not, write to the Free Software Foundation,
873N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
873N/A#
873N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
873N/A# or visit www.oracle.com if you need additional information or have any
873N/A# questions.
873N/A#
873N/A
873N/A# @test
873N/A# @bug 4212732 6485027
873N/A# @summary Test handling of the Class-Path attribute in jar file manifests
873N/A# @author Martin Buchholz
873N/A#
873N/A# @run shell Class-Path2.sh
873N/A
873N/A# To run this test manually, simply do ./Class-Path2.sh
873N/A
873N/A. ${TESTSRC-.}/Util.sh
873N/A
873N/Aset -u
873N/A
873N/ACleanup() {
873N/A Sys rm -rf pkg Main.java Main.class Main.jar jars
873N/A Sys rm -rf MANIFEST.MF A.jar B.zip
873N/A}
873N/A
873N/ACleanup
873N/ASys mkdir pkg
873N/A
873N/A#----------------------------------------------------------------
873N/A# Create mutually referential jar files
873N/A#----------------------------------------------------------------
873N/Acat >pkg/A.java <<EOF
873N/Apackage pkg;
873N/Aimport pkg.B;
873N/Apublic class A {
873N/A public static int f() { return B.g(); }
873N/A public static int g() { return 0; }
873N/A}
873N/AEOF
873N/A
873N/Acat >pkg/B.java <<EOF
873N/Apackage pkg;
873N/Aimport pkg.A;
873N/Apublic class B {
873N/A public static int f() { return A.g(); }
873N/A public static int g() { return 0; }
873N/A}
873N/AEOF
873N/A
873N/ASys "$javac" pkg/A.java pkg/B.java
873N/A
873N/AMkManifestWithClassPath "./sub/B.zip"
873N/ASys "$jar" cmf MANIFEST.MF A.jar pkg/A.class
873N/A
873N/AMkManifestWithClassPath "../A.jar"
873N/ASys "$jar" cmf MANIFEST.MF B.zip pkg/B.class
873N/A
873N/Acat >Main.java <<EOF
873N/Aimport pkg.*;
873N/Apublic class Main {
873N/A public static void main(String []a) { System.exit(A.f() + B.f()); }
873N/A}
873N/AEOF
873N/A
873N/ASys rm -rf pkg
873N/A
873N/ASys mkdir jars
873N/ASys mkdir jars/sub/
873N/ASys mv A.jar jars/.
873N/ASys mv B.zip jars/sub/.
873N/A
873N/A#
873N/A# Test 1: Compiling
873N/A#
873N/A
873N/ASuccess "$javac" ${TESTTOOLVMOPTS} -cp "jars/A.jar" Main.java
873N/ASuccess "$java" ${TESTVMOPTS} -cp "jars/A.jar${PS}." Main
873N/A
873N/ASuccess "$javac" ${TESTTOOLVMOPTS} -cp "jars/sub/B.zip" Main.java
873N/ASuccess "$java" ${TESTVMOPTS} -cp "jars/sub/B.zip${PS}." Main
873N/A
873N/A#
873N/A# Test 2: Use of extension directories is incorrect
873N/A#
873N/A
873N/ASuccess "$javac" ${TESTTOOLVMOPTS} -extdirs jars -cp None Main.java
873N/ASuccess "$java" ${TESTVMOPTS} -Djava.ext.dirs="jars" -cp . Main
873N/A
873N/ASuccess "$javac" ${TESTTOOLVMOPTS} -extdirs jars/sub -cp None Main.java
873N/ASuccess "$java" ${TESTVMOPTS} -Djava.ext.dirs="jars/sub" -cp . Main
873N/A
873N/ACleanup
873N/A
873N/ABottom Line