Fix iOS build of method refs needing unbox/box + add Objects.deepEquals#5150
Merged
Merged
Conversation
Two issues reported building CodeRAD apps for iOS (r/cn1):
1. Method references whose implementation signature differs from the
functional interface's failed to compile in the generated Xcode
project, e.g. `obj::setSomeValue` (setSomeValue(double)) bound to a
Consumer<Double>:
error: passing 'JAVA_OBJECT' to parameter of incompatible type
'JAVA_DOUBLE'
ParparVM consumes invokedynamic directly and synthesizes the lambda
adapter class itself in Parser.visitInvokeDynamicInsn. It loaded each
SAM argument verbatim and invoked the target method directly, with no
adaptation between the SAM signature and the implementation method
signature. The real LambdaMetafactory is required to box/unbox/widen/
cast there, so a Double object reached a primitive double parameter.
The adapter now replicates that adaptation for every argument and the
return value: unbox (with a CHECKCAST to the wrapper when the SAM type
is erased to Object), box via valueOf, primitive widening/narrowing,
and reference checkcast. Lambdas and same-signature method references
hit the identity path and are unchanged.
2. java.util.Objects.deepEquals was missing from the iOS runtime, so
callers such as CodeRAD's ButtonListPropertyView produced a call to an
undeclared C function. Added it, faithful to the JDK's deepEquals0
(dispatch to the matching Arrays.equals/deepEquals overload by array
element type, else a.equals(b)).
LambdaIntegrationTest gains adaptsBoxingUnboxingInMethodReferences, which
compiles -> translates -> builds the generated C with clang -> runs it,
covering unbox, erased-generic unbox, return boxing and int->long
widening. Reproduces the compile error pre-fix; passes post-fix.
StreamApiIntegrationTest (heavy generic-lambda boxing) still passes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Contributor
✅ ByteCodeTranslator Quality ReportTest & Coverage
Benchmark Results
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two issues reported building CodeRAD apps for iOS (r/cn1, 7.0.225+: "Cannot build for iOS with CodeRAD on latest versions").
1. Method references needing box/unbox/widen/cast broke the Xcode build
A method reference whose implementation signature differs from the functional interface's failed to compile in the generated Xcode project. The reporter's case —
obj::setSomeValuewheresetSomeValue(double)bound to aConsumer<Double>:ParparVM consumes
invokedynamicdirectly and synthesizes the lambda adapter class itself inParser.visitInvokeDynamicInsn. It loaded each SAM argument verbatim and invoked the target method directly, with no adaptation between the SAM signature and the implementation method signature. The realLambdaMetafactoryis required to box/unbox/widen/cast there, so aDoublereached a primitivedoubleparameter and the generated C did not compile.The adapter now replicates that adaptation for every argument and the return value:
CHECKCASTto the wrapper when the SAM type is erased toObject, e.g. generic functional interfaces),valueOf,Lambdas and same-signature method references hit the identity path and are unchanged.
2.
Objects.deepEqualsmissing from the iOS runtimeCodeRAD's
ButtonListPropertyViewcallsjava.util.Objects.deepEquals, which the iOS runtime (vm/JavaAPI) didn't provide, producingcall to undeclared function java_util_Objects_deepEquals___.... Added it, faithful to the JDK'sdeepEquals0(dispatch to the matchingArrays.equals/Arrays.deepEqualsoverload by array element type, elsea.equals(b)).Testing
LambdaIntegrationTestgainsadaptsBoxingUnboxingInMethodReferences, which compiles Java → translates → builds the generated C with clang → runs it, covering unbox, erased-generic unbox, return boxing, andint→longwidening.error: passing 'JAVA_OBJECT' ... incompatible type 'JAVA_DOUBLE'.RESULT=73,RESULT=145);StreamApiIntegrationTest(heavy generic-lambda boxing) still passes — no regression.🤖 Generated with Claude Code