melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle
Apache License 2.0
659 stars 88 forks source link

It fails to run a benchmark that relies on apache-poi #251

Open holgerbrandl opened 1 year ago

holgerbrandl commented 1 year ago

When trying to run a benchmark that relies on apache-poi (a popular library to process ms office documents, see https://poi.apache.org/) it fails with

λ ./gradlew jmhJar
λ java -jar build/libs/poi-jmh-jmh.jar
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openjdk.jmh.util.Utils (file:/D:/projects/misc/poi-jmh/build/libs/poi-jmh-jmh.jar) to method java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of org.openjdk.jmh.util.Utils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
# JMH version: 1.36
# VM version: JDK 11.0.8, OpenJDK 64-Bit Server VM, 11.0.8+10
# VM invoker: C:\Users\brandl\.jdks\adopt-openjdk-11.0.8\bin\java.exe
# VM options: <none>
# Blackhole mode: full + dont-inline hint (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
# Warmup: 2 iterations, 10 s each
# Measurement: 5 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: org.kalasim.benchmarks.ExcelTest.doSomething

# Run progress: 0.00% complete, ETA 00:05:50
# Fork: 1 of 5
# Warmup Iteration   1: ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
<failure>

java.io.IOException: Your InputStream was neither an OLE2 stream, nor an OOXML stream or you haven't provide the poi-ooxml*.jar in the classpath/modulepath - FileMagic: OOXML, having providers: [org.apache.poi.hssf.usermodel.HSSFWorkbookFactory@27352a35]
        at org.apache.poi.ss.usermodel.WorkbookFactory.wp(WorkbookFactory.java:334)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:311)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:277)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:255)
        at org.jetbrains.kotlinx.dataframe.io.XlsxKt.readExcel(xlsx.kt:88)
        at org.jetbrains.kotlinx.dataframe.io.XlsxKt.readExcel$default(xlsx.kt:81)
        at org.kalasim.benchmarks.ExcelTest.doSomething(ExcelTest.kt:20)
        at org.kalasim.benchmarks.jmh_generated.ExcelTest_doSomething_jmhTest.doSomething_avgt_jmhStub(ExcelTest_doSomething_jmhTest.java:190)
        at org.kalasim.benchmarks.jmh_generated.ExcelTest_doSomething_jmhTest.doSomething_AverageTime(ExcelTest_doSomething_jmhTest.java:152)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:475)
        at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:458)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

How to reproduce? Simple clone the prepared minimalistic example https://github.com/holgerbrandl/poi-jmh-example and run the command from above.

I suspect this being an issue with the flat-jar. When running the same code bit from the benchmark independently in https://github.com/holgerbrandl/poi-jmh-example/blob/master/src/jmh/kotlin/org/kalasim/benchmarks/ExcelTest.kt#L25 in works without problem