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

[native-image] Incompatible change of initialization policy: trying to change RERUN #1462

Closed
aclement opened this issue Jul 3, 2019 · 7 comments
Assignees

Comments

@aclement
Copy link

aclement commented Jul 3, 2019

MacbookPro: Graal 19.1.0

I'm upgrading my spring boot feature with Graal 19.1 support. But something has changed and I don't understand the latest message mentioning RERUN.

I'm just doing a very basic app which works with my feature and 19.0.x:

With existing feature (with minor changes to upgrade to latest APIs which have moved package):


Error: Class initialization of sun.reflect.misc.Trampoline failed. Use the option 
--initialize-at-run-time=sun.reflect.misc.Trampoline to explicitly request delayed 
initialization of this class.

With the existing feature, Trampoline was explicitly in the buildTimeInitialization list.
So I removed Trampoline from the explicit list.

Error: No instances are allowed in the image heap for a class that is initialized or 
reinitialized at image runtime: com.sun.jmx.mbeanserver.MXBeanLookup. Try marking this class for build-time
initialization with --initialize-at-build-time=com.sun.jmx.mbeanserver.MXBeanLookup

Added MXBeanLookup to build time initialization list:



Error: Incompatible change of initialization policy for com.sun.jmx.mbeanserver.MXBeanLookup: 
trying to change RERUN ensure com.sun.jmx.mbeanserver.MXBeanLookup#mbscToLookup
clean state to BUILD_TIME from feature org.springframework.boot.graal.support.InitializationHandler.register


Any advice?

@vjovanov
Copy link
Member

vjovanov commented Jul 3, 2019

Could you send me the full reproducer? That would make it easier for me to fix the issue.

@aclement
Copy link
Author

aclement commented Jul 3, 2019

Hey, thanks for taking a look. Ok, this should do it (unless you are on windows...):

git clone [email protected]:aclement/spring-boot-graal-feature.git 
cd spring-boot-graal-feature
git checkout graal_19_1_0
mvn clean package
cd samples/commandlinerunner
./compile.sh

Some of the config is statically defined and passed in to the image builder, other stuff is computed (by chasing down spring configuration). If you want to tweak the static stuff, see the files in src/main/resources (and rebuild the feature afterwards).

It could well be something I'm doing wrong but I don't quite understand the message to know what to change.

@vjovanov
Copy link
Member

vjovanov commented Jul 4, 2019

The problem here is not in class initialization mechanism itself. It actually exactly says what is the problem: Our JDK support marks com.sun.jmx.mbeanserver.MXBeanLookup as RERUN and you try to make it BUILD_TIME.

I think the problem here is that RERUN should not be used for com.sun.jmx.mbeanserver.MXBeanLookup. I think we should recompute field values here if we want to clean state and we should initialize this class at build-time.

Do you have an idea of how com.sun.jmx.mbeanserver.MXBeanLookup ends up in the image heap?

@aclement
Copy link
Author

aclement commented Jul 4, 2019

If I remove it (from build time init) I get this:


Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: com.sun.jmx.mbeanserver.MXBeanLookup. Try marking this class for build-time initialization with --initialize-at-build-time=com.sun.jmx.mbeanserver.MXBeanLookup
Detailed message:
Trace:  object com.sun.jmx.mbeanserver.MXBeanSupport
        object javax.management.StandardMBean
        object com.sun.jmx.mbeanserver.NamedObject
        object java.util.HashMap$Node
        object java.util.HashMap$Node[]
        object java.util.HashMap
        object java.util.HashMap$Node
        object java.util.HashMap$Node
        object java.util.HashMap$Node[]
        object java.util.HashMap
        object com.sun.jmx.mbeanserver.Repository
        object com.sun.jmx.interceptor.DefaultMBeanServerInterceptor
        object com.sun.jmx.mbeanserver.JmxMBeanServer
        object java.lang.Object[]
        object java.util.ArrayList
        method javax.management.MBeanServerFactory.removeMBeanServer(MBeanServer)
Call path from entry point to javax.management.MBeanServerFactory.removeMBeanServer(MBeanServer): 
        at javax.management.MBeanServerFactory.removeMBeanServer(MBeanServerFactory.java:422)
        at javax.management.MBeanServerFactory.releaseMBeanServer(MBeanServerFactory.java:154)
        at org.springframework.jmx.support.MBeanServerFactoryBean.destroy(MBeanServerFactoryBean.java:210)
        at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:256)
        at org.springframework.beans.factory.support.DisposableBeanAdapter.run(DisposableBeanAdapter.java:233)
        at com.oracle.svm.core.jdk.RuntimeSupport.executeHooks(RuntimeSupport.java:144)
        at com.oracle.svm.core.jdk.RuntimeSupport.executeStartupHooks(RuntimeSupport.java:89)
        at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:139)
        at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

        at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:130)
        at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:565)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:683)

which I guess indicates it comes in due to org.springframework.jmx.support.MBeanServerFactoryBean.destroy(MBeanServerFactoryBean.java:210)

@vjovanov
Copy link
Member

vjovanov commented Jul 4, 2019

@olpaw it seems that we can't use rerun for com.sun.jmx.mbeanserver.MXBeanLookup

@aclement
Copy link
Author

aclement commented Jul 4, 2019

I used some substitutes to temporarily get around the code bringing it in (as I don't actually need it for this app). Nice work on the compile times!

19.0.2:  [total]:  98,917.96 ms
19.1.0:  [total]:  75,521.97 ms

@olpaw
Copy link
Member

olpaw commented Jul 8, 2019

Fixed on master: 5b48670

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

4 participants