You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Andrew James (Jira)" <ji...@apache.org> on 2021/09/25 18:31:00 UTC

[jira] [Closed] (NETBEANS-6062) Static block not executed in Java Ant project

     [ https://issues.apache.org/jira/browse/NETBEANS-6062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew James closed NETBEANS-6062.
----------------------------------
    Resolution: Fixed

> Static block not executed in Java Ant project
> ---------------------------------------------
>
>                 Key: NETBEANS-6062
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-6062
>             Project: NetBeans
>          Issue Type: Bug
>    Affects Versions: 12.4
>         Environment: NetBeans 12.4
> Java 15.0.2 (Adopt Open JDK)
> Windows 10
>            Reporter: Andrew James
>            Priority: Major
>         Attachments: NETBEANS-6062.zip
>
>
> A simple Java Ant project in NetBeans 12.4 (using Java 15) does not execute the static code block, when the project is executed from within the IDE.
> Steps to reproduce:
> File > New Project > Java with Ant
> Create two classes:
> -(Whenever I try to format the below code, it looks completely wrong in the ticket, so it's just presented as plain text - sorry I do not know how this system handles code snippets).-
> *1) Main.java*
> {code:java}
> public class Main {
>      public static void main(String args[]) {
>          System.out.println(Test.i);
>      }
> }
> {code}
> *2) Test.java*
> {code:java}
> class Test {
>      static int i;
>      static {
>          i = 10;
>      }
> }
> {code}
>  
> *Actual results:*
> When the project is run from within the IDE, the output is "0". The static block in Test is not executed.
> *Expected results:*
> The expected output is "10". The static block in Test is executed.
> *Note also:*
> The JAR built by the project runs correctly, when executed from the command line, outside of the IDE.
> The same code shown above also runs as expected in the IDE when built using a Java Maven project, instead of a Java Ant project.
> This behavior does not appear when executing the same code, using NetBeans 12.0 and Java 11.



--
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