jdk/test/sun/rmi/rmic/manifestClassPath/run.sh
author chegar
Wed, 03 Dec 2014 14:22:58 +0000
changeset 27565 729f9700483a
parent 17933 b18cda672b79
permissions -rw-r--r--
8049367: Modular Run-Time Images Reviewed-by: chegar, dfuchs, ihse, joehw, mullan, psandoz, wetmore Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, bradford.wetmore@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, james.laskey@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17933
b18cda672b79 8014834: shell tests don't begin with #!/bin/sh
emc
parents: 14786
diff changeset
     1
#!/bin/sh
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
#
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 5627
diff changeset
     3
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# @test
5623
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    26
# @bug 6473331 6485027 6934615
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# @summary Test handling of the Class-Path attribute in jar file manifests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#          for the rmic tool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
# @author Andrey Ozerov
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
# @run shell run.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# To run this test manually, simply do ./run.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
. ${TESTSRC-.}/Util.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
set -u
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
Cleanup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    Sys rm -rf pkg Main.java MainI.java Main.class MainI.class Main_Stub.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    Sys rm -rf jars MANIFEST.MF A.jar B.zip
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
Cleanup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
Sys mkdir pkg
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
# Create mutually referential jar files
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
cat >pkg/A.java <<EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
package pkg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
public class A implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public int f(B b) { return b.g(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public int g() { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
cat >pkg/B.java <<EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
package pkg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
public class B implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public int f(A a) { return a.g(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public int g() { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
Sys "$javac" pkg/A.java pkg/B.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
5623
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    68
# NOTE: Previously, some lines were commented out and alternative lines
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    69
# provided, to work around javac bug 6485027. That bug, and related rmic
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    70
# bug 6934615 have now been fixed, so most of the workarounds have been
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    71
# removed. However, javac still does not evaluate jar class paths on
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    72
# the bootclasspath, including -extdirs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
5623
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    74
MkManifestWithClassPath "sub/B.zip"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
5623
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    77
MkManifestWithClassPath "../A.jar"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
Sys "$jar" cmf MANIFEST.MF B.zip pkg/B.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
Sys rm -rf pkg
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
Sys mkdir jars
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
Sys mv A.jar jars/.
5623
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    83
Sys mkdir jars/sub
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
    84
Sys mv B.zip jars/sub/.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
cat >MainI.java <<EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
import pkg.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
public interface MainI extends java.rmi.Remote {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public int doIt(A a, B b) throws java.rmi.RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
cat >Main.java <<EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
import pkg.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
import java.rmi.server.UnicastRemoteObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
public class Main implements MainI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public int doIt(A a, B b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
	return a.f(b) + b.f(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public static void main(String args[]) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
	Main impl = new Main();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
	try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
	    MainI stub = (MainI) UnicastRemoteObject.exportObject(impl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
	    int result = stub.doIt(new A(), new B());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
	    System.exit(result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
	} finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
	    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
		UnicastRemoteObject.unexportObject(impl, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
	    } catch (Exception e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
Success "$javac" -classpath "jars/A.jar"       Main.java MainI.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
Success "$rmic"  -classpath "jars/A.jar${PS}." Main
14786
a9f61e0cbe61 8003890: corelibs test scripts should pass TESTVMOPTS
chegar
parents: 7668
diff changeset
   117
Success "$java" ${TESTVMOPTS} -classpath "jars/A.jar${PS}." Main
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
Sys rm -f Main.class MainI.class Main_Stub.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
5623
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
   121
Success "$javac" -classpath "jars/sub/B.zip"       Main.java MainI.java
5c9695dc013a 6934615: Relative classpaths in jarfile manifests are handled inefficiently by rmic
jjg
parents: 2
diff changeset
   122
Success "$rmic"  -classpath "jars/sub/B.zip${PS}." Main
14786
a9f61e0cbe61 8003890: corelibs test scripts should pass TESTVMOPTS
chegar
parents: 7668
diff changeset
   123
Success "$java" ${TESTVMOPTS}  -classpath "jars/sub/B.zip${PS}." Main
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
Cleanup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
Bottom Line