Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalCallableAccessException on private fields #11

Open
ubuntudroid opened this issue Nov 27, 2024 · 0 comments
Open

IllegalCallableAccessException on private fields #11

ubuntudroid opened this issue Nov 27, 2024 · 0 comments

Comments

@ubuntudroid
Copy link

Suppose you have a data class with a private parameter:

data class Test(
    val a: String,
    private val b: String,
)

Calling pprint(Test("a", "b")) will result in the following exception:

kotlin.reflect.full.IllegalCallableAccessException: java.lang.IllegalAccessException: Class java.lang.Class<kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter> cannot access private final field java.lang.String com.test.Test.b of class java.lang.Class<com.test.Test>
    at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:280)
    at kotlin.reflect.jvm.internal.KProperty1Impl.get(KProperty1Impl.kt:35)
    at kotlin.reflect.jvm.internal.KProperty1Impl.invoke(KProperty1Impl.kt:41)
    <pprint callsite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant