-
Notifications
You must be signed in to change notification settings - Fork 68
Add Fields to Java2Swift Tool #55
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
Conversation
DougGregor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. The only real missing piece is how we test it... the testing of the Java2Swift path is not great right now, since we basically rely on regenerating its own sources (and not breaking) as "proof" that it didn't break. And unfortunately, none of the classes from the JDK that we build wrappers for include any public fields, so we don't see the effect of this change anywhere in the diff.
ktoso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though we won't have CI test this change tbh. Building Java2Swift (make) fails right now afair, but it's a nice step.
|
I just had a wild/silly idea for unit testing this. What if we hook into https://docs.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html in the unit tests so we can compile some Java code expressed as a string literal in Swift, then send that through Java2Swift and "diff" the expected output? If we wire it up correctly, it should make unit-testing changes to Java2Swift straightforward. |
|
Sure, why not I guess, anything that gets us some test coverage tbh :) |
Closes #22
This PR adds support for exporting java fields into swift. The way I was able to test this was applying the following diff and then running the following commands (I can also add automated tests for this, but wasn't sure what the plan for automated tests for this tool are):
And running the following commands from the base folder of the repo:
This prints out the following swift code (notice the 2
@JavaFieldannotations and not the static field, yet)