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.
Summary: | Incorrect error badges on invocations of methods with generated classes as parameters | ||
---|---|---|---|
Product: | editor | Reporter: | tms1979 <tms1979> |
Component: | Hints & Annotations | Assignee: | Jan Lahoda <jlahoda> |
Status: | VERIFIED FIXED | ||
Severity: | normal | CC: | mmirilovic |
Priority: | P3 | ||
Version: | 7.2 | ||
Hardware: | PC | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
Test case
Command line output of javac and nb-javac that illustrate the bug A release72 compatible nb-javac-impl.jar with a fix attempt |
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. reproducible with the sample project 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
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. (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. > 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. 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.
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.
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. 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) |
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].