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

Error: Incompatible change of initialization policy for java.io.RandomAccessFile: trying to change RERUN for JDK native code support via JNI to BUILD_TIME super type of org.apache.fontbox.ttf.BufferedRandomAccessFile #2723

Closed
kalaspuffar opened this issue Jul 29, 2020 · 10 comments
Assignees

Comments

@kalaspuffar
Copy link

Describe the issue

We want to improve the speed of running pdfbox so we tried to compile with graalvm into a native image.

graalvm-ce-java8-20.3.0-dev/bin/native-image -jar pdfbox-app-2.0.20.jar pdfbox-app-2.0.20 --initialize-at-build-time=com.github.jaiimageio.impl.common.PackageUtil --no-fallback --no-server

Latest pdfbox can be downloaded at:
http://apache.mirrors.spacedump.net/pdfbox/2.0.20/pdfbox-app-2.0.20.jar

Sadly we get the error:
[pdfbox-app-2.0.20:30813] classlist: 4,780.65 ms, 1.58 GB
[pdfbox-app-2.0.20:30813] (cap): 1,094.08 ms, 1.58 GB
[pdfbox-app-2.0.20:30813] setup: 3,508.85 ms, 1.58 GB
[pdfbox-app-2.0.20:30813] (clinit): 593.70 ms, 2.70 GB
[pdfbox-app-2.0.20:30813] analysis: 48,464.63 ms, 2.70 GB
Error: Incompatible change of initialization policy for java.io.RandomAccessFile: trying to change RERUN for JDK native code support via JNI to BUILD_TIME super type of org.apache.fontbox.ttf.BufferedRandomAccessFile
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. Download PDFBox-app
  2. Run native-image

Describe GraalVM and your environment:

  • GraalVM version: graalvm-ce-java8-20.3.0-dev
  • JDK major version: 8
  • OS: Linux tauriel 5.7.4-gentoo-x86_64 Feature/instrumentation api #1 SMP Sat Jun 27 14:00:58 CEST 2020 x86_64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz GenuineIntel GNU/Linux
  • Architecture: x86_64

More details

Consider adding the --native-image-info and --verbose flags when building your native image and paste output below.

Add any other information about the problem here. Especially important are stack traces or log output. Feel free to link to gists or to screenshots if necessary.

Executing [
/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/bin/java \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
-d64 \
-XX:-UseJVMCIClassLoader \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-Xms1g \
-Xmx13316721864 \
-Duser.country=US \
-Duser.language=en \
-Djava.awt.headless=true \
-Dorg.graalvm.version=20.3.0-dev \
-Dorg.graalvm.config= \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
-Djvmci.class.path.append=/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/jvmci/graal.jar \
-javaagent:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/svm.jar \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
-Xbootclasspath/a:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/boot/graaljs-scriptengine.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/boot/graal-sdk.jar \
-cp \
/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/pointsto.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/javacpp-shadowed.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/llvm-wrapper-shadowed.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/objectfile.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/svm.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/llvm-platform-specific-shadowed.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/builder/svm-llvm.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/jvmci/graal.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/jvmci/graal-truffle-jfr-impl.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/jvmci/jvmci-api.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/jvmci/graal-management.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/jvmci/jvmci-hotspot.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/resources.jar \
com.oracle.svm.hosted.NativeImageGeneratorRunner \
-watchpid \
8992 \
-imagecp \
/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/boot/graaljs-scriptengine.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/boot/graal-sdk.jar:/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/library-support.jar:/home/danielp/pdfwork/perftest/pdfbox-app-2.0.20.jar \
-H:Path=/home/danielp/pdfwork/perftest \
-H:Class=org.apache.pdfbox.tools.PDFBox \
-H:ClassInitialization=com.github.jaiimageio.impl.common.PackageUtil:build_time \
-H:FallbackThreshold=0 \
-H:+DumpTargetInfo \
-H:CLibraryPath=/home/danielp/apps/graalvm-ce-java8-20.3.0-dev/jre/lib/svm/clibraries/linux-amd64 \
-H:Name=pdfbox-app-2.0.20 \

]

[pdfbox-app-2.0.20:9023]    classlist:   4,601.21 ms,  1.64 GB
[pdfbox-app-2.0.20:9023]        (cap):   1,071.11 ms,  1.64 GB
[pdfbox-app-2.0.20:9023]        setup:   3,366.92 ms,  1.64 GB
# Building image for target platform: org.graalvm.nativeimage.Platform$LINUX_AMD64
# Using native toolchain:
#   Name: GNU project C and C++ compiler (gcc)
#   Vendor: pc
#   Version: 10.2.0
#   Target architecture: x86_64
#   Path: /usr/bin/gcc
# Using CLibrary: com.oracle.svm.core.posix.linux.libc.GLibC
[pdfbox-app-2.0.20:9023]     (clinit):     521.84 ms,  2.75 GB
[pdfbox-app-2.0.20:9023]     analysis:  50,103.68 ms,  2.75 GB
Error: Incompatible change of initialization policy for java.io.RandomAccessFile: trying to change RERUN for JDK native code support via JNI to BUILD_TIME super type of org.apache.fontbox.ttf.BufferedRandomAccessFile
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
        at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1558)
        at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1308)
        at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1269)
        at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1228)
@munishchouhan
Copy link
Contributor

@kalaspuffar please share the code sample and command to reproduce this issue

@munishchouhan munishchouhan self-assigned this Aug 20, 2020
@kalaspuffar
Copy link
Author

Hi @mcraj017

The application we are trying to run on the graalvm is available at the link above. I don't have any specific code to share.

If you want to rebuild the application you can do that with the code at https://github.com/apache/pdfbox

Best regards
Daniel

@LightCampy
Copy link

LightCampy commented Aug 25, 2020

I notice that the similar error was metioned in this issue #1731 (comment) . Perhaps we can refer to it to find more context about the bug ?

@oubidar-Abderrahim
Copy link
Member

I raised a ticket to the dev team for this issue

@samyc1201
Copy link

I encounter the similar issue while using zip4j jar.

[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] Error: Incompatible change of initialization policy for java.io.RandomAccessFile: trying to change RERUN for JDK native code support via JNI to BUILD_TIME super type of net.lingala.zip4j.io.inputstream.NumberedSplitRandomAccessFile
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] com.oracle.svm.core.util.UserError$UserException: Incompatible change of initialization policy for java.io.RandomAccessFile: trying to change RERUN for JDK native code support via JNI to BUILD_TIME super type of net.lingala.zip4j.io.inputstream.NumberedSplitRandomAccessFile
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:99)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:113)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:113)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:113)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insert(ClassInitializationConfiguration.java:64)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.forceInitializeHosted(ConfigurableClassInitialization.java:472)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.forceInitializeHosted(ConfigurableClassInitialization.java:476)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.lambda$initializeSafeDelayedClasses$11(ClassInitializationFeature.java:319)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1603)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.initializeSafeDelayedClasses(ClassInitializationFeature.java:316)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.afterAnalysis(ClassInitializationFeature.java:256)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:753)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:753)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:555)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
[Mon Aug 31 11:21:20 SGT 2020][INFO] [SUB] 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
[Mon Aug 31 11:21:21 SGT 2020][INFO] [SUB] Error: Image build request failed with exit status 1
[Mon Aug 31 11:21:21 SGT 2020][FINE] Result for compile: 1

Looks like those using RandomAccessFile would cause issue in GraalVM native image.

@samyc1201
Copy link

@oubidar-Abderrahim hi, is there any update on this? I see another java library which giving same issue trying to change RERUN for JDK native code support via JNI to BUILD_TIME super type of, how should we avoid that? In fact, we never touch anything related to RERUN or BUILD_TIME in the library.

@Christewart
Copy link

I seem to be running into the same issue with bitcoin-s when trying to build our appSever

The native image version is `20.2.0

Steps to reproduce

  1. clone https://github.com/Christewart/bitcoin-s-core/tree/2021-01-09-sbt-nativeimage-plugin-server
  2. Run sbt appServer/nativeImage

and here is the error I am receiving:

[info] /home/chris/.cache/coursier/jvm/[email protected]/bin/native-image -cp /home/chris/dev/bitcoin-s/app/server/target/native-image-internal/manifest.jar org.bitcoins.server.BitcoinSServerMain /home/chris/dev/bitcoin-s/app/server/target/native-image/bitcoin-s-server
[/home/chris/dev/bitcoin-s/app/server/target/native-image/bitcoin-s-server:62640] classlist: 26,906.61 ms, 0.91 GB
[/home/chris/dev/bitcoin-s/app/server/target/native-image/bitcoin-s-server:62640] (cap): 1,067.20 ms, 0.91 GB
[/home/chris/dev/bitcoin-s/app/server/target/native-image/bitcoin-s-server:62640] setup: 2,639.96 ms, 0.92 GB
[/home/chris/dev/bitcoin-s/app/server/target/native-image/bitcoin-s-server:62640] (clinit): 1,787.26 ms, Error: Incompatible change of initialization policy for javax.net.ssl.SSLContext: trying to change RERUN for substitutions to BUILD_TIME super type of com.typesafe.sslconfig.ssl.tracing.TracingSSLContext
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
6.40 GB
[/home/chris/dev/bitcoin-s/app/server/target/native-image/bitcoin-s-server:62640] analysis: 88,822.32 ms, 6.40 GB
Error: Image build request failed with exit status 1
[error] native-image command failed with exit code '1'
[error] (appServer / nativeImage) native-image command failed with exit code '1'
[error] Total time: 121 s (02:01), completed Jan 9, 2021, 7:55:47 AM

@oubidar-Abderrahim
Copy link
Member

This issue is tracked internally at GR-25845.
Could you please try with 21.0.0-dev?

@sdeleuze
Copy link
Collaborator

Is this issue expected to be fixed (based on last comment maybe but I am not sure)?

@vjovanov
Copy link
Member

With the latest GraalVM this error doesn't happen anymore. I reach AWT issues, but the initialization issues are fixed.

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

8 participants