@PostConstruct and @PreDestroy method reported as unused elements
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 17
### What happened
Methods annotated with CDI @PostConstruct and @PreDestroy are reported as unused methods by the IDE Hints. Methods annotated with @PostConstruct and @PreDestroy are intended to be invoked by the CDI Framework implementation, not by the programmer. This error does not occur in 12.6 version.
### How to reproduce
1. Create a new Jakarta 10 Web Profile maven project;
2. Define a new CDI Managed Bean and add a private void method annotated with @PostConstruct and add a private void method annotaded with @PreDestroy;
3. The IDE wil hint these methods as "unused methods";
### Did this work correctly in an earlier version?
Apache NetBeans 12.6 or earlier
### Operating System
Oracle Linux 9.1 x64
### JDK
OpenJDK 11
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
_No response_
### Are you willing to submit a pull request?
No
Contributor guide
Research direction
No source file or test is named. Reproduce the warning in a Jakarta 10 Web Profile Maven project with private CDI lifecycle methods, then trace the IDE Hints logic that reports unused methods and its handling of @PostConstruct and @PreDestroy. Done means both annotations no longer produce unused-method warnings, with a regression test if the relevant test area is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100