Attempting to serialize a File with this code:
YamlWriter writer = new YamlWriter ( new FileWriter ( new File ( "out.yml" ) ) );
writer.write ( new File ( "asdf.yml" ) );
writer.close();
produces this exception:
Exception in thread "main" com.esotericsoftware.yamlbeans.YamlException: Error writing YAML.
at com.esotericsoftware.yamlbeans.YamlWriter.writeInternal(YamlWriter.java:100)
at com.esotericsoftware.yamlbeans.YamlWriter.clearAnchors(YamlWriter.java:117)
at com.esotericsoftware.yamlbeans.YamlWriter.close(YamlWriter.java:128)
at example.YAMLExample.main(YAMLExample.java:28)
Caused by: com.esotericsoftware.yamlbeans.YamlException: Error creating object prototype to determine default values.
at com.esotericsoftware.yamlbeans.YamlWriter.writeValue(YamlWriter.java:240)
at com.esotericsoftware.yamlbeans.YamlWriter.writeInternal(YamlWriter.java:95)
... 3 more
Caused by: java.lang.reflect.InvocationTargetException: Unable to find a no-arg constructor for class: java.io.File
at com.esotericsoftware.yamlbeans.Beans.createObject(Beans.java:103)
at com.esotericsoftware.yamlbeans.YamlWriter.writeValue(YamlWriter.java:238)
... 4 more
I know File doesn't follow the bean specification, but it's very inconvenient to write around this kind of problem. This should be fixed at library level.