[graalvm-users] [External] : java.lang.Thread.sleep() supported in GraalVM?

Gilles DUBOSCQ gilles.m.duboscq at oracle.com
Tue Oct 17 09:28:08 UTC 2023


Hi Erix,
If you have already removed all usages of --initialize-at-build-time / --initialize-at-runtime and used the native-image-agent, you can indeed try to isolate the issue like you mentioned.
In general though, if you get "Classes that should be initialized at run time got initialized during image building" you have to use the recommended --trace-class-initialization= flag and try to understand what is causing the unexpected initialization.

You can also use native-image --verbose to see the fully expanded native-image option to see if there's anything providing unexpected initialization directives (-H:ClassInitialization=...).

 Gilles
________________________________
From: Eric Samson <erix.samson at gmail.com>
Sent: Tuesday, 17 October 2023 11:17
To: Gilles DUBOSCQ <gilles.m.duboscq at oracle.com>
Cc: graalvm-users at oss.oracle.com <graalvm-users at oss.oracle.com>
Subject: Re: [graalvm-users] [External] : java.lang.Thread.sleep() supported in GraalVM?

... (completing previous sentence) that's why I'm trying GraalVM now (to have better start time and real .exe).

I also wanted to add this app is super simple: 1 class, 1 main method, 1 JPanel, 1 JLabel, that's it.
I'm not using any fancy Groovy dynamic trick, nor Groovy Swing Builder, this is just good old Swing in Groovy.

:: best regards, Erix

Le mar. 17 oct. 2023 à 11:13, Eric Samson <erix.samson at gmail.com<mailto:erix.samson at gmail.com>> a écrit :
I don't know if it can help, but I was able to package my Groovy Swing app with JPackage. The only difficulty was to identify which Groovy jars were needed.
Then creating the installer worked fine and I can run the installed exe.

But if I understand well, this is not "real" native compilation, and launch time still is too big for what I need. That's
________________________________
De : Eric Samson <erix.samson at gmail.com<mailto:erix.samson at gmail.com>>
Envoyé : mardi 17 octobre 2023 10:10
À : Gilles DUBOSCQ <gilles.m.duboscq at oracle.com<mailto:gilles.m.duboscq at oracle.com>>; Eric Samson <erix.samson at gmail.com<mailto:erix.samson at gmail.com>>
Cc : graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com> <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Objet : Re: [graalvm-users] [External] : java.lang.Thread.sleep() supported in GraalVM?

Hi Gilles and Christian,

I'm a bit lost now.
I'm going to try 2 things:

  *   Migrate my simple Groovy Swing app to pure Java and see if it works.
  *   Create a very simple Groovy app with no Swing and see if it works.

Do you have other ideas to test?

Best regards, Erix.
________________________________
De : Eric Samson via GraalVM-Users <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Envoyé : lundi 16 octobre 2023 20:33
À : Gilles DUBOSCQ <gilles.m.duboscq at oracle.com<mailto:gilles.m.duboscq at oracle.com>>
Cc : graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com> <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Objet : Re: [graalvm-users] [External] : java.lang.Thread.sleep() supported in GraalVM?

I have tried both your suggestions and now the error messages get much more complicated:

Error: Classes that should be initialized at run time got initialized during image building:
 org.codehaus.groovy.reflection.CachedClass$3 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$3 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$3
org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply
org.codehaus.groovy.runtime.DefaultGroovyMethods was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.DefaultGroovyMethods got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.DefaultGroovyMethods
org.codehaus.groovy.util.ReferenceBundle was unintentionally initialized at build time. To see why org.codehaus.groovy.util.ReferenceBundle got initialized use --trace-class-initialization=org.codehaus.groovy.util.ReferenceBundle
org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod
org.codehaus.groovy.vmplugin.v8.IndyInterface was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v8.IndyInterface got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v8.IndyInterface
org.codehaus.groovy.reflection.stdclasses.IntegerCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.IntegerCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.IntegerCachedClass
org.codehaus.groovy.runtime.GroovyCategorySupport was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.GroovyCategorySupport got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.GroovyCategorySupport
org.codehaus.groovy.reflection.CachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass
org.codehaus.groovy.reflection.stdclasses.CachedClosureClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.CachedClosureClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.CachedClosureClass
org.codehaus.groovy.reflection.stdclasses.NumberCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.NumberCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.NumberCachedClass
org.codehaus.groovy.reflection.stdclasses.BigIntegerCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.BigIntegerCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.BigIntegerCachedClass
org.codehaus.groovy.reflection.ClassInfo$LazyClassLoaderRef was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.ClassInfo$LazyClassLoaderRef got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.ClassInfo$LazyClassLoaderRef
org.codehaus.groovy.reflection.ReflectionUtils was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.ReflectionUtils got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.ReflectionUtils
org.codehaus.groovy.reflection.GroovyClassValueFactory was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.GroovyClassValueFactory got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.GroovyClassValueFactory
org.codehaus.groovy.reflection.CachedClass$6 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$6 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$6
org.codehaus.groovy.vmplugin.v9.Java9 was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v9.Java9 got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v9.Java9
org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod
org.codehaus.groovy.util.LazyReference was unintentionally initialized at build time. To see why org.codehaus.groovy.util.LazyReference got initialized use --trace-class-initialization=org.codehaus.groovy.util.LazyReference
org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod
org.codehaus.groovy.reflection.stdclasses.CharacterCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.CharacterCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.CharacterCachedClass
org.codehaus.groovy.reflection.stdclasses.DoubleCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.DoubleCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.DoubleCachedClass
org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef
org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv
org.codehaus.groovy.util.ReferenceType$2 was unintentionally initialized at build time. To see why org.codehaus.groovy.util.ReferenceType$2 got initialized use --trace-class-initialization=org.codehaus.groovy.util.ReferenceType$2
groovy.lang.MetaClassImpl was unintentionally initialized at build time. To see why groovy.lang.MetaClassImpl got initialized use --trace-class-initialization=groovy.lang.MetaClassImpl
org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod
com.sun.beans.util.Cache$Kind$1 was unintentionally initialized at build time. To see why com.sun.beans.util.Cache$Kind$1 got initialized use --trace-class-initialization=com.sun.beans.util.Cache$Kind$1
org.codehaus.groovy.reflection.stdclasses.ArrayCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.ArrayCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.ArrayCachedClass
org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus
org.codehaus.groovy.reflection.stdclasses.CachedSAMClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.CachedSAMClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.CachedSAMClass
org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus
org.codehaus.groovy.util.ReferenceType$1 was unintentionally initialized at build time. To see why org.codehaus.groovy.util.ReferenceType$1 got initialized use --trace-class-initialization=org.codehaus.groovy.util.ReferenceType$1
org.codehaus.groovy.reflection.CachedClass$4 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$4 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$4
groovy.lang.GroovySystem was unintentionally initialized at build time. To see why groovy.lang.GroovySystem got initialized use --trace-class-initialization=groovy.lang.GroovySystem
org.codehaus.groovy.vmplugin.VMPluginFactory was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.VMPluginFactory got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.VMPluginFactory
org.codehaus.groovy.vmplugin.v8.IndyInterface$CallType was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v8.IndyInterface$CallType got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v8.IndyInterface$CallType
org.codehaus.groovy.reflection.ReflectionCache was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.ReflectionCache got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.ReflectionCache
org.codehaus.groovy.util.ReferenceType$4 was unintentionally initialized at build time. To see why org.codehaus.groovy.util.ReferenceType$4 got initialized use --trace-class-initialization=org.codehaus.groovy.util.ReferenceType$4
org.codehaus.groovy.runtime.m12n.SimpleExtensionModule was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.m12n.SimpleExtensionModule got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.m12n.SimpleExtensionModule
org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule
org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod
org.codehaus.groovy.runtime.MetaClassHelper was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.MetaClassHelper got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.MetaClassHelper
org.codehaus.groovy.util.ReferenceType$3 was unintentionally initialized at build time. To see why org.codehaus.groovy.util.ReferenceType$3 got initialized use --trace-class-initialization=org.codehaus.groovy.util.ReferenceType$3
org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod
com.sun.beans.util.Cache$Kind$3 was unintentionally initialized at build time. To see why com.sun.beans.util.Cache$Kind$3 got initialized use --trace-class-initialization=com.sun.beans.util.Cache$Kind$3
org.codehaus.groovy.reflection.stdclasses.BooleanCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.BooleanCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.BooleanCachedClass
org.codehaus.groovy.reflection.CachedClass$1 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$1 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$1
org.codehaus.groovy.reflection.CachedClass$7 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$7 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$7
org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayPutAtMetaMethod
org.codehaus.groovy.reflection.stdclasses.BigDecimalCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.BigDecimalCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.BigDecimalCachedClass
org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayGetAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayMetaMethod
org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
org.codehaus.groovy.vmplugin.v8.Java8 was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v8.Java8 got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v8.Java8
com.sun.beans.introspect.ClassInfo was unintentionally initialized at build time. To see why com.sun.beans.introspect.ClassInfo got initialized use --trace-class-initialization=com.sun.beans.introspect.ClassInfo
org.codehaus.groovy.vmplugin.v8.CacheableCallSite was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v8.CacheableCallSite got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v8.CacheableCallSite
org.codehaus.groovy.vmplugin.v16.Java16 was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v16.Java16 got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v16.Java16
org.codehaus.groovy.reflection.CachedClass$5 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$5 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$5
org.codehaus.groovy.reflection.stdclasses.StringCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.StringCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.StringCachedClass
java.beans.Introspector was unintentionally initialized at build time. To see why java.beans.Introspector got initialized use --trace-class-initialization=java.beans.Introspector
org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod
com.sun.beans.util.Cache$Kind was unintentionally initialized at build time. To see why com.sun.beans.util.Cache$Kind got initialized use --trace-class-initialization=com.sun.beans.util.Cache$Kind
org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod
org.codehaus.groovy.reflection.CachedClass$2 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$2 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$2
org.codehaus.groovy.util.ReferenceType was unintentionally initialized at build time. To see why org.codehaus.groovy.util.ReferenceType got initialized use --trace-class-initialization=org.codehaus.groovy.util.ReferenceType
org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod
com.sun.beans.util.Cache$Kind$2 was unintentionally initialized at build time. To see why com.sun.beans.util.Cache$Kind$2 got initialized use --trace-class-initialization=com.sun.beans.util.Cache$Kind$2
org.codehaus.groovy.reflection.CachedClass$8 was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.CachedClass$8 got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$8
org.codehaus.groovy.reflection.stdclasses.LongCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.LongCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.LongCachedClass
org.codehaus.groovy.reflection.stdclasses.FloatCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.FloatCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.FloatCachedClass
org.codehaus.groovy.reflection.ClassInfo was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.ClassInfo got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.ClassInfo
org.codehaus.groovy.reflection.stdclasses.ObjectCachedClass was unintentionally initialized at build time. To see why org.codehaus.groovy.reflection.stdclasses.ObjectCachedClass got initialized use --trace-class-initialization=org.codehaus.groovy.reflection.stdclasses.ObjectCachedClass
org.apache.groovy.plugin.GroovyRunnerRegistry was unintentionally initialized at build time. To see why org.apache.groovy.plugin.GroovyRunnerRegistry got initialized use --trace-class-initialization=org.apache.groovy.plugin.GroovyRunnerRegistry
org.codehaus.groovy.vmplugin.v10.Java10 was unintentionally initialized at build time. To see why org.codehaus.groovy.vmplugin.v10.Java10 got initialized use --trace-class-initialization=org.codehaus.groovy.vmplugin.v10.Java10
org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod
org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod was unintentionally initialized at build time. To see why org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod got initialized use --trace-class-initialization=org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod
To see how the classes got initialized, use --trace-class-initialization=org.codehaus.groovy.reflection.CachedClass$3,org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply,org.codehaus.groovy.runtime.DefaultGroovyMethods,org.codehaus.groovy.util.ReferenceBundle,org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod,org.codehaus.groovy.vmplugin.v8.IndyInterface,org.codehaus.groovy.reflection.stdclasses.IntegerCachedClass,org.codehaus.groovy.runtime.GroovyCategorySupport,org.codehaus.groovy.reflection.CachedClass,org.codehaus.groovy.reflection.stdclasses.CachedClosureClass,org.codehaus.groovy.reflection.stdclasses.NumberCachedClass,org.codehaus.groovy.reflection.stdclasses.BigIntegerCachedClass,org.codehaus.groovy.reflection.ClassInfo$LazyClassLoaderRef,org.codehaus.groovy.reflection.ReflectionUtils,org.codehaus.groovy.reflection.GroovyClassValueFactory,org.codehaus.groovy.reflection.CachedClass$6,org.codehaus.groovy.vmplugin.v9.Java9,org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod,org.codehaus.groovy.util.LazyReference,org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod,org.codehaus.groovy.reflection.stdclasses.CharacterCachedClass,org.codehaus.groovy.reflection.stdclasses.DoubleCachedClass,org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef,org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv,org.codehaus.groovy.util.ReferenceType$2,groovy.lang.MetaClassImpl,org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod,com.sun.beans.util.Cache$Kind$1,org.codehaus.groovy.reflection.stdclasses.ArrayCachedClass,org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus,org.codehaus.groovy.reflection.stdclasses.CachedSAMClass,org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus,org.codehaus.groovy.util.ReferenceType$1,org.codehaus.groovy.reflection.CachedClass$4,groovy.lang.GroovySystem,org.codehaus.groovy.vmplugin.VMPluginFactory,org.codehaus.groovy.vmplugin.v8.IndyInterface$CallType,org.codehaus.groovy.reflection.ReflectionCache,org.codehaus.groovy.util.ReferenceType$4,org.codehaus.groovy.runtime.m12n.SimpleExtensionModule,org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule,org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod,org.codehaus.groovy.runtime.MetaClassHelper,org.codehaus.groovy.util.ReferenceType$3,org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod,com.sun.beans.util.Cache$Kind$3,org.codehaus.groovy.reflection.stdclasses.BooleanCachedClass,org.codehaus.groovy.reflection.CachedClass$1,org.codehaus.groovy.reflection.CachedClass$7,org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayPutAtMetaMethod,org.codehaus.groovy.reflection.stdclasses.BigDecimalCachedClass,org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayGetAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.ArrayMetaMethod,org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport,org.codehaus.groovy.vmplugin.v8.Java8,com.sun.beans.introspect.ClassInfo,org.codehaus.groovy.vmplugin.v8.CacheableCallSite,org.codehaus.groovy.vmplugin.v16.Java16,org.codehaus.groovy.reflection.CachedClass$5,org.codehaus.groovy.reflection.stdclasses.StringCachedClass,java.beans.Introspector,org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod,com.sun.beans.util.Cache$Kind,org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod,org.codehaus.groovy.reflection.CachedClass$2,org.codehaus.groovy.util.ReferenceType,org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod,com.sun.beans.util.Cache$Kind$2,org.codehaus.groovy.reflection.CachedClass$8,org.codehaus.groovy.reflection.stdclasses.LongCachedClass,org.codehaus.groovy.reflection.stdclasses.FloatCachedClass,org.codehaus.groovy.reflection.ClassInfo,org.codehaus.groovy.reflection.stdclasses.ObjectCachedClass,org.apache.groovy.plugin.GroovyRunnerRegistry,org.codehaus.groovy.vmplugin.v10.Java10,org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod,org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod

I've watched some Groovy on GraalVM tutorials and it seems to be working, but there was no AWT / Swing.
Does it mean that Swing + GraalVM is not a valid option? Or is it because of Groovy + Swing?



________________________________
De : Gilles DUBOSCQ <gilles.m.duboscq at oracle.com<mailto:gilles.m.duboscq at oracle.com>>
Envoyé : lundi 16 octobre 2023 20:10
À : Eric Samson <erix.samson at gmail.com<mailto:erix.samson at gmail.com>>
Cc : graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com> <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Objet : Re: [External] : [graalvm-users] java.lang.Thread.sleep() supported in GraalVM?

It looks like the issue is not with Thread.sleep but Swing/AWT on Windows (specifically sun.awt.shell.Win32ShellFolderManager2$ComInvoker).

I think it's not a good idea to use --initialize-at-build-time, you're likely to get into a lot of such corner cases. In general only code that has been designed for it or has explicit support in native-image works well under --initialize-at-build-time. I would recommend to use --initialize-at-build-time only on specific packages or type for which you know there is a real benefit.
If you really want to initialize everything at build time, maybe you can try to use --initialize-at-run-time=sun.awt.shell.Win32ShellFolder2

 Gilles
________________________________
From: Eric Samson <erix.samson at gmail.com<mailto:erix.samson at gmail.com>>
Sent: Monday, 16 October 2023 19:10
To: Gilles DUBOSCQ <gilles.m.duboscq at oracle.com<mailto:gilles.m.duboscq at oracle.com>>
Cc: graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com> <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Subject: Re: [External] : [graalvm-users] java.lang.Thread.sleep() supported in GraalVM?

Hi Gilles,

Thanks for the quick reply.
Here is the error message:

Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image runtime.  To see how this object got instantiated use --trace-object-instantiation=java.lang.Thread. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.

I've tried the option --initialize-at-runtime=java.lang.Thread, without success.

StackTrace:
Trace: Object was reached by
  reading field java.util.concurrent.ThreadPoolExecutor$Worker.thread of constant
    java.util.concurrent.ThreadPoolExecutor$Worker at 63a4cfd: java.util.concurrent.ThreadPoolExecutor$Worker at 63a4cfd[State = 1, empty queue]
  reading field java.util.HashMap$Node.key of constant
    java.util.HashMap$Node at 53798803: java.util.concurrent.ThreadPoolExecutor$Worker at 63a4cfd[State = 1, empty queue]=j...
  indexing into array java.util.HashMap$Node[]@2f2400d: [Ljava.util.HashMap$Node;@2f2400d
  reading field java.util.HashMap.table of constant
    java.util.HashMap at 1ac46e3c: {java.util.concurrent.ThreadPoolExecutor$Worker at 63a4cfd[State = 1, empty queue]=...
  reading field java.util.HashSet.map of constant
    java.util.HashSet at 74b3b357: [java.util.concurrent.ThreadPoolExecutor$Worker at 63a4cfd[State = 1, empty queue]]
  reading field java.util.concurrent.ThreadPoolExecutor.workers of constant
    sun.awt.shell.Win32ShellFolderManager2$ComInvoker at 7f227548: sun.awt.shell.Win32ShellFolderManager2$ComInvoker at 7f227548[Running, pool size = ...
  scanning root sun.awt.shell.Win32ShellFolderManager2$ComInvoker at 7f227548: sun.awt.shell.Win32ShellFolderManager2$ComInvoker at 7f227548[Running, pool size = ... embedded in
    sun.awt.shell.ShellFolder.invoke(ShellFolder.java:537)
  parsing method sun.awt.shell.ShellFolder.invoke(ShellFolder.java:537) reachable via the parsing context
    at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:292)
    at com.oracle.svm.core.code.FactoryMethodHolder.Win32ShellFolder2_constructor_79b7324abf2daa84de416777f746e499d5310ac3(generated:0)
    at sun.awt.shell.Win32ShellFolderManager2.getDesktop(Win32ShellFolderManager2.java:171)
    at sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Win32ShellFolderManager2.java:504)
    at javax.swing.filechooser.FileSystemView.isFileSystemRoot(FileSystemView.java:423)
    at javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:581)
    at javax.swing.filechooser.FileSystemView.isParent(FileSystemView.java:338)
    at javax.swing.JFileChooser.setSelectedFile(JFileChooser.java:513)
    at javax.swing.JFileChooser.setFileFilter(JFileChooser.java:1472)
    at javax.swing.JFileChooser.setup(JFileChooser.java:398)
    at javax.swing.JFileChooser.<init>(JFileChooser.java:362)
    at com.oracle.svm.core.code.FactoryMethodHolder.JFileChooser_constructor_0980039f483e9a48b2389d8a4a1a9cd473a16dbd(generated:0)
    at javax.swing.text.html.FormView$BrowseFileAction.actionPerformed(FormView.java:968)
    at java.awt.MenuItem.processActionEvent(MenuItem.java:692)
    at java.awt.MenuItem.processEvent(MenuItem.java:651)
    at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:379)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.awt.EventQueue$4.run(EventQueue.java:716)
    at com.oracle.svm.core.jdk.Target_java_security_AccessController.executePrivileged(SecuritySubstitutions.java:171)
    at sun.font.SunFontManager.<init>(SunFontManager.java:457)
    at sun.awt.Win32FontManager.<init>(Win32FontManager.java:88)
    at com.oracle.svm.core.code.FactoryMethodHolder.Win32FontManager_constructor_002b6104bcda27602265e5cec50c16a5ebc813af(generated:0)
    at static root method.(Unknown Source)

My Groovy code snippet:

@groovy.transform.CompileStatic
class App {
    static void main(String[] args) {
    // some very simple Swing UI init here
    while (true) {
            time = LocalTime.now()
            label.text = " " + time.format("HH:mm:ss")
            Thread.sleep(1000)
        }
 }

My native-compile command line:
native-image --report-unsupported-elements-at-runtime --initialize-at-build-time --trace-class-initialization=java.lang.Thread --no-fallback -H:ConfigurationFileDirectories=conf/ -cp ".;%GROOVY_HOME%lib\groovy-4.0.9.jar;%GROOVY_HOME%lib\groovy-datetime-4.0.9.jar" displaytime.App

My native-agent command line (works well):
java -agentlib:native-image-agent=config-output-dir=conf/ displaytime.App

:: Cordialement/Best regards, Erix


Le lun. 16 oct. 2023 à 18:48, Gilles DUBOSCQ <gilles.m.duboscq at oracle.com<mailto:gilles.m.duboscq at oracle.com>> a écrit :
Hi Eric,
Yes Thread.sleep() should work in GraalVM native-image.
It would help to know what kind of error you're seeing exactly.
 Gilles
________________________________
From: Eric Samson via GraalVM-Users <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Sent: Monday, 16 October 2023 18:38
To: graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com> <graalvm-users at oss.oracle.com<mailto:graalvm-users at oss.oracle.com>>
Subject: [External] : [graalvm-users] java.lang.Thread.sleep() supported in GraalVM?

Hi everyone,

I'm totally new to GraalVM.
I've set up the whole environment for Windows this morning.

I'm now trying to natively compile a Groovy app (with neither dynamic nor meta programming).
I've been able to compile it and use the native-image-agent to generate the /conf files.

Now I'm trying to generate the executable and I get an error message due to the fact I'm using Thread.sleep(x) in my main loop.

Sleep is a static method of the Thread class. I understand there must be some kind of conflicts between the class being initialized at build-time or runtime. But I'm not sure how to fix it. I've spent a lot of time in the GraalVM documentation and several Web sites (stackOverflow, etc.) but could not find a good example of how to use Thread.sleep in GraalVM.

Sorry for the noob question. Any hint would be greatly appreciated. Thanks in advance.
Best regards, Erix.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oss.oracle.com/pipermail/graalvm-users/attachments/20231017/ccfa8735/attachment-0001.html>


More information about the GraalVM-Users mailing list