{"record":{"id":"f569f14a705eab75","repo":"Tencent/tinker","slug":"file-is-null","errorCode":null,"errorMessage":"file is null.","messagePattern":"file is null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Dex.java","lineNumber":129,"sourceCode":"    }\n\n    /**\n     * Creates a new dex buffer of the dex in {@code in}, and closes {@code in}.\n     */\n    public Dex(InputStream in) throws IOException {\n        loadFrom(in);\n    }\n\n    public Dex(InputStream in, int initSize) throws IOException {\n        loadFrom(in, initSize);\n    }\n\n    /**\n     * Creates a new dex buffer from the dex file {@code file}.\n     */\n    public Dex(File file) throws IOException {\n        if (file == null) {\n            throw new IllegalArgumentException(\"file is null.\");\n        }\n\n        if (FileUtils.hasArchiveSuffix(file.getName())) {\n            ZipFile zipFile = null;\n            try {\n                zipFile = new ZipFile(file);\n                ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME);\n                if (entry != null) {\n                    InputStream inputStream = null;\n                    try {\n                        inputStream = zipFile.getInputStream(entry);\n                        loadFrom(inputStream, (int) entry.getSize());\n                    } finally {\n                        if (inputStream != null) {\n                            inputStream.close();\n                        }\n                    }\n                } else {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Dex.java#L111-L147","documentation":"Thrown by the Dex(File) constructor when the File argument is null. This is a plain argument-contract failure before any I/O happens: the library refuses to guess what to load. All other constructors (InputStream, byte[], ByteBuffer) bypass this check.","triggerScenarios":"Calling new Dex((File) null) or new Dex(file, MUTF_8?) style overloads with a null File — typically the result of a failed lookup (e.g. zip extraction returned null, a path variable never set) passed straight into the constructor.","commonSituations":"Patch/build scripts where the dex path comes from an environment variable, gradle task input, or a previous step that silently produced no file; refactorings that changed the variable being passed.","solutions":["Check the upstream step that produced the File — it is null because a download, unzip, or path resolution failed; fix that first.","Add an explicit null/exists() check before constructing Dex and fail with a descriptive message naming the expected path.","If null is a legitimate state in your flow, branch to a different code path instead of relying on the constructor to validate."],"exampleFix":"// before\nDex dex = new Dex(maybeNullFile);\n\n// after\nif (file == null || !file.exists()) {\n    throw new IllegalStateException(\"dex input missing: \" + expectedPath);\n}\nDex dex = new Dex(file);","handlingStrategy":"validation","validationCode":"if (file == null) throw new IllegalArgumentException(\"dex file path unresolved: \" + describedSource);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve and assert file inputs at the boundary where they are produced, not deep inside parsing code.","Log the expected path when a File lookup fails so the null is diagnosable at its origin."],"tags":["dex","null-check","constructor","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}