[Bug]: `JavaReflectionTreeBuilder` doesn't build annotations on the return type
tenax66 opened this issue · comments
Describe the bug
JavaReflectionTreeBuilder
builds usual annotations but not annotations applied to a return type.
I found this while working on #5320 .
JavaReflectionTreeBuilderTest
fails after the @Nullable
annotation is applied to the classes under some specific packages. (like spoon.reflect.code
, spoon.reflect.declaration
)
Source code you are trying to analyze/transform
import org.jspecify.annotations.Nullable;
public class Foo {
public @Nullable String test() {
return null;
}
}
Source code for your Spoon processing
public static void main(String[] args) {
JavaReflectionTreeBuilder builder = new JavaReflectionTreeBuilder(
new FactoryImpl(new DefaultCoreFactory(), new StandardEnvironment()));
CtType<Foo> result = builder.scan(Foo.class);
System.out.println(result.toString());
}
Actual output
public class Foo {
public Foo() {
}
public java.lang.String test() {
}
}
Expected output
public class Foo {
public Foo() {
}
public @org.jspecify.annotations.Nullable() java.lang.String test() {
}
}
Spoon Version
10.4.2
JVM Version
penjdk 17.0.7 2023-04-18 OpenJDK Runtime Environment Homebrew (build 17.0.7+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.7+0, mixed mode, sharing)
What operating system are you using?
macOS Ventura 13.2.1