revelc / formatter-maven-plugin

Formatter Maven Plugin
https://code.revelc.net/formatter-maven-plugin
Apache License 2.0
291 stars 91 forks source link

NPE: Cannot invoke "org.eclipse.jdt.internal.compiler.ast.TypeReference.extraDimensions()" with version 2.24 #907

Open rsvoboda opened 5 months ago

rsvoboda commented 5 months ago

Describe the bug After move from 2.23.0 to 2.24.x I cannot build my project and I get Cannot invoke "org.eclipse.jdt.internal.compiler.ast.TypeReference.extraDimensions()" because "typeReference" is null

Versions (OS, Maven, Java, and others, as appropriate):

To Reproduce

git clone https://github.com/quarkus-qe/quarkus-jdkspecifics
cd quarkus-jdkspecifics

FAIL:
mvn clean verify -DskipTests -DskipITs -Dformatter-maven-plugin.version=2.24.1 -Dquarkus.platform.version=3.11.0

PASS:
mvn clean verify -DskipTests -DskipITs -Dformatter-maven-plugin.version=2.23.0 -Dquarkus.platform.version=3.11.0

Expected behavior Project compiles without error

Additional context Last "caused by" from the stacktrace:

Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.internal.compiler.ast.TypeReference.extraDimensions()" because "typeReference" is null
    at org.eclipse.jdt.core.dom.ASTConverter.convertToSingleVariableDeclaration (ASTConverter.java:3970)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3537)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:2865)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:2298)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:2859)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:1965)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:1402)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3109)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3246)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3133)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:738)
    at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations (ASTConverter.java:208)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3477)
    at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:1521)
    at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert (CompilationUnitResolver.java:344)
    at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTCached (ASTParser.java:1269)
    at org.eclipse.jdt.core.dom.ASTParser.lambda$0 (ASTParser.java:1120)
    at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles (JavaModelManager.java:5839)
    at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST (ASTParser.java:1120)
    at org.eclipse.jdt.core.dom.ASTParser.createAST (ASTParser.java:868)
    at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.parseSourceCode (DefaultCodeFormatter.java:316)
    at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode (DefaultCodeFormatter.java:220)
    at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format (DefaultCodeFormatter.java:184)
    at net.revelc.code.formatter.java.JavaFormatter.doFormat (JavaFormatter.java:63)
    at net.revelc.code.formatter.AbstractCacheableFormatter.formatFile (AbstractCacheableFormatter.java:84)
    at net.revelc.code.formatter.FormatterMojo.doFormatFile (FormatterMojo.java:721)
    at net.revelc.code.formatter.FormatterMojo.formatFile (FormatterMojo.java:667)
    at net.revelc.code.formatter.FormatterMojo.execute (FormatterMojo.java:471)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    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:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    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:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
hazendaz commented 5 months ago

Looks to be an open issue with eclipse. See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2494

Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Rostislav Svoboda @.> Sent: Wednesday, June 5, 2024 4:37:26 AM To: revelc/formatter-maven-plugin @.> Cc: Subscribed @.***> Subject: [revelc/formatter-maven-plugin] NPE: Cannot invoke "org.eclipse.jdt.internal.compiler.ast.TypeReference.extraDimensions()" with version 2.24 (Issue #907)

Describe the bug After move from 2.23.0 to 2.24.x I cannot build my project and I get Cannot invoke "org.eclipse.jdt.internal.compiler.ast.TypeReference.extraDimensions()" because "typeReference" is null

Versions (OS, Maven, Java, and others, as appropriate):

To Reproduce

git clone https://github.com/quarkus-qe/quarkus-jdkspecifics cd quarkus-jdkspecifics

FAIL: mvn clean verify -DskipTests -DskipITs -Dformatter-maven-plugin.version=2.24.1 -Dquarkus.platform.version=3.11.0

PASS: mvn clean verify -DskipTests -DskipITs -Dformatter-maven-plugin.version=2.23.0 -Dquarkus.platform.version=3.11.0

Expected behavior Project compiles without error

Additional context Last "caused by" from the stacktrace:

Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.internal.compiler.ast.TypeReference.extraDimensions()" because "typeReference" is null at org.eclipse.jdt.core.dom.ASTConverter.convertToSingleVariableDeclaration (ASTConverter.java:3970) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3537) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:2865) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:2298) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:2859) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:1965) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:1402) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3109) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3246) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3133) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:738) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations (ASTConverter.java:208) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:3477) at org.eclipse.jdt.core.dom.ASTConverter.convert (ASTConverter.java:1521) at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert (CompilationUnitResolver.java:344) at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTCached (ASTParser.java:1269) at org.eclipse.jdt.core.dom.ASTParser.lambda$0 (ASTParser.java:1120) at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles (JavaModelManager.java:5839) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST (ASTParser.java:1120) at org.eclipse.jdt.core.dom.ASTParser.createAST (ASTParser.java:868) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.parseSourceCode (DefaultCodeFormatter.java:316) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode (DefaultCodeFormatter.java:220) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format (DefaultCodeFormatter.java:184) at net.revelc.code.formatter.java.JavaFormatter.doFormat (JavaFormatter.java:63) at net.revelc.code.formatter.AbstractCacheableFormatter.formatFile (AbstractCacheableFormatter.java:84) at net.revelc.code.formatter.FormatterMojo.doFormatFile (FormatterMojo.java:721) at net.revelc.code.formatter.FormatterMojo.formatFile (FormatterMojo.java:667) at net.revelc.code.formatter.FormatterMojo.execute (FormatterMojo.java:471) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) 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:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) 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:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)

— Reply to this email directly, view it on GitHubhttps://github.com/revelc/formatter-maven-plugin/issues/907, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHODI7ELUUK2SD7DLDG4PDZF3E4NAVCNFSM6AAAAABI2HBO7CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTKMRVHAZDGNQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

AlejandroBertolo commented 1 month ago

Hello @hazendaz ! I believe this insidious bug has been fixed in the JDT by now, meaning full Java21 support should finally be at hand :) It would bring me real joy to see this plugin updated! If there is something I can do to help, let me know!