Skip to content

OverridingMethodInconsistentArgumentNamesChecker fails when original function contains multiple parameters with the same name #5398

@SquidDev

Description

@SquidDev

Error-prone version: 2.45.0
BugPattern: OverridingMethodInconsistentArgumentNamesChecker

I have a codebase which depends on a partially obfuscated library (Minecraft modding, if interested. Nothing nefarious!). While the LVT is present for all functions, it has been mangled, and all parameters are called o. When overriding a function from this library, this causes OverridingMethodInconsistentArgumentNamesChecker to crash, as that (reasonably) expects all parameters to have a unique name.

Stack trace
 java.lang.IllegalArgumentException: Multiple entries with same key: o=0 and o=1
at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:382)
at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:376)
at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:246)
at com.google.common.collect.RegularImmutableBiMap.fromEntryArray(RegularImmutableBiMap.java:98)
at com.google.common.collect.ImmutableBiMap$Builder.buildOrThrow(ImmutableBiMap.java:479)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:686)
at com.google.errorprone.bugpatterns.OverridingMethodInconsistentArgumentNamesChecker.getParams(OverridingMethodInconsistentArgumentNamesChecker.java:72)
at com.google.errorprone.bugpatterns.OverridingMethodInconsistentArgumentNamesChecker.matchMethod(OverridingMethodInconsistentArgumentNamesChecker.java:53)
at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:539)
at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:881)
at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:178)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:649)
at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:178)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:855)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:152)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:661)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:178)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:623)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:66)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:231)
at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:133)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1436)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1383)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:963)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)

As such a class cannot be created from Java source code directly, there's not really an easy reproducer here. Happy to put one together using org.ow2.asm if useful? Also happy if you just want to close as "won't fix", as I realise this is a bit of a silly use-case!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions