JDK-4312654 : javac -J-D.javac.pipe.output=true does NOT redirect to file in 1.3RC1
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_95,windows_98,windows_nt
  • CPU: x86
  • Submitted: 2000-02-15
  • Updated: 2001-10-18
  • Resolved: 2000-11-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Description

Name: rlT66838			Date: 02/15/2000


java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)


In Java 1.2 developers could redirect compiler output to a file by typing
javac -J-Djavac.pipe.output=true MyClass.java > MyClass.err.

Additionally developers could redirect compiler output by typing java -Xstdout
MyClass.java > MyClass.err.

Both of these command lines would result in a file MyClass.err that contained
compiler output.  Naturally, files of this nature are essential for locating
syntax errors and other compiler errors.

What can we do to regain this critical ability to capture compiler output on
Win32 platform?
(Review ID: 101261) 
======================================================================

Name: rlT66838			Date: 02/17/2000


C:\java -version
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)



I have followed instructions in tech article 2089, which suggests using the
following line to redirect javac error messages to a file (necessary because
they scroll off scn):

2) compile using javac -J-Djavac.pipe.output=true myclass.java >outputfile


This does not work.  would appreciate a workaround .thankyou
(Review ID: 101391)


Name: skT45625			Date: 08/02/2000


C:\>java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

C:\>



Before JDK 2 version 1.3 you could set the compiler
property "javac.pipe.output" to true by using the following syntax:

javac -J-Djavac.pipe.output=true MyProg.java > errors.txt

However, this doesn't work with version 1.3. The setting has no effect.
(Review ID: 107880)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin FIXED IN: merlin INTEGRATED IN: merlin-beta VERIFIED IN: merlin-beta3
2004-06-14

SUGGESTED FIX roken: key={0} " ! + "arguments={1}"; return MessageFormat.format(msg, args); } } --- 407,424 ---- /** Get and format message string from resource. */ ! private static String getText(String key, String arg0, String arg1) { if (messageRB == null) initResource(); try { ! String [] args = {arg0, arg1}; return MessageFormat.format(messageRB.getString(key), args); } catch (MissingResourceException e) { if (arg0 == null) arg0 = "null"; ! if (arg1 == null) arg1 = "null"; ! String [] args = {key, arg0, arg1}; String msg = "javac message file broken: key={0} " ! + "arguments={1}, {2}"; return MessageFormat.format(msg, args); } } ========================================> /gafter/neal-gjc/src/share/javac/com/sun/tools/javac/v8/resources/javac.properties ------- javac.properties ------- *** /tmp/dmjaa7W Fri Oct 27 10:46:17 2000 --- javac.properties Fri Oct 27 10:29:51 2000 *************** *** 83,88 **** --- 83,96 ---- Version information javac.opt.arg.pathname= <pathname> + javac.opt.arg.file=+ <filename> + javac.opt.Xstdout=+ Redirect standard output + javac.opt.X=+ Print a synopsis of nonstandard options + javac.opt.help=+ Print a synopsis of standard options ## errors *************** *** 96,101 **** --- 104,111 ---- {0} requires argument javac.err.invalid.source= invalid source release: {0} + javac.err.error.writing.file=+ error writing {0}; {1} ## messages *************** *** 103,108 **** --- 113,121 ---- Usage: {0} <options> <source files>\n where possible options include: + javac.msg.usage.nonstandard.footer=+ These options are non-standard and subject to change without notice. + javac.msg.bug= An exception has occurred in the compiler ({0}). Please file a bug at the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi)
2004-06-11

SUGGESTED FIX ========================================> /gafter/neal-gjc/src/share/javac/com/sun/tools/javac/Main.java ------- Main.java ------- *** /tmp/dL.aG4W Fri Oct 27 10:46:16 2000 --- Main.java Wed Oct 25 17:22:18 2000 *************** *** 17,23 **** */ public static void main(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("javac", false); System.exit(compiler.compile(args)); } --- 17,23 ---- */ public static void main(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("javac"); System.exit(compiler.compile(args)); } *************** *** 26,32 **** */ public static int compile(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("javac", false); return compiler.compile(args); } } --- 26,32 ---- */ public static int compile(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("javac"); return compiler.compile(args); } } ========================================> /gafter/neal-gjc/src/share/javac/com/sun/tools/javac/GJMain.java ------- GJMain.java ------- *** /tmp/dpbaa5W Fri Oct 27 10:46:16 2000 --- GJMain.java Wed Oct 25 17:21:52 2000 *************** *** 17,23 **** */ public static void main(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("gjc", true); System.exit(compiler.compile(args)); } --- 17,23 ---- */ public static void main(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("gjc"); System.exit(compiler.compile(args)); } *************** *** 26,32 **** */ public int compile(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("gjc", true); return compiler.compile(args); } } --- 26,32 ---- */ public int compile(String[] args) { com.sun.tools.javac.v8.Main compiler = ! new com.sun.tools.javac.v8.Main("gjc"); return compiler.compile(args); } } ========================================> /gafter/neal-gjc/src/share/javac/com/sun/tools/javac/v8/Main.java ------- Main.java ------- *** /tmp/dteaW5W Fri Oct 27 10:46:16 2000 --- Main.java Fri Oct 27 10:28:05 2000 *************** *** 10,19 **** package com.sun.tools.javac.v8; import java.io.IOException; import java.util.ResourceBundle; import java.util.MissingResourceException; - import java.text.MessageFormat; import com.sun.tools.javac.v8.util.*; import com.sun.tools.javac.v8.code.*; --- 10,21 ---- package com.sun.tools.javac.v8; + import java.io.FileOutputStream; import java.io.IOException; + import java.io.PrintStream; + import java.text.MessageFormat; import java.util.ResourceBundle; import java.util.MissingResourceException; import com.sun.tools.javac.v8.util.*; import com.sun.tools.javac.v8.code.*; *************** *** 43,48 **** --- 45,57 ---- EXIT_SYSERR = 3, // System error or resource exhaustion. EXIT_ABNORMAL = 4; // Compiler terminated abnormally + /** Options type + */ + private static final String + OPT_STANDARD = "S", // normal, documented options + OPT_NONSTANDARD = "N", // documentation available via -X + OPT_SECRET = "S"; // secret, never-documented options + /** A three-column matrix describing all possible options. * First column: The option's name * Second column: The key to locate the option's argument, "" if there *************** *** 49,123 **** * is none. * Third column: The key to locate the internationalized string which * describes the option. * * The first and second columns are important internally, since they * are used to construct the table of actual options that's passed * as an argument to the JavaCompiler constructor. */ ! static String[][] standardOptions = { ! {"-g", "", "opt.g"}, ! {"-g:none", "", "opt.g.none"}, ! {"-g:{lines,vars,source}", "", "opt.g.lines.vars.source"}, ! {"-O", "", "opt.O"}, ! {"-nowarn", "", "opt.nowarn"}, ! {"-verbose", "", "opt.verbose"}, ! {"-deprecation", "", "opt.deprecation"}, ! {"-classpath", "opt.arg.path", "opt.classpath"}, ! {"-sourcepath", "opt.arg.path", "opt.sourcepath"}, ! {"-bootclasspath", "opt.arg.path", "opt.bootclasspath"}, ! {"-extdirs", "opt.arg.dirs", "opt.extdirs"}, ! {"-d", "opt.arg.directory", "opt.d"}, ! {"-encoding", "opt.arg.encoding", "opt.encoding"}, ! {"-source", "opt.arg.release", "opt.source"}, ! {"-target", "opt.arg.release", "opt.target"}}; ! ! //GJ options: ! /*if_not[PUREJAVA]*/ ! static String[][] extendedOptions = { ! {"-gj", "", "opt.gj"}, ! {"-moreinfo", "", "opt.moreinfo"}, ! {"-printflat", "", "opt.printflat"}, ! {"-printsearch", "", "opt.printsearch"}, ! {"-prompt", "", "opt.prompt"}, ! {"-retrofit", "opt.arg.pathname", "opt.retrofit"}, ! {"-s", "", "opt.s"}, ! {"-scramble", "", "opt.scramble"}, ! {"-scrambleall", "", "opt.scrambleall"}, ! {"-switchcheck", "", "opt.switchcheck"}, ! {"-warnunchecked", "", "opt.warnunchecked"}, ! {"-version", "", "opt.version"}}; /*end[PUREJAVA]*/ - /** Command-line options currently available. - */ - String[][] enabledOptions; - /** * Construct a compiler instance. */ ! public Main(String name, boolean gjEnabled) { ownName = name; - /*if_not[PUREJAVA]*/ - if (gjEnabled) { - int stdLen = standardOptions.length; - int optLen = stdLen + extendedOptions.length; - enabledOptions = new String[optLen][]; - int i = 0; - while (i < stdLen) { - enabledOptions[i] = standardOptions[i]; - i++; - } - while (i < optLen) { - enabledOptions[i] = extendedOptions[i-stdLen]; - i++; - } - } else { - /*end[PUREJAVA]*/ - enabledOptions = standardOptions; - /*if_not[PUREJAVA]*/ - } - /*end[PUREJAVA]*/ } /** A table of all options that's passed to the JavaCompiler constructor. --- 58,110 ---- * is none. * Third column: The key to locate the internationalized string which * describes the option. + * Fourth column: A single-letter string that distinguishes option type + * from among "S"tandard, "N"onstandard, and "S"ecret. * * The first and second columns are important internally, since they * are used to construct the table of actual options that's passed * as an argument to the JavaCompiler constructor. */ ! private static String[][] optionStrings = { ! {"-g", "", "opt.g", OPT_STANDARD}, ! {"-g:none", "", "opt.g.none", OPT_STANDARD}, ! {"-g:{lines,vars,source}", "", "opt.g.lines.vars.source", OPT_STANDARD}, ! {"-O", "", "opt.O", OPT_STANDARD}, ! {"-nowarn", "", "opt.nowarn", OPT_STANDARD}, ! {"-verbose", "", "opt.verbose", OPT_STANDARD}, ! {"-deprecation", "", "opt.deprecation", OPT_STANDARD}, ! {"-classpath", "opt.arg.path", "opt.classpath", OPT_STANDARD}, ! {"-sourcepath", "opt.arg.path", "opt.sourcepath", OPT_STANDARD}, ! {"-bootclasspath", "opt.arg.path", "opt.bootclasspath", OPT_STANDARD}, ! {"-extdirs", "opt.arg.dirs", "opt.extdirs", OPT_STANDARD}, ! {"-d", "opt.arg.directory", "opt.d", OPT_STANDARD}, ! {"-encoding", "opt.arg.encoding", "opt.encoding", OPT_STANDARD}, ! {"-source", "opt.arg.release", "opt.source", OPT_STANDARD}, ! {"-target", "opt.arg.release", "opt.target", OPT_STANDARD}, ! {"-help", "", "opt.help", OPT_STANDARD}, /*if_not[PUREJAVA]*/ ! {"-gj", "", "opt.gj", OPT_STANDARD}, ! {"-moreinfo", "", "opt.moreinfo", OPT_STANDARD}, ! {"-printflat", "", "opt.printflat", OPT_STANDARD}, ! {"-printsearch", "", "opt.printsearch", OPT_STANDARD}, ! {"-prompt", "", "opt.prompt", OPT_STANDARD}, ! {"-retrofit", "opt.arg.pathname", "opt.retrofit", OPT_STANDARD}, ! {"-s", "", "opt.s", OPT_STANDARD}, ! {"-scramble", "", "opt.scramble", OPT_STANDARD}, ! {"-scrambleall", "", "opt.scrambleall", OPT_STANDARD}, ! {"-switchcheck", "", "opt.switchcheck", OPT_STANDARD}, ! {"-warnunchecked", "", "opt.warnunchecked", OPT_STANDARD}, ! {"-version", "", "opt.version", OPT_STANDARD}, /*end[PUREJAVA]*/ + {"-Xstdout", "opt.arg.file", "opt.Xstdout", OPT_NONSTANDARD}, + {"-X", "", "opt.X", OPT_NONSTANDARD} + }; /** * Construct a compiler instance. */ ! public Main(String name) { ownName = name; } /** A table of all options that's passed to the JavaCompiler constructor. *************** *** 129,149 **** /** Print a string that explains usage. */ ! void help() { ! System.err.println(getLocalizedString("msg.usage.header", ownName)); ! for (int i = 0; i < enabledOptions.length; i++) { ! // Allow for undocumented '-X' options. ! if (!enabledOptions[i][0].startsWith("-X")) { ! // Documented option. ! String s = " " + enabledOptions[i][0] + " "; ! if (!enabledOptions[i][1].equals("")) ! s += getLocalizedString(enabledOptions[i][1]); System.err.print(s); for (int j = s.length(); j < 28; j++) System.err.print(" "); ! System.err.println(getLocalizedString(enabledOptions[i][2])); } } System.err.println(); } /** Report a usage error. --- 116,138 ---- /** Print a string that explains usage. */ ! void help(String kind) { ! if (kind == OPT_STANDARD) ! System.err.println(getLocalizedString("msg.usage.header", ownName)); ! for (int i = 0; i < optionStrings.length; i++) { ! if (optionStrings[i][3] == kind) { ! // we only document the kind asked for ! String s = " " + optionStrings[i][0] + " "; ! if (!optionStrings[i][1].equals("")) ! s += getLocalizedString(optionStrings[i][1]); System.err.print(s); for (int j = s.length(); j < 28; j++) System.err.print(" "); ! System.err.println(getLocalizedString(optionStrings[i][2])); } } System.err.println(); + if (kind == OPT_NONSTANDARD) + System.err.println(getLocalizedString("msg.usage.nonstandard.footer")); } /** Report a usage error. *************** *** 150,162 **** */ void error(String key, String arg) { System.err.println(ownName + ": " ! + getLocalizedString(key, arg)); ! help(); } /** Does argument string match option pattern? * @param pattern The option pattern, as found in the first column of ! * the enabledOptions matrix. * @param arg The command line argument string. */ private boolean matches(String pattern, String arg) { --- 139,159 ---- */ void error(String key, String arg) { System.err.println(ownName + ": " ! + getLocalizedString(key, arg, null)); ! help(OPT_STANDARD); } + /** Report a usage error. + */ + void error(String key, String arg0, String arg1) { + System.err.println(ownName + ": " + + getLocalizedString(key, arg0, arg1)); + help(OPT_STANDARD); + } + /** Does argument string match option pattern? * @param pattern The option pattern, as found in the first column of ! * the optionStrings matrix. * @param arg The command line argument string. */ private boolean matches(String pattern, String arg) { *************** *** 207,219 **** ac++; if (arg.startsWith("-")) { int j = 0; ! while (j < enabledOptions.length && ! !matches(enabledOptions[j][0], arg)) j++; ! if (j == enabledOptions.length) { error("err.invalid.flag", arg); return null; } ! String operand = enabledOptions[j][1]; if (operand.length() != 0) { if (ac == args.length) { error("err.req.arg", arg); --- 204,216 ---- ac++; if (arg.startsWith("-")) { int j = 0; ! while (j < optionStrings.length && ! !matches(optionStrings[j][0], arg)) j++; ! if (j == optionStrings.length) { error("err.invalid.flag", arg); return null; } ! String operand = optionStrings[j][1]; if (operand.length() != 0) { if (ac == args.length) { error("err.req.arg", arg); *************** *** 224,229 **** --- 221,239 ---- } if (arg.equals("-moreinfo")) { Type.moreInfo = true; + } else if (arg.equals("-X")) { + help(OPT_NONSTANDARD); + } else if (arg.equals("-help")) { + help(OPT_STANDARD); + } else if (arg.equals("-Xstdout")) { + try { + PrintStream out = new PrintStream(new FileOutputStream(operand)); + System.setOut(out); + System.setErr(out); + } catch (java.io.FileNotFoundException e) { + error("err.error.writing.file", operand, e.toString()); + return null; + } } else if (arg.equals("-version")) { System.err.println( ownName + " " + JavaCompiler.version() + ", " + *************** *** 265,271 **** JavaCompiler comp = null; try { if (args.length == 0) { ! help(); return EXIT_CMDERR; } --- 275,281 ---- JavaCompiler comp = null; try { if (args.length == 0) { ! help(OPT_STANDARD); return EXIT_CMDERR; } *************** *** 368,380 **** * @param key The key for the localized string. */ private static String getLocalizedString(String key) { ! return getText("javac." + key, null); } private static String getLocalizedString(String key, String arg0) { ! return getText("javac." + key, arg0); } private static final String javacRB = "com.sun.tools.javac.v8.resources.javac"; private static ResourceBundle messageRB; --- 378,394 ---- * @param key The key for the localized string. */ private static String getLocalizedString(String key) { ! return getText("javac." + key, null, null); } private static String getLocalizedString(String key, String arg0) { ! return getText("javac." + key, arg0, null); } + private static String getLocalizedString(String key, String arg0, String arg1) { + return getText("javac." + key, arg0, arg1); + } + private static final String javacRB = "com.sun.tools.javac.v8.resources.javac"; private static ResourceBundle messageRB; *************** *** 393,409 **** /** Get and format message string from resource. */ ! private static String getText(String key, String arg0) { if (messageRB == null) initResource(); try { ! String [] args = {arg0}; return MessageFormat.format(messageRB.getString(key), args); } catch (MissingResourceException e) { if (arg0 == null) arg0 = "null"; ! String [] args = {key, arg0}; String msg = "javac message file b
2004-06-11

PUBLIC COMMENTS .
2004-06-10

EVALUATION The javac.pipe.output property is obsolete and should not be brought forward to the new compiler. -Xstdout is useful under win32 due to shell inadequacies and should be brought forward. -Xstdout <filename> william.maddox@Eng 2000-10-25
2000-10-25