Bug 138171 - Internal compilation error while copying resources
Summary: Internal compilation error while copying resources
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 142383 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-24 00:19 EDT by Ramnivas Laddad CLA
Modified: 2006-05-18 06:49 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ramnivas Laddad CLA 2006-04-24 00:19:17 EDT
This is with 1.5.1a.

I am developing a web application and I ran into this compiler crash.
The resource to be copied (Thumbs.db) was in use and therefore could
not be copied. However, AJC ended up producing an internal error instead
of a warning or a normal error.

java.io.FileNotFoundException
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at org.aspectj.util.FileUtil.makeOutputStream(FileUtil.java:1258)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.writeResource(AjBuildManager.java:504)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.copyResourcesFromFile(AjBuildManager.java:482)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.copyResourcesToDestination(AjBuildManager.java:424)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:320)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:161)
at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122)
at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

FileNotFoundException thrown: C:\work\workspace\MyCompany\class\images\Thumbs.db (Access is denied)
Comment 1 Wes Isberg CLA 2006-05-10 13:33:42 EDT
The problem is not that the compiler fails, but the message isn't nice.  But errors I think are restricted to compile-time errors - not unexpected exceptions stemming from configuration errors.

I don't see a clean way around the verbosity, but I agree with the sentiment.  It would be nice if for every stack trace stemming from a user or environment error we could guess  what the error was a provide instructions on how to fix - or at least note for IOExceptions the affected file in an error message.  Here I think the message (at the bottom) is clear enough, but printing the stack might be unnecessary.  But I don't think we can know for all these whether to print the stack; we might know it in FileUtil.makeOutputStream(..) or in all the callers thereof, but we can't really call it a compiler error so it ends up being an abort, handled like all the others.

Reopen if you disagree, but I don't see a clean fix for this class of problems, and a point fix for this case introduces a new kind of error.  It might be that we create a new message kind, AbortWarning, which stops processing but by convention only emits a message and not a trace.  that crosscutting smell.
Comment 2 Ramnivas Laddad CLA 2006-05-10 19:35:42 EDT
Any stack trace produced by a compiler is very unnerving to user--new or old.
It reduces confidence in the tool due to a dobut that there may be more 
problems not yet known. I don't remember, for example, Javac ever producing 
a stack trace.

Here I can see a nice message produced by the compiler:
Error copying resources: C:\work\workspace\MyCompany\class\images\Thumbs.db (Access is denied)

Here is an advice that would do the job (not that I am suggesting this as necessarily a good way of implementing, but only as a possible way):
Object around() : execution(* FileUtil.makeOutputStream(..))
      && cflow(execution(* AjBuildManager.copyResourcesToDestination(..))) {
    try {
         return proceed();
    } catch (IOException ex) { // or perhaps even Exception
         printError("Error copying resources: " + ex.getMessage());
    }
}
Comment 3 Andrew Clement CLA 2006-05-18 02:51:05 EDT
*** Bug 142383 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Clement CLA 2006-05-18 04:18:51 EDT
I've fixed this - now a proper error is produced for this case rather than a stack trace.  My fix is a *bit* like Ramnivas' aspect hand coded ;)

fix will be in next dev build.
Comment 5 Andrew Clement CLA 2006-05-18 06:49:07 EDT
fix available.