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
Cast to Buffer #6331
Cast to Buffer #6331
Conversation
Thank you! This doesn't only affect Android; if libGDX were compiled on any machine using Java 9 or higher, that set of JARs would have been incompatible with Java 8, without this PR. There's ways to compile with JDK 9 or higher and target JDK 8, but they can only be used if you're compiling with JDK 9 or higher, not with JDK 8, so the build files get more complex. I like this solution, and I hope it works on GWT -- buffers already were a problem there in places like |
I executed some of the gwt tests with buffer in the name and didn't find any problems. |
I think that's great to have in regards to compatibility. +1 to have this merged. |
+1. I think the alternative of adding the |
Another option I'm liking more, is to use Gradle 6.7's |
@PokeMMO Does it work in combination with android? Because from the link it looks like a java plugin feature which can't be applied to android projects |
99.9% sure it does, I tested by setting it to an unavailable JDK and it complained. Seems like the following format works
|
Just tested it and it seem to work. |
It also includes auto-provisioning (via adoptopenjdk) a JDK if necessary, which makes setup easier if we do end up utilizing multiple JDKs. Auto download can be turned off via gradle property, for paranoid folks like myself. |
I'm in favor of changing the source to use |
+1 to what @tommyettinger said. There is no reason we can't have both. For users of libGDX, there are no negatives as the casts are hidden for them. Although I am using This still says it's a "Draft". Looks sort of finished? I'd say, we merge if this is complete? Then someone would probably have to add the |
I'm in favor of both, we can merge this now and still use toolchains via gradle later if we decide to go that route. |
It's only a draft because @mgsx-dev said that there is stuff to discuss |
I'm not against merging it in the meantime (while we add Just for reference, this is the full list of affected methods signatures:
And a nice blog post that covers the issue https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/ |
Indeed, this change (weird cast) is very fragile, as obigu said we could miss some cast or remove some accidentally in the future. Also, user code can use Buffer (they are not hidden) and should not forget to cast them in their own code as well for some obscure reasons. In the worse case scenario (if it can't be fixed by some build options), maybe we should totally abstract Buffer. If i'm not wrong, for now the workaround is to build with Java 8. I think it's fine to keep it like this until we find a better solution. |
Yes, let's keep it until we find a better solution. |
If you compile you android app with a jdk greater than 8 and try to run it on an android device with API level lower than 29 (from my experience) the app crashes. The methods position, limit, flip and clear from buffer subtypes are the problem.
Detailed description is here:
https://stackoverflow.com/a/58435689/7912520
I just applied the suggested fix.
@PokeMMO found an issue on the google issue tracker, but they seem no to care. https://issuetracker.google.com/issues/123015428