-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Native Image] NullPointer in Method.invoke #10197
Comments
Hi @allardbe-sla, |
Hi, I also tried building in -diagnostic-mode, I had hoped to get more logging in runtime with it, but that didn't helped either. Let me know what Information I could provide to you next. |
could you please share with us a concise reproducer for your issue? |
Check Windows Version# ver
Microsoft Windows [版本 10.0.22621.4037] Setup Visual Studio Build Tool
Install Option
System Environment
MSVCVARS64=D:\Install\Dev\Vsbt\Ide\VC\Auxiliary\Build\vcvars64.bat
INCLUDE=D:\Install\Dev\Vsbt\Ide\VC\Tools\MSVC\14.42.34433\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
lib=D:\Install\Dev\Vsbt\Ide\VC\Tools\MSVC\14.42.34433\lib\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64 D:\helloworld\target>echo %MSVCVARS64% && %MSVCVARS64%
D:\Install\Dev\Vsbt\Ide\VC\Auxiliary\Build\vcvars64.bat
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.12.3
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64' App.javapackage com.example;
public class App {
public static void main( String[] args ) {
System.out.println( "Hello World!" );
}
} pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>helloworld</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>23</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>
<boot.version>3.4.0</boot.version>
<lifecycle.mapping>1.0.0</lifecycle.mapping>
<flatten.maven.plugin>1.1.0</flatten.maven.plugin>
<maven.compiler.plugin>3.13.0</maven.compiler.plugin>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin}</version>
<configuration>
<fork>true</fork>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.App</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.4</version>
<configuration>
<buildArgs>
<buildArg>-Ob</buildArg>
<buildArg>--parallelism=8</buildArg>
</buildArgs>
<mainClass>com.example.App</mainClass>
</configuration>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> BuildD:\helloworld>mvn clean package -DskipTests -Pnative native:compile
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.example:helloworld >-----------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ helloworld ---
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ helloworld ---
[INFO] skip non existing resourceDirectory D:\helloworld\src\main\resources
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ helloworld ---
[WARNING] Parameter 'compilerVersion' (user property 'maven.compiler.compilerVersion') is deprecated: This parameter is no longer evaluated by the underlying compilers, instead the actual version of the javac binary is automatically retrieved.
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 1 source file with javac [forked debug release 23] to target\classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ helloworld ---
[INFO] skip non existing resourceDirectory D:\helloworld\src\test\resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ helloworld ---
[WARNING] Parameter 'compilerVersion' (user property 'maven.compiler.compilerVersion') is deprecated: This parameter is no longer evaluated by the underlying compilers, instead the actual version of the javac binary is automatically retrieved.
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [forked debug release 23] to target\test-classes
[INFO]
[INFO] --- surefire:3.2.5:test (default-test) @ helloworld ---
[WARNING] Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.
[INFO] Tests are skipped.
[INFO]
[INFO] --- native:0.10.4:test (test-native) @ helloworld ---
[INFO] Skipping native-image tests (parameter 'skipTests' or 'skipNativeTests' is true).
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ helloworld ---
[INFO] Building jar: D:\helloworld\target\helloworld-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- native:0.10.4:compile-no-fork (build-native) @ helloworld ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] Downloaded GraalVM reachability metadata repository from file:/D:/Install/Space/MvnRepo/org/graalvm/buildtools/graalvm-reachability-metadata/0.10.4/graalvm-reachability-metadata-0.10.4-repository.zip
[INFO] Executing: D:\Install\Dev\Java\Graal23\bin\native-image.cmd @target\tmp\native-image-17403297315738778648.args com.example.App
========================================================================================================================
GraalVM Native Image: Generating 'helloworld' (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... (4.0s @ 0.11GB)
Java version: 23.0.1+11, vendor version: Oracle GraalVM 23.0.1+11.1
Graal compiler: optimization level: b, target machine: x86-64-v3, PGO: off
C compiler: cl.exe (microsoft, x64, 19.42.34435)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
- 11.89GB of memory (75.6% of 15.73GB system memory, determined at start)
- 8 thread(s) (40.0% of 20 available processor(s), set via '--parallelism=8')
[2/8] Performing analysis... [*****] (3.2s @ 0.19GB)
1,956 reachable types (58.6% of 3,336 total)
1,733 reachable fields (37.2% of 4,658 total)
8,592 reachable methods (35.9% of 23,960 total)
748 types, 7 fields, and 91 methods registered for reflection
53 types, 30 fields, and 48 methods registered for JNI access
1 native library: version
[3/8] Building universe... (0.7s @ 0.21GB)
[4/8] Parsing methods... [*] (0.4s @ 0.22GB)
[5/8] Inlining methods... [***] (0.4s @ 0.27GB)
[6/8] Compiling methods... [*] (1.9s @ 0.31GB)
[7/8] Laying out methods... [*] (0.6s @ 0.33GB)
[8/8] Creating image... [*] (0.8s @ 0.36GB)
1.96MB (36.55%) for code area: 4,619 compilation units
3.31MB (61.85%) for image heap: 52,814 objects and 120 resources
87.39kB ( 1.59%) for other data
5.36MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
993.80kB svm.jar (Native Image) 673.73kB byte[] for java.lang.String
784.04kB java.base 524.84kB heap alignment
85.53kB com.oracle.svm.svm_enterprise 492.46kB byte[] for code metadata
22.02kB jdk.graal.compiler 356.81kB java.lang.String
21.34kB org.graalvm.nativeimage.base 316.76kB java.lang.Class
17.28kB jdk.proxy2 147.16kB java.util.HashMap$Node
16.91kB jdk.internal.vm.ci 114.52kB char[]
15.16kB org.graalvm.collections 91.69kB com.oracle.svm.core.hub.DynamicHubCompanion
12.68kB jdk.proxy1 84.95kB java.lang.Object[]
4.10kB jdk.proxy3 81.02kB byte[] for reflection metadata
826.00B for 4 more packages 508.06kB for 519 more object types
Use '--emit build-report' to create a report with more details.
------------------------------------------------------------------------------------------------------------------------
Security report:
- Binary includes Java deserialization.
- Use '--enable-sbom' to assemble a Software Bill of Materials (SBOM).
------------------------------------------------------------------------------------------------------------------------
Recommendations:
PGO: Use Profile-Guided Optimizations ('--pgo') for improved throughput.
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
0.7s (5.1% of total time) in 119 GCs | Peak RSS: 0.86GB | CPU load: 0.92
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
D:\helloworld\target\helloworld.exe (executable)
========================================================================================================================
Finished generating 'helloworld' in 12.6s.
[INFO]
[INFO] >>> native:0.10.4:compile (default-cli) > package @ helloworld >>>
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ helloworld ---
[INFO] skip non existing resourceDirectory D:\helloworld\src\main\resources
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ helloworld ---
[WARNING] Parameter 'compilerVersion' (user property 'maven.compiler.compilerVersion') is deprecated: This parameter is no longer evaluated by the underlying compilers, instead the actual version of the javac binary is automatically retrieved.
[INFO] Nothing to compile - all classes are up to date.
[WARNING] Overwriting artifact's file from D:\helloworld\target\helloworld-1.0-SNAPSHOT.jar to D:\helloworld\target\classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ helloworld ---
[INFO] skip non existing resourceDirectory D:\helloworld\src\test\resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ helloworld ---
[WARNING] Parameter 'compilerVersion' (user property 'maven.compiler.compilerVersion') is deprecated: This parameter is no longer evaluated by the underlying compilers, instead the actual version of the javac binary is automatically retrieved.
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [forked debug release 23] to target\test-classes
[INFO]
[INFO] --- surefire:3.2.5:test (default-test) @ helloworld ---
[WARNING] Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.
[INFO] Tests are skipped.
[INFO]
[INFO] --- native:0.10.4:test (test-native) @ helloworld ---
[INFO] Skipping native-image tests (parameter 'skipTests' or 'skipNativeTests' is true).
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ helloworld ---
[INFO]
[INFO] --- native:0.10.4:compile-no-fork (build-native) @ helloworld ---
[INFO] Executing: D:\Install\Dev\Java\Graal23\bin\native-image.cmd @target\tmp\native-image-4264931306803712110.args com.example.App
========================================================================================================================
GraalVM Native Image: Generating 'helloworld' (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... (4.1s @ 0.11GB)
Java version: 23.0.1+11, vendor version: Oracle GraalVM 23.0.1+11.1
Graal compiler: optimization level: b, target machine: x86-64-v3, PGO: off
C compiler: cl.exe (microsoft, x64, 19.42.34435)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
- 11.89GB of memory (75.6% of 15.73GB system memory, determined at start)
- 8 thread(s) (40.0% of 20 available processor(s), set via '--parallelism=8')
[2/8] Performing analysis... [*****] (3.5s @ 0.19GB)
1,956 reachable types (58.6% of 3,336 total)
1,733 reachable fields (37.2% of 4,658 total)
8,592 reachable methods (35.9% of 23,960 total)
748 types, 7 fields, and 91 methods registered for reflection
53 types, 30 fields, and 48 methods registered for JNI access
1 native library: version
[3/8] Building universe... (0.7s @ 0.22GB)
[4/8] Parsing methods... [*] (0.4s @ 0.23GB)
[5/8] Inlining methods... [***] (0.5s @ 0.26GB)
[6/8] Compiling methods... [*] (2.0s @ 0.31GB)
[7/8] Laying out methods... [*] (0.7s @ 0.33GB)
[8/8] Creating image... [*] (1.0s @ 0.21GB)
1.96MB (36.55%) for code area: 4,619 compilation units
3.31MB (61.85%) for image heap: 52,819 objects and 120 resources
87.39kB ( 1.59%) for other data
5.36MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
993.80kB svm.jar (Native Image) 673.73kB byte[] for java.lang.String
784.04kB java.base 524.63kB heap alignment
85.53kB com.oracle.svm.svm_enterprise 492.46kB byte[] for code metadata
22.02kB jdk.graal.compiler 356.81kB java.lang.String
21.34kB org.graalvm.nativeimage.base 316.76kB java.lang.Class
17.28kB jdk.proxy2 147.53kB java.util.HashMap$Node
16.91kB jdk.internal.vm.ci 114.52kB char[]
15.16kB org.graalvm.collections 91.69kB com.oracle.svm.core.hub.DynamicHubCompanion
12.68kB jdk.proxy1 84.95kB java.lang.Object[]
4.10kB jdk.proxy3 81.02kB byte[] for reflection metadata
826.00B for 4 more packages 507.90kB for 519 more object types
Use '--emit build-report' to create a report with more details.
------------------------------------------------------------------------------------------------------------------------
Security report:
- Binary includes Java deserialization.
- Use '--enable-sbom' to assemble a Software Bill of Materials (SBOM).
------------------------------------------------------------------------------------------------------------------------
Recommendations:
PGO: Use Profile-Guided Optimizations ('--pgo') for improved throughput.
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
0.7s (5.2% of total time) in 116 GCs | Peak RSS: 0.86GB | CPU load: 1.20
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
D:\helloworld\target\helloworld.exe (executable)
========================================================================================================================
Finished generating 'helloworld' in 13.2s.
[INFO]
[INFO] <<< native:0.10.4:compile (default-cli) < package @ helloworld <<<
[INFO]
[INFO]
[INFO] --- native:0.10.4:compile (default-cli) @ helloworld ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] Executing: D:\Install\Dev\Java\Graal23\bin\native-image.cmd @target\tmp\native-image-1320350705667134685.args com.example.App
========================================================================================================================
GraalVM Native Image: Generating 'helloworld' (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... (4.2s @ 0.11GB)
Java version: 23.0.1+11, vendor version: Oracle GraalVM 23.0.1+11.1
Graal compiler: optimization level: b, target machine: x86-64-v3, PGO: off
C compiler: cl.exe (microsoft, x64, 19.42.34435)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
- 11.89GB of memory (75.6% of 15.73GB system memory, determined at start)
- 8 thread(s) (40.0% of 20 available processor(s), set via '--parallelism=8')
[2/8] Performing analysis... [*****] (3.6s @ 0.21GB)
1,956 reachable types (58.6% of 3,336 total)
1,733 reachable fields (37.2% of 4,658 total)
8,592 reachable methods (35.9% of 23,957 total)
748 types, 7 fields, and 91 methods registered for reflection
53 types, 30 fields, and 48 methods registered for JNI access
1 native library: version
[3/8] Building universe... (0.7s @ 0.21GB)
[4/8] Parsing methods... [*] (0.4s @ 0.23GB)
[5/8] Inlining methods... [***] (0.5s @ 0.26GB)
[6/8] Compiling methods... [**] (2.0s @ 0.32GB)
[7/8] Laying out methods... [*] (0.7s @ 0.32GB)
[8/8] Creating image... [*] (1.1s @ 0.22GB)
1.96MB (36.55%) for code area: 4,619 compilation units
3.31MB (61.85%) for image heap: 52,808 objects and 120 resources
87.39kB ( 1.59%) for other data
5.36MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
993.80kB svm.jar (Native Image) 673.73kB byte[] for java.lang.String
784.04kB java.base 524.85kB heap alignment
85.53kB com.oracle.svm.svm_enterprise 492.46kB byte[] for code metadata
22.02kB jdk.graal.compiler 356.81kB java.lang.String
21.34kB org.graalvm.nativeimage.base 316.76kB java.lang.Class
17.28kB jdk.proxy2 147.31kB java.util.HashMap$Node
16.91kB jdk.internal.vm.ci 114.52kB char[]
15.16kB org.graalvm.collections 91.69kB com.oracle.svm.core.hub.DynamicHubCompanion
12.68kB jdk.proxy1 84.95kB java.lang.Object[]
4.10kB jdk.proxy3 81.02kB byte[] for reflection metadata
826.00B for 4 more packages 507.90kB for 519 more object types
Use '--emit build-report' to create a report with more details.
------------------------------------------------------------------------------------------------------------------------
Security report:
- Binary includes Java deserialization.
- Use '--enable-sbom' to assemble a Software Bill of Materials (SBOM).
------------------------------------------------------------------------------------------------------------------------
Recommendations:
PGO: Use Profile-Guided Optimizations ('--pgo') for improved throughput.
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
0.7s (5.2% of total time) in 115 GCs | Peak RSS: 0.85GB | CPU load: 1.09
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
D:\helloworld\target\helloworld.exe (executable)
========================================================================================================================
Finished generating 'helloworld' in 13.8s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.928 s
[INFO] Finished at: 2024-12-15T23:29:51+08:00
[INFO] ------------------------------------------------------------------------ Testcd target && helloworld.exe
Hello World! |
Describe the Issue
I have a spring-boot application. That application make use of 'prototype beans' (objects created in runtime). I instantiate them over an injected ObjectProvider in a singleton bean.
The first time I tried, I got a
MissingReflectionRegistrationError
with the proper data over my prototype beanfactory-method
. However, once I added that data in a reflect-config.json file in the Exception just became a NullPointerException.Here the trace:
The MethodAccessor seems to be null, but I don't know why.
Using the latest version of GraalVM can resolve many issues.
GraalVM Version
Tried with the latest JDK11, and then with the current 23
Operating System and Version
bullseye-20240926-slim
Troubleshooting Confirmation
Run Command
/app
Expected Behavior
just runs
Actual Behavior
crashed
Steps to Reproduce
Additional Context
I'd be glad to provide more if I knew what is relevant.
Run-Time Log Output and Error Messages
No response
The text was updated successfully, but these errors were encountered: