# Using Java Reflection with Kotlin Companion Objects

DevFeed: [Using Java Reflection with Kotlin Companion Objects](<https://devfeed.tech/articles/using-java-reflection-with-kotlin-companion-objects-25122.md>)

Original publisher: [Read original article](<https://handstandsam.com/2023/02/01/using-java-reflection-with-kotlin-companion-objects/>)

Author: Sam Edwards

Published: 2023-02-01T18:45:27Z

Content type: tutorial

Language: en

Sources: [Handstand Sam](<https://devfeed.tech/sources/handstand-sam.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [how-to](<https://devfeed.tech/tags/how-to.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [updates](<https://devfeed.tech/tags/updates.md>)

## AI overview

This tutorial explains how to use Java reflection to access and modify properties on Kotlin companion objects. It covers obtaining the companion object instance, working with the generated Java class, and accessing private backing fields.

## Source excerpt

Kotlin companion objects allow you to add static data and methods associated with a class. This is similar to how Java has static fields and methods. The problem is that Java doesn't really know what a companion object it, so trying to access one using standard Java reflection might make you go crazy. 🤪 The [...]