# Kotlin 2.5 companion blocks and extensions: features, limitations, and setup

DevFeed: [Kotlin 2.5 companion blocks and extensions: features, limitations, and setup](<https://devfeed.tech/articles/the-evolution-of-statics-say-goodbye-to-kotlin-companion-objects-85773.md>)

Original publisher: [Read original article](<https://proandroiddev.com/the-evolution-of-statics-say-goodbye-to-kotlin-companion-objects-dbe625b92896?source=rss----c72404660798---4>)

Author: Nav Singh

Published: 2026-10-12T23:57:23Z

Content type: tutorial

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [The Julia Language](<https://devfeed.tech/topics/julia.md>), [Groovy](<https://devfeed.tech/topics/groovy.md>), [openjdk](<https://devfeed.tech/topics/openjdk.md>)

Tags: [androiddev](<https://devfeed.tech/tags/androiddev.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [companion](<https://devfeed.tech/tags/companion.md>), [experimental](<https://devfeed.tech/tags/experimental.md>), [high-performance](<https://devfeed.tech/tags/high-performance.md>), [java](<https://devfeed.tech/tags/java.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [new-features](<https://devfeed.tech/tags/new-features.md>), [sdks](<https://devfeed.tech/tags/sdks.md>), [static](<https://devfeed.tech/tags/static.md>)

## AI overview

The article introduces Kotlin 2.5's experimental companion blocks and companion extensions. It explains how these features compile to static members, enable Java calls without `@JvmStatic`, and allow static-like extensions on classes from other modules. It also notes that companion blocks cannot implement interfaces and gives setup instructions for Kotlin 2.5.0-Beta1.

## Source excerpt

AI generated image For years, we used companion object to group class-level members (constants, factory methods). However, companion objects are actual object singletons under the hood. This introduces memory overhead and causes friction when interoperating with Java (requiring @JvmStaticannotations). data class User(val name: String, val age: Int) { companion object { @JvmStatic fun createDefault(): User = User("Guest", 18) } }AI generated imageKotlin 2.5 introduces companion blocks and companion extensions: Companion Blocks: Drop the object keyword. On the JVM, they compile down directly into high-performance native static members. Companion Extensions: Let us attach new static-like methods or properties to any class from the outside, even classes inside external dependencies or standard Java SDKs we don't control. Companion Blocks vs. Companion Objects Under the Hood: A companion object creates a nested singleton subclass instantiation. A companion block compiles directly to static bytecode members on the parent class. Interface Limitation: Companion objects are still required if static-scoped layer needs to implement an interface. Companion blocks cannot implement interfaces because they are not real objects. Java Interop: Java code can call companion block members directly via User.createDefault(). Companion objects still require User.Companion.createDefault() unless decorated with @JvmStatic. Companion Extensions vs. Regular Extension Functions Call Site: Regular extensions require an existing instance (userInstance.isValid()). Companion extensions are invoked statically on the type itself (User.systemAdmin()). Use Cases: Regular extensions add instance operations (mapping, filtering, etc.). Companion extensions serve as third-party factories, cross-module configuration initializers, or domain constants. Implementation🛠 Setting Up the project Companion Blocks and Extensions are arriving as experimental features in Kotlin 2.5.0-Beta1 To try this out today, we