Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-Sealed abstract classes not parsed #696

Closed
StefanPuia opened this issue Dec 13, 2021 · 1 comment · Fixed by #726
Closed

Non-Sealed abstract classes not parsed #696

StefanPuia opened this issue Dec 13, 2021 · 1 comment · Fixed by #726

Comments

@StefanPuia
Copy link

StefanPuia commented Dec 13, 2021

Non-sealed abstract classes seem to not be handled properly.
I found a few threads on this since they were a preview feature, but not much since they were released.

This seems to fail with different errors depending on the order of the abstract and non-sealed tokens
abstract non-sealed:
com.google.googlejavaformat.java.FormatterException: 3:2: error: expected token: 'non'; generated class instead

non-sealed abstract:
com.google.googlejavaformat.java.FormatterException: 3:9: error: class, interface, enum, or record expected

here is an example project and the full stack trace provided by spotless
https://github.com/StefanPuia/google-java-format-java-17-sealed
https://github.com/StefanPuia/google-java-format-java-17-sealed/runs/4512594407?check_suite_focus=true#step:4:195

@cushon
Copy link
Collaborator

cushon commented Jan 24, 2022

Thanks, I agree this is a bug:

package com.demo;

public abstract non-sealed class AbstractNonSealedClass extends SealedClass {

}
java \
  --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
  AbstractNonSealedClass.java
...
./abstract-non-sealed/src/main/java/com/demo/AbstractNonSealedClass.java:3:2: error: expected token: 'non'; generated class instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants