You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Eirik Bakke (Jira)" <ji...@apache.org> on 2021/07/25 16:51:00 UTC
[jira] [Resolved] (NETBEANS-5757) Compile-on-Save drops static
initializer (vanilla javac)
[ https://issues.apache.org/jira/browse/NETBEANS-5757?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eirik Bakke resolved NETBEANS-5757.
-----------------------------------
Fix Version/s: Next
Resolution: Fixed
Confirmed fixed by https://github.com/apache/netbeans/pull/3054 , which was merged.
> 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
> Priority: Major
> Fix For: Next
>
>
> 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."
> 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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists