oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
19.99k stars 1.6k forks source link

Custom ClassLoader behaves differently under JVM and Native Image #5913

Open linghengqian opened 1 year ago

linghengqian commented 1 year ago

Describe the issue A clear and concise description of the issue. We recommend using the latest snapshot builds to replicate the issue as bugs are constantly being fixed in the master branch

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

  1. [e.g.: git clone --depth 1 https://git.myrepo.com/projectone ]
  2. [e.g.: mvn clean package]
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 22.3.1.r17-grl
sdk use java 22.3.1.r17-grl

gu install native-image
sudo apt-get install build-essential libz-dev zlib1g-dev -y

git clone git@github.com:linghengqian/driver-classloader-graalvm-test.git
cd ./driver-classloader-graalvm-test/
./gradlew -Pagent clean test
./gradlew metadataCopy --task test
./gradlew clean nativeTest

Describe GraalVM and your environment:

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.

> Task :nativeTest
JUnit Platform on Native Image - report
----------------------------------------

org.apache.commons.dbcp2.TestBasicDataSource > testThreaded() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testCanCloseStatementTwice() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testNoRsetClose() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testOpening() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testCanCloseConnectionTwice() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testIsClosed() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testCanCloseCallableStatementTwice() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testAutoCommitBehavior() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testHashing() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testCanClosePreparedStatementTwice() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testClosing() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testPrepareStatementOptions() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testBackPointers() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testHashCode() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testConnectionsAreDistinct() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testMaxTotal() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testRepeatedBorrowAndReturn() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testCanCloseResultSetTwice() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testClearWarnings() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testSimple2() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testSimple() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testPooling() SUCCESSFUL

org.apache.commons.dbcp2.TestBasicDataSource > testDriverClassLoader() FAILED

Failures (1):
  JUnit Jupiter:TestBasicDataSource:testDriverClassLoader()
    MethodSource [className = 'org.apache.commons.dbcp2.TestBasicDataSource', methodName = 'testDriverClassLoader', methodParameterTypes = '']
    => org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
       org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
       org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
       org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
       org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
       org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:31)
       org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:180)
       org.apache.commons.dbcp2.TestBasicDataSource.testDriverClassLoader(TestBasicDataSource.java:67)
       java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568)
       org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
       org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
       [...]

Test run finished after 2828 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[        23 tests found           ]
[         0 tests skipped         ]
[        23 tests started         ]
[         0 tests aborted         ]
[        22 tests successful      ]
[         1 tests failed          ]

> Task :nativeTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeTest'.
> Process 'command '/home/linghengqian/TwinklingLiftWorks/git/public/driver-classloader-graalvm-test/build/native/nativeTestCompile/driver-classloader-graalvm-test-tests'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 14s
8 actionable tasks: 8 executed
oubidar-Abderrahim commented 1 year ago

Hi, Thank you for reporting this, we will take a look into it shortly

oubidar-Abderrahim commented 1 year ago

Tracked internally on GR 44508