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

joint compilation: public static final string does not compile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.11
    • 3.0.18, 4.0.12
    • None
    • OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)

    Description

      I haven't managed to reproduce this in a simple example, but as I'm upgrading my application from groovy 3 to 4 I have run into this situation.  I have a class that defines a public static final string like this:

      class PublicStaticString { 
         public static final String NONE = "None" 
      }
      

      Its java stub fails to compile with:

      error: no suitable constructor found for String(Object)
      public static final java.lang.String NONE = new java.lang.String((java.lang.Object)null);

       

      I can remove the "public" from the declaration and the class/stub will compile, but now any java class that references that field will fail to compile with:

      error: NONE has private access in PublicStaticString
               selectNoneButton.setText(PublicStaticString.NONE);

      The only way I know to fix this is to convert the java class to groovy.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              jasongarrett Jason Garrett
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: