fix for bug #817, hide javac warning msgs

This commit is contained in:
benfry
2008-06-11 17:32:56 +00:00
parent c76c7c7bc4
commit 0244e095d0
3 changed files with 82 additions and 54 deletions
+45 -30
View File
@@ -44,16 +44,16 @@ public class Compiler {
* @return
* @throws RunnerException Only if there's a problem. Only then.
*/
public boolean compile(Sketch sketch,
public boolean compile(Sketch sketch,
String buildPath) throws RunnerException {
// This will be filled in if anyone gets angry
RunnerException exception = null;
String baseCommand[] = new String[] {
"-source", "1.5",
"-target", "1.5",
"-target", "1.5",
"-classpath", sketch.getClassPath(),
"-nowarn", // we're not currently interested in warnings (ignored?)
"-nowarn", // we're not currently interested in warnings (ignored?)
"-d", buildPath // output the classes in the buildPath
};
//PApplet.println(baseCommand);
@@ -94,36 +94,51 @@ public class Compiler {
};
// Wrap as a PrintWriter since that's what compile() wants
PrintWriter writer = new PrintWriter(internalWriter);
result = com.sun.tools.javac.Main.compile(command, writer);
// Close out the stream for good measure
writer.flush();
writer.close();
BufferedReader reader =
BufferedReader reader =
new BufferedReader(new StringReader(errorBuffer.toString()));
String line = null;
while ((line = reader.readLine()) != null) {
//System.out.println("got line " + line); // debug
// Check to see if this is the last line.
String lastFormat = "\\d+ error[s]?";
if (PApplet.match(line, lastFormat) != null) {
if ((PApplet.match(line, "\\d+ error[s]?") != null) ||
(PApplet.match(line, "\\d+ warning[s]?") != null)) {
break;
}
// Hide these because people are getting confused
// http://dev.processing.org/bugs/show_bug.cgi?id=817
// com/sun/tools/javac/resources/compiler.properties
if (line.startsWith("Note: ")) {
// if you mention serialVersionUID one more time, i'm kickin' you out
if (line.indexOf("serialVersionUID") != -1) continue;
// {0} uses unchecked or unsafe operations.
// Some input files use unchecked or unsafe operations.
if (line.indexOf("or unsafe operations") != -1) continue;
// {0} uses or overrides a deprecated API.
// Some input files use or override a deprecated API.
if (line.indexOf("or override") != -1) continue;
// Recompile with -Xlint:deprecation for details.
// Recompile with -Xlint:unchecked for details.
if (line.indexOf("Recompile with -Xlint:") != -1) continue;
System.err.println(line);
continue;
}
//System.out.println("got line " + line);
String errorFormat = "([\\w\\d_]+.java):(\\d+):\\s*(.*)\\s*";
String[] pieces = PApplet.match(line, errorFormat);
if (pieces == null) {
exception = new RunnerException("Cannot parse error text: " + line);
exception.hideStackTrace();
// Send out the rest of the error message to the console.
// Send out the rest of the error message to the console.
System.err.println(line);
while ((line = reader.readLine()) != null) {
System.err.println(line);
@@ -134,7 +149,7 @@ public class Compiler {
// Line numbers are 1-indexed from javac
int dotJavaLineIndex = PApplet.parseInt(pieces[1]) - 1;
String errorMessage = pieces[2];
int codeIndex = -1;
int codeLine = -1;
for (int i = 0; i < sketch.getCodeCount(); i++) {
@@ -148,7 +163,7 @@ public class Compiler {
if (codeIndex == 0) { // main class, figure out which tab
for (int i = 1; i < sketch.getCodeCount(); i++) {
SketchCode code = sketch.getCode(i);
SketchCode code = sketch.getCode(i);
if (code.flavor == Sketch.PDE) {
if (code.preprocOffset <= dotJavaLineIndex) {
@@ -166,16 +181,16 @@ public class Compiler {
if (errorMessage.equals("cannot find symbol")) {
handleCannotFindSymbol(reader, exception);
} else if (errorMessage.startsWith("package") &&
errorMessage.endsWith("does not exist")) {
exception = new RunnerException("P" + errorMessage.substring(1) +
exception = new RunnerException("P" + errorMessage.substring(1) +
". You might be missing a library.");
exception.hideStackTrace();
} else {
exception = new RunnerException(errorMessage);
}
exception = new RunnerException(errorMessage);
}
}
} catch (IOException e) {
String bigSigh = "Error while compiling. (" + e.getMessage() + ")";
@@ -189,10 +204,10 @@ public class Compiler {
// Success means that 'result' is set to zero
return (result == 0);
}
// Tell-tale signs of old code copied and pasted from the web.
// Detect classes BFont, BGraphics, BImage; methods framerate, push;
// Tell-tale signs of old code copied and pasted from the web.
// Detect classes BFont, BGraphics, BImage; methods framerate, push;
// and variables LINE_LOOP and LINE_STRIP.
static HashMap crusties = new HashMap();
static {
@@ -206,7 +221,7 @@ public class Compiler {
}
void handleCannotFindSymbol(BufferedReader reader,
void handleCannotFindSymbol(BufferedReader reader,
RunnerException rex) throws IOException {
String symbolLine = reader.readLine();
/*String locationLine =*/ reader.readLine();
@@ -214,12 +229,12 @@ public class Compiler {
String caretLine = reader.readLine();
rex.setColumn(caretColumn(caretLine));
String[] pieces =
String[] pieces =
PApplet.match(symbolLine, "symbol\\s*:\\s*(\\w+)\\s+(.*)");
if (pieces != null) {
if (pieces[0].equals("class") ||
pieces[0].equals("variable")) {
rex.setMessage("Cannot find a " + pieces[0] + " " +
rex.setMessage("Cannot find a " + pieces[0] + " " +
"named \u201C" + pieces[1] + "\u201D");
if (crusties.get(pieces[1]) != null) {
handleCrustyCode(rex);
@@ -231,8 +246,8 @@ public class Compiler {
String methodName = pieces[1].substring(0, leftParen);
String methodParams = pieces[1].substring(leftParen + 1, rightParen);
String message =
String message =
"Cannot find a function named \u201C" + methodName + "\u201D";
if (methodParams.length() > 0) {
if (methodParams.indexOf(',') != -1) {
@@ -255,15 +270,15 @@ public class Compiler {
}
}
}
void handleCrustyCode(RunnerException rex) {
rex.setMessage("This code needs to be updated, " +
"please read the \u201Cchanges\u201D reference.");
Base.showReference("changes.html");
}
protected int caretColumn(String caretLine) {
return caretLine.indexOf("^");
}
+10 -7
View File
@@ -1,5 +1,11 @@
0141 core
_ P3D smooshes the top row of pixels when drawing text (or images)
_ http://dev.processing.org/bugs/show_bug.cgi?id=466
_ textAlign(CENTER) with P3D and OPENGL produces messy result
_ probably rounding error with the images
_ http://dev.processing.org/bugs/show_bug.cgi?id=475
_ pdf not rendering unicode (though it renders to screen)
_ try updating to newer itext
@@ -168,9 +174,6 @@ _ perhaps also DEL or other nonprintables?
_ book example 25-03
_ when using createFont("xxxx.ttf"), should use textMode(SHAPE) with PDF
_ because ttf files will not be installed on the system when opening pdf
_ textAlign(CENTER) with P3D and OPENGL produces messy result
_ probably rounding error with the images
_ http://dev.processing.org/bugs/show_bug.cgi?id=475
_ text position is quantized in JAVA2D
_ http://dev.processing.org/bugs/show_bug.cgi?id=806
@@ -185,6 +188,8 @@ _ leave smooth off, get the gl object, then enable line smooth
threading [1.0]
_ major threading overhaul before 1.0 (compendium)
_ http://dev.processing.org/bugs/show_bug.cgi?id=511
_ PDE locks up during setup() (since no window shown)
_ http://dev.processing.org/bugs/show_bug.cgi?id=687
_ if too many errors come through during setup, app will terminate
@@ -193,8 +198,6 @@ _ seen especially on old mac laptops (slow ppc garbage)
_ Frame skipping with processor intensive applets using 1.6
_ http://dev.processing.org/bugs/show_bug.cgi?id=766
_ introduce calc()
_ major threading overhaul before 1.0 (compendium)
_ http://dev.processing.org/bugs/show_bug.cgi?id=511
_ applet sizing issues with external vm
_ could this possibly be related to the linux bug?
_ http://dev.processing.org/bugs/show_bug.cgi?id=430
@@ -411,12 +414,12 @@ _ is there a way to catch cmd-q when running a sketch?
_ so that it could avoid quitting if the sketch hasn't been stopped
_ or if the sketch window is foremost
_ maybe a hack where a new menubar is added?
_ --display not working on osx
_ http://dev.processing.org/bugs/show_bug.cgi?id=531
CORE / PFont and text()
_ P3D smooshes the top row of pixels when drawing text (or images)
_ http://dev.processing.org/bugs/show_bug.cgi?id=466
_ some fonts broken in java 1.5 on osx have changed again
_ http://dev.processing.org/bugs/show_bug.cgi?id=407
_ filed as bug #4769141 with apple
+27 -17
View File
@@ -1,4 +1,11 @@
0141 pde
X hide javac warning messages
X "xxxx xxxx uses unsafe operations.", "recompile with -Xlint:xxxx"
X http://dev.processing.org/bugs/show_bug.cgi?id=817
_ nanoxml getChildren() et al should use getFullName() not getName()
_ http://dev.processing.org/bugs/show_bug.cgi?id=813
charset changes
_ make sure that export is using utf8 for writing the .pde files etc
@@ -14,10 +21,10 @@ o this is a bad idea--since it's probably
X need to set a default charset for use in files (utf8)
X add option to change charset or specify as part of loading
X need to specify the default encoding
_ xml element needs to be readable from other charsets
_ same with the other methods like loadStrings()
_ could also be a way to handle gzip too?
_ tho charset + gzip would be a problem
fixed earlier
X stop button sometimes causes lockups when libraries or code folder is in use
X http://dev.processing.org/bugs/show_bug.cgi?id=126
. . .
@@ -31,8 +38,8 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=49
_ (could also just warn user to install elsewhere)
o perhaps the get around this by building into sketch folder
o when non-ascii chars in use, just launch everything externally
_ also fails with export-to-application
_ http://dev.processing.org/bugs/show_bug.cgi?id=252
_ export and export to application fail with umlauts in folder name
_ http://dev.processing.org/bugs/show_bug.cgi?id=252
_ too many NPEs on loadimage may freeze the app (visualizar example?)
_ hopefully this should be fixed with 0136 changes
_ lots of runtime exceptions still being lost on osx
@@ -40,29 +47,26 @@ _ particularly with multi-threaded applications
_ macosx dropping exceptions all the time.. grr
_ solution is to export, and then see how it runs
_ this is particularly bad with threaded applications
_ stop button needs to update itself and work properly [1.0]
_ also editor buttons to light up and clear properly
_ http://dev.processing.org/bugs/show_bug.cgi?id=396
_ need someone to go out and test all scenarios of this
[ known bugs ]
_ "Target VM failed to initialize: VM initialization failed" when trying to run
_ http://dev.processing.org/bugs/show_bug.cgi?id=796
_ slow response on file, sketchbook, and examples menus
_ http://dev.processing.org/bugs/show_bug.cgi?id=786
_ could be all the listeners?
_ actually it's prolly just the insertMenu() garbage
_ need to have a better way of dealing with this
_ sometimes not launching
_ (in particular while cpu load is a little higher on g5?)
_ http://dev.processing.org/bugs/show_bug.cgi?id=775
_ this may just be a macosx (ppc?) bug
_ stop button needs to update itself and work properly [1.0]
_ also editor buttons to light up and clear properly
_ http://dev.processing.org/bugs/show_bug.cgi?id=396
_ need someone to go out and test all scenarios of this
. . .
@@ -71,6 +75,7 @@ new/open/close/save
_ file-save stops running sketch
_ http://dev.processing.org/bugs/show_bug.cgi?id=810
_ don't copy hidden files (.svn especially) on export/save as
_ http://dev.processing.org/bugs/show_bug.cgi?id=761
_ make .java files and friends go to correct locations on export (app)
_ on mac, window opens to prevent quit on close
_ but the window is not properly set as untitled
@@ -184,6 +189,7 @@ _ e.g. ocd is broken in 0125 because of method signature changes
DOC / Bugzilla
_ remove LATER, REMIND, WORKSFORME as categories; add VERIFY
_ set default reported bug priority to 4 or 5
_ * disable changes to a bug (except by admin) after closed *
_ fix "reply" garbage added
@@ -600,7 +606,8 @@ _ preprocessor error if last line of code is a comment with no CR after it,
_ an OutOfMemoryError wants to happen,
_ but right now there's a hack to add a CR in PdePreprocessor
_ http://dev.processing.org/bugs/show_bug.cgi?id=5
_ Parsing error when using char literals
_ http://dev.processing.org/bugs/show_bug.cgi?id=281
PDE / Editor
@@ -637,8 +644,6 @@ _ unchecking 'use external editor' sketch should not set modified
_ dangerous if a version that hasn't been re-loaded has possibility
_ to overwrite. i.e. make a change and save in external editor,
_ don't actually
_ run/stop button highlight is almost completely broken
_ http://dev.processing.org/bugs/show_bug.cgi?id=396
_ when running with external editor, hide the editor text area
_ http://dev.processing.org/bugs/show_bug.cgi?id=20
_ horizontal scroller gets weird sometimes
@@ -1065,7 +1070,7 @@ _ java.lang.NoClassDefFoundError: quicktime/std/StdQTException
_ people not installing qt? no QTJAVA set?
_ http://dev.processing.org/bugs/show_bug.cgi?id=669
_ simulate this by removing qtjava.zip, then make a handler for it
_ then close the bug because nobody ever responds
_ which will open the reference for it
_ add more information about multiple camera inputs
_ add info about "access" errors being quicktime errors
_ documented in faq, add something to the lib "camera not installed"
@@ -1132,6 +1137,11 @@ _ http://www.adobe.com/svg/eol.html
LIBRARIES / XML
_ handle charset decoding in xml element parser?
_ same with the other methods like loadStrings()
_ could also be a way to handle gzip too?
_ tho charset + gzip would be a problem
_ need to handle how save() works inside xml lib
_ need to handle <!ENTITY tags for svg documents
_ vectors shouldn't be exposed, need to expose attr lists as arrays