Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

I cannot start JavaFX app with images in FXML in a modular project  #441

@Octarine-J

Description

@Octarine-J

When an OpenJFX app uses Java 11 module system and UI is loaded from FXML that contains Images with URLs, it cannot be started. The reason is in this code in javafx/scene/image/Image.java:

if (!URL_QUICKMATCH.matcher(url).matches()) {
    final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    URL resource;
    if (url.charAt(0) == '/') {
        // FIXME: JIGSAW -- use Class.getResourceAsStream if resource is in a module
        resource = contextClassLoader.getResource(url.substring(1));
    } else {
        // FIXME: JIGSAW -- use Class.getResourceAsStream if resource is in a module
        resource = contextClassLoader.getResource(url);
    }
    if (resource == null) {
        throw new IllegalArgumentException("Invalid URL or resource not found");
    }
    return resource.toString();
}

Fix this already! It has been ages since Java 9 is released, and you still have these FIXMEs ?
This is a major issue, you cannot start the app from the IDE, nor a user can start the app with standard Java 11 options for modular apps (--module-path and --module).

I even can fix it myself if you give me authorization to do so.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions