Skip to content

Extend Swift wrappers of Java classes in modules that have made more methods/fields available #18

Open
@DougGregor

Description

@DougGregor

The JavaClass type, which is the Swift wrapper for Java's java.lang.Class, is provided in the Swift JavaKit module. Many of the methods on java.lang.Class require classes from java.lang.reflect that are part of the Swift JavaKitReflection module. For example, getDeclaredMethods() requires java.lang.reflect.Method that is only available in JavaKitReflection.

Java2Swift drops any methods/constructors that involve Java classes that have not been wrapped in Swift, so JavaKit is missing any of those methods. Instead, JavaKitReflection has a handcrafted extension of JavaClass that adds all of the methods from java.lang.Class that involve at least one type from the Java classes that are wrapped into Swift within JavaKitReflection.

We should teach Java2Swift to recognize those cases where a Java class has already been wrapped in Swift (e.g., by using the translation manifest) and produce an extension of the Swift wrapper type that includes only those methods/constructors/etc. that involve at least one Java class that's being wrapped in the module being generated. The manually-written JavaKitReflection/JavaClass+Refection.swift file referenced above could therefore be replaced with a generated one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions