Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 212342 - Incorrect error badges on invocations of methods with generated classes as parameters
Incorrect error badges on invocations of methods with generated classes as pa...
Status: VERIFIED FIXED
Product: editor
Classification: Unclassified
Component: Hints & Annotations
7.2
PC Linux
: P3 with 1 vote (vote)
: 7.2.1
Assigned To: Jan Lahoda
issues@editor
72patch2-verified
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-10 22:01 UTC by tms1979
Modified: 2012-10-11 13:13 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments
Test case (206.99 KB, application/zip)
2012-05-10 22:01 UTC, tms1979
Details
Command line output of javac and nb-javac that illustrate the bug (14.54 KB, text/plain)
2012-07-25 19:20 UTC, tms1979
Details
A release72 compatible nb-javac-impl.jar with a fix attempt (1.70 MB, application/java-archive)
2012-07-30 07:09 UTC, Jan Lahoda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tms1979 2012-05-10 22:01:27 UTC
Created attachment 119321 [details]
Test case

The test case should show the incorrect error badge issue right away in development builds. Note that I only see it in the nightly (201205100400) but I can't reproduce it in 7.1.2.

In certain circumstances invocations of methods that have generated classes as parameter types get an incorrect error badge. They also appear twice in the code completion popup, once with a normal entry and once with an entry that has no associated JavaDoc. The text messages for the error badges are of the following (amusing) form:
reference to generatedParameter is ambiguous, both method generatedParameter(GeneratedClass2) in TestAPApplication2 and method generatedParameter(GeneratedClass2) in TestAPApplication2 match.

Invocations of methods with a return type that is a generated class but without parameter types of generated classes don't show an incorrect error badge but won't show in the code completion popup.

The log gets filled with:
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=METHOD; sigs=testapapplication2.TestAPApplication2 generatedParameter (LGeneratedClass2;)V ]

And:
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Incorrect error badges detected, file=/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestAPApplication2.java.
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Going to recompute root=/home/thormick/NetBeansProjects/TestAPApplication2/src, files in error=[file:/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestClass.java, file:/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestAPApplication2.java].
Comment 1 tms1979 2012-05-23 20:14:29 UTC
Reproduced in 7.2beta, though what error badges go on what lines and class files as well as which JavaDoc entries are missing has changed.
Comment 2 Jiri Prox 2012-07-12 11:09:22 UTC
reproducible with the sample project
Comment 3 tms1979 2012-07-25 19:20:22 UTC
Created attachment 122375 [details]
Command line output of javac and nb-javac that illustrate the bug

Reproduced both in 7.2 release and in nb-javac.

Plain Old javac Compiler:

thormick@thormick-SH67H3 ~/src/netbeans/jet-main/thormick-work $ /usr/lib/jvm/java-7-openjdk-amd64/bin/javac -verbose -cp ~/NetBeansProjects/TestAPApplication2/lib/TestAP2.jar -processorpath ~/NetBeansProjects/TestAPApplication2/lib/TestAP2.jar -sourcepath ~/NetBeansProjects/TestAPApplication2/src -d classes -s source ~/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestAPApplication2.java ~/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestClass.java 
 ... snip, see attached log for full output ...
[checking testapapplication2.TestAPApplication2]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-7-openjdk-amd64/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]]
[wrote RegularFileObject[classes/testapapplication2/TestAPApplication2.class]]
[checking testapapplication2.GeneratedClass2]
[wrote RegularFileObject[classes/testapapplication2/GeneratedClass2.class]]
[checking testapapplication2.TestClass]
[wrote RegularFileObject[classes/testapapplication2/TestClass.class]]
[checking testapapplication2.GeneratedClass]
[wrote RegularFileObject[classes/testapapplication2/GeneratedClass.class]]
[total 215ms]
1 warning
thormick@thormick-SH67H3 ~/src/netbeans/jet-main/thormick-work $ find .
.
./classes
./classes/testapapplication2
./classes/testapapplication2/TestClass.class
./classes/testapapplication2/GeneratedClass.class
./classes/testapapplication2/TestAPApplication2.class
./classes/testapapplication2/GeneratedClass2.class
./source
./source/testapapplication2
./source/testapapplication2/GeneratedClass2.java
./source/testapapplication2/GeneratedClass.java
thormick@thormick-SH67H3 ~/src/netbeans/jet-main/thormick-work $ rm -rf classes/testapapplication2 source/testapapplication2

And nb-javac:

thormick@thormick-SH67H3 ~/src/netbeans/jet-main/thormick-work $ /usr/lib/jvm/java-7-openjdk-amd64/bin/java -cp ../nb-javac/make/netbeans/nb-javac/dist/javac-api.jar:../nb-javac/make/netbeans/nb-javac/dist/javac-impl.jar com.sun.tools.javac.Main -verbose -cp ~/NetBeansProjects/TestAPApplication2/lib/TestAP2.jar -processorpath ~/NetBeansProjects/TestAPApplication2/lib/TestAP2.jar -sourcepath ~/NetBeansProjects/TestAPApplication2/src -d classes -s source ~/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestAPApplication2.java ~/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestClass.java 
 ... snip ...
Round 2:
	input files: {}
	annotations: []
	last round: true
[checking testapapplication2.TestAPApplication2]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-7-openjdk-amd64/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]]
/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestAPApplication2.java:32: error: reference to generatedParameter is ambiguous, both method generatedParameter(GeneratedClass2) in TestAPApplication2 and method generatedParameter(GeneratedClass2) in TestAPApplication2 match
        testAPA2.generatedParameter(null); // There's no error badge on this line but it causes an error badge on the file in the source-tree. Rem it out and it goes away.
                ^
[checking testapapplication2.GeneratedClass2]
[checking testapapplication2.TestClass]
/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestClass.java:6: error: The type of returnGenerated() is erroneous
        testAPA2.returnGenerated(); // Shown 0 times when doing CTRL+space after the .
                ^
/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestClass.java:7: error: reference to generatedParameter is ambiguous, both method generatedParameter(GeneratedClass2) in TestAPApplication2 and method generatedParameter(GeneratedClass2) in TestAPApplication2 match
        testAPA2.generatedParameter(null); // Shown 2 times when doing CTRL+space after the .
                ^
/home/thormick/NetBeansProjects/TestAPApplication2/src/testapapplication2/TestClass.java:8: error: reference to parameterAndReturnGenerated is ambiguous, both method parameterAndReturnGenerated(GeneratedClass2) in TestAPApplication2 and method parameterAndReturnGenerated(GeneratedClass2) in TestAPApplication2 match
        testAPA2.parameterAndReturnGenerated(null); // Code completion OK.
                ^
[checking testapapplication2.GeneratedClass]
[total 176ms]
4 errors
4 warnings
thormick@thormick-SH67H3 ~/src/netbeans/jet-main/thormick-work $ find .
.
./classes
./source
./source/testapapplication2
./source/testapapplication2/GeneratedClass2.java
./source/testapapplication2/GeneratedClass.java
Comment 4 tms1979 2012-07-26 14:40:34 UTC
This bug can be traced back to nb-javac changeset 1615, http://hg.netbeans.org/main/nb-javac/rev/f0085bb2129a

Reverting the changes in tip fixes this on the command line, building NetBeans against this fixes the bugs I see in the editor.
Comment 5 Jan Lahoda 2012-07-26 15:06:53 UTC
(In reply to comment #4)
> This bug can be traced back to nb-javac changeset 1615,
> http://hg.netbeans.org/main/nb-javac/rev/f0085bb2129a

Yes, thanks and sorry for not updating the bug. This change is involved, but it seems that fixing this would not be enough - the classfiles produced when I disabled the first part of the change are still not fully correct, even though the errors are no longer produced.

> 
> Reverting the changes in tip fixes this on the command line, building NetBeans
> against this fixes the bugs I see in the editor.
Comment 6 tms1979 2012-07-26 15:14:31 UTC
> Yes, thanks and sorry for not updating the bug.
Quite alright, now I know this isn't overlooked. I didn't see any dev activity here and it's keeping me from using 7.2, so when it was released with this regression I just decided to give it another poke.

> This change is involved, but it
> seems that fixing this would not be enough - the classfiles produced when I
> disabled the first part of the change are still not fully correct, even though
> the errors are no longer produced.

Yeah, I suspected it wasn't that easy and that just reverting that would cause something else to pop up elsewhere. Thanks for the attention either way.
Comment 7 Jan Lahoda 2012-07-30 07:09:39 UTC
Created attachment 122516 [details]
A release72 compatible nb-javac-impl.jar with a fix attempt

If you could/would like to test the fix, replace the original:
${NETBEANS_INSTALL_DIR}/java/modules/ext/nb-javac-impl.jar
with the attached version (please keep the original in case something would go wrong), and change timestamp of ${NETBEANS_INSTALL_DIR}/java/.lastModified. With this patch, it should be even better than in 7.1 (fixes the attached case for me), but there are still dark corners we may need to investigate.

Thanks.
Comment 8 tms1979 2012-07-30 11:02:06 UTC
I've tested the fix and both the test case and the project I originally saw erroneous errors in look like they're fixed. Thank you!

> With this patch, it should be even better than in 7.1 (fixes the attached case
> for me), but there are still dark corners we may need to investigate.

I bet, I'll be sure to report anything I find in the future.
Comment 9 Jan Lahoda 2012-08-03 15:08:17 UTC
An improved version of the patch, that should handle overloaded method correctly as well:
http://hg.netbeans.org/main/nb-javac/rev/dacef54b96de
Merged into NetBeans proper as:
http://hg.netbeans.org/main-silver/rev/2cc4cc48034b

Probably too dangerous for patch 1, but if there will be a subsequent patch, it might be a good candidate.

Thanks for the report - if you see another/more problems, please file them. Thanks.
Comment 10 Jan Lahoda 2012-10-09 01:42:39 UTC
release72:
http://hg.netbeans.org/releases/rev/2e181de2a8ac
Comment 11 Quality Engineering 2012-10-10 14:17:00 UTC
Integrated into 'releases', will be available in build *201210100934* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/2e181de2a8ac
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #212342: Incorrect error badges on invocations of methods with generated classes as parameters (backported from default branch)


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