-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Internal
-
Not Needed
Method sun.nio.ch.DirectBuffer.cleaner() does not take any parameters in Java 8, code https://github.com/mongodb/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/internal/connection/tlschannel/util/DirectBufferDeallocator.java#L54 passes null array as a paramter to this method. This leads to NullPointerException when building native image with GraalVM (see below for stacktrace).
Steps to reproduce error:
Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
$git clone https://github.com/retriku/graalvm-scala-mongodb-npe.git $sbt clean compile 'show graalvm-native-image:packageBin'
[error] Fatal error:com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing com.mongodb.internal.connection.tlschannel.util.DirectBufferDeallocator$Java8Deallocator.<init>()
[error] Parsing context:
[error] at com.mongodb.internal.connection.tlschannel.util.DirectBufferDeallocator.<init>(DirectBufferDeallocator.java:114)
[error] at com.mongodb.internal.connection.tlschannel.DirectBufferAllocator.<init>(DirectBufferAllocator.java:37)
[error] at com.mongodb.internal.connection.tlschannel.TlsChannel.<clinit>(TlsChannel.java:70)
[error] at com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:126)
[error] at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:307)
[error] at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureTypeFlowCreated(MethodTypeFlow.java:282)
[error] at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
[error] at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:363)
[error] at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:471)
[error] at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:540)
[error] at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:539)
[error] at com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:188)
[error] at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:172)
[error] at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
[error] at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
[error] at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
[error] at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
[error] at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
[error] at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
[error] Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: java.lang.NullPointerException
[error] at parsing com.mongodb.internal.connection.tlschannel.util.DirectBufferDeallocator$Java8Deallocator.<init>(DirectBufferDeallocator.java:54)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2578)
[error] at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:111)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3439)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3391)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3236)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1122)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1007)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
[error] at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:81)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
[error] at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:131)
[error] at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:709)
[error] at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:605)
[error] at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:163)
[error] at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:321)
[error] at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:293)
[error] ... 14 more
[error] Caused by: java.lang.NullPointerException
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins.lambda$foldInvocationUsingReflection$3(ReflectionPlugins.java:374)
[error] at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
[error] at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
[error] at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[error] at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[error] at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
[error] at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[error] at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins.lambda$foldInvocationUsingReflection$4(ReflectionPlugins.java:374)
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins.traceConstant(ReflectionPlugins.java:565)
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins.pushConstant(ReflectionPlugins.java:539)
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins.foldInvocationUsingReflection(ReflectionPlugins.java:394)
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins.access$200(ReflectionPlugins.java:95)
[error] at com.oracle.svm.hosted.snippets.ReflectionPlugins$5.defaultHandler(ReflectionPlugins.java:335)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.apply(InvocationPlugin.java:105)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.execute(InvocationPlugin.java:170)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.applyInvocationPlugin(BytecodeParser.java:2197)
[error] at com.oracle.svm.hosted.phases.AnalysisGraphBuilderPhase$AnalysisBytecodeParser.applyInvocationPlugin(AnalysisGraphBuilderPhase.java:86)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.tryInvocationPlugin(BytecodeParser.java:2183)
[error] at com.oracle.svm.hosted.phases.AnalysisGraphBuilderPhase$AnalysisBytecodeParser.tryInvocationPlugin(AnalysisGraphBuilderPhase.java:67)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.appendInvoke(BytecodeParser.java:1889)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genDynamicInvokeHelper(BytecodeParser.java:1762)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeVirtual(BytecodeParser.java:1712)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeVirtual(BytecodeParser.java:1697)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5371)
[error] at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3431)
[error] ... 30 more