Mercurial > hg > truffle
diff graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java @ 16045:a8322288e838
improve error reporting in MatchProcessor
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 05 Jun 2014 12:16:36 -0700 |
parents | 6a62ccbd1658 |
children | 2acc00d0322a |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Thu Jun 05 20:33:33 2014 +0200 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Thu Jun 05 12:16:36 2014 -0700 @@ -52,20 +52,22 @@ * channel for any debug messages and debugging annotation processors requires some special * setup. */ - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; - private static final String LOGFILE = new File(System.getProperty("java.io.tmpdir"), "hotspotvmconfigprocessor.log").getPath(); - - private static PrintWriter log; + private PrintWriter log; /** - * Logging facility for the debugging the annotation processor. + * Logging facility for debugging the annotation processor. */ - private static synchronized PrintWriter getLog() { + private PrintWriter getLog() { if (log == null) { try { - log = new PrintWriter(new FileWriter(LOGFILE, true)); + // Create the log file within the generated source directory so it's easy to find. + // /tmp isn't platform independent and java.io.tmpdir can map anywhere, particularly + // on the mac. + FileObject file = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", getClass().getSimpleName() + "log"); + log = new PrintWriter(new FileWriter(file.toUri().getPath(), true)); } catch (IOException e) { // Do nothing } @@ -73,7 +75,7 @@ return log; } - private static synchronized void logMessage(String format, Object... args) { + private void logMessage(String format, Object... args) { if (!DEBUG) { return; } @@ -84,7 +86,7 @@ } } - private static synchronized void logException(Throwable t) { + private void logException(Throwable t) { if (!DEBUG) { return; } @@ -104,7 +106,7 @@ logMessage("throw for %s:\n", element); } logException(t); - processingEnv.getMessager().printMessage(Kind.ERROR, "Exception throw during processing: " + t.toString() + " " + Arrays.toString(Arrays.copyOf(t.getStackTrace(), 8)), element); + errorMessage(element, "Exception throw during processing: %s %s", t, Arrays.toString(Arrays.copyOf(t.getStackTrace(), 4))); } //@formatter:off