Skip to content

IllegalCallableAccessException on private fields #11

@ubuntudroid

Description

@ubuntudroid

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions