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

Stub generator doesn't escape strings with mixed single and double quotes

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.5
    • 1.8-rc-2, 1.7.9, 1.9-beta-1
    • Compiler
    • None

    Description

      Single and double quotes when mixed in Groovy strings within annotations are not translated correctly into Java strings in generated stubs. Internal quotes are not escaped.

      This issue is related to GROOVY-4470. I used the same source code to demonstrate it.

      StringAnno.groovy
      @interface StringAnno {
        String val()
      }
      
      StringAnnoUser.groovy
      @StringAnno(val = 'single quote string with "double quote string"')
      class StringAnnoUser {}
      
      StringAnnoUser.java (generated stub)
      import java.lang.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import groovy.lang.*;
      import groovy.util.*;
      
      @StringAnno(val="single quote string with "double quote string"") public class StringAnnoUser
        extends java.lang.Object  implements
          groovy.lang.GroovyObject {
      public StringAnnoUser
      () {}
      public  groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;}
      public  void setMetaClass(groovy.lang.MetaClass mc) { }
      public  java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;}
      public  java.lang.Object getProperty(java.lang.String property) { return null;}
      public  void setProperty(java.lang.String property, java.lang.Object value) { }
      }
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            guillaume Guillaume Sauthier
            mgryszko Marcin Gryszko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment