{"record":{"id":"5c7f78d1315fd6e6","repo":"HMCL-dev/HMCL","slug":"unrecognized-installer","errorCode":null,"errorMessage":"Unrecognized installer","messagePattern":"Unrecognized installer","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineInstallTask.java","lineNumber":271,"sourceCode":"    /// Creates a task that installs OptiFine from a local installer JAR.\n    ///\n    /// @param dependencyManager repository-scoped download services\n    /// @param manifest           working manifest receiving the OptiFine patch\n    /// @param gameVersion       Minecraft version expected by the installation\n    /// @param installer         the OptiFine installer JAR\n    /// @return the task producing the OptiFine patch\n    /// @throws IOException              if the installer is malformed or unsupported\n    /// @throws VersionMismatchException if the installer targets another Minecraft version\n    public static Task<GameInstancePatch> install(\n            DefaultDependencyManager dependencyManager,\n            GameInstanceManifest manifest,\n            String gameVersion,\n            Path installer) throws IOException, VersionMismatchException {\n        try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(installer)) {\n            Path configClass = fs.getPath(\"Config.class\");\n            if (!Files.exists(configClass)) configClass = fs.getPath(\"net/optifine/Config.class\");\n            if (!Files.exists(configClass)) configClass = fs.getPath(\"notch/net/optifine/Config.class\");\n            if (!Files.exists(configClass)) throw new IOException(\"Unrecognized installer\");\n            ConstantPool pool = ConstantPoolScanner.parse(Files.readAllBytes(configClass), ConstantType.UTF8);\n            List<String> constants = new ArrayList<>();\n            pool.list(Utf8Constant.class).forEach(utf8 -> constants.add(utf8.get()));\n            String mcVersion = getOrDefault(constants, constants.indexOf(\"MC_VERSION\") + 1, null);\n            String ofEdition = getOrDefault(constants, constants.indexOf(\"OF_EDITION\") + 1, null);\n            String ofRelease = getOrDefault(constants, constants.indexOf(\"OF_RELEASE\") + 1, null);\n\n            if (mcVersion == null || ofEdition == null || ofRelease == null)\n                throw new IOException(\"Unrecognized OptiFine installer\");\n\n            if (!mcVersion.equals(gameVersion))\n                throw new VersionMismatchException(mcVersion, gameVersion);\n\n            OptiFineRemoteVersion remoteVersion = new OptiFineRemoteVersion(\n                    mcVersion,\n                    ofEdition + \"_\" + ofRelease,\n                    Collections.singletonList(\"\"),\n                    false);","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineInstallTask.java#L253-L289","documentation":"Thrown during install() when the OptiFine installer jar contains no recognizable Config.class at any of the three known locations (root, net/optifine, notch/net/optifine). The installer's structure is not one HMCL can parse to extract MC_VERSION/OF_EDITION/OF_RELEASE.","triggerScenarios":"Opening the installer zip and probing for Config.class, net/optifine/Config.class, notch/net/optifine/Config.class — none exist, meaning the file is not actually an OptiFine installer (wrong jar passed as `installer` argument).","commonSituations":"User selects an arbitrary mod or OptiFabric jar instead of the OptiFine installer, downloads an HTML error page named .jar, or OptiFine changes packaging in future builds.","solutions":["Ensure the file is a genuine OptiFine installer downloaded from optifine.net (e.g. OptiFine_1.20.1_HD_U_I6.jar).","Check the jar contains a Config.class entry (open with an archive tool).","Re-download the installer; avoid unofficial mirrors that serve wrong files."],"exampleFix":"// before\nif (!Files.exists(configClass)) throw new IOException(\"Unrecognized installer\");\n// after\nif (!Files.exists(configClass))\n    throw new IOException(\"Unrecognized installer: \" + installer.getFileName()\n        + \" is not an OptiFine installer (Config.class not found)\");","handlingStrategy":"validation","validationCode":"try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(installer)) {\n    boolean isOptiFine = Files.exists(fs.getPath(\"Config.class\"))\n        || Files.exists(fs.getPath(\"net/optifine/Config.class\"))\n        || Files.exists(fs.getPath(\"notch/net/optifine/Config.class\"));\n    if (!isOptiFine) throw new IllegalArgumentException(\"Not an OptiFine installer: \" + installer);\n}","typeGuard":null,"tryCatchPattern":"try {\n    await(task);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().equals(\"Unrecognized installer\")) {\n        // prompt user to select a genuine OptiFine_*_HD_U_*.jar\n    }\n}","preventionTips":["Only download installers from optifine.net","Verify the jar contains Config.class before installing","Do not pass OptiFabric or mod jars to the installer task"],"tags":["optifine","installer","jar-structure","wrong-file"],"backgroundTag":"invalid-argument-format","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"}