Closed GoogleCodeExporter closed 9 years ago
Let us have a look at the source of java.io.File.
public File getAbsoluteFile() {
String absPath = getAbsolutePath();
return new File(absPath, fs.prefixLength(absPath));
}
This method creates a cycle. Unfortunately the returned File has a different
identity
(different memory address) then the owner. SnakeYAML gets an endless chain of
objects
while trying to serialise the File object as a JavaBean.
(SnakeYAML can handle cycles which end up at the same object)
Solution:
1) Implement Represent to use !!java.io.File tag
This is how it may look like: (Please note that Tag is used instead of String)
http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyam
l/issues/issue46/FileTest.java
2) Do not use java.io.File at all. One may expect to serialise the whole
content and
not only the filename. JDK7 will (almost) deprecate java.io.File in favor of
Path and
others.(http://java.sun.com/developer/technicalArticles/javase/nio/)
Original comment by aso...@gmail.com
on 25 Jan 2010 at 2:44
Original comment by aso...@gmail.com
on 28 Jan 2010 at 2:55
Original issue reported on code.google.com by
ah...@ionosinst.de
on 25 Jan 2010 at 10:57