hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
855 stars 158 forks source link

added graalvm native image reflect config for a seamless experience #578

Open cmdjulian opened 1 year ago

cmdjulian commented 1 year ago

Description

This changes adds the required graalvm reflection config for the two missing fields. This config is picked up by graalvm during native compilation and registers the two fields for reflective access on the compiled native image java app. See here for more details.

Related Issue

https://github.com/hivemq/hivemq-mqtt-client/issues/448

Type of Change

Checklist

cla-bot[bot] commented 1 year ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @cmdjulian on file. In order for us to review and merge your code, please sign our Contributor License Agreement to get yourself added. You'll find the CLA and more information here: https://github.com/hivemq/hivemq-community/blob/master/CONTRIBUTING.adoc#contributor-license-agreement

cmdjulian commented 1 year ago

@cla-bot check

cla-bot[bot] commented 1 year ago

The cla-bot has been summoned, and re-checked this pull request!

SgtSilvio commented 1 year ago

Thank you for your contribution @cmdjulian! In general, it would be best if JCTools would ship with the right native image configuration. As JCTools is only a dependency, the user of the hivemq-mqtt-client can update the JCTools version transitively which might need a change in the native image configuration as well. But I agree that we can at least make the user experience better. I am unsure if reflective access is the right thing here. We have the hivemq-mqtt-client running in a native image as part of the mqtt-cli, where we --initialize-at-build-time the JCTools classes, see https://github.com/hivemq/mqtt-cli/blob/master/build.gradle.kts#L416. Maybe we can just include these settings instead of the reflection config?

cmdjulian commented 1 year ago

Yeah you right. Thanks for pointing this out.
I had a look at JCTools, and is seems like they use a lot of reflection and Unsafe. I was thinking about contributing a PR over there as well, maybe I find some time in the future to do so.