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

* desugar: added compiler plugin that extends ByteBuffer with Java9 API #615

Merged
merged 4 commits into from Jan 23, 2022

Conversation

dkimitsa
Copy link
Contributor

@dkimitsa dkimitsa commented Jan 3, 2022

Overview

Java9 adds overridden methods with covariant return types in ByteBuffer:

  • flip
  • clear
  • mark
  • reset
  • rewind
  • position
  • limit
    It becomes problem when using external dependency that was compiled as -release 9 and caused exceptions:

java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer
The only options is to re-compile the dependency. But it is not always possible.

Discussion

This might be achieved by just adapting runtime classes but having it as Plugin allows to enable or disable the behaviour.

Other changes

Desugar plugins were extended with option to disable using plugin arguments:

<pluginArguments>
    <argument>desugar:enableJdk9ByteBufferApi=false</argument>
    <argument>desugar:enableJava9StringConcat=false</argument>
</pluginArguments>

## Overview
Java9 adds overridden methods with covariant return types in ByteBuffer:
- flip
- clear
- mark
- reset
- rewind
- position
- limit
It becomes problem when using external dependency that was compiled as `-release 9` and caused exceptions:
> java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer
The only options is to re-compile the dependency. But it is not always possible.

## Discussion
This might be achieved by just adapting runtime classes but having it as Plugin allows to enable or disable the behaviour.

## Other changes
Desugar plugins were extended with option to disable using plugin arguments:
```
<pluginArguments>
    <argument>desugar:enableJdk9ByteBufferApi=false</argument>
    <argument>desugar:enableJava9StringConcat=false</argument>
</pluginArguments>
```
# Conflicts:
#	compiler/compiler/src/main/java/org/robovm/compiler/config/Config.java
… new methods were added. Otherwise it will produce NPE while trying to pick entries for these new added methods
@Tom-Ski Tom-Ski merged commit c50fbd5 into MobiVM:master Jan 23, 2022
@Tom-Ski
Copy link
Member

Tom-Ski commented Jan 23, 2022

Nice!

@dkimitsa dkimitsa deleted the desugaring/bytebuffer branch February 1, 2022 10:37
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.

None yet

2 participants