Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
12.4
-
None
-
NetBeans 12.4 without nb-javac installed (started from clean user and cache directories to ensure no trace of nb-javac was left from my old installation). Java 11.0.11 or Java 17-ea+25. Windows 10.
Description
Very great to see Compile-on-Save now working without the external nb-javac plugin! Here's the first bug I've found around this. To reproduce, create an empty maven-based Java project and add the following class:
public class StaticInitializerExample { private static final String SOME_CONSTANT; static { SOME_CONSTANT = "I am a constant."; } public static final void main(String args[]) { System.out.println(SOME_CONSTANT); } }
Do a clean build and run. The application will print, "I am a constant."
Now do any trivial change to the code, such as adding a comment, and save. Run again. The application will now print "null", rather than the correct output.
Tested on both Java 11.0.11 and Java 17-ea+25. I also tested with NetBeans 11.3 with nb-javac installed; in that case the output is correct (still "I am a constant."). In the latter case you can also change the constant in the static initializer, and CoS will apply the change correctly.
Attachments
Issue Links
- fixes
-
NETBEANS-6062 Static block not executed in Java Ant project
-
- Closed
-
- is duplicated by
-
NETBEANS-5832 Static block not compiled
-
- Resolved
-