Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 113119 - Wrong annotation hints on @Annotation and implements
Wrong annotation hints on @Annotation and implements
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Hints
6.x
All All
: P4 with 1 vote (vote)
: 6.x
Assigned To: Jan Lahoda
issues@java
: NETFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-17 18:37 UTC by dalecooper82
Modified: 2009-05-22 07:21 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
wrong hint line (6.81 KB, image/png)
2007-08-20 22:53 UTC, dalecooper82
Details
wrong hint line (9.63 KB, image/png)
2007-08-20 22:54 UTC, dalecooper82
Details
Patch for java.hints (1.81 KB, patch)
2009-04-16 13:52 UTC, misterm
Details | Diff
Patch for java.hints (1.75 KB, patch)
2009-05-13 19:23 UTC, misterm
Details | Diff
Broken sample Java file for better fix (166 bytes, text/plain)
2009-05-13 19:24 UTC, misterm
Details
Broken sample Java file for better fix (146 bytes, text/plain)
2009-05-13 19:29 UTC, misterm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dalecooper82 2007-08-17 18:37:17 UTC
If I have

@Entity
public class EntityBean implements Serializable, TextInterface{

Then annotation hints on the line with @Entity offers to "Implement methods from TextInterface", while hints on the
class definition line says "Create EJB Persistence Unit"
Comment 1 Vitezslav Stejskal 2007-08-20 19:32:28 UTC
Could you please elaborate on what is actually wrong? I am sorry for my ignorance, but I don't know much about @Entity
and entity beans. Thanks.
Comment 2 dalecooper82 2007-08-20 22:35:37 UTC
Sure, np.

Simply put, the hints are switched. The hint on line with 

"public class SomeClass implements SomeInterface"

should offer to implement abstract methods (as is the case in NB551). Not the line with "@Entity"

Put aside @Entity, while coding I saw that in standard JSE classes/annotations too. It seems like the hint for
implementing abstract classes is somehow glued to previous annotation instead of offending line.

Is this better?

If I see that again with JSE, I will try to post example, screenshot.

Dale


Comment 3 dalecooper82 2007-08-20 22:52:05 UTC
a) I have renamed the issue as it is generic, not bound to @Entity annotation only but any Java @Annotation.

b) see attached screenshots I made with @Deprecated annotation. 

HTH, dale
Comment 4 dalecooper82 2007-08-20 22:53:27 UTC
Created attachment 46919 [details]
wrong hint line
Comment 5 dalecooper82 2007-08-20 22:54:16 UTC
Created attachment 46920 [details]
wrong hint line
Comment 6 Vitezslav Stejskal 2007-08-21 11:39:29 UTC
Thanks Dale for an excellent report. I'm passing it on to the hints guys for closer look.
Comment 7 Jan Lahoda 2007-08-28 13:31:29 UTC
Well, the "non-abstract" error is simply placed at the first line of the class header - which in the given case contains
only "@Deprecated" annotation.
Comment 8 David Strupl 2009-03-31 16:01:44 UTC
Resolving all issues with milestone "future" as LATER. If you feel strongly that
it should be implemented please reopen and set the target milestone to "next".
Comment 9 misterm 2009-03-31 16:05:43 UTC
I'd like to NetFIX [1] this bug. Is it possible? 
[1] http://wiki.netbeans.org/NetFIX
Comment 10 Jan Lahoda 2009-03-31 19:38:44 UTC
I am willing to review (and apply) the patch in java.hints, so you patch(es) is(are) welcome (unless Max, the current
owner of java.hints, disagrees).

I would recommend to first define the scope - what kind of errors do you want to move to a more appropriate place (and
what are the more appropriate places). The actual implementation of this should not be that difficult - see
ErrorHintsProvider.getLine in java.hints module. Creating a few tests would also be good, see ErrorHintsProviderTest in
java.hints. Note that there is a debugging panel "Errors" in the navigator that shows the error as returned by the
parser (javac): the start, end and preferred positions, error kind, etc. This panel is enabled only if assertions are
enabled in the IDE.

For the @Entity annotation, you would need to look at a different module (probably j2ee.jpa.verification or
j2ee.ejbverification).
Comment 11 misterm 2009-04-16 13:52:22 UTC
Created attachment 80251 [details]
Patch for java.hints
Comment 12 misterm 2009-04-16 13:58:59 UTC
To start, I have changed the way lines are highlighted for all class should be abstract errors (as listed in ImplementAllAbstractMethods). Now it highlights the class name instead of the annotation.

I also intend to change the EJB hint in order to highlight the annotation.

I find it hard to propose changes for the several other possible errors, so I think we should address just the cases 
that have been reported in this issue. Other cases will result in new issues that could be addressed on their own.

Still haven't had the time to look at the tests, sorry.
Comment 13 misterm 2009-05-07 14:55:54 UTC
j2ee.jpa.verification implements the Persistence Unit fix. However, given its common infrastructure for problem 
detection and highlighting, a clean fix to this module would require analyzing all warnings it can generate and decide 
which ones belong to the @Entity annotation, to the class and to other annotations it can handle.

Therefore, I suggest the current patch is applied to java.hints and another issue is filed against 
j2ee.jpa.verification.
Comment 14 Jan Lahoda 2009-05-10 18:10:50 UTC
The patch seems fine to me, except that "compiler.err.abstract.cant.be.instantiated" is listed twice. (Also, it might be
reasonable to replace the cascade if with a switch here, but that is nitpick). Would be good to have some tests,
however. If you could provide test cases (small Java classes on which the fixed version provides better results, similar to:
http://hg.netbeans.org/jet-main/file/tip/java.hints/test/unit/data/javahints/TestShortErrors1.java
), I can create the automated test cases from them myself.

Thanks.
Comment 15 misterm 2009-05-13 19:22:07 UTC
> The patch seems fine to me, except that "compiler.err.abstract.cant.be.instantiated" is listed twice. 

That's because ImplementAllAbstractMethods also contains the error twice in getCodes() and I used it to generate the 
strings. I will submit a new patch without the duplicated line.

> (Also, it might be reasonable to replace the cascade if with a switch here, but that is nitpick). 

Unless it falls through, that would actually change semantics, if I got the code right. For instance, the current code 
would move the token from dot in:

p.new Something();

to Something since it would match dot and new.

> Would be good to have some tests, however. If you could provide test cases (small Java classes on which the fixed 
> version provides better results, similar to: 
> http://hg.netbeans.org/jetmain/file/tip/java.hints/test/unit/data/javahints/TestShortErrors1.java), I 
> can create the automated test cases from them myself.

I will attach a few examples soon.
Comment 16 misterm 2009-05-13 19:23:19 UTC
Created attachment 82078 [details]
Patch for java.hints
Comment 17 misterm 2009-05-13 19:24:31 UTC
Created attachment 82079 [details]
Broken sample Java file for better fix
Comment 18 misterm 2009-05-13 19:29:24 UTC
Created attachment 82080 [details]
Broken sample Java file for better fix
Comment 19 Jiri Kovalsky 2009-05-14 13:19:13 UTC
Honzo, can you review the latest version of the patch? Thanks!
Comment 20 Jan Lahoda 2009-05-21 09:02:25 UTC
Thanks for the patch, I have integrated it:
http://hg.netbeans.org/jet-main/rev/68c1809c4fa4
Comment 21 misterm 2009-05-21 15:09:01 UTC
JPA issue submitted as # 165112. Closing this issue.
Comment 22 Quality Engineering 2009-05-22 07:21:22 UTC
Integrated into 'main-golden', will be available in build *200905220201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/68c1809c4fa4
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #113119: correct placing of error underline for compiler.err.does.not.override.abstract and compiler.err.abstract.cant.be.instantiated errors.

Contributed by misterm@netbeans.org.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo