OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | August 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[fractal-commits] [8405] trunk/juliac/plugin/jdt/src/main/java/org/objectweb/fractal/juliac/ compile/jdt/JDTCompiler.java: Improved error messages.


Title: [8405] trunk/juliac/plugin/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/JDTCompiler.java: Improved error messages.
Revision
8405
Author
seintur
Date
2008-08-28 20:35:46 +0200 (Thu, 28 Aug 2008)

Log Message

Improved error messages.

Modified Paths

Diff

Modified: trunk/juliac/plugin/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/JDTCompiler.java (8404 => 8405)


--- trunk/juliac/plugin/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/JDTCompiler.java	2008-08-28 17:21:12 UTC (rev 8404)
+++ trunk/juliac/plugin/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/JDTCompiler.java	2008-08-28 18:35:46 UTC (rev 8405)
@@ -71,14 +71,38 @@
         if (result.hasErrors()) {
             
             compilationHasErrors = true;
-            ICompilationUnit icu = result.compilationUnit;
-            SourceFile sf = units.get(icu);
             
             /*
              * Retrieve the name of the file where the error occured.
+             * 
+             * It happens that the source file may not be found. The cause of
+             * this is not yet clear to me, but a NPE was reported by S\xE9bastien
+             * Jourdain:
+             * http://mail.ow2.org/wws/arc/rntl-sco-2006/2008-08/msg00064.html
              */
+            ICompilationUnit icu = result.compilationUnit;
+            SourceFile sf = units.get(icu);
             StringBuffer msg = new StringBuffer();
-            msg.append(sf.toString());
+            if( sf == null ) {
+                char[][] packageNames = icu.getPackageName();
+                for (char[] packageName : packageNames) {
+                    msg.append(packageName);
+                    msg.append('.');
+                }
+                char[] mainTypeName = icu.getMainTypeName();
+                msg.append(mainTypeName);
+                msg.append(" (");
+                char[] fileName = icu.getFileName();
+                msg.append(fileName);
+                msg.append(')');
+            }
+            else {
+                /*
+                 * sf provides the absolute path to the source file whereas
+                 * icu.getFileName() only return its short name.
+                 */
+                msg.append(sf.toString());
+            }
             msg.append(':');
             
             /*


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.