{"record":{"id":"6d8bf16cef54e2d5","repo":"pentaho/pentaho-kettle","slug":"clone-not-supported-for-basefilefield","errorCode":null,"errorMessage":"Clone not supported for ","messagePattern":"Clone not supported for ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/file/BaseFileField.java","lineNumber":142,"sourceCode":"  }\n\n  @Override\n  public int compareTo( TextFileInputFieldInterface field ) {\n    return position - field.getPosition();\n  }\n\n  public boolean equal( Object obj ) {\n    BaseFileField field = (BaseFileField) obj;\n\n    return ( position == field.getPosition() );\n  }\n\n  @Override\n  public Object clone() {\n    try {\n      return super.clone();\n    } catch ( CloneNotSupportedException ex ) {\n      throw new IllegalArgumentException( \"Clone not supported for \" + this.getClass().getName() );\n    }\n  }\n\n  @Override\n  public int getPosition() {\n    return position;\n  }\n\n  public void setPosition( int position ) {\n    this.position = position;\n  }\n\n  @Override\n  public int getLength() {\n    return length;\n  }\n\n  @Override","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/file/BaseFileField.java#L124-L160","documentation":"BaseFileField.clone() calls super.clone() (Object.clone), which throws CloneNotSupportedException unless the runtime class implements Cloneable. If a subclass of BaseFileField is not Cloneable, the catch block rethrows it as an IllegalArgumentException naming the class. This is an internal defensive wrapper that should never fire for correctly declared classes.","triggerScenarios":"Calling clone() on a BaseFileField instance whose concrete class does not implement the Cloneable marker interface.","commonSituations":"Someone added a new field-meta subclass extending BaseFileField but forgot to declare 'implements Cloneable'; refactoring removed the interface; reflection/serialization frameworks cloning step metadata at transformation copy time.","solutions":["Make the concrete field class implement java.lang.Cloneable (it is a marker interface, no methods needed).","Verify which class name appears in the message and check its 'implements' list.","As a workaround, construct a new instance and copy fields manually instead of relying on clone()."],"exampleFix":"// before\npublic class MyField extends BaseFileField { }\n// after\npublic class MyField extends BaseFileField implements Cloneable { }","handlingStrategy":"try-catch","validationCode":"if (!BaseFileField.class.isAssignableFrom(field.getClass()) || !Cloneable.class.isAssignableFrom(field.getClass())) {\n  throw new IllegalStateException(field.getClass().getName() + \" must implement Cloneable\");\n}","typeGuard":"boolean isCloneable(Object o) { return o instanceof Cloneable; }","tryCatchPattern":"try {\n  Object copy = field.clone();\n} catch (IllegalArgumentException e) {\n  // fall back to manual copy\n  throw new IllegalStateException(\"Class must implement Cloneable: \" + e.getMessage(), e);\n}","preventionTips":["Always declare 'implements Cloneable' on any subclass of BaseFileField.","Add a unit test that clones every metadata class instance.","Prefer copy constructors over clone() in new code."],"tags":["java","clone","reflection"],"backgroundTag":"unsupported-operation","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"}