This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 178452

Summary: Editor produces no error for missing annotation value
Product: java Reporter: Jesse Glick <jglick>
Component: SourceAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 199215    

Description Jesse Glick 2009-12-10 15:24:59 UTC
At least in a package-info.java, if I am missing a mandatory attribute in an annotation, the editor seems to display no error or warning.

(When I go to compile, the annotation processor dies with an IncompleteAnnotationException, but I should not have to wait that long.)
Comment 1 Jesse Glick 2009-12-18 12:51:38 UTC
Might ultimately be a bug in javac, since behavior even from an Ant build is odd: I would expect that a missing mandatory attribute would be flagged as a fatal error before annotation processors are even run. The Javadoc

"Thrown to indicate that a program has attempted to access an element of an annotation type that was added to the annotation type definition after the annotation was compiled (or serialized)."

gives no indication that this is expected to be thrown from inside an AP.
Comment 2 Jan Lahoda 2009-12-18 13:10:54 UTC
Yes, it is a bug in javac - there is actually no code to verify annotations on packages. I am not quite sure what is the proper fix, but a bit hackish solution would be to add explicit verification of package annotations of package-info.java in JavaCompiler.attribute.
Comment 3 Jesse Glick 2009-12-18 13:33:53 UTC
(In reply to comment #2)
> it is a bug in javac - there is actually no code to verify annotations on
> packages.

Interesting. I have also noticed that @SuppressWarnings is accepted without warning in package-info.java even though it is not declared to accept ElementType.PACKAGE!

These issues seem pretty basic. Is there a JDK bug filed? If so, can probably put jdk_bug_NNNNNNN in status whiteboard, close, and wait for fixes to appear in a JDK 7 javac drop.
Comment 4 Jan Lahoda 2009-12-18 14:06:27 UTC
Re @SuppressWarnings: that's the same problem (the annotation is never validated).

There is currently no JDK bug that I would know of - I was searching existing reports, but found nothing, and did not have time to report a new one yet.
Comment 5 Jesse Glick 2009-12-21 10:01:29 UTC
When you file a javac bug, please add me to the CC list.
Comment 6 Jan Lahoda 2010-08-04 13:12:21 UTC
I made a fix in NB:
http://hg.netbeans.org/jet-main/rev/228d93109f77
http://hg.netbeans.org/main/nb-javac/rev/584dfd1a6cf1

and contacted javac people. No response from them so far.
Comment 7 Quality Engineering 2010-08-06 03:19:29 UTC
Integrated into 'main-golden', will be available in build *201008060001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/228d93109f77
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #178452: new javac library: ensures that package annotations are validated and errors reported for them.