Heads up: incompatible java.lang.Long change coming

35 views
Skip to first unread message

Tom Ball

unread,
Aug 29, 2022, 1:27:23 PM8/29/22
to j2objc-discuss
TL;DR: java.lang.Long's constructor initWithLong: will be changed to initWithLongLong:.

Explanation:

The java.lang.Long(long) constructor was translated as initWithLong:(jlong), following normal method name mangling. A jlong is equivalent to the Objective C "long long".

The problem is that java.lang.Long extends java.lang.Number, which extends NSNumber, and NSNumber has two initializers: initWithLong:(long) and initWithLongLong:(long long), so these types conflict with the transpiled Java method.

The solution therefore is to generate initWithLongLong:(jlong) init methods  for those classes that extend the java.lang.Number(long) constructor. Any native sources with "[[JavaLangLong alloc] initWithLong:nnn]" need to be updated to initWithLongLong:, since Objective-C doesn't have a safe way to alias a method name. References to the related C functions won't have to be changed, though, as we'll provide inlined compatibility functions.
Reply all
Reply to author
Forward
0 new messages