Skip to content

8378524: Compile-time constant generated through annotation processor is not usable in repeated annotation but fails compilation#30112

Closed
dbalek wants to merge 1 commit intoopenjdk:masterfrom
dbalek:dbalek/8378524
Closed

8378524: Compile-time constant generated through annotation processor is not usable in repeated annotation but fails compilation#30112
dbalek wants to merge 1 commit intoopenjdk:masterfrom
dbalek:dbalek/8378524

Conversation

@dbalek
Copy link
Copy Markdown
Contributor

@dbalek dbalek commented Mar 6, 2026

Consider snippet like:

@Rep(Constants.C)
@Rep(Constants.C)
public class Test {}

@Repeatable(Reps.class)
@interface Rep {
    int value();
}
@interface Reps {
    Rep[] value();
}

and the class Constants being generated by an annotation processor on the source compilation.

Currently, while processing repeated annotations on class Test, javac first creates a synthesized Attribute.Compound for container annotation Reps. Then, it creates a new JCAnnotation tree from this attribute and runs various validity checks upon this tree. Finally, it tries to attribute generated container annotation tree only to get (in ideal case) the same Attribute.Compound from which the JCAnnotation tree was generated.

Moreover, since the values used in annotations @Rep are generated by an annotation processor in a later compilation phase, created JCAnnotation tree contains JCErroneous trees for unresolved Constants.C values. Running attribution on such tree produces the false errors mentioned in the bug report: expression not allowed as annotation value.

The proposal here is:
Remove unnecessary attribution of the generated container annotation producing false errors. This change makes the resulting code to be similar to what is already done in the case of type annotations.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)

Issue

  • JDK-8378524: Compile-time constant generated through annotation processor is not usable in repeated annotation but fails compilation (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30112/head:pull/30112
$ git checkout pull/30112

Update a local copy of the PR:
$ git checkout pull/30112
$ git pull https://git.openjdk.org/jdk.git pull/30112/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30112

View PR using the GUI difftool:
$ git pr show -t 30112

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30112.diff

Using Webrev

Link to Webrev Comment

… is not usable in repeated annotation but fails compilation
@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Mar 6, 2026
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Mar 6, 2026

Hi @dbalek, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user dbalek" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 6, 2026

@dbalek This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8378524: Compile-time constant generated through annotation processor is not usable in repeated annotation but fails compilation

Reviewed-by: jlahoda, vromero

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 130 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@lahodaj, @vicente-romero-oracle) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Mar 6, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 6, 2026

@dbalek The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@dbalek
Copy link
Copy Markdown
Contributor Author

dbalek commented Mar 6, 2026

/covered

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label Mar 6, 2026
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Mar 6, 2026

Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Mar 11, 2026
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 11, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Mar 11, 2026

Webrevs

@lahodaj
Copy link
Copy Markdown
Contributor

lahodaj commented Mar 11, 2026

/reviewers 2 reviewer

Copy link
Copy Markdown
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I think another (javac) Reviewer should look at this as well. Thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 11, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 11, 2026

@lahodaj
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Mar 11, 2026
Copy link
Copy Markdown
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

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

lgtm

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 13, 2026
@dbalek
Copy link
Copy Markdown
Contributor Author

dbalek commented Mar 16, 2026

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 16, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 16, 2026

@dbalek
Your change (at version b195928) is now ready to be sponsored by a Committer.

@lahodaj
Copy link
Copy Markdown
Contributor

lahodaj commented Mar 16, 2026

/sponsor

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 16, 2026

Going to push as commit c04fe76.
Since your change was applied there have been 130 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 16, 2026
@openjdk openjdk bot closed this Mar 16, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Mar 16, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 16, 2026

@lahodaj @dbalek Pushed as commit c04fe76.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

compiler compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants