hrldcpr / pcollections

A Persistent Java Collections Library
Other
765 stars 79 forks source link

Add native-image.properties #80

Closed jkremser closed 4 years ago

jkremser commented 4 years ago

GraalVM's native-image tool can create executable self-contained applications out of jar files by doing a lot of magic, like evaluating static initializers during the compilation, making a snapshot of the memory heap, etc. However sometimes some classes' initialization need to be deferred to run-time to pass the build. This PR adds the property file that is read by the native-image tool during the compilation and the argumets are appended to the build tool. It's harmless for the jar itself and will be ignored by all the other tools.

hrldcpr commented 4 years ago

Can you explain a bit more about why this is necessary? What part of the static initialization is causing issues? Or is this only an issue in Micrometer or Mongonaut because of the way they are using PCollections?

It would be nice if native-image could figure this out automatically, since you won't always be able to modify upstream projects. I'd rather avoid putting a seemingly random config file in this project, but if it's the only way to help downstream projects then I'm open to it.

jkremser commented 4 years ago

I think, it isn't only Micrometer's or Mongonaut's issue, but potentially arbitrary downstream project that wants to be compilable to a native image will benefit from this change. I agree, it's not ideal and these configs can be also provided by the downstream project that actually cares about the native image, however this way it will have a bigger impact. Hopefully we will figure out something better in the future.

Perhaps an additional dummy (no code) artifact that will only have the config file under the META-INF could also work.

hrldcpr commented 4 years ago

Cool, thanks for the explanation. This is fine for now and I'll go ahead and merge it in and make a new release

hrldcpr commented 4 years ago

This is now live in PCollections v3.1.2