Skip to content

Add regression test for Java annotation @Retention visibility (#389) - #26339

Merged
SolalPirelli merged 2 commits into
scala:mainfrom
jozanek:issue-389-annotation-retention-test
Jun 23, 2026
Merged

SolalPirelli merged 2 commits into
scala:mainfrom
jozanek:issue-389-annotation-retention-test

Conversation

@jozanek

@jozanek jozanek commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #389.

The original request — having the backend honour a Java annotation's @Retention rather than assuming everything is runtime-visible — is already resolved: the Java parser now reads meta-annotations on @interface declarations (JavaParsers.modifiers/annotationDecl), so an explicit @Retention is respected end-to-end. This PR is therefore coverage + documentation, not a behavioral change: it locks in the existing behavior and documents the one remaining compatibility default. It replaces the disabled, partest-based tests/disabled/reflect/run/t4788.

How much have you relied on LLM-based tools in this contribution?

Extensively, for codebase investigation, writing the regression test, and drafting this description. I have reviewed every line and am responsible for the contribution (per LLM_POLICY.md).

How was the solution tested?

New automated test, an end-to-end tests/run/i389 test that uses Java reflection to assert a Java-defined annotation's @Retention is honored: RUNTIME is visible at runtime, while CLASS/SOURCE are not, checked on both a class and a method. The Java annotation sources are read by dotty's Java parser, so this exercises the path #389 was about. Verified with testCompilation i389.

@jozanek
jozanek force-pushed the issue-389-annotation-retention-test branch from a0019fa to 8fe98f2 Compare June 15, 2026 22:36
@Gedochao

Copy link
Copy Markdown
Contributor

Hey, I know this is still a draft, so just a reminder before this is tagged as ready to review - please remember to use the PR template and answer the questions contained there in the PR description.

@jozanek
jozanek marked this pull request as ready for review June 16, 2026 09:47

@SolalPirelli SolalPirelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the test be kept as an end-to-end test in tests using reflection? Manually invoking part of the compiler is less maintainable, we try to keep most tests e2e if they can be.

@jozanek

jozanek commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@SolalPirelli test/PR desc updated, please have a look again.

@SolalPirelli SolalPirelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks

@SolalPirelli
SolalPirelli enabled auto-merge (squash) June 22, 2026 07:05
@Gedochao

Copy link
Copy Markdown
Contributor

Seems the CI isn't running.
Might need a rebase.

@Gedochao
Gedochao force-pushed the issue-389-annotation-retention-test branch from f0b02fd to 9dfacae Compare June 23, 2026 09:20
@Gedochao

Copy link
Copy Markdown
Contributor

(rebased)

@SolalPirelli
SolalPirelli merged commit 3f638dd into scala:main Jun 23, 2026
45 checks passed
@jozanek
jozanek deleted the issue-389-annotation-retention-test branch June 23, 2026 21:53
@WojciechMazur WojciechMazur added this to the 3.10.0 milestone Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unless JavaParser reads annotations we need to assume all annotations to be Runtime visible.

4 participants