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

config script: unexpected NPE when processing compiler config DSL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.6
    • 3.0.0-beta-1, 2.5.7
    • None
    • None

    Description

      I started experimenting with using config script to enable static compilation by default. I ran into GROOVY-7856 pretty much right away. So I decided to comment out my config script like this:

      withConfig(configuration) {
          source(classValidator: { !it.isInterface() }) { ->
              //ast(groovy.transform.CompileStatic)
          }
      }
      

      Now I get this NPE because there is no delegate CompilationCustomizer found for the SourceAwareCustomizer.

      java.lang.NullPointerException
      	at org.codehaus.groovy.control.customizers.DelegatingCustomizer.<init>(DelegatingCustomizer.java:36)
      	at org.codehaus.groovy.control.customizers.SourceAwareCustomizer.<init>(SourceAwareCustomizer.java:50)
      	at org.codehaus.groovy.control.customizers.builder.SourceAwareCustomizerFactory.postCompleteNode(SourceAwareCustomizerFactory.java:95)
      	at org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder.postNodeCompletion(CompilerCustomizationBuilder.groovy:48)
      	at groovy.util.FactoryBuilderSupport.dispatchNodeCall(FactoryBuilderSupport.java:903)
      	at groovy.util.FactoryBuilderSupport.doInvokeMethod(FactoryBuilderSupport.java:787)
      	at groovy.util.FactoryBuilderSupport.invokeMethod(FactoryBuilderSupport.java:507)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:413)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:337)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:64)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:176)
      	at config$_run_closure1.doCall(config.groovy:4)
      	at config$_run_closure1.doCall(config.groovy)
      ...
      

      Could the SourceAwareCustomizerFactory be more forgiving and supply a "no-op" CompilationCustomizer in newInstance?

          public Object newInstance(final FactoryBuilderSupport builder, final Object name, final Object value, final Map attributes) throws InstantiationException, IllegalAccessException {
              SourceOptions data = new SourceOptions();
              if (value instanceof CompilationCustomizer) {
                  data.delegate = (CompilationCustomizer) value;
              }
              // add
              else {
                  data.delegate = new CompilationCustomizer(0) {};
              }
              // end
              return data;
          }
      

      Attachments

        Activity

          People

            paulk Paul King
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: