Skip to content
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

1.0.0-rc14 native image build error: No instances are allowed in the image heap #1125

Closed
ahmadmo opened this issue Mar 31, 2019 · 3 comments
Closed
Assignees

Comments

@ahmadmo
Copy link

ahmadmo commented Mar 31, 2019

I'm using Quartz in my project. building a native image results in:

[error] Error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: sun.security.provider.NativePRNG
[error] Detailed message:
[error] Error: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: sun.security.provider.NativePRNG
[error] Trace:  object java.security.SecureRandom
[error]         method java.rmi.server.ObjID.<init>()
[error] Call path from entry point to java.rmi.server.ObjID.<init>(): 
[error]         at java.rmi.server.ObjID.<init>(ObjID.java:111)
[error]         at sun.rmi.transport.LiveRef.<init>(LiveRef.java:74)
[error]         at sun.rmi.server.UnicastServerRef.<init>(UnicastServerRef.java:167)
[error]         at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:320)
[error]         at org.quartz.core.QuartzScheduler.bind(QuartzScheduler.java:372)
[error]         at org.quartz.core.QuartzScheduler.initialize(QuartzScheduler.java:235)
[error]         at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1360)
[error]         at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1559)
[error]         at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1575)
@cstancu
Copy link
Member

cstancu commented Apr 1, 2019

The initialization of NativePRNG is rerun at run time. This article should help understanding class initialization on native-image.

@cstancu cstancu self-assigned this Apr 1, 2019
@matneu
Copy link
Member

matneu commented Jul 10, 2019

RMI's ObjID is the issue here, as it has a static field that's initialized with SecureRandom.
For RMI, delaying initialization for the following classes should get you further:
--initialize-at-run-time=java.rmi.server.ObjID,sun.rmi.transport.ObjectTable,sun.rmi.transport.Transport,sun.rmi.transport.tcp.TCPEndpoint,sun.rmi.registry.RegistryImpl,sun.rmi.transport.DGCImpl,sun.rmi.transport.DGCClient

@cstancu
Copy link
Member

cstancu commented Dec 23, 2019

@matneu thanks! @ahmadmo RMI won't work in general because object serialization is not supporoted. See #1935.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants