The exception was thrown during the newInstance call at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:299):
T ref = (T) constructor.newInstance(args);
The type being constructed should be CustomTool, and I think it is. If the type had been CustomTool[] or ToolInstallation[] or ToolInstallation, then DataBoundConfigurator.getDataBoundConstructor would have returned null, and DefaultConfiguratorRegistry.internalLookup would not have created an instance of DataBoundConfigurator. So, it seems to be a matter of incorrect arguments being generated for the CustomTool constructor. Perhaps the error is triggered by the @CheckForNull LabelSpecifics[] labelSpecifics parameter of that constructor. If CustomTool.getLabelSpecifics returns an empty array, then the type of this array does not implement java.util.Collection, so DataBoundConfiguration.describe assigns args[i] = Collections.singletonList(converted), which is not acceptable to the constructor. If this theory is correct, then the error could be fixed either by changing CustomTool to use a collection type instead of the array type, or by changing DataBoundConfiguration to check for array types as well. I cannot currently test these changes myself. |