Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 13566 Details for
Bug 70717
Batch compiler should report compilation errors to console
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to apply on HEAD
patch_for_70717.txt (text/plain), 12.04 KB, created by
Olivier Thomann
on 2004-07-23 12:08:59 EDT
(
hide
)
Description:
Patch to apply on HEAD
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2004-07-23 12:08:59 EDT
Size:
12.04 KB
patch
obsolete
>Index: Main.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.156 >diff -u -r1.156 Main.java >--- Main.java 21 Jul 2004 09:57:00 -0000 1.156 >+++ Main.java 23 Jul 2004 15:59:10 -0000 >@@ -49,6 +49,61 @@ > > public class Main implements ProblemSeverities, SuffixConstants { > >+ public static class Logger { >+ >+ PrintWriter out; >+ PrintWriter err; >+ PrintWriter log; >+ >+ public Logger(PrintWriter out, PrintWriter err) { >+ this.out = out; >+ this.err = err; >+ } >+ >+ public void setLog(PrintWriter log) { >+ this.log = log; >+ } >+ >+ public void close() { >+ if (log != null) { >+ this.log.close(); >+ } >+ } >+ >+ public void flush() { >+ this.out.flush(); >+ this.err.flush(); >+ if (this.log != null) { >+ this.log.flush(); >+ } >+ } >+ >+ public void printErr(String s) { >+ this.err.print(s); >+ if (this.log != null) { >+ this.log.print(s); >+ } >+ } >+ >+ public void printlnErr(String s) { >+ this.err.println(s); >+ if (this.log != null) { >+ this.log.println(s); >+ } >+ } >+ >+ public void printlnOut(String s) { >+ this.out.println(s); >+ } >+ >+ public void printlnOut() { >+ this.out.println(); >+ } >+ >+ public void printOut(char c) { >+ this.out.print(c); >+ } >+ } > static { > relocalize(); > } >@@ -63,7 +118,7 @@ > public String[] classpaths; > public String destinationPath; > public String[] encodings; >- public PrintWriter err; >+ public Logger logger; > public int exportedClassFilesCounter; > public String[] filenames; > public boolean generatePackagesStructure; >@@ -78,8 +133,6 @@ > public Map options; > public CompilerOptions compilerOptions; // read-only > >- public PrintWriter out; >- > public boolean proceed = true; > public boolean proceedOnError = false; > public boolean produceRefInfo = false; >@@ -93,8 +146,7 @@ > > public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) { > >- this.out = outWriter; >- this.err = errWriter; >+ this.logger = new Logger(outWriter, errWriter); > this.systemExitWhenFinished = systemExitWhenFinished; > this.options = new CompilerOptions().getMap(); > } >@@ -300,7 +352,7 @@ > // System.out.println(new CompilerOptions(this.options)); > // } > if (this.showProgress) >- this.out.println(Main.bind("progress.compiling")); //$NON-NLS-1$ >+ this.logger.printlnOut(Main.bind("progress.compiling")); //$NON-NLS-1$ > for (int i = 0; i < this.repetitions; i++) { > this.globalProblemsCount = 0; > this.globalErrorsCount = 0; >@@ -309,8 +361,8 @@ > this.exportedClassFilesCounter = 0; > > if (this.repetitions > 1) { >- this.out.flush(); >- this.out.println( >+ this.logger.flush(); >+ this.logger.printlnOut( > Main.bind( > "compile.repetition", //$NON-NLS-1$ > String.valueOf(i + 1), >@@ -320,40 +372,36 @@ > performCompilation(); > } > if (this.showProgress) >- this.out.println(); >+ this.logger.printlnOut(); > } > if (this.systemExitWhenFinished) { >- this.out.flush(); >- this.err.flush(); >+ this.logger.flush(); > System.exit(this.globalErrorsCount > 0 ? -1 : 0); > } > } catch (InvalidInputException e) { >- this.err.println(e.getMessage()); >+ this.logger.printlnErr(e.getMessage()); > if (this.systemExitWhenFinished) { >- this.out.flush(); >- this.err.flush(); >+ this.logger.flush(); > if (this.log != null) { >- this.err.close(); >- } >+ this.logger.close(); >+ } > System.exit(-1); > } > return false; > } catch (RuntimeException e) { // internal compiler failure > if (this.systemExitWhenFinished) { >- this.out.flush(); >- this.err.flush(); >+ this.logger.flush(); > if (this.log != null) { >- this.err.close(); >+ this.logger.close(); > } > System.exit(-1); > } > return false; > //e.printStackTrace(); > } finally { >- this.out.flush(); >- this.err.flush(); >+ this.logger.flush(); > if (this.log != null) { >- this.err.close(); >+ this.logger.close(); > } > } > if (this.globalErrorsCount == 0) >@@ -1169,7 +1217,7 @@ > // no user classpath specified. > String classProp = System.getProperty("java.class.path"); //$NON-NLS-1$ > if ((classProp == null) || (classProp.length() == 0)) { >- this.err.println(Main.bind("configure.noClasspath")); //$NON-NLS-1$ >+ this.logger.printlnErr(Main.bind("configure.noClasspath")); //$NON-NLS-1$ > classProp = System.getProperty("user.dir"); //$NON-NLS-1$ > } > StringTokenizer tokenizer = new StringTokenizer(classProp, File.pathSeparator); >@@ -1187,7 +1235,7 @@ > */ > String javaversion = System.getProperty("java.version");//$NON-NLS-1$ > if (javaversion != null && javaversion.equalsIgnoreCase("1.1.8")) { //$NON-NLS-1$ >- this.err.println(Main.bind("configure.requiresJDK1.2orAbove")); //$NON-NLS-1$ >+ this.logger.printlnErr(Main.bind("configure.requiresJDK1.2orAbove")); //$NON-NLS-1$ > this.proceed = false; > return; > } >@@ -1225,7 +1273,7 @@ > > if (this.log != null) { > try { >- this.err = new PrintWriter(new FileOutputStream(this.log, false)); >+ this.logger.setLog(new PrintWriter(new FileOutputStream(this.log, false))); > } catch (IOException e) { > throw new InvalidInputException(Main.bind("configure.cannotOpenLog")); //$NON-NLS-1$ > } >@@ -1264,7 +1312,7 @@ > for (int i = 0, max = this.classpaths.length; i < max; i++) { > File file = new File(this.classpaths[i]); > if (!file.exists()) { // signal missing classpath entry file >- this.err.println(Main.bind("configure.incorrectClasspath", this.classpaths[i])); //$NON-NLS-1$ >+ this.logger.printlnErr(Main.bind("configure.incorrectClasspath", this.classpaths[i])); //$NON-NLS-1$ > } > } > if (this.destinationPath == null) { >@@ -1391,7 +1439,7 @@ > this.lineDelta += unitLineCount; > if (Main.this.showProgress > && this.lineDelta > 2000) { // in -log mode, dump a dot every 2000 lines compiled >- Main.this.out.print('.'); >+ Main.this.logger.printOut('.'); > this.lineDelta = 0; > } > } >@@ -1404,8 +1452,8 @@ > if (problems[i] != null) { > Main.this.globalProblemsCount++; > if (localErrorCount == 0) >- Main.this.err.println("----------"); //$NON-NLS-1$ >- Main.this.err.print( >+ Main.this.logger.printlnErr("----------"); //$NON-NLS-1$ >+ Main.this.logger.printErr( > Main.this.globalProblemsCount > + ". " //$NON-NLS-1$ > + (problems[i].isError() >@@ -1416,18 +1464,18 @@ > } else { > Main.this.globalWarningsCount++; > } >- Main.this.err.print(" "); //$NON-NLS-1$ >- Main.this.err.print( >+ Main.this.logger.printErr(" "); //$NON-NLS-1$ >+ Main.this.logger.printErr( > Main.bind("requestor.in", new String(problems[i].getOriginatingFileName()))); //$NON-NLS-1$ > try { >- Main.this.err.println( >+ Main.this.logger.printlnErr( > ((DefaultProblem) problems[i]).errorReportSource(unitSource)); >- Main.this.err.println(problems[i].getMessage()); >+ Main.this.logger.printlnErr(problems[i].getMessage()); > } catch (Exception e) { >- Main.this.err.println( >+ Main.this.logger.printlnErr( > Main.bind("requestor.notRetrieveErrorMessage", problems[i].toString())); //$NON-NLS-1$ > } >- Main.this.err.println("----------"); //$NON-NLS-1$ >+ Main.this.logger.printlnErr("----------"); //$NON-NLS-1$ > if (problems[i].isError()) > localErrorCount++; > } >@@ -1435,8 +1483,7 @@ > // exit? > if (Main.this.systemExitWhenFinished && !Main.this.proceedOnError && (localErrorCount > 0)) { > Main.this.printStats(); >- Main.this.err.flush(); >- Main.this.out.flush(); >+ Main.this.logger.flush(); > System.exit(-1); > } > } >@@ -1565,7 +1612,7 @@ > } catch (IOException e) { > String fileName = this.destinationPath + new String(relativeName); > e.printStackTrace(); >- this.err.println(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$ >+ this.logger.printlnErr(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$ > } > this.exportedClassFilesCounter++; > } >@@ -1593,7 +1640,7 @@ > } catch (IOException e) { > String fileName = this.destinationPath + new String(relativeName); > e.printStackTrace(); >- this.err.println(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$ >+ this.logger.printlnErr(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$ > } > this.exportedClassFilesCounter++; > } >@@ -1633,7 +1680,7 @@ > > long time = System.currentTimeMillis() - this.startTime; > if (this.lineCount != 0) { >- this.out.println( >+ this.logger.printlnOut( > Main.bind( > "compile.instantTime", //$NON-NLS-1$ > new String[] { >@@ -1641,44 +1688,44 @@ > String.valueOf(time), > String.valueOf(((int)(this.lineCount * 10000.0 / time)) / 10.0)})); > } else { >- this.out.println(Main.bind("compile.totalTime", String.valueOf(time))); //$NON-NLS-1$ >+ this.logger.printlnOut(Main.bind("compile.totalTime", String.valueOf(time))); //$NON-NLS-1$ > } > } > if (this.globalProblemsCount > 0) { > if (this.globalProblemsCount == 1) { >- this.err.print(Main.bind("compile.oneProblem")); //$NON-NLS-1$ >+ this.logger.printErr(Main.bind("compile.oneProblem")); //$NON-NLS-1$ > } else { >- this.err.print( >+ this.logger.printErr( > Main.bind("compile.severalProblems", String.valueOf(this.globalProblemsCount))); //$NON-NLS-1$ > } >- this.err.print(" ("); //$NON-NLS-1$ >+ this.logger.printErr(" ("); //$NON-NLS-1$ > if (this.globalErrorsCount > 0) { > if (this.globalErrorsCount == 1) { >- this.err.print(Main.bind("compile.oneError")); //$NON-NLS-1$ >+ this.logger.printErr(Main.bind("compile.oneError")); //$NON-NLS-1$ > } else { >- this.err.print( >+ this.logger.printErr( > Main.bind("compile.severalErrors", String.valueOf(this.globalErrorsCount))); //$NON-NLS-1$ > } > } > if (this.globalWarningsCount > 0) { > if (this.globalErrorsCount > 0) { >- this.err.print(", "); //$NON-NLS-1$ >+ this.logger.printErr(", "); //$NON-NLS-1$ > } > if (this.globalWarningsCount == 1) { >- this.err.print(Main.bind("compile.oneWarning")); //$NON-NLS-1$ >+ this.logger.printErr(Main.bind("compile.oneWarning")); //$NON-NLS-1$ > } else { >- this.err.print( >+ this.logger.printErr( > Main.bind("compile.severalWarnings", String.valueOf(this.globalWarningsCount))); //$NON-NLS-1$ > } > } >- this.err.println(")"); //$NON-NLS-1$ >+ this.logger.printlnErr(")"); //$NON-NLS-1$ > } > if (this.exportedClassFilesCounter != 0 > && (this.showProgress || this.timing || this.verbose)) { > if (this.exportedClassFilesCounter == 1) { >- this.out.println(Main.bind("compile.oneClassFileGenerated")); //$NON-NLS-1$ >+ this.logger.printlnOut(Main.bind("compile.oneClassFileGenerated")); //$NON-NLS-1$ > } else { >- this.out.println( >+ this.logger.printlnOut( > Main.bind( > "compile.severalClassFilesGenerated", //$NON-NLS-1$ > String.valueOf(this.exportedClassFilesCounter))); >@@ -1686,13 +1733,11 @@ > } > } > public void printUsage() { >- this.out.println(Main.bind("misc.usage", System.getProperty("path.separator"))); //$NON-NLS-1$//$NON-NLS-2$ >- this.out.flush(); >- this.err.flush(); >+ this.logger.printlnOut(Main.bind("misc.usage", System.getProperty("path.separator"))); //$NON-NLS-1$//$NON-NLS-2$ >+ this.logger.flush(); > } > public void printVersion() { >- this.out.println(Main.bind("misc.version")); //$NON-NLS-1$ >- this.out.flush(); >- this.err.flush(); >+ this.logger.printlnOut(Main.bind("misc.version")); //$NON-NLS-1$ >+ this.logger.flush(); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 70717
: 13566