jjg@535: /* ohair@554: * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. jjg@535: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@535: * jjg@535: * This code is free software; you can redistribute it and/or modify it jjg@535: * under the terms of the GNU General Public License version 2 only, as jjg@535: * published by the Free Software Foundation. jjg@535: * jjg@535: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@535: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@535: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@535: * version 2 for more details (a copy is included in the LICENSE file that jjg@535: * accompanied this code). jjg@535: * jjg@535: * You should have received a copy of the GNU General Public License version jjg@535: * 2 along with this work; if not, write to the Free Software Foundation, jjg@535: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@535: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@535: */ jjg@535: jjg@535: jjg@535: /* jjg@535: * @test jjg@535: * @bug 6942649 jjg@535: * @summary add hidden option to identify location and version of javac classes jjg@535: */ jjg@535: jjg@535: import java.io.*; jjg@535: jjg@535: public class T6942649 { jjg@535: public static void main(String... args) throws Exception { jjg@535: new T6942649().run(); jjg@535: } jjg@535: jjg@535: void run() throws Exception { jjg@535: test("-XDshowClass", "com.sun.tools.javac.Main"); jjg@535: test("-XDshowClass=com.sun.tools.javac.util.Log", "com.sun.tools.javac.util.Log"); jjg@535: } jjg@535: jjg@535: void test(String opt, String clazz) throws Exception { jjg@535: System.err.println("test " + opt); jjg@535: StringWriter sw = new StringWriter(); jjg@535: PrintWriter pw = new PrintWriter(sw); jjg@535: int rc = com.sun.tools.javac.Main.compile(new String[] { opt }, pw); jjg@535: pw.close(); jjg@535: String out = sw.toString(); jjg@535: System.err.println("javac rc=" + rc + "\n" + out); jjg@535: if (!out.contains(clazz)) jjg@535: throw new Exception("class name not found in output"); jjg@535: int lastDot = clazz.lastIndexOf("."); jjg@535: if (!out.contains(clazz.substring(lastDot + 1) + ".class")) jjg@535: throw new Exception("location of class not found in output"); jjg@535: if (!out.contains("MD5 checksum: ")) jjg@535: throw new Exception("checksum not found in output"); jjg@535: } jjg@535: }