Skip to content

Restructure Kotlin APIs to Share Common Code in core/#2726

Open
rbebb wants to merge 1 commit into
google-ai-edge:mainfrom
rbebb:2628-create-core-package
Open

Restructure Kotlin APIs to Share Common Code in core/#2726
rbebb wants to merge 1 commit into
google-ai-edge:mainfrom
rbebb:2628-create-core-package

Conversation

@rbebb

@rbebb rbebb commented Jul 5, 2026

Copy link
Copy Markdown

Summary

The goal of this is to prep the Kotlin APIs for eventual Kotlin Multiplatform support. For now, that just means that common code is shared in core/.

Also, the Kotlin rules for Bazel don’t support Kotlin Multiplatform yet (see this GitHub Issue for updates) so that's why I didn't use Kotlin Multiplatform's expect/actual syntax. Once the Kotlin rules for Bazel do add support, the code can be simplified a bit.

Changes

  • Created /core package that can be built separately
  • Changed /kotlin/java/ directory to /kotlin/kotlin/
  • Made NativeLibraryLoader and Engine abstract classes with platform specific implementations
  • Marked platform specific Engine implementations as internal but kept the API to create and use an Engine the same
  • Changed LiteRtLmJniException to LiteRtLmNativeException to better reflect the intent for eventual multiplatform support
  • Replaced some JVM APIs with Kotlin APIs

Questions/Comments

  • This is my first PR for LiteRT-LM
    • Is there anything about PR and commit formatting that should be changed?
  • I'm open to any and all feedback on the implementation!

@google-cla

google-cla Bot commented Jul 5, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

- The goal is to prep the Kotlin APIs for Kotlin Multiplatform use
- Platform specific Engine implementations are marked as internal, but
  the API to create and use an Engine is still the same
- LiteRtLmJniException changed to LiteRtLmNativeException to better
  reflect the intent for eventual multiplatform support
@rbebb rbebb force-pushed the 2628-create-core-package branch from d07a1c8 to 39ad456 Compare July 5, 2026 21:36
}
```

#### Multiplatform

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume a -core package won't be published just yet, so this multiplatform section might not be necessary for now.

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