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

Add support for Java 9 String concatenation #558

Merged
merged 2 commits into from
Oct 19, 2021

Conversation

CoderBaron
Copy link
Contributor

@CoderBaron CoderBaron commented Feb 6, 2021

This PR adds support for Java 9 String concatenation by rewriting its invokedynamic instructions to StringBuilder appends.

This makes it possible to compile your Java 9+ code with RoboVM. New language features like private/static/default interface methods [Java 9], local-variable type inference (the var keyword) [Java 10], switch expressions [Java 14] or text blocks [Java 15] will work now.

Caution when using Java 11+: Nested classes are handled differently from now on. Previously you have been able to access private methods/fields of nested classes in the outer class and vice versa, however this will now result in an IllegalAccessError.

@colorizenl
Copy link

@CoderBaron Thanks for this, should be extremely useful. Until now it was possible to use RoboVM for JAR files compiled with Java 9-11, but it requires the following Gradle option:

compileJava {
    options.compilerArgs << "-XDstringConcat=inline"
}

Obviously, this only works for your own code. Any libraries compiled with Java 9+ would become unusable, which should be fixed by this. Obviously, the libraries would still not work if they use new APIs, so in parallel to this I'm also eagerly following #527.

@dkimitsa
Copy link
Contributor

@CoderBaron
thanks looks good, could you please share more information about "java 11+ Nested classes are handled differently" like JEP.
Thx !

@CoderBaron
Copy link
Contributor Author

In JEP 181 they added support for accessing private nested members directly, dropping the need to create access bridge methods. Of course with a runtime below version 11, Java fails to find these methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants