groovy
  1. groovy
  2. GROOVY-5292

Stub generation doesn't handle 'protected' multi-line String correctly.

    Details

    • Number of attachments :
      0

      Description

      When using the groovyc joint compilation feature, the generated stub is incorrect when the groovy source includes a protected (possibly affects public too, I didn't test) multi-line String 'constant'.

      For example,

      class Example

      { protected static final String CONSTANT_VALUE = """ I am a constant value Thank you """ }

      would generate a stub:

      public Example extends java.lang.Object implements groovy.lang.GroovyObject

      { protected static final java.lang.String CONSTANT_VALUE = " I am a constant value Thank you "; }

      This is a syntactically incorrect Java statement.

        Issue Links

          Activity

          Hide
          Jay Ashworth added a comment - - edited

          I apologize, the formatting wasn't preserved.
          Sample code:

          Example.groovy
          class Example {
            protected static final String CONSTANT_VALUE = """
          I am a constant value
          Thank you
          """
          }
          

          Generating stub:

          Example.java
          public Example extends java.lang.Object implements groovy.lang.GroovyObject { 
          protected static final java.lang.String CONSTANT_VALUE = "
          I am a constant value
          Thank you
          ";
          }
          
          Show
          Jay Ashworth added a comment - - edited I apologize, the formatting wasn't preserved. Sample code: Example.groovy class Example { protected static final String CONSTANT_VALUE = """ I am a constant value Thank you """ } Generating stub: Example.java public Example extends java.lang. Object implements groovy.lang.GroovyObject { protected static final java.lang. String CONSTANT_VALUE = " I am a constant value Thank you "; }
          Hide
          Paul King added a comment -

          I think this is an edge case left over from GROOVY-5150

          Show
          Paul King added a comment - I think this is an edge case left over from GROOVY-5150
          Hide
          Paul King added a comment -

          Your suspicions were correct. This affected both public and protected fields but should be fixed now.

          Show
          Paul King added a comment - Your suspicions were correct. This affected both public and protected fields but should be fixed now.

            People

            • Assignee:
              Paul King
              Reporter:
              Jay Ashworth
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: