Details
Description
1. Create a Maven project with just this simple class:
public class Truc { private static Integer n; static { n = 123; } public static void main(String[] args) { System.out.println("n is " + n); } }
2. Execute it with Run File or Run Project.
-> The program outputs "n is null".
3. Execute it with Clean and Build Project.
-> The program outputs "n is 123".
In fact, each time the source is changed, running it with Run File or Run Project will not compile the static blocks and will completely skip it (ie. n will be back to null).
Attachments
Issue Links
- duplicates
-
NETBEANS-5757 Compile-on-Save drops static initializer (vanilla javac)
- Resolved
- links to