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 — instanceOf pattern bug in release 1.10.0 (not in 1.9!) · Issue #594 · google/google-java-format

instanceOf pattern bug in release 1.10.0 (not in 1.9!) #594

New issue
Copy link
New issue
Copy link
Closed
Closed
instanceOf pattern bug in release 1.10.0 (not in 1.9!)#594
Copy link
Assignees
cushon

Description

@Polly-Schulze
Polly-Schulze
opened on Apr 14, 2021
Issue body actions

Consider the following minimal example:

public class MinimalExample {
  public void thisIsNotFormattedCorrectly(Object something){
    if(something instanceof String somethingAsString){
      return;
    }
    //doSomethingElse
  }
}

When formatting this with the 1.9 jar: java -jar google-java-format-1.9-all-deps.jar PATH/MinimalExample.java the class is formatted correctly.

When formatting it with the 1.10 jar: java -jar google-java-format-1.10.0-all-deps.jar PATH/MinimalExample.java I get the following error:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.googlejavaformat.java.JavacTokens$CommentSavingTokenizer (file:/[PATH]/git/google-java-format-1.10.0-all-deps.jar) to field com.sun.tools.javac.parser.JavaTokenizer.reader
WARNING: Please consider reporting this to the maintainers of com.google.googlejavaformat.java.JavacTokens$CommentSavingTokenizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[PATH]/MinimalExample.java:3:30: error: java.lang.LinkageError: com.sun.source.tree.BindingPatternTree.getName()
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:67)
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:47)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBindingPattern.accept(JCTree.java:2231)
	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitInstanceOf(Java14InputAstVisitor.java:207)
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitInstanceOf(Java14InputAstVisitor.java:47)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2178)
	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitIf(JavaInputAstVisitor.java:1081)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitIf(JavaInputAstVisitor.java:157)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1513)
	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitStatements(JavaInputAstVisitor.java:2181)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.methodBody(JavaInputAstVisitor.java:1495)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitMethod(JavaInputAstVisitor.java:1482)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitMethod(JavaInputAstVisitor.java:157)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:925)
	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.addBodyDeclarations(JavaInputAstVisitor.java:3531)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitClassDeclaration(JavaInputAstVisitor.java:2004)
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitClass(Java14InputAstVisitor.java:104)
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitClass(Java14InputAstVisitor.java:47)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:832)
	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:374)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:157)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:603)
	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
	at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
	at com.google.googlejavaformat.java.Formatter.format(Formatter.java:170)
	at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:291)
	at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:267)
	at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:45)
	at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:26)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoSuchMethodException: com.sun.source.tree.BindingPatternTree.getName()
	at java.base/java.lang.Class.getMethod(Class.java:2201)
	at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:63)
	... 42 more
	Suppressed: java.lang.NoSuchMethodException: com.sun.source.tree.BindingPatternTree.getVariable()
		at java.base/java.lang.Class.getMethod(Class.java:2201)
		at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:58)
		... 42 more
Reacted by Kishan B

Activity

  1. Polly-Schulze
    changed the title [-]Instance of pattern bug in release 1.10.0[/-] [+]Instance of pattern bug in release 1.10.0 (not in 1.9!)[/+] on Apr 14, 2021
  2. Polly-Schulze
    changed the title [-]Instance of pattern bug in release 1.10.0 (not in 1.9!)[/-] [+]instanceOf pattern bug in release 1.10.0 (not in 1.9!)[/+] on Apr 14, 2021
  3. cushon commented on Apr 14, 2021

    @cushon
    cushon
    on Apr 14, 2021
    Collaborator
    More actions

    What version of java are you using, what is the output of java -fullversion?

  4. Polly-Schulze commented on Apr 15, 2021

    @Polly-Schulze
    Polly-Schulze
    on Apr 15, 2021
    Author
    More actions

    Sorry, this is my first time writing an issue. I should`ve said so directly. It is:

    java --version
    openjdk 15.0.2 2021-01-19
    OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.2+7, mixed mode, sharing)
    

    My main goal is to update to Java 16. Hence I started by updating the google java formatter and gradle. Then this occurred.

    Reacted by Liam Miller-Cushon
  5. cushon commented on Apr 15, 2021

    @cushon
    cushon
    on Apr 15, 2021
    Collaborator
    More actions

    Thanks! I'm working on a fix.

    Reacted by Polly-Schulze and Kishan B
  6. cushon
    self-assigned this
    on Apr 15, 2021
  7. cushon commented on Apr 21, 2021

    @cushon
    cushon
    on Apr 21, 2021
    Collaborator
    More actions

    32b63aa

  8. cushon
    closed this as completedon Apr 21, 2021
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.