Description
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.