Skip to content

Unable to format records #460

@anthonyvdotbe

Description

@anthonyvdotbe

To reproduce:

  • build 16b56a3 with mvn clean verify
  • create Foo.java in core\target:
record Foo(int id) {}
Foo.java:1:2: error: java.util.NoSuchElementException
        at com.google.common.collect.MoreCollectors$ToOptionalState.getElement(MoreCollectors.java:158)
        at com.google.common.collect.MoreCollectors.lambda$static$1(MoreCollectors.java:70)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:582)
        at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitRecordDeclaration(Java14InputAstVisitor.java:121)
        at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitClass(Java14InputAstVisitor.java:86)
        at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitClass(Java14InputAstVisitor.java:44)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:823)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
        at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:330)
        at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:375)
        at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:158)
        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:330)
        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)

Metadata

Metadata

Assignees

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