Execute the following command and make sure all tests are okay:
$ ./gradlew test
Then execute the following command, which will fail as shown in the logs:
$ ./gradlew nativeTest
Expected behavior:
The tests should finish successfully, just like the ./gradlew test does. Instead, the following error appears in the logs:
Resource with path db/mysql_conf_override could not be found on any of these classloaders: [jdk.internal.loader.ClassLoaders$AppClassLoader@2f7c7260]
Logs:
========================================================================================================================
GraalVM Native Image: Generating 'native-build-tools-bug-report-tests' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing... (13.4s @ 0.16GB)
Java version: 21.0.1+12, vendor version: Oracle GraalVM 21.0.1+12.1
Graal compiler: optimization level: 2, target machine: armv8-a, PGO: off
C compiler: cc (apple, arm64, 15.0.0)
Garbage collector: Serial GC (max heap size: 80% of RAM)
2 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
- org.graalvm.junit.platform.JUnitPlatformFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
- 12.09GB of memory (75.6% of 16.00GB system memory, determined at start)
- 8 thread(s) (100.0% of 8 available processor(s), determined at start)
[junit-platform-native] Running in 'test listener' mode using files matching pattern [junit-platform-unique-ids*] found in folder [/Users/meletis/Code/mine/native-build-tools-bug-report/build/test-results/test/testlist] and its subfolders.
Found pending operations, continuing analysis.
[2/8] Performing analysis... [******] (40.9s @ 1.62GB)
13,717 reachable types (87.8% of 15,620 total)
22,094 reachable fields (61.8% of 35,747 total)
71,606 reachable methods (59.6% of 120,094 total)
4,437 types, 1,404 fields, and 3,655 methods registered for reflection
96 types, 99 fields, and 102 methods registered for JNI access
5 native libraries: -framework CoreServices, -framework Foundation, dl, pthread, z
[3/8] Building universe... (6.8s @ 1.64GB)
[4/8] Parsing methods... [***] (11.0s @ 1.84GB)
[5/8] Inlining methods... [***] (1.9s @ 1.47GB)
[6/8] Compiling methods... [**********] (102.8s @ 5.04GB)
[7/8] Layouting methods... [*****] (26.7s @ 1.96GB)
[8/8] Creating image... [***] (11.7s @ 2.83GB)
35.52MB (54.93%) for code area: 40,608 compilation units
28.27MB (43.71%) for image heap: 350,891 objects and 143 resources
901.88kB ( 1.36%) for other data
64.67MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
14.05MB java.base 9.90MB byte[] for code metadata
5.31MB testcontainers-1.19.1.jar 4.83MB byte[] for java.lang.String
5.97MB svm.jar (Native Image) 2.54MB java.lang.String
3.66MB java.xml 2.41MB java.lang.Class
3.44MB mysql-connector-j-8.0.33.jar 1.67MB byte[] for embedded resources
849.06kB docker-java-transport-zerodep-3.3.3.jar 873.16kB byte[] for reflection metadata
533.92kB java.security.jgss 835.89kB byte[] for general heap data
444.65kB jna-5.12.1.jar 642.98kB com.oracle.svm.core.hub.DynamicHubCompanion
401.41kB docker-java-api-3.3.3.jar 393.03kB c.o.svm.core.hub.DynamicHub$ReflectionMetadata
389.65kB java.management 369.88kB java.util.HashMap$Node
6.30MB for 52 more packages 3.88MB for 3026 more object types
Use '-H:+BuildReport' to create a report with more details.
------------------------------------------------------------------------------------------------------------------------
Security report:
- Binary includes Java deserialization.
- Use '--enable-sbom' to embed a Software Bill of Materials (SBOM) in the binary.
------------------------------------------------------------------------------------------------------------------------
Recommendations:
PGO: Use Profile-Guided Optimizations ('--pgo') for improved throughput.
INIT: Adopt '--strict-image-heap' to prepare for the next GraalVM release.
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
QBM: Use the quick build mode ('-Ob') to speed up builds during development.
------------------------------------------------------------------------------------------------------------------------
18.8s (8.6% of total time) in 155 GCs | Peak RSS: 2.84GB | CPU load: 3.38
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
/Users/meletis/Code/mine/native-build-tools-bug-report/build/native/nativeTestCompile/native-build-tools-bug-report-tests (executable)
========================================================================================================================
Finished generating 'native-build-tools-bug-report-tests' in 3m 37s.
[native-image-plugin] Native Image written to: /Users/meletis/Code/mine/native-build-tools-bug-report/build/native/nativeTestCompile
Resolve mutations for :nativeTest (Thread[#555,Execution worker Thread 7,5,main]) started.
:nativeTest (Thread[#555,Execution worker Thread 7,5,main]) started.
> Task :nativeTest
Caching disabled for task ':nativeTest' because:
Build cache is disabled
Task ':nativeTest' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Starting process 'command '/Users/meletis/Code/mine/native-build-tools-bug-report/build/native/nativeTestCompile/native-build-tools-bug-report-tests''. Working directory: /Users/meletis/Code/mine/native-build-tools-bug-report Command: /Users/meletis/Code/mine/native-build-tools-bug-report/build/native/nativeTestCompile/native-build-tools-bug-report-tests --xml-output-dir /Users/meletis/Code/mine/native-build-tools-bug-report/build/test-results/test-native
Successfully started process 'command '/Users/meletis/Code/mine/native-build-tools-bug-report/build/native/nativeTestCompile/native-build-tools-bug-report-tests''
JUnit Platform on Native Image - report
----------------------------------------
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
org.example.MyAppTest > testMySQLContainerIsRunning() FAILED
Failures (2):
JUnit Jupiter:MyAppTest:testMySQLContainerIsRunning()
MethodSource [className = 'org.example.MyAppTest', methodName = 'testMySQLContainerIsRunning', methodParameterTypes = '']
=> java.lang.ExceptionInInitializerError
java.base@21.0.1/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
java.base@21.0.1/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
java.base@21.0.1/java.util.Optional.orElseGet(Optional.java:364)
java.base@21.0.1/java.util.ArrayList.forEach(ArrayList.java:1596)
java.base@21.0.1/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mysql:5.7
org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:359)
org.testcontainers.containers.GenericContainer.start(GenericContainer.java:334)
org.example.MyAppTest.<clinit>(MyAppTest.java:21)
[...]
Caused by: java.lang.IllegalArgumentException: Resource with path db/mysql_conf_override could not be found on any of these classloaders: [jdk.internal.loader.ClassLoaders$AppClassLoader@2f7c7260]
org.testcontainers.utility.MountableFile.getClasspathResource(MountableFile.java:158)
org.testcontainers.utility.MountableFile.forClasspathResource(MountableFile.java:103)
org.testcontainers.containers.JdbcDatabaseContainer.optionallyMapResourceParameterAsVolume(JdbcDatabaseContainer.java:322)
org.testcontainers.containers.MySQLContainer.configure(MySQLContainer.java:76)
org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:339)
[...]
JUnit Jupiter:MyAppTest
ClassSource [className = 'org.example.MyAppTest', filePosition = null]
=> java.lang.NoClassDefFoundError: Could not initialize class org.example.MyAppTest
java.base@21.0.1/java.lang.reflect.Method.invoke(Method.java:580)
java.base@21.0.1/java.util.ArrayList.forEach(ArrayList.java:1596)
java.base@21.0.1/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1116)
java.base@21.0.1/java.util.ArrayList.forEach(ArrayList.java:1596)
Test run finished after 1909 ms
[ 2 containers found ]
[ 0 containers skipped ]
[ 2 containers started ]
[ 0 containers aborted ]
[ 1 containers successful ]
[ 1 containers failed ]
[ 1 tests found ]
[ 0 tests skipped ]
[ 1 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 1 tests failed ]
> Task :nativeTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':nativeTest'.
> Process 'command '/Users/meletis/Code/mine/native-build-tools-bug-report/build/native/nativeTestCompile/native-build-tools-bug-report-tests'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --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 4m
9 actionable tasks: 9 executed
Watched directory hierarchies: [/Users/meletis/Code/mine/native-build-tools-bug-report]
System Info (please complete the following information):
The test resources are not included at runtime when executing "nativeTest".
Steps to reproduce the behavior:
Expected behavior:
The tests should finish successfully, just like the
./gradlew test
does. Instead, the following error appears in the logs:Logs:
System Info (please complete the following information):
macOS
Oracle GraalVM 21.0.1+12.1
21
native-gradle-plugin:0.9.28