I'm having the same issue as ClassCastException in ant schemagen task using jaxb-ri-2.2.7. However, my biggest question is not about the issue itself, but the exception in the error log:
java.lang.ClassCastException: com.sun.tools.javac.api.JavacTrees cannot be cast to com.sun.source.util.Trees
By looking into the problem, I found that JavacTrees
is a child class of DocTrees
, and DocTrees
is a child class of Trees
. Specifically, the class definitions are:
public class JavacTrees extends DocTrees {
// ...
}
public abstract class DocTrees extends Trees {
// ...
}
public abstract class Trees {
// ...
}
The above ClassCastException
basically means that an object failed to cast into its parent class. I don't remember anything like that in any textbook I read.
Can somebody explain this exception to me? Thanks.