Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1811

Impossibile to build Undertow based GraalVM native image due to unsafe.staticFieldBase() on static volatile int failing with UnsupportedFeatureError

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.2.2.Final
    • 2.2.2.Final
    • Core
    • None
    • Hide
      1. git clone --depth 1 https://github.com/SoftInstigate/graalvm-undertow-issue.git
      2. cd graalvm-undertow-issue
      3. mvn clean package -Pnative
      4. ./target/graalvm-undertow-issue-native
      Show
      git clone --depth 1 https://github.com/SoftInstigate/graalvm-undertow-issue.git cd graalvm-undertow-issue mvn clean package -Pnative ./target/graalvm-undertow-issue-native
    • Workaround Exists
    • Hide

      Downgrading xnio to version 3.5.9.Final removes transitive dependency to joss-threads:2.3.0.Beta2 that introduces the failing EnhancedQueueExecutor class

      <dependency>
        <groupId>org.jboss.xnio</groupId>
        <artifactId>xnio-api</artifactId>
        <version>3.5.9.Final</version>
      </dependency>
       <dependency>
        <groupId>org.jboss.xnio</groupId>
        <artifactId>xnio-nio</artifactId>
        <version>3.5.9.Final</version>
      </dependency>

       

      Show
      Downgrading xnio to version 3.5.9.Final removes transitive dependency to joss-threads:2.3.0.Beta2 that introduces the failing EnhancedQueueExecutor class <dependency>   <groupId>org.jboss.xnio</groupId>   <artifactId>xnio-api</artifactId>   <version>3.5.9.Final</version> </dependency>  <dependency>   <groupId>org.jboss.xnio</groupId>   <artifactId>xnio-nio</artifactId>   <version>3.5.9.Final</version> </dependency>  
    • Hide
      undertow native image builds with GraalVM 21.0.0

      tested on RESTHeart https://restheart.org/docs/graalvm/#build-restheart-with-default-plugins-as-native-image
      Show
      undertow native image builds with GraalVM 21.0.0 tested on RESTHeart https://restheart.org/docs/graalvm/#build-restheart-with-default-plugins-as-native-image

    Description

      The GraalVM native image of a project that uses undertow, fails at runtime with following error.

      Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Unsupported method of Unsafe at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87) at jdk.internal.misc.Unsafe.staticFieldBase(Unsafe.java:236) at sun.misc.Unsafe.staticFieldBase(Unsafe.java:677) at org.jboss.threads.EnhancedQueueExecutor.<clinit>(EnhancedQueueExecutor.java:295) at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351) at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271) at org.xnio.XnioWorker.<init>(XnioWorker.java:139) at org.xnio.nio.NioXnioWorker.<init>(NioXnioWorker.java:84) at org.xnio.nio.NioXnio.build(NioXnio.java:233) at org.xnio.XnioWorker$Builder.build(XnioWorker.java:1191) at org.xnio.Xnio.createWorker(Xnio.java:481) at org.xnio.Xnio.createWorker(Xnio.java:463) at org.xnio.Xnio.createWorker(Xnio.java:450) at io.undertow.Undertow.start(Undertow.java:122) at com.softinstigate.App.main(App.java:25)
      

       The problem comes from EnhancedQueueExecutor class of jboss-threads Here the static class initializer of EnhancedQueueExecutor fails on this line:

      static volatile int sequence = 1;
      ...
      sequence  = unsafe.staticFieldBase(EnhancedQueueExecutor.class.getDeclaredField("sequence"));
      

       

       

      Attachments

        Activity

          People

            flaviarnn Flavia Rainone
            a.dicesare@softinstigate.com Andrea Di Cesare (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: