Skip to content

Compilation error due to seemingly misplaced annotation on class/interface method #2997

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

Closed
d4span opened this issue Mar 13, 2023 · 5 comments

Comments

@d4span
Copy link

d4span commented Mar 13, 2023

I currently get several compilation errors due to seemingly misplaced @NotNull annotations before the return type of certain class/interface methods. For instance, I get a compilation error on the annotation before the return type (Iterable<S>) of the following example method (in a class/interface implementing/extending Spring's CrudRepository):

public <S extends SomeType> @NotNull Iterable<S> saveAll(@NotNull Iterable<S> entities) {
    // implementation goes here
}

However, the same code compiles just fine with OpenJDK 17, e.g. when built with Maven or IntelliJ IDEA.

Environment
  • Operating System: Ubuntu Linux 22.04
  • JDK version: 17.0.5
  • Visual Studio Code version: 1.76.1
  • Java extension version: 1.15
@fbricon
Copy link
Collaborator

fbricon commented Mar 13, 2023

I can't seem to be able to reproduce this issue. Can you provide a sample project demonstrating this issue?

@d4span
Copy link
Author

d4span commented Mar 13, 2023

Interestingly, it looks like this error occurs since we added Kotlin to our Maven build (which was at the end of last week). We use the most recent Kotlin version and followed pretty much the documentation here: https://kotlinlang.org/docs/maven.html

Edit 1: When I revert our code to a commit just before the addition of Kotlin, everything works fine again.

Edit 2: I will try to create a sample project that reproduces this error.

@fbricon
Copy link
Collaborator

fbricon commented Mar 13, 2023

vscode-java doesn't support Kotlin

@d4span
Copy link
Author

d4span commented Mar 13, 2023

I see. This might be my fault.

We currently do not have any Kotlin code in our code base, therefore I expected the Java plugin to continue to work (perhaps because I am used to this behavior from other IDEs). But as I mentioned, we changed the Maven build, and if this change is not supported, then you can close this issue.

@rgrunber
Copy link
Member

See #531 to track any changes to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants