-
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 images throw MissingResourceRegistrationError
despite the resource being actually registered (but not present)
#9038
Comments
Thanks for reporting this issue. We will take care of it. |
@zakkak I am having trouble to reproduce it running latest native-image with my code snippet. Directory:
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)
🟢 PASS GraalVM CE 22.0.1+8.1 (build 22.0.1+8-jvmci-b01)
🟢 PASS (Latest) Mandrel-24.2.0-dev6eefc9c7aae9 (build 24-beta+3-ea)
|
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 |
Describe the issue
While working on quarkusio/quarkus#36378 I came across the following issue.
When using
-H:ThrowMissingRegistrationErrors= -H:MissingRegistrationReportingMode=Exit
at build time the resulting native image throws an exception if it tries to access a resource that is not available but was registered.The native image should not throw a missing registration error in that case, as the resource is actually registered (in
resource-config.json
) despite not existing.cc @vjovanov
Steps to reproduce the issue
This results in:
while I would expect it to result in:
Describe GraalVM and your environment:
More context:
My understanding is that the generated native images rely on the embedded resources map to throw these errors instead of a "registration" map. So if we register
*.txt
the native image will only know about the txt files that ended up being embedded in the native image (i.e. they were on the classpath), the current implementation can't understand that any*.txt
is actually registered...This is an issue for applications trying to load a resource that was not available at build time but can handle that case, e.g. trying to load a configuration and falling back on the default if it doesn't exist...
The text was updated successfully, but these errors were encountered: