Skip to content

Make the "environment" parameter to @JavaMethod initializers optionally-typed and default to nil #70

Closed
@DougGregor

Description

@DougGregor

Right now, an initializer of an @JavaClass type requires an environment parameter, e.g.,

@JavaClass("org.swift.javakit.examples.MyClass")
struct MyClass {
  @JavaMethod
  init(environment: JNIEnvironment)
}

We could allow this to be:

@JavaClass("org.swift.javakit.examples.MyClass")
struct MyClass {
  @JavaMethod
  init(environment: JNIEnvironment? = nil)
}

And, if nil is passed, use JavaVirtualMachine.shared().environment() (introduced in #69) as the default value. This requires some work on the @JavaMethod macro implementation, and collapsing JavaKitVM down into JavaKit, but should otherwise be straightforward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions