Mail Archive Home | fractal-commits List | August 2008 Index
| <-- Date Index --> | <-- Thread Index --> |
Improved error messages.
--- 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 --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.