{"record":{"id":"c55c3c53077bab2e","repo":"Tencent/tinker","slug":"getcurrentinstructionset-fail","errorCode":null,"errorMessage":"getCurrentInstructionSet fail:","messagePattern":"getCurrentInstructionSet fail:","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/SharePatchFileUtil.java","lineNumber":478,"sourceCode":"\n    /**\n     * change the jar file path as the makeDexElements do\n     * Android O change its path\n     *\n     * @param path\n     * @param optimizedDirectory\n     * @return\n     */\n    public static String optimizedPathFor(File path, File optimizedDirectory) {\n        if (ShareTinkerInternals.isAfterAndroidO()) {\n            // dex_location = /foo/bar/baz.jar\n            // odex_location = /foo/bar/oat/<isa>/baz.odex\n\n            String currentInstructionSet;\n            try {\n                currentInstructionSet = ShareTinkerInternals.getCurrentInstructionSet();\n            } catch (Exception e) {\n                throw new TinkerRuntimeException(\"getCurrentInstructionSet fail:\", e);\n            }\n\n            File parentFile = path.getParentFile();\n            String fileName = path.getName();\n            int index = fileName.lastIndexOf('.');\n            if (index > 0) {\n                fileName = fileName.substring(0, index);\n            }\n\n            String result = parentFile.getAbsolutePath() + \"/oat/\"\n                + currentInstructionSet + \"/\" + fileName + ShareConstants.ODEX_SUFFIX;\n            return result;\n        }\n\n        String fileName = path.getName();\n        if (!fileName.endsWith(ShareConstants.DEX_SUFFIX)) {\n            int lastDot = fileName.lastIndexOf(\".\");\n            if (lastDot < 0) {","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/SharePatchFileUtil.java#L460-L496","documentation":"SharePatchFileUtil.optimizedPathFor computes the /oat/<isa>/xxx.odex path on Android O+. It calls ShareTinkerInternals.getCurrentInstructionSet(); if that throws (reflection into VMRuntime or unreadable Build.CPU_ABI), it is rethrown as TinkerRuntimeException('getCurrentInstructionSet fail:'). The odex location cannot be computed without knowing the ISA, so this is fatal to the dex-opt step.","triggerScenarios":"Any exception inside getCurrentInstructionSet(): reflection failure calling VMRuntime.is64BitRuntime (hidden-API blocking on newer Android), Build.CPU_ABI returning empty or an unrecognized value, or class-not-found on heavily restricted ROMs.","commonSituations":"Non-SDK interface restrictions (Android 9+ greylist) breaking the VMRuntime reflection; emulators or obscure ABIs; proguard/R8 stripping or renaming touching the reflection path; running in processes where the runtime is atypical (isolated processes).","solutions":["Ensure tinker is up to date — newer versions read the ISA via supported APIs or cached values compatible with hidden-API restrictions.","Check whether your app targets a SDK where Build.CPU_ABI is deprecated/empty (API 21+ multi-ABI) and rely on tinker's own detection instead of custom pre-checks.","If you wrap this call yourself, catch TinkerRuntimeException and disable tinker's dex-opt path for that process (e.g. only load patch in the main process).","Verify no proguard rules keep-away the android.os classes or tinker reflection helpers."],"exampleFix":"// before\nString odexPath = SharePatchFileUtil.optimizedPathFor(dexFile, optDir); // fatal if isa lookup fails\n\n// after\nString odexPath;\ntry {\n    odexPath = SharePatchFileUtil.optimizedPathFor(dexFile, optDir);\n} catch (TinkerRuntimeException e) {\n    ShareTinkerLog.w(TAG, \"isa lookup failed, skip custom odex path\", e);\n    odexPath = new File(optDir, dexFile.getName() + \".odex\").getAbsolutePath();\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { path = SharePatchFileUtil.optimizedPathFor(dex, dir); } catch (TinkerRuntimeException e) { /* skip custom odex path, use default dir */ }","preventionTips":["Keep tinker (and its reflection targets) current for new Android hidden-API restrictions.","Do not invoke optimizedPathFor in isolated/unusual processes where VMRuntime reflection may fail.","Cache the instruction set once per process instead of repeated reflective lookups."],"tags":["reflection","hidden-api","instruction-set","android-o"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}