{"record":{"id":"f96631d30f0b3f4a","repo":"HMCL-dev/HMCL","slug":"failed-to-load-javafx-cache","errorCode":null,"errorMessage":"Failed to load JavaFX cache","messagePattern":"Failed to load JavaFX cache","errorType":"exception","errorClass":"PatchException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/util/SelfDependencyPatcher.java","lineNumber":190,"sourceCode":"\n        // Otherwise we're free to download in Java 11+\n        LOG.info(\"Missing JavaFX dependencies, attempting to patch in missing classes\");\n\n        // Download missing dependencies\n        List<DependencyDescriptor> missingDependencies = patcher.checkMissingDependencies();\n        if (!missingDependencies.isEmpty()) {\n            try {\n                patcher.fetchDependencies(missingDependencies);\n            } catch (IOException e) {\n                throw new PatchException(\"Failed to download dependencies\", e);\n            }\n        }\n\n        // Add the dependencies\n        try {\n            patcher.loadFromCache();\n        } catch (IOException ex) {\n            throw new PatchException(\"Failed to load JavaFX cache\", ex);\n        } catch (ReflectiveOperationException | NoClassDefFoundError ex) {\n            throw new PatchException(\"Failed to add dependencies to classpath!\", ex);\n        }\n        LOG.info(\" - Done!\");\n    }\n\n    private Repository showChooseRepositoryDialog() {\n        final JPanel panel = new JPanel();\n        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));\n\n        for (String line : i18n(\"repositories.chooser\").split(\"\\n\")) {\n            panel.add(new JLabel(line));\n        }\n\n        final ButtonGroup buttonGroup = new ButtonGroup();\n\n        for (Repository repository : repositories) {\n            final JRadioButton button = new JRadioButton(repository.name);","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/util/SelfDependencyPatcher.java#L172-L208","documentation":"After downloading JavaFX dependencies, patch() loads them from the local cache via loadFromCache(). If that step throws IOException (unreadable/corrupt cached jars), it is rethrown as this PatchException, meaning the cached JavaFX modules could not be read back.","triggerScenarios":"patch() calls loadFromCache() and it throws IOException — cache directory unreadable, cached JARs corrupted or deleted mid-read, or permission problems on the cache files.","commonSituations":"Corrupt cache after an interrupted download; cache files with wrong permissions; antivirus locking the cache directory; cache cleared between download and load.","solutions":["Delete the HMCL JavaFX cache directory and rerun so dependencies are re-downloaded","Fix filesystem permissions on the cache directory/user home","Exclude the cache directory from antivirus scanning","Fall back to a JDK with bundled JavaFX to bypass caching entirely"],"exampleFix":"// before\n# corrupt cache\nrm -rf ~/.hmcl/cache/openjfx   # or HMCL's javafx cache location\njava -jar HMCL.jar\n// after: cache rebuilt automatically; alternatively:\n/path/to/jdk-with-javafx/bin/java -jar HMCL.jar","handlingStrategy":"try-catch","validationCode":"Path cacheDir = Path.of(System.getProperty(\"user.home\"), \".hmcl\", \"openjfx-cache\");\nif (Files.isDirectory(cacheDir) && !Files.isReadable(cacheDir)) {\n    LOG.warning(\"JavaFX cache unreadable; delete it and rerun\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    SelfDependencyPatcher.patchIfNeeded();\n} catch (PatchException e) {\n    if (e.getMessage().contains(\"cache\")) {\n        // delete corrupt cache and retry once\n        FileUtils.deleteDirectory(cacheDir);\n        SelfDependencyPatcher.patchIfNeeded();\n    }\n}","preventionTips":["Do not interrupt HMCL while it downloads JavaFX dependencies","Keep the cache directory writable and free of antivirus locks","Clear the cache after JVM crashes to avoid stale corrupt files"],"tags":["cache","javafx","io"],"backgroundTag":"file-read-failed","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}