Skip to content
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

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

Open
DougGregor opened this issue Sep 30, 2024 · 0 comments
Labels

Comments

@DougGregor
Copy link
Member

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.

@DougGregor DougGregor added the good first issue Good for newcomers label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants