{"record":{"id":"d83b0d89fadc9861","repo":"pentaho/pentaho-kettle","slug":"must-use-the-messageclass-props-constructor","errorCode":null,"errorMessage":"Must use the messageClass, props constructor","messagePattern":"Must use the messageClass, props constructor","errorType":"validation","errorClass":"IllegalAccessException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/core/vfs/connections/ui/dialog/VFSDetailsCompositeHelper.java","lineNumber":50,"sourceCode":"import org.pentaho.di.ui.core.widget.ComboVar;\nimport org.pentaho.di.ui.core.widget.PasswordTextVar;\nimport org.pentaho.di.ui.core.widget.PasswordVisibleTextVar;\nimport org.pentaho.di.ui.core.widget.TextVar;\n\nimport java.util.Set;\n\n/**\n * This class provides common layout logic to all VFSDetailComposites.  You can still roll your own layout but these\n * methods will greatly simplify the process, if you keep within the mold.\n */\npublic class VFSDetailsCompositeHelper {\n  private PropsUI props;\n  private int margin;\n  private int maxLabelWidth = 0;\n  private final Class<?> pkg;\n\n  public VFSDetailsCompositeHelper() throws IllegalAccessException {\n    throw new IllegalAccessException( \"Must use the messageClass, props constructor\" );\n  }\n\n  public VFSDetailsCompositeHelper( Class<?> messageClass, PropsUI props ) {\n    this.props = props;\n    margin = Const.MARGIN;\n    pkg = messageClass;\n  }\n\n  public PropsUI getProps() {\n    return props;\n  }\n\n  public int getMaxLabelWidth() {\n    return maxLabelWidth;\n  }\n\n  public int getMargin() {\n    return margin;","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/core/vfs/connections/ui/dialog/VFSDetailsCompositeHelper.java#L32-L68","documentation":"VFSDetailsCompositeHelper has a no-argument constructor that unconditionally throws IllegalAccessException. The class can only be constructed with the (Class<?> messageClass, PropsUI props) constructor, so the default constructor is deliberately disabled to force callers to supply the i18n message bundle class and UI properties.","triggerScenarios":"Calling `new VFSDetailsCompositeHelper()` with no arguments; reflective instantiation via Class.newInstance() or frameworks that resolve a zero-arg constructor.","commonSituations":"Copy-pasting construction code from other Kettle composite helpers that have default constructors; dependency-injection or reflection-based UI tooling that assumes a no-arg constructor exists and is usable.","solutions":["Use the two-argument constructor: new VFSDetailsCompositeHelper(PluginMessages.class, PropsUI.getInstance()).","If instantiating reflectively, look up the (Class, PropsUI) constructor via getConstructor(Class.class, PropsUI.class) and invoke it with arguments.","If this is a DI/container scenario, register a factory that supplies messageClass and PropsUI instead of the default constructor."],"exampleFix":"// before\nVFSDetailsCompositeHelper helper = new VFSDetailsCompositeHelper();\n// after\nVFSDetailsCompositeHelper helper = new VFSDetailsCompositeHelper( MyPlugin.class, PropsUI.getInstance() );","handlingStrategy":"type-guard","validationCode":"// ensure required args before constructing\nif ( messageClass == null || props == null ) throw new IllegalArgumentException( \"messageClass and props required\" );","typeGuard":"// check constructor args before use\nboolean canConstruct = ( messageClass != null && props != null );","tryCatchPattern":"try {\n  helper = new VFSDetailsCompositeHelper( messageClass, props );\n} catch ( IllegalAccessException e ) {\n  throw new IllegalStateException( \"Used disabled no-arg constructor\", e );\n}","preventionTips":["Never call the zero-argument constructor; treat it as reserved-for-reflection poison.","Always pass the plugin's message bundle class and PropsUI.getInstance().","When using reflection, request the two-argument constructor explicitly."],"tags":["java","constructor","vfs","swing-ui"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}