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 246498 - Call to method of an annotation-processor-created class shown as error "cannot find symbol" for no apparent reason.
Summary: Call to method of an annotation-processor-created class shown as error "canno...
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Windows 8 x64
: P3 normal with 2 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-16 18:09 UTC by alangiv
Modified: 2016-09-13 17:28 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Example of the cannot find symbol. (10.40 KB, image/png)
2015-02-17 20:40 UTC, bisoldi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alangiv 2014-08-16 18:09:04 UTC
A static method of an annotation processor-created class is shown with a red underline yet the modules that call it build just fine and work properly at runtime.

Product Version = NetBeans IDE 8.0 (Build 201403101706)
Operating System = Windows 8 version 6.2 running on amd64
Java; VM; Vendor = 1.8.0_05
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.5-b02
Comment 1 alangiv 2014-08-16 19:17:05 UTC
More specifically: A call to a static or regular method of an annotation-processor-created class is shown with an error "cannot find symbol" yet the modules that call it build just fine, and work properly at run-time.

Now after some rebuilding, closing and reopening Netbeans and some more cleaning & rebuilding the error has gone away.  Most odd - this same cleaning and rebuilding went on before yet the error persisted.
Comment 2 alangiv 2014-08-17 10:43:39 UTC
At some stage something really broke and even the import statement of the generated class failed.  I checked the produced JAR file and the class was there as intended.  I cleaned and rebuilt all projects, restarted and cleaned several times and nothing changed.

Eventually I closed Netbeans, deleted the folder "8.0" in %USERPROFILE%\AppData\Local\NetBeans\Cache\ and now everything is working again, so I would say there is definitely a bug off sorts involved - something is not getting refreshed.
Comment 3 bisoldi 2015-02-17 19:56:39 UTC
I am experiencing (roughly) the same problem.  I reproduced the problem in Netbeans 8.0.2 in Ubuntu 14.04 with Oracle JDK 7.

In a @PostConstruct method, I'm trying to call a method on an @Inject object.  Odd thing is that it recognizes (autocompletes) all of the methods on that object except for one.  That one object has the same footprint as all the others (i.e. "public void").  I have that object's .java file open in NB and while NB doesn't recognize the method, it all compiles just fine.

What would be needed to demonstrate this case?
Comment 4 bisoldi 2015-02-17 20:00:43 UTC
Additionally, while it flags the method-call with "Cannot find symbol", the line with the red exclamation point and light bulb, AND the file in the Projects window, it does not flag the filename at the top as having an error.
Comment 5 bisoldi 2015-02-17 20:40:12 UTC
Created attachment 152041 [details]
Example of the cannot find symbol.
Comment 6 DavidLeoni 2015-09-13 10:40:57 UTC
When I get the 'cannot find symbol', along with the problems listed in the comments above, I also experience the impossibility to run tests involving flagged code, because I get ExceptionInInitializerError. Rebuilding solves issues, but of course it's time consuming when testing. 

Cleaning Netbeans cache fixes the problem, but (on windows, at least) takes time 
and seems to be required often.

Tested with Netbeans 8.0.2, Maven 3.0.5, JDK 1.7_10, Windows 7
Comment 7 bugmenot1 2016-02-23 15:37:43 UTC
In my case the import statement for the generated class was underlined, even after stopping NetBeans, deleting the cache, restarting NetBeans and rebuilding everything. This problem vanished after I installed the latest plugin updates today. I suggest to install the latest updates and maybe close this bug.
Comment 8 bugmenot1 2016-09-13 17:28:59 UTC
Disregard my last comment, the "problem gone" state was very temporary.

My case:
Two Maven projects M (model) and S (service). S uses M as a dependency.
M has generated classes.

In project S, a generated class from M does not show up in suggestions for import statements. When manually adding the correct import statement, the name of the generated class is underlined and the class using it is marked as erroneous in the file tree and in "Action Items". "Go to source" using Ctrl+Click on the name of the generated class does not work.

Tested with nightly build 201609130002. Deleting the cache (while NetBeans is closed) does not help.