{"record":{"id":"767d92bcc8ee54c6","repo":"pxb1988/dex2jar","slug":"while-accept-annotation-in-field-s","errorCode":null,"errorMessage":"while accept annotation in field:%s.","messagePattern":"while accept annotation in field:(.+?)\\.","errorType":"exception","errorClass":"DexException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java","lineNumber":999,"sourceCode":"        return getString(typeIdIn.getInt(id * 4));\r\n    }\r\n\r\n    private int acceptField(ByteBuffer in, int lastIndex, DexClassVisitor dcv,\r\n            Map<Integer, Integer> fieldAnnotationPositions, Object value, int config) {\r\n        int diff = readULeb128i(in);\r\n        int field_access_flags = readULeb128i(in);\r\n        int field_id = lastIndex + diff;\r\n        Field field = getField(field_id);\r\n        // //////////////////////////////////////////////////////////////\r\n        DexFieldVisitor dfv = dcv.visitField(field_access_flags, field, value);\r\n        if (dfv != null) {\r\n            if ((config & SKIP_ANNOTATION) == 0) {\r\n                Integer annotation_offset = fieldAnnotationPositions.get(field_id);\r\n                if (annotation_offset != null) {\r\n                    try {\r\n                        read_annotation_set_item(annotation_offset, dfv);\r\n                    } catch (Exception e) {\r\n                        throw new DexException(e, \"while accept annotation in field:%s.\", field.toString());\r\n                    }\r\n                }\r\n            }\r\n            dfv.visitEnd();\r\n        }\r\n        // //////////////////////////////////////////////////////////////\r\n        return field_id;\r\n    }\r\n\r\n    private int acceptMethod(ByteBuffer in, int lastIndex, DexClassVisitor cv, Map<Integer, Integer> methodAnnos,\r\n            Map<Integer, Integer> parameterAnnos, int config, boolean firstMethod) {\r\n        int offset = in.position();\r\n        int diff = readULeb128i(in);\r\n        int method_access_flags = readULeb128i(in);\r\n        int code_off = readULeb128i(in);\r\n        int method_id = lastIndex + diff;\r\n        Method method = getMethod(method_id);\r\n\r","sourceCodeStart":981,"sourceCodeEnd":1017,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java#L981-L1017","documentation":"While visiting a field, DexFileReader wraps any exception from read_annotation_set_item in DexException('while accept annotation in field:%s.', field) naming the field via its DexField toString. The annotation_set_item at the recorded offset failed to decode. The root cause is in the exception's cause chain.","triggerScenarios":"A field_annotation entry whose annotations_off points to malformed annotation data (bad encoded_value bytes, offset out of bounds); reading an obfuscated or corrupted dex where field annotation offsets were mangled.","commonSituations":"Packed/protected APKs from app stores; dex rewritten by repackaging tools that moved sections without fixing offsets; dex2jar pipelines converting such apps.","solutions":["Unwrap and inspect getCause() to find the actual annotation decode failure","Rebuild the dex from source with d8/dx to regenerate valid annotation offsets","Construct the reader with SKIP_ANNOTATION in the config to bypass annotation decoding entirely","If the app is packed, unpack/deprotect it first before running dex analysis"],"exampleFix":"// before\nDexFileReader reader = new DexFileReader(file, 0);\n// after\nDexFileReader reader = new DexFileReader(file, DexFileReader.SKIP_ANNOTATION);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    new DexFileReader(file, config).accept(visitor);\n} catch (DexException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"while accept annotation in field:\")) {\n        String field = e.getMessage().substring(\"while accept annotation in field:\".length());\n        log.warn(\"Skipping annotations of field \" + field, e.getCause());\n        return parseSkippingAnnotations(file); // retry with SKIP_ANNOTATION\n    }\n    throw e;\n}","preventionTips":["Inspect getCause() first — this wrapper hides the real decode error","Use SKIP_ANNOTATION config when annotation fidelity is not required","Validate APK/dex integrity before analysis; repackagers frequently corrupt field annotation offsets"],"tags":["dex","annotation","field"],"backgroundTag":"file-read-failed","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}