Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.5.6
-
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; }