Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3996

Enum static field initialization inconsistency

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.7
    • 1.6.8, 1.7.1, 1.8-beta-1
    • None
    • None

    Description

      Output of the code

      enum Color {
      	R, G, B
      	static Color[] ALL_COLORS = [R, G, B];
      }
      
      println Color.ALL_COLORS
      

      is correct - [R, G, B]

      But if I just make the static field public then the code fails with output as [null, null, null]

      enum Color {
      	R, G, B
      	public static Color[] ALL_COLORS = [R, G, B];
      }
      
      println Color.ALL_COLORS
      

      Attachments

        Issue Links

          Activity

            People

              roshandawrani Roshan Dawrani
              roshandawrani Roshan Dawrani
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: