Repository navigation
Description
Summary
The #7007 fix taught overload dispatch to accept primitive widening. Combined with the ambiguity rejection added in the same change, any pair of overloads differing only in numeric width is now unresolvable: both candidates match after widening, and the call is refused. This is a regression - the pre-fix exact-match dispatch resolved twice(5) fine.
Found during a regression pass over the last two days of engine churn (JavaMethodFunctionDefinition.java was touched 9 times in that window).
Where (HEAD 38034d9c8)
engine/src/main/java/com/arcadedb/function/java/JavaMethodFunctionDefinition.java:285-294, typeMatches:
if (paramType.isPrimitive()) {
final Class<?> argPrimitiveType = unwrap(arg.getClass());
return argPrimitiveType != null
&& (argPrimitiveType == paramType || WIDENING_CONVERSIONS.getOrDefault(argPrimitiveType, Set.of()).contains(paramType));
}and :250-257, which refuses as soon as two candidates match:
for (final Method m : pool) {
if (acceptsArgumentTypes(m, args)) {
if (match != null)
throw ambiguousOverloadException(allCandidates, args);
match = m;
}
}An Integer argument now matches int exactly and long by widening, so both overloads qualify and neither wins. Java's own resolution picks the most specific (int); this picks nothing.
Repro
Verified at 38034d9c8. Register a class whose overloads differ only in width:
public static class Lib {
public static long twice(long v){ return v*2; }
public static int twice(int v){ return v*2; }
public static String only(String s){ return s+"!"; }
}
db.getSchema().registerFunctionLibrary(
new JavaClassFunctionLibraryDefinition("t", Lib.class.getName()));SELECT `t.twice`(5) -> THREW FunctionExecutionException: Error on executing function
'Lib::twice': cannot resolve which overload to call among
[public static int Lib.twice(int), public static long Lib.twice(long)]
for argument type(s) [java.lang.Integer]
SELECT `t.only`('a') -> {"v":"a!"} (control: single-candidate dispatch still fine)
Scope - narrower than it looks, and stated deliberately
This does not affect SQL's built-in functions. I checked, because that would have made it severe:
SELECT abs(5) -> {"v":5}
SELECT abs(-5) -> {"v":5}
SELECT abs(5.5) -> {"v":5.5}
SELECT sqrt(4) -> {"v":2}
SELECT max(1,2) -> {"v":2}
Those are engine-internal SQL functions and never enter this dispatcher. math.abs is not registered by default either (Unknown function name 'math.abs'), so no standard library is wired through here out of the box.
So the blast radius is: a user who registers their own Java class via JavaClassFunctionLibraryDefinition, where that class has width-differing overloads. Width-differing overloads are an ordinary Java idiom, so this is reachable, but it needs an explicit registration.
Suggested fix
Prefer the most specific applicable candidate instead of refusing when several apply, i.e. resolve in two passes: exact matches first, and only fall back to widening candidates when no exact match exists. That preserves both the #7007 widening behaviour and the pre-fix ability to call twice(5).
Keeping the ambiguity error is right for genuinely ambiguous cases (two unrelated reference types), but an exact match should always beat a widened one - which is what Java itself does.
Note the related interaction: JavaClassFunctionLibraryDefinition keys functions by bare method name, so both overloads land under twice and reach this dispatcher together. That grouping was the #7007 fix's own doing, so the two halves need to be consistent.
Scope / confidence
High - reproduced, with a single-candidate control in the same run and the built-in SQL functions checked to bound the claim.
Activity
fix(#7110): the overload winner must be strictly more specific than e…
fix(#7110): overload specificity spans the longest applicable signatu…
fix(#7110): judge the pre-packed vararg shape per overload during spe…
Merge pull request #7117 from ArcadeData/fix/issues-7109-7110-7111-7112
lvca commentedon Sep 3, 2026
Fixed in #7117 (milestone 26.9.1).
A Java function library registered with overloads that differ only in numeric width (
twice(int)andtwice(long)) is callable again. Overload selection now follows the Java rules: the narrowest primitive overload that accepts the argument wins (an exact match over a widened one,longoverdouble), and a call is rejected as ambiguous only when no overload is strictly more specific, exactly asjavacresolves it. Overloads that differ in reference types (ObjectvsString) are still reported as ambiguous.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(ArcadeData#7109,ArcadeData#7110,ArcadeData#7111,ArcadeData#7112):…