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 176240

Summary: EE (managed bean) Life-cycle methods considered as not used
Product: java Reporter: alexismp <alexismp>
Component: SourceAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal CC: arungupta, marfous, misterm, muellermi, mzao, pjiricka, sdedic, terje7601
Priority: P1    
Version: 6.x   
Hardware: PC   
OS: Mac OS X   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on:    
Bug Blocks: 232305    

Description alexismp 2009-11-09 07:40:02 UTC
(NB6.8beta)
In a Java EE managed bean (EJB, JSF managed bean, plain managed bean, etc...), methods annotated with @PostConstruct (@PreDestroy) are always marked as not used, while in fact they always are when executed in a container.
Comment 1 Jan Lahoda 2011-10-10 17:50:35 UTC
*** Bug 203198 has been marked as a duplicate of this bug. ***
Comment 2 Jan Lahoda 2012-07-02 09:48:25 UTC
*** Bug 215004 has been marked as a duplicate of this bug. ***
Comment 3 Marian Mirilovic 2012-10-17 11:16:22 UTC
*** Bug 176241 has been marked as a duplicate of this bug. ***
Comment 4 Jan Lahoda 2013-02-14 12:28:36 UTC
*** Bug 226104 has been marked as a duplicate of this bug. ***
Comment 5 Martin Fousek 2014-07-03 06:45:56 UTC
*** Bug 244076 has been marked as a duplicate of this bug. ***
Comment 6 Petr Jiricka 2014-07-14 08:17:50 UTC
5 duplicates - I think this deserves some consideration.
Comment 7 Martin Fousek 2014-07-21 08:46:19 UTC
*** Bug 244882 has been marked as a duplicate of this bug. ***
Comment 8 Martin Fousek 2014-07-21 08:48:27 UTC
(In reply to Petr Jiricka from comment #6)
> 5 duplicates - I think this deserves some consideration.

I must agree. Number of complaining users is growing.
Comment 9 misterm 2015-05-08 05:21:00 UTC
I can confirm this is really cumbersome. I like my error stripes clean, but some less experienced developers on the team might think these methods need some cleaning.

This issue should be expanded, based on duplicates such as 176241, as to cover unused Java EE boilerplate, such as @Id as well. Also notice any persistent fields on entities which are assigned are useful since they can be queried.
Comment 10 Svata Dedic 2015-09-22 15:26:59 UTC
Moving to java.source, marking as high prio ENHANCEMENT. There has to be a common API for specification-defined usage and / or names. E.g. 

* hints check naming and access rights, which might be defined by some technology (c.f. serialVersionUID)
* editor highlights unused symbols, which can be marked by annotations or injected in some special subtypes (c.f. @Autowired)

Not sure whether the API should allow to extend "usage" relationship to capture real usage of fields outside plain java access, i.e. Spring configuration for a property accesses setter etc.