Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/rmic/RMIGenerator/RmicDefault.java
38855 views
/*1* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24* @bug 423654325* @summary rmic w/o -d should put class files in package directory26* @author Dana Burns27* @library ../../../../java/rmi/testlibrary28*29* @build StreamPipe30* @run main RmicDefault31*/3233/*34* Ensure that, in the absence of a -d argument, rmic will deposit35* the generated class files in the package directory as opposed36* to the old behaviour of depositing them in the local directory.37* JavaTest/jtreg does not support setting the classpath yet, so do38* the javac directly.39*/4041import java.io.File;42import java.io.IOException;4344public class RmicDefault {45public static void main(String args[]) throws Exception {46String javahome = System.getProperty("java.home");47String testclasses = System.getProperty("test.classes");48String userDir = System.getProperty("user.dir");4950if (javahome.regionMatches(true, javahome.length() - 4,51File.separator + "jre", 0, 4))52{53javahome = javahome.substring(0, javahome.length() - 4);54}5556Process javacProcess = Runtime.getRuntime().exec(57javahome + File.separator + "bin" + File.separator +58"javac -d " + testclasses + " " +59System.getProperty("test.src") + File.separator + "packagedir" +60File.separator + "RmicMeImpl.java");6162StreamPipe.plugTogether(javacProcess.getInputStream(), System.out);63StreamPipe.plugTogether(javacProcess.getErrorStream(), System.out);6465javacProcess.waitFor();6667Process rmicProcess = Runtime.getRuntime().exec(68javahome + File.separator + "bin" + File.separator +69"rmic -classpath " + testclasses + " packagedir.RmicMeImpl");7071StreamPipe.plugTogether(rmicProcess.getInputStream(), System.out);72StreamPipe.plugTogether(rmicProcess.getErrorStream(), System.err);7374rmicProcess.waitFor();7576File stub = new File(userDir + File.separator + "packagedir" +77File.separator + "RmicMeImpl_Stub.class");78if (!stub.exists()) {79throw new RuntimeException("TEST FAILED: could not find stub");80}8182System.err.println("TEST PASSED");83}84}858687