participate


Annotation Processing - javac does not print enough information about an exception
<<   Back to Forum  |   Give us Feedback Topics: « Previous | Next
This topic has 4 replies on 1 page.
sahoo
Posts:69
Registered: 11/19/04
javac does not print enough information about an exception   
Nov 27, 2007 9:32 PM

 
I am very surprised to find that javac does not print the stack trace of exceptions that are thrown by annotation processors, not even in -verbose mode. Nor does it tell me which annotation processor threw the exception. Given below is an example of javac output in -verbose mode:
Round 1:
input files: {sahoo.EmploymentRecord}
annotations: [javax.persistence.Embeddable]
last round: false
error: Exception thrown while constructing Processor object: java.lang.NullPointerException

What's harm in printing more details about the exception?

Sahoo
 
brucechapman
Posts:692
Registered: 24/11/98
Re: javac does not print enough information about an exception   
Nov 28, 2007 1:01 PM (reply 1 of 4)  (In reply to original post )

 
What's harm in printing more details about the exception?

This is a known issue.

If you are developing an annotation processor, you want to see the stack trace. But if someone else is running your buggy annotation processor, then they probably don't want to see it. At the moment javac does not know what sort of user you are. I think there is a desire to address this at some point. The thinking is that the terse mode would be normal, but processor developers could use a command line switch to enable full stack trace output. At least it is better than it was, javac used to report Exceptions from processors as though they were bugs in javac and asked the user to file a bug with Sun!

Actually, in the case you posted, the exception was not thrown while running the processor, but while constructing it. Check your default constructor, and initializers.
 
j.d.darcy
Posts:175
Registered: 3/8/05
Re: javac does not print enough information about an exception   
Nov 28, 2007 7:03 PM (reply 2 of 4)  (In reply to #1 )

 
brucechapman wrote:
What's harm in printing more details about the exception?

This is a known issue.

If you are developing an annotation processor, you want to see the stack trace. But if someone else is running your buggy annotation processor, then they probably don't want to see it. At the moment javac does not know what sort of user you are. I think there is a desire to address this at some point. The thinking is that the terse mode would be normal, but processor developers could use a command line switch to enable full stack trace output. At least it is better than it was, javac used to report Exceptions from processors as though they were bugs in javac and asked the user to file a bug with Sun!

Bruce is correct. While writing the javac implementation of JSR 269, we had internal discussion over how to handle such issues. Since we assumed there would be many more people running annotation processors rather than developing them, by default the stack trace is not shown. Bug 6401798 "Add -Xlint=developer option to help debug annotation processing issues" was filed to track the need to provide more detailed information to annotation processor developers.
 
brucechapman
Posts:692
Registered: 24/11/98
Re: javac does not print enough information about an exception   
Nov 29, 2007 1:35 AM (reply 3 of 4)  (In reply to #2 )

 
This is not your case, but I have in the past wrapped my whole process method in a try {} catch (exception e) {} block in order to print out an exception to find exactly where it was coming from, not ideal, but it does the trick.

Though as I said, for your case it seems to be somewhere in the constructor / initializers. You could just try constructing a new instance inside a main() method in a temporary class, and see if that sheds any light on your problem.

Bruce
 
sahoo
Posts:69
Registered: 11/19/04
Re: javac does not print enough information about an exception   
Nov 29, 2007 6:34 AM (reply 4 of 4)  (In reply to #3 )

 
The exception was coming from @Override init(). Yes, I know wrapping the whole method body with try catch (Exception e) does the trick and that's what I have done in my code; I thought I mentioned it while posting the original question. Having said that I would love to see the RFE #6401798 being addressed in some future release.

Thanks,
Sahoo
 
This topic has 4 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 133

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums