Skip to content

Call resolver: Java overloads -- a confident link goes to an arbitrary overload of the right method #3835

Closed

Description

@squid-protocol

What

In Java, a class often has several methods with the same name (overloads). When the resolver links a call to one of them, it links to an arbitrary one. Nothing at the call site (argument count or types) chooses between them. The link is right at the method level but wrong at the unit level, so function-level fan-in and PageRank pile onto one overload.

Evidence

Measured vs scip-java 0.12.3 (javac-resolved SCIP, #3783) on google/gson @ 854c8255 (tests/import_graph_corpus.json). The reference has 7,858 edges:

  • 1,653 of the 1,923 confident wrong links are a different overload of the reference's target: same file, same name.
  • Counting those right, confident precision goes from 59.8% to 94.3%, and recall from 36.3% to 58.4%. These are the overload-blind metrics in call_graph_resolution.py, OVERLOADED_LANGS.

Samples, all checked in source:

  • extras/.../RawCollectionsExample.java:43, Gson gson = new Gson();: the engine links Gson@247, scip-java links Gson@243. That is the no-argument constructor public Gson().
  • .../RawCollectionsExample.java:51, gson.fromJson(array.get(0), String.class): the engine links fromJson@1087 (JsonReader, TypeToken), scip-java links fromJson@1159 (JsonElement, Class<T>). Gson.java has 10 fromJson overloads.
  • .../RawCollectionsExample.java:48, gson.toJson(collection): the engine links toJson@670, scip-java links toJson@565 (Object).

Likely fix

Pick the overload by argument count. The detector already records each unit's args, and a call site's argument count is countable with the same bracket matching. That settles overloads that differ in arity; Gson() versus Gson(Excluder, …) is typical.

Same-arity overloads stay a guess. For example, the 2-argument fromJson(String, Class) and fromJson(Reader, Type). Those links could fall to the ambiguous group instead of confident, which stops them feeding PageRank.

Measure against the overload-blind metrics with the callgraph-miss-sweep skill, and include the net-change rule.

Epic #3772.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions