author | tschatzl |
Fri, 22 Nov 2019 10:03:38 +0100 | |
changeset 59218 | a1155217a563 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
31720 | 2 |
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* @test |
|
31720 | 25 |
* @bug 4236543 8129833 |
2 | 26 |
* @summary rmic w/o -d should put class files in package directory |
27 |
* @author Dana Burns |
|
28 |
* @library ../../../../java/rmi/testlibrary |
|
29 |
* |
|
30 |
* @build StreamPipe |
|
22614
2e2f77dc2599
8031179: update RMI tests to declare othervm explicitly
ewang
parents:
14778
diff
changeset
|
31 |
* @run main/othervm RmicDefault |
2 | 32 |
*/ |
33 |
||
34 |
/* |
|
35 |
* Ensure that, in the absence of a -d argument, rmic will deposit |
|
36 |
* the generated class files in the package directory as opposed |
|
37 |
* to the old behaviour of depositing them in the local directory. |
|
38 |
* JavaTest/jtreg does not support setting the classpath yet, so do |
|
39 |
* the javac directly. |
|
40 |
*/ |
|
41 |
||
42 |
import java.io.File; |
|
43 |
||
44 |
public class RmicDefault { |
|
31720 | 45 |
private static final String PKG_DIR = "packagedir"; |
46 |
private static final String[] remoteClasses = new String[] { |
|
47 |
"RmicMeImpl", "AppletServer" |
|
48 |
}; |
|
49 |
||
2 | 50 |
public static void main(String args[]) throws Exception { |
51 |
String javahome = System.getProperty("java.home"); |
|
52 |
String testclasses = System.getProperty("test.classes"); |
|
53 |
String userDir = System.getProperty("user.dir"); |
|
31720 | 54 |
String cmd = javahome + File.separator + "bin" + File.separator + |
55 |
"javac -d " + testclasses + " " + System.getProperty("test.src") + |
|
56 |
File.separator + PKG_DIR + File.separator; |
|
2 | 57 |
|
31720 | 58 |
for (String clz : remoteClasses) { |
59 |
System.out.println("Working on class " + clz); |
|
60 |
Process javacProcess = Runtime.getRuntime().exec(cmd + clz + ".java"); |
|
2 | 61 |
|
31720 | 62 |
StreamPipe.plugTogether(javacProcess.getInputStream(), System.out); |
63 |
StreamPipe.plugTogether(javacProcess.getErrorStream(), System.out); |
|
2 | 64 |
|
31720 | 65 |
javacProcess.waitFor(); |
2 | 66 |
|
31720 | 67 |
Process rmicProcess = Runtime.getRuntime().exec( |
68 |
javahome + File.separator + "bin" + File.separator + |
|
69 |
"rmic -classpath " + testclasses + " " + PKG_DIR + "." + clz); |
|
2 | 70 |
|
31720 | 71 |
StreamPipe.plugTogether(rmicProcess.getInputStream(), System.out); |
72 |
StreamPipe.plugTogether(rmicProcess.getErrorStream(), System.err); |
|
2 | 73 |
|
31720 | 74 |
rmicProcess.waitFor(); |
75 |
int exitCode = rmicProcess.exitValue(); |
|
76 |
if (rmicProcess.exitValue() != 0) { |
|
77 |
throw new RuntimeException("Rmic failed. The exit code is " + exitCode); |
|
78 |
} |
|
2 | 79 |
|
31720 | 80 |
File stub = new File(userDir + File.separator + PKG_DIR + File.separator + clz + "_Stub.class"); |
81 |
if (!stub.exists()) { |
|
82 |
throw new RuntimeException("TEST FAILED: could not find stub"); |
|
83 |
} |
|
2 | 84 |
} |
85 |
||
86 |
System.err.println("TEST PASSED"); |
|
87 |
} |
|
88 |
} |