Groovy
  1. Groovy
  2. GROOVY-5260

Groovyc stub generation doesn't handle all primitive types properly

    Details

      Description

      The problem manifests when a long value is effectively being changed to an 'int' and results in an exception during compilation.

      Example class:

      class AnObject {
          public static final long serialVersionUID = -5239748510188117876L
      }
      

      Using groovy 1.8.5, the generated stub (during joint compilation using the 'Groovyc' ant taskdef) looks like (sans imports):

      public class AnObject implements
          groovy.lang.GroovyObject {
      public static final long serialVersionUID = -5239748510188117876;
      }
      

      The problem is that this yields a compilation exception 'integer number too large'.

      If you exclude the 'public' keyword on the member definition and re-compile, the stub instead looks like:

      public class AnObject implements
          groovy.lang.GroovyObject {
      public static final  long getSerialVersionUID() { return (long)0;}
      }
      

      This can then compile successfully.

        Activity

        Mark Thomas made changes -
        Workflow jira [ 12974036 ] Default workflow, editable Closed status [ 12981210 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12734183 ] Default workflow, editable Closed status [ 12745969 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Cédric Champeau made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Cédric Champeau made changes -
        Fix Version/s 1.8.6 [ 18245 ]
        Fix Version/s 2.0-beta-3 [ 18244 ]
        Summary groovyc stub generation changes when public keyword is included for class member - results in error with long (i.e. serialVersionUID) value Groovyc stub generation doesn't handle all primitive types properly
        Description The problem manifests when a long value is effectively being changed to an 'int' and results in an exception during compilation.

        Example class:

        class AnObject {
            public static final long serialVersionUID = -5239748510188117876L
        }

        Using groovy 1.8.5, the generated stub (during joint compilation using the 'Groovyc' ant taskdef) looks like (sans imports):

        public class AnObject implements
            groovy.lang.GroovyObject {
        public static final long serialVersionUID = -5239748510188117876;
        }

        The problem is that this yields a compilation exception 'integer number too large'.

        If you exclude the 'public' keyword on the member definition and re-compile, the stub instead looks like:

        public class AnObject implements
            groovy.lang.GroovyObject {
        public static final long getSerialVersionUID() { return (long)0;}
        }

        This can then compile successfully.
        The problem manifests when a long value is effectively being changed to an 'int' and results in an exception during compilation.

        Example class:
        {code}
        class AnObject {
            public static final long serialVersionUID = -5239748510188117876L
        }
        {code}
        Using groovy 1.8.5, the generated stub (during joint compilation using the 'Groovyc' ant taskdef) looks like (sans imports):

        {code}
        public class AnObject implements
            groovy.lang.GroovyObject {
        public static final long serialVersionUID = -5239748510188117876;
        }
        {code}

        The problem is that this yields a compilation exception 'integer number too large'.

        If you exclude the 'public' keyword on the member definition and re-compile, the stub instead looks like:
        {code}
        public class AnObject implements
            groovy.lang.GroovyObject {
        public static final long getSerialVersionUID() { return (long)0;}
        }
        {code}

        This can then compile successfully.
        Cédric Champeau made changes -
        Field Original Value New Value
        Assignee Cedric Champeau [ melix ]
        Jay Ashworth created issue -

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            Jay Ashworth
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development