java-kotlin-interop

Guide Java and Kotlin interoperability with JSpecify null safety and JVM annotations.

1|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/iceflower/opencode-agents-and-skills --skill java-kotlin-interop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-kotlin-interop
Source: https://github.com/iceflower/opencode-agents-and-skills/tree/main/skills/java-kotlin-interop
Command: npx skills add https://github.com/iceflower/opencode-agents-and-skills --skill java-kotlin-interop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill bridges the gap between Java and Kotlin, enabling smooth interoperability in mixed-language projects by addressing common challenges like null safety, type conversions, and API access.

Core Features & Use Cases

  • Null Safety: Ensures type safety across Java/Kotlin boundaries using JSpecify annotations.
  • API Compatibility: Generates Java-friendly APIs from Kotlin code (static methods, default parameters, checked exceptions).
  • Collection Handling: Manages differences between mutable and immutable collections.
  • Use Case: Integrate a new Kotlin microservice with an existing Java monolith by ensuring all shared data models and service calls are correctly typed and accessible from both languages.

Quick Start

Use the java-kotlin-interop skill to understand how to call a Kotlin function with default parameters from Java.

Frequently Asked Questions about java-kotlin-interop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle null safety when calling Kotlin code from Java?

Null safety across Java and Kotlin boundaries is managed using JSpecify annotations. This ensures type safety and correct null handling when integrating Kotlin functions into existing Java codebases.

What is the best way to call a Kotlin function with default parameters from Java?

Calling Kotlin functions with default parameters from Java requires specific JVM annotations for API bridging. This generates Java-friendly APIs, allowing seamless access to default values and static methods.

How do I integrate Kotlin coroutines with an existing Java application?

Kotlin coroutine and Java integration is achieved by applying specific bridging patterns. This ensures asynchronous operations correctly map across language boundaries without blocking the JVM application.

Does Spring Framework work well with mixed Java and Kotlin projects?

Spring Framework supports mixed Java and Kotlin projects using specific patterns for API compatibility. It handles JVM annotations and collection differences, ensuring smooth interoperability within your Spring application.

Why do my Java collections throw mutation errors when accessed from Kotlin?

Java collection handling errors in Kotlin occur due to differences between mutable and immutable collections. Proper API bridging and type conversion strategies are required to manage these platform types safely.

Can I use SAM conversion to simplify Java interoperability in Kotlin?

SAM conversion simplifies Java interoperability in Kotlin by allowing single-method interfaces to be instantiated directly. This reduces boilerplate when passing behavior between mixed Java and Kotlin codebases.