1 /* |
1 /* |
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
38 * JavaTest/jtreg does not support setting the classpath yet, so do |
38 * JavaTest/jtreg does not support setting the classpath yet, so do |
39 * the javac directly. |
39 * the javac directly. |
40 */ |
40 */ |
41 |
41 |
42 import java.io.File; |
42 import java.io.File; |
43 import java.io.IOException; |
|
44 |
43 |
45 public class RmicDefault { |
44 public class RmicDefault { |
|
45 private static final String PKG_DIR = "packagedir"; |
|
46 private static final String[] remoteClasses = new String[] { |
|
47 "RmicMeImpl", "AppletServer" |
|
48 }; |
|
49 |
46 public static void main(String args[]) throws Exception { |
50 public static void main(String args[]) throws Exception { |
47 String javahome = System.getProperty("java.home"); |
51 String javahome = System.getProperty("java.home"); |
48 String testclasses = System.getProperty("test.classes"); |
52 String testclasses = System.getProperty("test.classes"); |
49 String userDir = System.getProperty("user.dir"); |
53 String userDir = System.getProperty("user.dir"); |
|
54 String cmd = javahome + File.separator + "bin" + File.separator + |
|
55 "javac -d " + testclasses + " " + System.getProperty("test.src") + |
|
56 File.separator + PKG_DIR + File.separator; |
50 |
57 |
51 Process javacProcess = Runtime.getRuntime().exec( |
58 for (String clz : remoteClasses) { |
52 javahome + File.separator + "bin" + File.separator + |
59 System.out.println("Working on class " + clz); |
53 "javac -d " + testclasses + " " + |
60 Process javacProcess = Runtime.getRuntime().exec(cmd + clz + ".java"); |
54 System.getProperty("test.src") + File.separator + "packagedir" + |
|
55 File.separator + "RmicMeImpl.java"); |
|
56 |
61 |
57 StreamPipe.plugTogether(javacProcess.getInputStream(), System.out); |
62 StreamPipe.plugTogether(javacProcess.getInputStream(), System.out); |
58 StreamPipe.plugTogether(javacProcess.getErrorStream(), System.out); |
63 StreamPipe.plugTogether(javacProcess.getErrorStream(), System.out); |
59 |
64 |
60 javacProcess.waitFor(); |
65 javacProcess.waitFor(); |
61 |
66 |
62 Process rmicProcess = Runtime.getRuntime().exec( |
67 Process rmicProcess = Runtime.getRuntime().exec( |
63 javahome + File.separator + "bin" + File.separator + |
68 javahome + File.separator + "bin" + File.separator + |
64 "rmic -classpath " + testclasses + " packagedir.RmicMeImpl"); |
69 "rmic -classpath " + testclasses + " " + PKG_DIR + "." + clz); |
65 |
70 |
66 StreamPipe.plugTogether(rmicProcess.getInputStream(), System.out); |
71 StreamPipe.plugTogether(rmicProcess.getInputStream(), System.out); |
67 StreamPipe.plugTogether(rmicProcess.getErrorStream(), System.err); |
72 StreamPipe.plugTogether(rmicProcess.getErrorStream(), System.err); |
68 |
73 |
69 rmicProcess.waitFor(); |
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 } |
70 |
79 |
71 File stub = new File(userDir + File.separator + "packagedir" + |
80 File stub = new File(userDir + File.separator + PKG_DIR + File.separator + clz + "_Stub.class"); |
72 File.separator + "RmicMeImpl_Stub.class"); |
81 if (!stub.exists()) { |
73 if (!stub.exists()) { |
82 throw new RuntimeException("TEST FAILED: could not find stub"); |
74 throw new RuntimeException("TEST FAILED: could not find stub"); |
83 } |
75 } |
84 } |
76 |
85 |
77 System.err.println("TEST PASSED"); |
86 System.err.println("TEST PASSED"); |
78 } |
87 } |
79 } |
88 } |