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

Wed, 06 Apr 2011 20:33:44 -0700

author
ohair
date
Wed, 06 Apr 2011 20:33:44 -0700
changeset 962
0ff2bbd38f10
parent 0
959103a6100f
permissions
-rw-r--r--

7033660: Update copyright year to 2011 on any files changed in 2011
Reviewed-by: dholmes

     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 #
    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
    32 # To run this test manually, simply do ./Class-Path2.sh
    34 . ${TESTSRC-.}/Util.sh
    36 set -u
    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 }
    43 Cleanup
    44 Sys mkdir pkg
    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
    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
    67 Sys "$javac" pkg/A.java pkg/B.java
    69 MkManifestWithClassPath "./sub/B.zip"
    70 Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class
    72 MkManifestWithClassPath "../A.jar"
    73 Sys "$jar" cmf MANIFEST.MF B.zip pkg/B.class
    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
    82 Sys rm -rf pkg
    84 Sys mkdir jars
    85 Sys mkdir jars/sub/
    86 Sys mv A.jar jars/.
    87 Sys mv B.zip jars/sub/.
    89 #
    90 # Test 1: Compiling 
    91 #
    93 Success "$javac" ${TESTTOOLVMOPTS} -cp "jars/A.jar" Main.java
    94 Success "$java"  ${TESTVMOPTS}     -cp "jars/A.jar${PS}." Main
    96 Success "$javac" ${TESTTOOLVMOPTS} -cp "jars/sub/B.zip"       Main.java
    97 Success "$java"  ${TESTVMOPTS}     -cp "jars/sub/B.zip${PS}." Main
    99 #
   100 # Test 2: Use of extension directories is incorrect
   101 #
   103 Success "$javac" ${TESTTOOLVMOPTS} -extdirs jars          -cp None Main.java
   104 Success "$java"  ${TESTVMOPTS}     -Djava.ext.dirs="jars" -cp .    Main
   106 Success "$javac" ${TESTTOOLVMOPTS} -extdirs jars/sub          -cp None Main.java
   107 Success "$java"  ${TESTVMOPTS}     -Djava.ext.dirs="jars/sub" -cp .    Main
   109 Cleanup
   111 Bottom Line

mercurial