Comments (4)
Thanks for reporting this issue. We will take care of it.
from graal.
@zakkak I am having trouble to reproduce it running latest native-image with my code snippet.
Directory:
.
./Main.java
./myfile-1.txt
./myfile-2.txt
Files just contain "Hello from file 1" etc.
Code:
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
public class Main {
public static void main(String[] args) throws IOException {
for (String s : new String[] { "myfile-1.txt", "myfile-2.txt", "myfile-3.txt" }) {
try (final InputStream is = Objects.requireNonNull(Main.class.getResourceAsStream("/" + s),
"File " + s + " not found.")) {
System.out.print(new String(is.readAllBytes(), StandardCharsets.US_ASCII));
} catch (NullPointerException e) {
System.out.println(e.getMessage());
}
}
}
}
🔴 FAIL GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
$ javac Main.java
$ java -agentlib:native-image-agent=config-output-dir=agent-stuff Main
Hello from file 1
Hello from file 2
File myfile-3.txt not found.
$ cat agent-stuff/resource-config.json
{
"resources":{
"includes":[{
"pattern":"\\Qmyfile-1.txt\\E"
}, {
"pattern":"\\Qmyfile-2.txt\\E"
}, {
"pattern":"\\Qmyfile-3.txt\\E"
}]},
"bundles":[]
}
$ native-image -H:+UnlockExperimentalVMOptions -H:ThrowMissingRegistrationErrors= -H:ConfigurationFileDirectories=agent-stuff Main main
$ ./main
Hello from file 1
Hello from file 2
Exception in thread "main" com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path myfile-3.txt without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.resources.MissingResourceRegistrationUtils.missingResource(MissingResourceRegistrationUtils.java:41)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.Resources.createInputStream(Resources.java:418)
at [email protected]/java.lang.Class.getResourceAsStream(DynamicHub.java:821)
at Main.main(Main.java:9)
at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
🟢 PASS GraalVM CE 22.0.1+8.1 (build 22.0.1+8-jvmci-b01)
$ rm -rf agent-stuff
$ java -agentlib:native-image-agent=config-output-dir=agent-stuff Main
Hello from file 1
Hello from file 2
File myfile-3.txt not found.
$ cat agent-stuff/resource-config.json
{
"resources":{
"includes":[{
"pattern":"\\Qmyfile-1.txt\\E"
}, {
"pattern":"\\Qmyfile-2.txt\\E"
}, {
"pattern":"\\Qmyfile-3.txt\\E"
}]},
"bundles":[]
}
$ native-image -H:+UnlockExperimentalVMOptions -H:ThrowMissingRegistrationErrors= -H:ConfigurationFileDirectories=agent-stuff Main main
$ ./main
Hello from file 1
Hello from file 2
File myfile-3.txt not found.
🟢 PASS (Latest) Mandrel-24.2.0-dev6eefc9c7aae9 (build 24-beta+3-ea)
$ rm -rf agent-stuff
$ java -agentlib:native-image-agent=config-output-dir=agent-stuff Main
$ cat agent-stuff/reachability-metadata.json
{
"reflection":[
],
"resources":[{
"glob":"myfile-1.txt"
},{
"glob":"myfile-2.txt"
},{
"glob":"myfile-3.txt"
}],
"bundles":[],
"serialization":[
],
"jni":[
{
"type":"sun.launcher.LauncherHelper",
"fields":[{"name":"isStaticMain"},{"name":"noArgMain"}]
}
]
}
$ native-image -H:+UnlockExperimentalVMOptions -H:ThrowMissingRegistrationErrors= -H:ConfigurationFileDirectories=agent-stuff Main main
$ ./main
Hello from file 1
Hello from file 2
File myfile-3.txt not found.
from graal.
You are right, I probably mixed up the versions when reporting this. Updating the description accordingly. Thanks!
Update: On the other hand the logs clearly show 22.0.1
, perhaps I built an older graal version using JDK 22...
from graal.
The issue is fixed by backporting 2368a2f (part of #7827 which seems to include a number of other fixes probably worth backporting)
from graal.
Related Issues (20)
- native-image fails to set up Windows build environment HOT 2
- native-image not honoring abstract="true" and constructor overloading in the spring context.xml HOT 4
- Images with JFR will not build due to out of date substitution
- [GR-54994] Avoid duplicate JFR ThreadSleep events
- Native image fails to build inside Docker container on Mac with Apple Silicon using GraalVM CE 22.3.0 HOT 3
- Executable for JavaFX Modular CLI sample application built on Windows 11 with GraalVM 22.0.1+8.1 failed to run HOT 1
- Windows ARM64 Support HOT 1
- In my JNI library call a function in another share libray built by native-image, message : Segmentation fault HOT 3
- There is no way to know how to obtain the native-image binary tool. HOT 1
- MacOS only: Preferences.exportSubtree()/childrenNames() always kills process with "Fatal error reported via JNI: JVM_ArrayCopy called: Unimplemented" HOT 6
- [GR-55241] Performance regression of Scala compiler on GraalVM 17 -> 21 HOT 4
- GraalError: failed guarantee: value too large to fit into space HOT 1
- java.lang.Error: no ComponentUI class for: javax.swing.JRootPane HOT 4
- native-image-agent ceased to work as expected with AWT/JNI HOT 4
- [GR-55550] WASI signature conflict for fd_advise HOT 1
- native image fails to generate binary for a simple array manipulation HOT 1
- Cannot invoke "clojure.lang.Var.isBound()" because "clojure.lang.Compiler.LOADER" is null
- docker pull container-registry.oracle.com/graalvm/native-image -> UNAUTHORIZED HOT 1
- Fatal error: com.oracle.svm.core.util.VMError$HostedError: guarantee failed
- MacOS only: System.getProperty("os.arch") is "x86_64" from JVM and then "amd64" from native image.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graal.