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

groovyc ant task generates invalid stub (picks wrong constructor) and fails in Java 1.7 compilation

    XMLWordPrintableJSON

Details

    Description

      The current master branch of Grails won't compile with Java 1.7 . It compiles ok with Java 1.6 .

      The error message is:

      [ant:groovyc] /tmp/groovy-generated-614097634888075990-java-sourc
      [ant:groovyc] e/org/codehaus/groovy/grails/cli/interactive/GrailsInteractiveCompletor.java:15: error: unreported exception IOException; must b
      [ant:groovyc] e caught or declared to be thrown
      [ant:groovyc] super ((java.io.InputStream)null);
      [ant:groovyc]       ^
      

      Reproducing error:

      git clone https://github.com/grails/grails-core.git
      cd grails-core
      git checkout 1239b8ed
      ./gradlew clean compileGroovy
      

      Generated stub with error:

      package org.codehaus.groovy.grails.cli.interactive;
      
      import java.lang.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import groovy.lang.*;
      import groovy.util.*;
      
      @groovy.transform.CompileStatic() public class GrailsInteractiveCompletor
        extends jline.SimpleCompletor  implements
          groovy.lang.GroovyObject {
      public GrailsInteractiveCompletor
      (grails.util.BuildSettings settings, java.util.List<java.io.File> scriptResources) {
      super ((java.io.InputStream)null);
      }
      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) { }
      public  grails.util.BuildSettings getSettings() { return (grails.util.BuildSettings)null;}
      public  void setSettings(grails.util.BuildSettings value) { }
      public  java.util.Map getCompletorCache() { return (java.util.Map)null;}
      public  void setCompletorCache(java.util.Map value) { }
      @java.lang.Override() public  int complete(java.lang.String buffer, int cursor, java.util.List clist) { return (int)0;}
      public static  java.lang.String[] getScriptNames(java.util.List<java.io.File> scriptResources) { return (java.lang.String[])null;}
      }
      

      However the stub is ok if I remove "groovyOptions.useAnt = true" and "options.useAnt = true" from the build.gradle of Grails:

      package org.codehaus.groovy.grails.cli.interactive;
      
      import java.lang.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import groovy.lang.*;
      import groovy.util.*;
      
      @groovy.transform.CompileStatic() public class GrailsInteractiveCompletor
        extends jline.SimpleCompletor  implements
          groovy.lang.GroovyObject {
      public GrailsInteractiveCompletor
      (grails.util.BuildSettings settings, java.util.List<java.io.File> scriptResources) {
      super ((java.lang.String)null);
      }
      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) { }
      public  grails.util.BuildSettings getSettings() { return (grails.util.BuildSettings)null;}
      public  void setSettings(grails.util.BuildSettings value) { }
      public  java.util.Map getCompletorCache() { return (java.util.Map)null;}
      public  void setCompletorCache(java.util.Map value) { }
      @java.lang.Override() public  int complete(java.lang.String buffer, int cursor, java.util.List clist) { return (int)0;}
      public static  java.lang.String[] getScriptNames(java.util.List<java.io.File> scriptResources) { return (java.lang.String[])null;}
      }
      

      diff of generated stubs:

      < super ((java.lang.String)null);
      ---
      > super ((java.io.InputStream)null);
      

      Source code of GrailsInteractiveCompletor:
      https://github.com/grails/grails-core/blob/1239b8edb606cca1c137285393a366898e18e196/grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/interactive/GrailsInteractiveCompletor.groovy#L47

      however the picked constructor in the successfull case is also invalid. The groovy source code is calling the constructor with the String[] constructor.

      Source code of the super class, jline's SimpleCompletor: https://github.com/jline/jline/blob/master/src/main/java/jline/SimpleCompletor.java#L53

      Attachments

        Activity

          People

            emilles Eric Milles
            lhotari Lari Hotari
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: