Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: JavaReflectionTreeBuilder doesn't build annotations on the return type #5424

Open
tenax66 opened this issue Sep 2, 2023 · 0 comments
Labels

Comments

@tenax66
Copy link
Contributor

tenax66 commented Sep 2, 2023

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

@tenax66 tenax66 added the bug label Sep 2, 2023
@tenax66 tenax66 changed the title [Bug]: JavaReflectionTreeBuilder doesn't build an annotation on the return type [Bug]: JavaReflectionTreeBuilder doesn't build annotations on the return type Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant