Skip to content

Fix NPE on goto to invalid method reference#9210

Draft
mbien wants to merge 1 commit intoapache:masterfrom
mbien:goto-invalid-method-reference
Draft

Fix NPE on goto to invalid method reference#9210
mbien wants to merge 1 commit intoapache:masterfrom
mbien:goto-invalid-method-reference

Conversation

@mbien
Copy link
Member

@mbien mbien commented Feb 17, 2026

  • check if element is a record before listing components
  • removed reflective method access

reproducer:

public class GoToInvalidMethodReferenceNPE {
    public static void main(String args[]) {
        ChangeListener listener = GoToInvalidMethodReferenceNPE::invalid;
        //                                                       ^^^^^^^ ctrl click (after parsing)
    }
}

fixes #8735

 - check if element is a record before listing components
 - removed reflective method access
@mbien mbien added this to the NB30 milestone Feb 17, 2026
@mbien mbien requested a review from lahodaj February 17, 2026 04:49
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Editor ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Feb 17, 2026
Comment on lines +482 to +483
if (peer.getKind() == ElementKind.RECORD_COMPONENT) {
for (RecordComponentElement component : ((TypeElement)peer.getEnclosingElement()).getRecordComponents()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

is this cast ok?

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

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Editor Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE on goto invalid lambda method reference

1 participant