Skip to content

feat: @Jvm* annotations for Java interoperability (KOJAK-65)#24

Open
endrju19 wants to merge 1 commit intomainfrom
feat/jvm-annotations
Open

feat: @Jvm* annotations for Java interoperability (KOJAK-65)#24
endrju19 wants to merge 1 commit intomainfrom
feat/jvm-annotations

Conversation

@endrju19
Copy link
Copy Markdown
Collaborator

@endrju19 endrju19 commented Apr 14, 2026

Summary

  • Add @JvmName to fix value class name mangling on publish() and getOutboxId() — without these, the methods are uncallable from Java (Kotlin inserts a dash in the method name)
  • Add @JvmOverloads on 7 constructors/methods to generate overloads with Kotlin default parameters visible from Java
  • Add @JvmStatic on 4 companion object methods so Java callers don't need .Companion.

15 annotations across 11 files, 4 modules (core, http, kafka, spring-boot). No logic changes.

Validated with a standalone Java 21 project (okapi-java-interop-example) that exercises all Okapi layers from pure Java — before and after annotations.

Test plan

  • ./gradlew test — all unit and integration tests pass
  • ./gradlew ktlintFormat — formatting clean
  • Bytecode verified with javappublish(), getOutboxId(), createPending() all have correct (non-mangled) names
  • Standalone Java 21 project compiles and runs against updated mavenLocal artifacts
  • CI green

Add @JvmName, @jvmoverloads, and @JvmStatic annotations across core,
HTTP, Kafka, and Spring Boot modules so Java consumers get a clean API.

@JvmName — fix value class name mangling:
- OutboxPublisher.publish(), TransactionalOutboxPublisher.publish(),
  SpringOutboxPublisher.publish() (OutboxId return type)
- OutboxEntry.getOutboxId() (OutboxId property)

@jvmoverloads — generate constructor/method overloads:
- OutboxPublisher(OutboxStore), OutboxScheduler(OutboxProcessor),
  OutboxPurger(OutboxStore), HttpMessageDeliverer(ServiceUrlResolver),
  HttpDeliveryInfo, KafkaDeliveryInfo, OutboxProcessor.processNext()

@JvmStatic — expose companion methods as static:
- OutboxEntry.createPending(), OutboxStatus.from(),
  HttpDeliveryInfo.deserialize(), KafkaDeliveryInfo.deserialize()
@endrju19
Copy link
Copy Markdown
Collaborator Author

endrju19 commented Apr 14, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Review scope: 7 parallel agents reviewed the PR from different angles:

  1. CLAUDE.md compliance -- aligned with Strategic Direction (Kotlin-first, Java as by-product)
  2. Shallow bug scan -- no real bugs; @JvmOverloads/@JvmName/@JvmStatic all correctly placed
  3. Git history context -- no conflicts with recent refactoring (KOJAK-61, KOJAK-62, KOJAK-63)
  4. Previous PR comments -- no unresolved comments from prior PRs apply
  5. Code comments compliance -- no KDoc/comment conflicts
  6. Java consumer API perspective -- all critical API paths (publish, createPending, from, deserialize) now callable from Java; DeliveryResult sealed switch works with Java 21 pattern matching
  7. Kotlin-Java bytecode analysis -- confirmed @JvmName correctly suppresses value class mangling, @JvmOverloads generates non-clashing overloads, @JvmStatic does not leak internal methods

Known limitation (accepted): @JvmOverloads on HttpDeliveryInfo/KafkaDeliveryInfo cannot drop the type parameter (first param with default -- @JvmOverloads only drops trailing defaults). Documented in KOJAK-65 as "partial fix".

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

Successfully merging this pull request may close these issues.

1 participant