nmatt opened a new issue, #8928:
URL: https://github.com/apache/netbeans/issues/8928

   ### Apache NetBeans version
   
   Apache NetBeans 27
   
   ### What happened
   
   A record class that is package-private is always shown as unused, unless 
there is a constructor invocation ("new" expression) in the same source file. 
The record class name is syntax-highlighted as unused, and a hint 'Remove 
unused "<record name>"' is shown, although the class is used within the same 
package.
   
   ### Language / Project Type / NetBeans Component
   
   _No response_
   
   ### How to reproduce
   
   Create a package-private record class:
   ```java
   package net.example;
   record Example(int n) { }
   ```
   Add a use of it in the same package:
   ```java
   package net.example;
   class Test { { System.out.println(new Example(0).n()); } }
   ```
   => The declaration of record Example erroneously shows it as unused.
   
   Add a usage within the record class itself:
   ```java
   package net.example;
   record Example(int n) { }
   class Test2 { { new Example(0); } }
   ```
   => The "unused" disappears.
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows 10
   
   ### JDK
   
   21
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to