Skip to content

Fails to compile java code with a valid java annotation syntax. #21319

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
msosnicki opened this issue Aug 2, 2024 · 2 comments · Fixed by #21867
Closed

Fails to compile java code with a valid java annotation syntax. #21319

msosnicki opened this issue Aug 2, 2024 · 2 comments · Fixed by #21867

Comments

@msosnicki
Copy link

Compiler version

3.3.4

Minimized code

https://github.com/msosnicki/scala-annotations-java-issue

Piece of code that contains errors:

public record AnnotatedRecord(
  @JsonProperty("userId")
  java.util.@jakarta.validation.Valid Optional<scalac.issues.@jakarta.validation.Valid UserId> userId) {};

The code in the repo compiles fine in presence of sbt compileOrder := CompileOrder.ScalaThenJava settings. If it's removed, it is not compiling anymore (same as in 2.13.14).

Output

[error] -- Error: /home/ssn/code/scala/scala-annotations-java/src/main/java/scalac/issues/AnnotatedRecord.java:7:12
[error] 7 |  java.util.@jakarta.validation.Valid Optional<scalac[email protected] UserId> userId) {};
[error]   |            ^^^^
[error]   |            identifier expected but @ found.
[error] -- Error: /home/ssn/code/scala/scala-annotations-java/src/main/java/scalac/issues/AnnotatedRecord.java:8:0
[error] 8 |
[error]   |^^^^^^
[error]   |identifier expected but eof found.
[error] two errors found

Expectation

Code compiles

@msosnicki msosnicki added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 2, 2024
@som-snytt
Copy link
Contributor

Linking #20026 and #20064 where I said I would do more java annotation parsing.

@Gedochao Gedochao added area:annotations compat:java and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 5, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Aug 5, 2024

cc @hamzaremmal @dwijnand

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

Successfully merging a pull request may close this issue.

5 participants