GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JDK 16: final variable in pattern matching with instanceof · Issue #588 · google/google-java-format

JDK 16: final variable in pattern matching with instanceof #588

New issue
Copy link
New issue
Copy link
Closed
#592
Closed
JDK 16: final variable in pattern matching with instanceof#588
#592
Copy link
Assignees
cushon

Description

@agavrilov76
agavrilov76
opened on Apr 11, 2021
Issue body actions

Declaring a variable final when matching pattern with instanceof operator causing an exception.

Code example:

if (person instanceof final Customer customer) {
    customer.pay();
}

Error:

com.google.googlejavaformat.java.FormatterException: 83:33: error: did not generate token "final"
    at com.google.googlejavaformat.java.Formatter.getFormatReplacements (Formatter.java:293)
    at com.google.googlejavaformat.java.Formatter.formatSource (Formatter.java:267)
    at com.google.googlejavaformat.java.Formatter.formatSource (Formatter.java:233)
    at com.coveo.AbstractFMT.formatSourceFile (AbstractFMT.java:216)
    at com.coveo.AbstractFMT.lambda$formatSourceFilesInDirectory$1 (AbstractFMT.java:157)
    at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:197)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:179)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:179)
    at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:197)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:179)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:484)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
    at java.util.stream.ReduceOps$ReduceTask.doLeaf (ReduceOps.java:952)
    at java.util.stream.ReduceOps$ReduceTask.doLeaf (ReduceOps.java:926)
    at java.util.stream.AbstractTask.compute (AbstractTask.java:327)
    at java.util.concurrent.CountedCompleter.exec (CountedCompleter.java:746)
    at java.util.concurrent.ForkJoinTask.doExec (ForkJoinTask.java:295)
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec (ForkJoinPool.java:1016)
    at java.util.concurrent.ForkJoinPool.scan (ForkJoinPool.java:1665)
    at java.util.concurrent.ForkJoinPool.runWorker (ForkJoinPool.java:1598)
    at java.util.concurrent.ForkJoinWorkerThread.run (ForkJoinWorkerThread.java:183)

Activity

  1. cushon commented on Apr 11, 2021

    @cushon
    cushon
    on Apr 11, 2021
    Collaborator
    More actions

    Thanks for the report, it looks like this wasn't supported prior to JDK 16: https://bugs.openjdk.java.net/browse/JDK-8257759

  2. cushon
    self-assigned this
    on Apr 11, 2021
  3. copybara-service
    added 4 commits that reference this issue on Apr 12, 2021

    Handle `final` variables in `instanceof` patterns

    9310295

    Handle `final` variables in `instanceof` patterns

    fa01637

    Handle `final` variables in `instanceof` patterns

    bb4470f

    Handle `final` variables in `instanceof` patterns

    fe5ac46
  4. copybara-service
    closed this as completedin fe5ac46on Apr 13, 2021
  5. fawind
    added a commit that references this issue on Dec 13, 2021

    Handle `final` variables in `instanceof` patterns

    940ff1d
  6. fawind
    added 4 commits that reference this issue on Jan 7, 2022

    Handle `final` variables in `instanceof` patterns

    77afc42

    Handle `final` variables in `instanceof` patterns

    ea550e9

    Handle `final` variables in `instanceof` patterns

    950286d

    Handle `final` variables in `instanceof` patterns

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

Metadata

Metadata

Assignees

  • @cushon
    cushon

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.