RFR: 8350051: [JMH] Several tests fails NPE

Erik Joelsson erikj at openjdk.org
Tue Feb 18 20:25:54 UTC 2025


On Fri, 14 Feb 2025 07:21:27 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> 
> Several JMH tests fails 'Cannot invoke "java.io.InputStream.available()" because "is" is null', because the file 'build/linux-x86_64-server-release/images/test/micro/benchmarks.jar' missing the required xml input file defined by test/micro/org/openjdk/bench/javax/xml/AbstractXMLMicro.java. This PR copy the required xml file to benchmarks.jar, and remove two unexist xml input file.
> 
> After this PR, below JMH tests will run passes.
> 
> 
> org.openjdk.bench.javax.xml.DOM.testBuild
> org.openjdk.bench.javax.xml.DOM.testModify
> org.openjdk.bench.javax.xml.DOM.testWalk
> org.openjdk.bench.javax.xml.SAXUsingJDK.testParse
> org.openjdk.bench.javax.xml.STAX.testParse
> 
> 
> Test command:
> 
> 
> rm -rf build/jmh-result/ ; mkdir -p build/jmh-result/ ; time for test in `cat list.txt` ; do time make test TEST="micro:$test" MICRO="FORK=1;WARMUP_ITER=2" CONF=release &> build/jmh-result/$test.log ; done
> 
> 
> Change has been verified locally, no risk.

I'm not sure if this is the right way to solve this. I would really like someone more familiar with the microbenchmarks to weigh in on how this was originally meant to work.

make/test/BuildMicrobenchmark.gmk line 127:

> 125:             $(TOPDIR)/test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/message_12.xml \
> 126:             $(TOPDIR)/test/jaxp/javax/xml/jaxp/unittest/transform/msgAttach.xml \
> 127:             $(MICROBENCHMARK_CLASSES)/org/openjdk/bench/javax/xml

If this is the correct solution, then copying these files should be handled separately from unpacking jars, preferably using a SetupCopyFiles macro call. Something like this (untested):

$(eval $(call SetupCopyFiles, COPY_JAXP_TEST_XML, \
    DEST := $(MICROBENCHMARK_CLASSES)/org/openjdk/bench/javax/xml, \
    FILES := \
        $(TOPDIR)/test/jaxp/javax/xml/jaxp/unittest/validation/tck/reZ003vExc23082309.xml \
        $(TOPDIR)/test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/message_12.xml \
        $(TOPDIR)/test/jaxp/javax/xml/jaxp/unittest/transform/msgAttach.xml, \
    FLATTEN := true, \
))

And then add $(COPY_JAXP_TEST_XML) to the list of dependencies in the `SetupJarArchive` call below.

-------------

PR Review: https://git.openjdk.org/jdk/pull/23625#pullrequestreview-2624942656
PR Review Comment: https://git.openjdk.org/jdk/pull/23625#discussion_r1960535658


More information about the build-dev mailing list