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

Incompatible with JDK 21 #934

Open
lalib opened this issue Sep 21, 2023 · 4 comments
Open

Incompatible with JDK 21 #934

lalib opened this issue Sep 21, 2023 · 4 comments

Comments

@lalib
Copy link

lalib commented Sep 21, 2023

What happened?

Failed with using Spotless Maven plugin and palantir rule:

[INFO] --- spotless:2.39.0:apply (default-cli) @ X ---
[ERROR] Step 'palantir-java-format' found problem in 'X.java':
253:44: error: expected token: '_'; generated  instead
com.palantir.javaformat.java.FormatterException: 253:44: error: expected token: '_'; generated  instead
    at com.palantir.javaformat.java.Formatter.getFormatReplacements (Formatter.java:302)
    at com.palantir.javaformat.java.Formatter.formatSource (Formatter.java:277)
    at com.palantir.javaformat.java.Formatter.formatSource (Formatter.java:245)
    at com.diffplug.spotless.glue.pjf.PalantirJavaFormatFormatterFunc.apply (PalantirJavaFormatFormatterFunc.java:43)
    at com.diffplug.spotless.FormatterFunc.apply (FormatterFunc.java:32)
    at com.diffplug.spotless.FormatterStepImpl$Standard.format (FormatterStepImpl.java:82)
    at com.diffplug.spotless.FormatterStep$Strict.format (FormatterStep.java:103)
    at com.diffplug.spotless.Formatter.compute (Formatter.java:246)
    at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:203)
    at com.diffplug.spotless.PaddedCell.calculateDirtyState (PaddedCell.java:190)
    at com.diffplug.spotless.maven.SpotlessApplyMojo.process (SpotlessApplyMojo.java:48)
    at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:229)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
@booniepepper
Copy link

booniepepper commented Oct 13, 2023

Also saw a failure (although a slightly different one) with Spotless and Gradle here: https://github.com/openfga/java-sdk/actions/runs/6510767947/job/17685150920?pr=27

@koppor
Copy link
Contributor

koppor commented Nov 16, 2023

This issue should be refined: When did you encounter this issue? I tried the plugin on Java 21 in a JavaFX project (at koppor/jabref#663) - and it worked.

@ollehallin
Copy link

This code fails to format with palantir-java-format 2.39.0:

final var currentOffsets = new HashMap<Integer, Long>();

currentOffsets.computeIfAbsent(partition, _ -> new AtomicLong()).set(consumerRecord.offset());

It generates

com.palantir.javaformat.java.FormatterException: 156:60: error: expected token: '_'; generated instead -> [Help 1]

@koppor
Copy link
Contributor

koppor commented Dec 15, 2023

For the interested readers: Using _ is from JEP-443. Good explanation at https://howtodoinjava.com/java/unnamed-patterns-and-variables/

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

No branches or pull requests

4 participants