Skip to content

core: fix java.nio.ByteBuffer Java 9+ incompatible usage - #6839

Merged
dapengzhang0 merged 1 commit into
grpc:masterfrom
dapengzhang0:fix-nio-buffer
Mar 18, 2020
Merged

dapengzhang0 merged 1 commit into
grpc:masterfrom
dapengzhang0:fix-nio-buffer

Conversation

@dapengzhang0

Copy link
Copy Markdown
Contributor

No description provided.

@dapengzhang0 dapengzhang0 changed the title core: fix NioBuffer Java 9+ incompatible usage Mar 18, 2020
@voidzcy

voidzcy commented Mar 18, 2020 •

Copy link
Copy Markdown
Contributor

We shouldn't need this, as we have sourceCompatibility = 1.7 in main build.gradle.

See my latest comment in #6829 (comment).

@dapengzhang0

Copy link
Copy Markdown
Contributor Author

This is for third party users who build grpc source with Java 9+, and publish to maven local, even with sourceCompatibility = 1.7 and targetCompatibility = 1.7 unchanged. Their android app or java 8 app with grpc library in local maven repo would fail.

@voidzcy

voidzcy commented Mar 18, 2020

Copy link
Copy Markdown
Contributor

This is for third party users who build grpc source with Java 9+, and publish to maven local, even with sourceCompatibility = 1.7 and targetCompatibility = 1.7 unchanged. Their android app or java 8 app with grpc library in local maven repo would fail.

Would they fail? I don't think so as long as gRPC has sourceCompatibility = 1.7. I remember I tried this before and it worked without any issue.

@dapengzhang0

Copy link
Copy Markdown
Contributor Author

Would they fail? I don't think so as long as gRPC has sourceCompatibility = 1.7. I remember I tried this before and it worked without any issue.

If you publish maven local of grpc master with java 11, and then build examples/android, you will fail. If you suppress the failure by dontwarn, you might fail in the runtime.

@voidzcy

voidzcy commented Mar 18, 2020

Copy link
Copy Markdown
Contributor

After looking around for a while, this seems to be more than source/target compatibility issue. The generated bytecode with JDK 9+ for method ByteBuffer#limit(int) would be treated as an overloaded method instead of an overridden method. So it cannot be found in JDK8's ByteBuffer.

@dapengzhang0

Copy link
Copy Markdown
Contributor Author

After looking around for a while, this seems to be more than source/target compatibility issue. The generated bytecode with JDK 9+ for method ByteBuffer#limit(int) would be treated as an overloaded method instead of an overridden method. So it cannot be found in JDK8's ByteBuffer.

Yes, the same source can be compiled and run in all jdk's, but in different binaries, and the jdk9+ binary is not backward compatible.

@dapengzhang0
dapengzhang0 merged commit e739eea into grpc:master Mar 18, 2020
@dapengzhang0
dapengzhang0 deleted the fix-nio-buffer branch March 18, 2020 23:07
@lock lock Bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants