Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-5832

Static block not compiled

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 12.4
    • None
    • java - Compiler

    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

          Activity

            People

              Chatanga Florent Lioult
              Chatanga Florent Lioult
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m