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

java 11 Parsing signatures failed #196

Closed
ningpp opened this issue Mar 28, 2022 · 6 comments
Closed

java 11 Parsing signatures failed #196

ningpp opened this issue Mar 28, 2022 · 6 comments
Assignees
Labels

Comments

@ningpp
Copy link

ningpp commented Mar 28, 2022

version 3.3 with java 11 Parsing signatures failed( version 3.2 is ok )
jdk-unsafe-17
jdk-deprecated-17
jdk-internal-17
jdk-non-portable
jdk-reflection

[ERROR] Failed to execute goal de.thetaphi:forbiddenapis:3.3:check (default) on project xyz-util: Parsing signatures failed: Method not found while parsing signature: java.text.NumberFormat#getCompactNumberInstance() -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal de.thetaphi:forbiddenapis:3.3:check (default) on project xyz-util: Parsing signatures failed: Method not found while parsing signature: java.text.NumberFormat#getCompactNumberInstance()
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Parsing signatures failed: Method not found while parsing signature: java.text.NumberFormat#getCompactNumberInstance()
at de.thetaphi.forbiddenapis.maven.AbstractCheckMojo.execute (AbstractCheckMojo.java:443)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
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)
Caused by: de.thetaphi.forbiddenapis.ParseException: Method not found while parsing signature: java.text.NumberFormat#getCompactNumberInstance()
at de.thetaphi.forbiddenapis.Signatures$UnresolvableReporting$1.parseFailed (Signatures.java:60)
at de.thetaphi.forbiddenapis.Signatures.addSignature (Signatures.java:212)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesFile (Signatures.java:312)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesStream (Signatures.java:278)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:274)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesFile (Signatures.java:294)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesStream (Signatures.java:278)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:274)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesFile (Signatures.java:294)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesStream (Signatures.java:278)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:274)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesFile (Signatures.java:294)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesStream (Signatures.java:278)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:274)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesFile (Signatures.java:294)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesStream (Signatures.java:278)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:274)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesFile (Signatures.java:294)
at de.thetaphi.forbiddenapis.Signatures.parseSignaturesStream (Signatures.java:278)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:274)
at de.thetaphi.forbiddenapis.Signatures.addBundledSignatures (Signatures.java:321)
at de.thetaphi.forbiddenapis.Checker.addBundledSignatures (Checker.java:322)
at de.thetaphi.forbiddenapis.maven.AbstractCheckMojo.execute (AbstractCheckMojo.java:404)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
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)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

@centic9
Copy link
Contributor

centic9 commented Mar 28, 2022

Did you try with matching java-11 signatures?

Java 11 vs. signatures-17 sounds like a mismatch in your setup.-

getCompactNumberInstance was added in Java 12.

@uschindler
Copy link
Member

uschindler commented Mar 28, 2022

Hi,
you are parsing signatures of Java version 17 (see the output you posted) with Java 11. It looks like the "targetVersion" or "release" property is wrongly configured.
This is not a bug, as this special Java 12 signature was added with version 3.3 and also mentioned in the release notes: https://github.com/policeman-tools/forbidden-apis/wiki/Changes#version-33-released-2022-03-26: "Add new signatures for historic and actual Java versions (issue #184, issue #185, pull #195), thanks to Marcono1234. This may break builds because new violations with jdk-unsafe could be detected in scanned code."

@uschindler uschindler self-assigned this Mar 28, 2022
@ningpp
Copy link
Author

ningpp commented Mar 28, 2022

i use 11 in pom, but i want upgrade to java 17 in future,
so i use jdk-unsafe-17, jdk-deprecated-17, jdk-internal-17 for easy upgrade in future.
is there any way to do this?

@uschindler
Copy link
Member

No, that's not possible. You have to use the signatures of your compilation target.

It just worked in forbiddenapis 3.2, because the signatures of 11 and 17 were identical. Now that 17 differs it fails. So it just worked by accident.

@uschindler
Copy link
Member

I would do the following: set target/release to the same version for compile and forbiddenapis task. When you upgrade change both. This will work flawless, because new additions in forbiddenapis won't suddenly break your build, because code compiled against 11 can't use this new problematic signatures anyways (they don't exist yet).

@ningpp
Copy link
Author

ningpp commented Mar 28, 2022

thank you.

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

No branches or pull requests

3 participants