Fri, 24 Apr 2020 03:58:51 +0100
Merge
aoqi@0 | 1 | #!/bin/sh |
aoqi@0 | 2 | # |
aoqi@0 | 3 | # Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 5 | # |
aoqi@0 | 6 | # This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 7 | # under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 8 | # published by the Free Software Foundation. |
aoqi@0 | 9 | # |
aoqi@0 | 10 | # This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 13 | # version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 14 | # accompanied this code). |
aoqi@0 | 15 | # |
aoqi@0 | 16 | # You should have received a copy of the GNU General Public License version |
aoqi@0 | 17 | # 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 19 | # |
aoqi@0 | 20 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 21 | # or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 22 | # questions. |
aoqi@0 | 23 | # |
aoqi@0 | 24 | |
aoqi@0 | 25 | # @test |
aoqi@0 | 26 | # @bug 4212732 6485027 |
aoqi@0 | 27 | # @summary Test handling of the Class-Path attribute in jar file manifests |
aoqi@0 | 28 | # @author Martin Buchholz |
aoqi@0 | 29 | # |
aoqi@0 | 30 | # @run shell Class-Path2.sh |
aoqi@0 | 31 | |
aoqi@0 | 32 | # To run this test manually, simply do ./Class-Path2.sh |
aoqi@0 | 33 | |
aoqi@0 | 34 | . ${TESTSRC-.}/Util.sh |
aoqi@0 | 35 | |
aoqi@0 | 36 | set -u |
aoqi@0 | 37 | |
aoqi@0 | 38 | Cleanup() { |
aoqi@0 | 39 | Sys rm -rf pkg Main.java Main.class Main.jar jars |
aoqi@0 | 40 | Sys rm -rf MANIFEST.MF A.jar B.zip |
aoqi@0 | 41 | } |
aoqi@0 | 42 | |
aoqi@0 | 43 | Cleanup |
aoqi@0 | 44 | Sys mkdir pkg |
aoqi@0 | 45 | |
aoqi@0 | 46 | #---------------------------------------------------------------- |
aoqi@0 | 47 | # Create mutually referential jar files |
aoqi@0 | 48 | #---------------------------------------------------------------- |
aoqi@0 | 49 | cat >pkg/A.java <<EOF |
aoqi@0 | 50 | package pkg; |
aoqi@0 | 51 | import pkg.B; |
aoqi@0 | 52 | public class A { |
aoqi@0 | 53 | public static int f() { return B.g(); } |
aoqi@0 | 54 | public static int g() { return 0; } |
aoqi@0 | 55 | } |
aoqi@0 | 56 | EOF |
aoqi@0 | 57 | |
aoqi@0 | 58 | cat >pkg/B.java <<EOF |
aoqi@0 | 59 | package pkg; |
aoqi@0 | 60 | import pkg.A; |
aoqi@0 | 61 | public class B { |
aoqi@0 | 62 | public static int f() { return A.g(); } |
aoqi@0 | 63 | public static int g() { return 0; } |
aoqi@0 | 64 | } |
aoqi@0 | 65 | EOF |
aoqi@0 | 66 | |
aoqi@0 | 67 | Sys "$javac" pkg/A.java pkg/B.java |
aoqi@0 | 68 | |
aoqi@0 | 69 | MkManifestWithClassPath "./sub/B.zip" |
aoqi@0 | 70 | Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class |
aoqi@0 | 71 | |
aoqi@0 | 72 | MkManifestWithClassPath "../A.jar" |
aoqi@0 | 73 | Sys "$jar" cmf MANIFEST.MF B.zip pkg/B.class |
aoqi@0 | 74 | |
aoqi@0 | 75 | cat >Main.java <<EOF |
aoqi@0 | 76 | import pkg.*; |
aoqi@0 | 77 | public class Main { |
aoqi@0 | 78 | public static void main(String []a) { System.exit(A.f() + B.f()); } |
aoqi@0 | 79 | } |
aoqi@0 | 80 | EOF |
aoqi@0 | 81 | |
aoqi@0 | 82 | Sys rm -rf pkg |
aoqi@0 | 83 | |
aoqi@0 | 84 | Sys mkdir jars |
aoqi@0 | 85 | Sys mkdir jars/sub/ |
aoqi@0 | 86 | Sys mv A.jar jars/. |
aoqi@0 | 87 | Sys mv B.zip jars/sub/. |
aoqi@0 | 88 | |
aoqi@0 | 89 | # |
aoqi@0 | 90 | # Test 1: Compiling |
aoqi@0 | 91 | # |
aoqi@0 | 92 | |
aoqi@0 | 93 | Success "$javac" ${TESTTOOLVMOPTS} -cp "jars/A.jar" Main.java |
aoqi@0 | 94 | Success "$java" ${TESTVMOPTS} -cp "jars/A.jar${PS}." Main |
aoqi@0 | 95 | |
aoqi@0 | 96 | Success "$javac" ${TESTTOOLVMOPTS} -cp "jars/sub/B.zip" Main.java |
aoqi@0 | 97 | Success "$java" ${TESTVMOPTS} -cp "jars/sub/B.zip${PS}." Main |
aoqi@0 | 98 | |
aoqi@0 | 99 | # |
aoqi@0 | 100 | # Test 2: Use of extension directories is incorrect |
aoqi@0 | 101 | # |
aoqi@0 | 102 | |
aoqi@0 | 103 | Success "$javac" ${TESTTOOLVMOPTS} -extdirs jars -cp None Main.java |
aoqi@0 | 104 | Success "$java" ${TESTVMOPTS} -Djava.ext.dirs="jars" -cp . Main |
aoqi@0 | 105 | |
aoqi@0 | 106 | Success "$javac" ${TESTTOOLVMOPTS} -extdirs jars/sub -cp None Main.java |
aoqi@0 | 107 | Success "$java" ${TESTVMOPTS} -Djava.ext.dirs="jars/sub" -cp . Main |
aoqi@0 | 108 | |
aoqi@0 | 109 | Cleanup |
aoqi@0 | 110 | |
aoqi@0 | 111 | Bottom Line |