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

8207017: Type annotations on anonymous classes in initializer blocks not written to class file #12519

Conversation

vicente-romero-oracle
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle commented Feb 10, 2023

Javac is not writing type annotations applied to anonymous classes inside of instance or static initializers. Basically for code like:

import java.lang.annotation.*;

class X {

    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.TYPE_USE)
    public @interface TA {
        String value() default "empty";
    }

    {
        class Local {}
        new @TA("LocalInstanceInitializerAnnonymous") Local() {};
    }

    static {
        class Local {}
        new @TA("LocalStaticAnnonymous") Local() {};
    }
}

not type annotations are generated as attributes of methods or . This PR is fixing this issue. The annotations are currently generated if the anonymous class is declared inside an instance or static method. The issue is only with initializers,

TIA


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8207017: Type annotations on anonymous classes in initializer blocks not written to class file

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12519

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 10, 2023

👋 Welcome back vromero! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 10, 2023
@openjdk
Copy link

openjdk bot commented Feb 10, 2023

@vicente-romero-oracle 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.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Feb 10, 2023
@mlbridge
Copy link

mlbridge bot commented Feb 10, 2023

Webrevs

Copy link
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.

Seems sensible.

@openjdk
Copy link

openjdk bot commented Feb 14, 2023

@vicente-romero-oracle 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:

8207017: Type annotations on anonymous classes in initializer blocks not written to class file

Reviewed-by: jlahoda

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 46 new commits pushed to the master branch:

  • 8c2c8b3: 8295344: Harden runtime/StackGuardPages/TestStackGuardPages.java
  • 6d4b02b: 8302324: Inheritance tree does not show correct type parameters/arguments
  • 7dfe75c: 8301842: JFR: increase checkpoint event size for stacktrace and string pool
  • 66742c8: 8302368: [ZGC] Client build fails after JDK-8300255
  • 7c50ab1: 8225409: G1: Remove the Hot Card Cache
  • 92474f1: 8301243: java/net/httpclient/http2/IdleConnectionTimeoutTest.java intermittent failure
  • ee5f6e1: 8302337: JDK crashes if lib/modules contains non-zero byte containing ATTRIBUTE_END
  • 7f71a10: 8301874: BarrierSetC2 should assign barrier data to stores
  • d782125: 8302214: Typo in javadoc of Arrays.compare and Arrays.mismatch
  • 94e7cc8: 8301226: Add clamp() methods to java.lang.Math and to StrictMath
  • ... and 36 more: https://git.openjdk.org/jdk/compare/c8ace482edead720c865cf996729a316025d937e...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 14, 2023
@vicente-romero-oracle
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 14, 2023

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

  • 8c2c8b3: 8295344: Harden runtime/StackGuardPages/TestStackGuardPages.java
  • 6d4b02b: 8302324: Inheritance tree does not show correct type parameters/arguments
  • 7dfe75c: 8301842: JFR: increase checkpoint event size for stacktrace and string pool
  • 66742c8: 8302368: [ZGC] Client build fails after JDK-8300255
  • 7c50ab1: 8225409: G1: Remove the Hot Card Cache
  • 92474f1: 8301243: java/net/httpclient/http2/IdleConnectionTimeoutTest.java intermittent failure
  • ee5f6e1: 8302337: JDK crashes if lib/modules contains non-zero byte containing ATTRIBUTE_END
  • 7f71a10: 8301874: BarrierSetC2 should assign barrier data to stores
  • d782125: 8302214: Typo in javadoc of Arrays.compare and Arrays.mismatch
  • 94e7cc8: 8301226: Add clamp() methods to java.lang.Math and to StrictMath
  • ... and 36 more: https://git.openjdk.org/jdk/compare/c8ace482edead720c865cf996729a316025d937e...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 14, 2023
@openjdk openjdk bot closed this Feb 14, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 14, 2023
@openjdk
Copy link

openjdk bot commented Feb 14, 2023

@vicente-romero-oracle Pushed as commit 2ef001e.

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

@vicente-romero-oracle vicente-romero-oracle deleted the JDK-8207017 branch February 14, 2023 16:21
@vicente-romero-oracle
Copy link
Contributor Author

@lahodaj thanks for the review

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
2 participants