test/tools/javac/Paths/Class-Path2.sh

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

mercurial