palantir / palantir/palantir-java-format
JDK 11 and local field name "sealed" cause error
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 907
- Forks
- 101
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 19
Description
What happened?
Test class:
package org.test;
public class Test {
void test() {
String sealed = "a sealed test";
}
}
executing: mvn -V spotless:2.36.0:apply
JDK 11
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Java version: 11.0.18, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@11/11.0.18/libexec/openjdk.jdk/Contents/Home
...
[INFO] --- spotless:2.36.0:apply (default-cli) @ test ---
[ERROR] Step 'palantir-java-format' found problem in 'src/main/java/org/test/Test.java':
No enum constant javax.lang.model.element.Modifier.SEALED
java.lang.IllegalArgumentException: No enum constant javax.lang.model.element.Modifier.SEALED
at java.lang.Enum.valueOf (Enum.java:240)
at javax.lang.model.element.Modifier.valueOf (Modifier.java:47)
at com.palantir.javaformat.java.ModifierOrderer.asModifier (ModifierOrderer.java:145)
at com.palantir.javaformat.java.ModifierOrderer.reorderModifiers (ModifierOrderer.java:59)
JDK 17
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Java version: 17.0.6, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.6/libexec/openjdk.jdk/Contents/Home
...
[INFO] --- spotless:2.36.0:apply (default-cli) @ test ---
[INFO] Writing clean file: ..../src/main/java/org/test/Test.java
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report with the supplied Test class under JDK 11, then inspect ModifierOrderer.asModifier and reorderModifiers in the stack trace. Trace how the local identifier "sealed" is interpreted during modifier ordering. Done means spotless:2.36.0:apply completes without the No enum constant error on JDK 11, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100