Skip to content

NullPointerException in InstanceOfAndCastMatchWrongType #4168

Closed

Description

@anthonyvdotbe

Similar to #4167

error-prone version: 2.23.0
BugPattern: InstanceOfAndCastMatchWrongType
Stack Trace:
java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.isPrimitive()" because "t" is null

The snippet on which it failed looks like:

if(baz instanceof Foo.Bar.Baz(String text, Locale locale, Charset charset)) {

    Some.staticMethod((Foo.Bar.Baz) baz, unrelated); // <-- NullPointerException on this line

}

where Foo is an enum, Bar a sealed interface and Baz a record that implements Bar.

Activity

  1. anthonyvdotbe commented on May 31, 2024

    @anthonyvdotbe
    ContributorAuthor

    @graememorgan I believe this requires an equivalent fix as what you did for #4349

  2. cushon commented on Feb 5, 2026

    @cushon
    Collaborator

    Fixed in 376b9d6

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions