Skip to content

Minor cleanups to the JavaKit module and samples #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 25, 2024

Conversation

DougGregor
Copy link
Member

Perform a few minor cleanups and expansions to the JavaKit module:

  • Rename JavaClass.init(in:) to JavaClass.init(environment:) and make the parameter optional, to match other similar APIs
  • Autogenerate the java.lang.Class binding rather than hand-rolling it
  • Import the various java.lang.* class wrappers for primitive types (like Integer and Double)
  • Clean up / fix up the JavaKit samples

Every other API uses the argument label "environment" for the JNI
environment, so be consistent. Additionally, make it an optional
parameter and query the running JVM to get the environment if we don't
already have one.
@DougGregor DougGregor merged commit c5a3d4d into swiftlang:main Oct 25, 2024
11 checks passed
@DougGregor DougGregor deleted the javakit-class-cleanup branch October 25, 2024 06:08

let jvm = try JavaVirtualMachine.shared(classPath: ["QuadraticSieve-1.0.jar"])
do {
let sieveClass = try JavaClass<SieveOfEratosthenes>(in: jvm.environment())
let sieveClass = try JavaClass<SieveOfEratosthenes>(environment: jvm.environment())
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, abusing the in: as label is always a tad too much in Swift libs 😆

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.

2 participants