Skip to content

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Oct 17, 2025

Consider code like:

I i = @Ann Object[]::new;

the initializer is a method reference over an array type, whose component is annotated - that follows from the grammar in JLS 4.3, and also matches what is parsed for code like:

I i = (@Ann Object[]) null;

But, the javac's parser will create a method reference, whose type is an annotated type - which is wrong. And also fails if the array type as such is also annotated.

The proposal herein is to simply use insertAnnotationsToMostInner to put the annotation at the correct place, as is done on other similar places. This one attaches the annotation at the correct nesting level.

Sadly, the code may be something very broken like:

I i = @Ann foobar()::new;

and insertAnnotationsToMostInner would fail for this code/AST. Hence if the method reference is not over a type, we'll create an AnnotatedType (to keep the info in the AST as before) + an error + an error AST node.


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-8369489: Marker annotation on inner class access crashes javac compiler (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27864

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 17, 2025

👋 Welcome back jlahoda! 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
Copy link

openjdk bot commented Oct 17, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Oct 17, 2025

@lahodaj 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 rfr Pull request is ready for review label Oct 17, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 17, 2025

Webrevs

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

Labels

compiler [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant