Stylianos Gakis
11/12/2024, 10:14 PMCaused by: java.lang.IllegalAccessError: failed to access class arrow.core.raise.RaiseKt__RaiseAccumulateKt from class com.hedvig.android.feature.profile.myinfo.MyInfoViewModelKt (arrow.core.raise.RaiseKt__RaiseAccumulateKt and com.hedvig.android.feature.profile.myinfo.MyInfoViewModelKt are in unnamed module of loader 'app')
And it's just pointing to this part of my code. This is quite curious, I don't even know where to start figuring out what is going on here 😄Stylianos Gakis
11/12/2024, 10:14 PMprivate fun MyInfoMember.validate(): Either<NonEmptyList<MyInfoMemberErrors>, ValidMyInfoMember> {
return either {
zipOrAccumulate(
{
val hasValidEmail = email.isNotBlank() && validateEmail(email).isSuccessful
if (!hasValidEmail) raise(MyInfoMemberErrors.Email)
email
},
{
val phoneNumber = phoneNumber ?: raise(MyInfoMemberErrors.PhoneNumber)
val hasValidPhoneNumber = phoneNumber.isNotBlank() == true && phoneNumberRegex.matches(phoneNumber)
if (!hasValidPhoneNumber) raise(MyInfoMemberErrors.PhoneNumber)
phoneNumber
},
) { email: String, phoneNumber: String ->
ValidMyInfoMember(email, phoneNumber)
}
}
}
And it points to the zipOrAccumulate
there.Stylianos Gakis
11/12/2024, 10:15 PMStylianos Gakis
11/12/2024, 10:16 PMStylianos Gakis
11/12/2024, 10:22 PM./gradlew app:dependencies
also seems to confirm that only arrow 2.0.0-beta.1 is on the classpath.
Does anyone have even a slight hint of where I should be heading towards to figure this out? I am stumped 😄dave08
11/13/2024, 2:50 AMStylianos Gakis
11/13/2024, 4:44 AMAlejandro Serrano.Mena
11/13/2024, 11:14 AMStylianos Gakis
11/13/2024, 11:33 AMAlejandro Serrano.Mena
11/13/2024, 11:35 AMStylianos Gakis
11/13/2024, 11:36 AMStylianos Gakis
11/13/2024, 4:11 PM./gradlew testDebugUnitTest --tests *
You should be getting 4 failing tests related to this:
if error is received show error section
if save button is clicked it is not showing anymore
can recover from a network error
if phone and email are updated they are received in state
I hope this is simple enough that it works for you. I just tried doing this exact thing on my machine after cloning it from scratch as well, without having any of the credentials and so on.CLOVIS
11/13/2024, 5:04 PMCLOVIS
11/13/2024, 5:06 PMYoussef Shoaib [MOD]
11/13/2024, 5:29 PMRaiseCancellationException
was marked as private
, but was being used for a catch
type in an inline function (and somehow the compiler didn't produce an error). Here I don't see something similar happening, but something else is fishy: RaiseKt__RaiseAccumulateKt
is named that way because RaiseAccumulate.kt
is declared as a JVM multifile class, but to my understanding, there shouldn't be such a special class for it then. I'll take a look at the decompiled bytecode to see where things are going wrong, but maybe this is a compiler bug??
The code for that file was also changed recently, so I need to familiarize myself with it, so sadly I might take some timeYoussef Shoaib [MOD]
11/13/2024, 7:17 PMRaiseKt__RaiseAccumulateKt.access$zipOrAccumulate$lambda$39$lambda-30
(and that last 0 ranges from 0 to 8). The access
prefix suggests this is originally a private method, and so we use it through a generated synthetic public method.
Decompiling RaiseAccumulate.kt
, I found methods that look like:
private static final <A, Error> A zipOrAccumulate$lambda$39$lambda-30$RaiseKt__RaiseAccumulateKt(RaiseAccumulate.Value<? extends A> $a$delegate) {
return $a$delegate.getValue(null, $$delegatedProperties[0]);
}
With the 0 again replaced with numbers from 0-8.
So clearly the reproducer tries to call the getter for the local properties in zipOrAccumulate
. That should be fine, except for the fact that the access$
methods are not generated! The real kicker (and the reason why the error isn't NoSuchMethodException
) is that RaiseKt__RaiseAccumulateKt
, is declared package-private! Hence, the code can't access RaiseKt__RaiseAccumulateKt
in the first place.
Pretty sure that this is thus a compiler bug to do with inlining. An immediate workaround we can do in Arrow is to avoid using delegation in zipOrAccumulate
.Alejandro Serrano.Mena
11/13/2024, 7:39 PMzipOrAccumulate
and use the previous implementationYoussef Shoaib [MOD]
11/13/2024, 7:42 PMAlejandro Serrano.Mena
11/13/2024, 7:42 PMYoussef Shoaib [MOD]
11/13/2024, 8:20 PMYoussef Shoaib [MOD]
11/13/2024, 8:52 PMpublic static final java.lang.Object access$zipOrAccumulate$lambda$39$lambda-30(arrow.core.raise.RaiseAccumulate$Value);
methods do get generated, they just weren't shown by default by CFR (but javap -p
showed them). Now I'm convinced the issue is simply that RaiseKt__RaiseAccumulateKt
is package private. I've been able to even recreate the issue in Arrow's tests by making a new test in a different package.Youssef Shoaib [MOD]
11/13/2024, 9:11 PMAlejandro Serrano.Mena
11/14/2024, 8:41 AMStylianos Gakis
11/14/2024, 8:45 AMAlejandro Serrano.Mena
11/14/2024, 8:46 AMbeta.2
, which hopefully should be out during the day
The API that changes is in a new 2.x API, so there's no need to preserve compatibility. The 1.x API (zipOrAccumulate) are fully compatible.Stylianos Gakis
11/14/2024, 11:38 AMYoussef Shoaib [MOD]
11/14/2024, 4:33 PM