Eirik Bakke created NETBEANS-5757:
-------------------------------------

             Summary: Compile-on-Save drops static initializer (vanilla javac)
                 Key: NETBEANS-5757
                 URL: https://issues.apache.org/jira/browse/NETBEANS-5757
             Project: NetBeans
          Issue Type: Bug
          Components: java - Compiler
    Affects Versions: 12.4
         Environment: 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.
            Reporter: Eirik Bakke


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:

{code:java}
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);
  }
}
{code}

Do a clean build and run. The application will print, "I am a constant."

Tested on both Java 11.0.11 and Java 17-ea+25.

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. I 
tested this with an older NetBeans version with nb-javac as well, and in that 
case the output is correct (still "I am a constant.").



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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

Reply via email to