I'm trying to extract all class/interface type references from a class declarations. I'm getting a weird behavior with FQ names. Here is a simple example:
CompilationUnit cu = StaticJavaParser.parse(
"public class foo extends java.lang.String {}");
cu.stream().
filter(ClassOrInterfaceType.class::isInstance).
forEach(System.out::println);
the output is:
java.lang.String
java.lang
java
I was expecting the java.lang.String
but the others? What does it ever mean that java.lang
is a ClassOrInterfaceType
?
I'm wondering if this is the expected behavior, in any case: is there a way to filter out these spurious elements? Thanks.