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

SyntaxException when extending groovy.lang.Script

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Abandoned
    • 2.3.0
    • None
    • Compiler
    • None

    Description

      We are facing an issue when using the following groovy script is used as a ScriptBaseClass with version 2.3.0 or greater:

      abstract class Templates extends Script {
          def test() {
              def a = [];
              return a;
          }
      }
      

       Error:

      Script1.groovy: 1: A transform used a generics containing ClassNode Templates for the super class Script1 directly. You are not supposed to do this. Please create a new ClassNode referring to the old ClassNode and use the new ClassNode instead of the old one. Otherwise the compiler will create wrong descriptors and a potential NullPointerException in TypeResolver in the OpenJDK. If this is not your own doing, please report this bug to the writer of the transform.
      

      The error happens when calling the following example (This example is working as expected when using Groovy 2.2.2):

      import java.io.IOException;
      import org.codehaus.groovy.control.CompilationFailedException;
      import org.codehaus.groovy.control.CompilerConfiguration;
      import groovy.lang.GroovyShell;
      import groovy.lang.Script;
      
      public class GroovyTest {
      	
      	public static void main(String[] args) throws CompilationFailedException, IOException {
      
      		CompilerConfiguration groovyCompilerConfiguration = new CompilerConfiguration();
      		groovyCompilerConfiguration.setScriptBaseClass("Templates");
      		groovyCompilerConfiguration.setDebug(true);
      		groovyCompilerConfiguration.setVerbose(true);
      		
      		GroovyShell shell = new GroovyShell(groovyCompilerConfiguration);
      		Script script = shell.parse("print \"test\"");
      	}
      
      }
      

      Is this an issue from Groovy or is this change expected?

      Thanks and regards

      Attachments

        Activity

          People

            Unassigned Unassigned
            brongniart Brongniart Jérôme
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: