Bug 54819 - Improve error messages from compiler / weaver
Summary: Improve error messages from compiler / weaver
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.2   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-15 09:52 EST by Adrian Colyer CLA
Modified: 2004-03-15 11:35 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Colyer CLA 2004-03-15 09:52:12 EST
Raising this enhancement request as a placeholder to capture work done in the
run up to 1.2. 

Three changes to message reporting are covered:

* print "error" or "warning" in front of messages output by command-line 
compiler (as appropriate of course)
* provide context information for messages output by weaver when source files 
are available
* provide "see also" references to binary source location (e.g. jar file) when 
source files are not available.
Comment 1 Adrian Colyer CLA 2004-03-15 11:35:53 EST
Now giving source or binary context whenever we can, and printing warning or 
error in front of command-line messages where appropriate

Samples of new message output:

For compiling tests/errors/DeclareError.java: 

AspectJ 1.1.1 would output: 
C:\ColyerRoot\...\tests\errors\DeclareError.java:5 can only call bad from C 

AspectJ 1.2 outputs: 

C:\ColyerRoot\...\tests\errors\DeclareError.java:5 error can only call bad from 
C 
new C().bad(); 
^^^^^^^^^^^^^^ 
        see also: C:\ColyerRoot\...\tests\errors\DeclareError.java:25 

(adds in source context information whenever it can). 

Here's how it looks when there is no source code available (i.e. we are passing 
binary source into the compiler). I took the contents of 
tests/errors/DeclareError.java and split each type into its own file, then 
compiled all but the aspect into cdd.jar. The resulting output is now the result 
of compiling A.java (the aspect) with -injars cdd.jar. 

AspectJ 1.1.1 would output: 
C:\ColyerRoot\...\org.aspectj.ajdt.core\D.java:6 can only call bad from C 

note that the file is reported as <working directory>\D.java. The D.java portion 
is the file name contained within D.class in cdd.jar. The prefix is appended by 
our message printer, even though in this case it is wrong (D.java was never in 
that directory). 

AspectJ 1.2 outputs:
D.java:6 error can only call bad from C 
(no source information available) 
        see also: C:
\ColyerRoot\Data\AspectJDev\AspectJ_M6_Port\tests\errors\amctemp\A.java:5 
        see also: C:
\ColyerRoot\Data\AspectJDev\AspectJ_M6_Port\tests\errors\amctemp\cdd.jar 

This informs the user that the error was found in binary source (no source 
information available), and adds a see also: line for the location of the binary 
source (in this case cdd.jar). The prefix is added to D.java only if file.
exists(). 
Note that an alternate design would be to not include the "see also" for the 
jar, but instead output something like this: 

C:\ColyerRoot\Data\AspectJDev\AspectJ_M6_Port\tests\errors\amctemp\cdd.jar (D.
java:6) error can only call bad from C 
(no source information available) 
        see also: C:
\ColyerRoot\Data\AspectJDev\AspectJ_M6_Port\tests\errors\amctemp\A.java:5 

I didn't do this because (a) for classes in packages the first line will 
probably get too long, and (b) it means that the filename in the source location 
is not a valid filename, and clients of the API might reasonably expect it to be 
so.