Skip to content

Correctly importing Optional::get() as -> T causes MethodNotFound #439

@ktoso

Description

@ktoso

We are now able to handle generics more properly in wrap-java and now we import Optional as:

@JavaClass("java.util.Optional")
open class JavaOptional<T: AnyJavaObject>: JavaObject {
  @JavaMethod
  open func get() -> T!

which then crashes

SwiftJava/JavaOptional.swift:2: Fatal error: 'try!' expression unexpectedly raised an error: java.lang.NoSuchMethodError: Ljava/util/Optional;.get()Ljava/lang/String;

so the String bit is coming unexpectedly because Swift sees the reified generic type as "String" and not "some T" therefore the downcall is forming an incorrect signature.

The problem is somewhere in the dynamicJavaMethodCall infra which can't handle the generic properly when forming the downcall signature

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions