Skip to content

[GR-71149][Native Image]Provide a mechanism to allow some indy and condy to initialize at build time #12453

@dmlloyd

Description

@dmlloyd

Feature request

Since #7834, bootstraps for indy and condy have been moved from build time to run time by default, with the exception of certain known JDK bootstraps (like those for lambdas, presumably).

However, this poses a problem to frameworks and runtimes (such as Quarkus) which may use indy and condy in compiled, generated, or transformed code. This may be done for many reasons, including reducing startup time without impacting throughput in most JVMs. One such example can be found in quarkusio/gizmo#459.

Another use case is using indy to (in JVM mode) dynamically link native call stubs, which simplifies usage of the FFM API (see https://github.com/dmlloyd/ffm-autolinker for an example). In this case, generating these stubs at build time makes perfect sense.

Describe the solution you'd like.

Ideally we would be able to provide a Feature of some sort which allows us to evaluate each bootstrap (and call site, ideally) to determine whether it should be build time, run time, or to leave it up to the compiler to decide.

Describe who do you think will benefit the most.

Since indy/condy is a core JVM feature, many advanced frameworks and compilers take advantage of it. So the benefit would be to the users in the end, but also to the developers of these frameworks who want to continue to use these features in a way that can work cohesively with native images.

Describe alternatives you've considered.

We discussed trying to access JVMCI directly to force the constant pool entries to initialize, but it is not clear whether JVMCI will exist in the long term, and it's not clear how we can do this from Quarkus.

It was also suggested to somehow manually trigger the bootstraps during build programmatically. While this could be possible for condy by generating a private static method in each class which uses ldc to load each constant and pop/pop2 to discard them in turn, and calling this method at boot time, this is not possible to do in a safe way (to my knowledge) for indy.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions