Skip to content

Ignore the signature-polymorphic MethodHandle in Animal Sniffer - #719

Merged
garydgregory merged 1 commit into
apache:masterfrom
ppkarwasz:fix/animal-sniffer-ignore-method-handle
Aug 29, 2026
Merged

Ignore the signature-polymorphic MethodHandle in Animal Sniffer#719
garydgregory merged 1 commit into
apache:masterfrom
ppkarwasz:fix/animal-sniffer-ignore-method-handle

Conversation

@ppkarwasz

Copy link
Copy Markdown
Member

MethodHandle's invokers (invokeExact, invoke) are signature-polymorphic: javac records the ad-hoc call-site descriptor in the bytecode, which no signature database lists, so the Animal Sniffer check on JDK 8 flags every such call site as an undefined reference — even though the invokers exist on all supported targets (Java 7+).

Seen in practice on apache/commons-xml#57, where six invokeExact call sites fail the JDK 8 CI legs; the workaround there is the same <ignore>java.lang.invoke.MethodHandle</ignore> in the component's own pom, which this change makes unnecessary for all components.

Only java.lang.invoke.MethodHandle is ignored: VarHandle is deliberately not listed, since it does not exist on a Java 8 target and a reference to it would be a real incompatibility.

🤖 Generated with Claude Code

javac records the ad-hoc call-site descriptor for MethodHandle's
invokers (invokeExact, invoke), which no signature database lists, so
the Animal Sniffer check on JDK 8 flags every such call site as an
undefined reference even though the invokers exist on all supported
targets (Java 7+).

Assisted-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ErRKq7RUeQ9LGrSboSUyYm
@garydgregory

Copy link
Copy Markdown
Member

@ppkarwasz
Are you sure? When I run locally on macOS, I see:

[INFO] --- animal-sniffer:1.27:check (checkAPIcompatibility) @ commons-xml ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java18:1.0
[INFO] 

Using:

Apache Maven 3.9.16 (2bdd9fddda4b155ebf8000e807eb73fd829a51d5)
Maven home: /opt/homebrew/Cellar/maven/3.9.16/libexec
Java version: 1.8.0_481, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "26.6.2", arch: "aarch64", family: "mac"

On GH CI here on Windows and Java 8, I see the same as above, using:

Apache Maven 3.9.16 (2bdd9fddda4b155ebf8000e807eb73fd829a51d5)
Maven home: C:\ProgramData\chocolatey\lib\maven\apache-maven-3.9.16
Java version: 1.8.0_502, vendor: Temurin, runtime: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.502-7\x64\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2025", version: "10.0", arch: "amd64", family: "windows"

What do you see and where?

@garydgregory

Copy link
Copy Markdown
Member

Oh, I see, you disabled it... ok.

@garydgregory
garydgregory merged commit 20098cc into apache:master Aug 29, 2026
9 checks passed
@ppkarwasz
ppkarwasz deleted the fix/animal-sniffer-ignore-method-handle branch August 29, 2026 13:07
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 this pull request may close these issues.

2 participants