{"record":{"id":"76bd9ea565989232","repo":"Tencent/matrix","slug":"method-fieldname-is-not-exists","errorCode":null,"errorMessage":"Method <fieldName> is not exists.","messagePattern":"Method <fieldName> is not exists\\.","errorType":"exception","errorClass":"NoSuchFieldException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/util/ReflectFiled.java","lineNumber":127,"sourceCode":"        } catch (IllegalAccessException e) {\n            MatrixLog.i(TAG, \"getWithoutThrow, exception occur :%s\", e);\n        } catch (IllegalArgumentException e) {\n            MatrixLog.i(TAG, \"getWithoutThrow, exception occur :%s\", e);\n        }\n        return fieldVal;\n    }\n\n    public synchronized boolean set(Object instance, Type val) throws NoSuchFieldException, IllegalAccessException,\n            IllegalArgumentException {\n        return set(instance, val, false);\n    }\n\n    public synchronized boolean set(Object instance, Type val, boolean ignoreFieldNoExist)\n            throws NoSuchFieldException, IllegalAccessException, IllegalArgumentException {\n        prepare();\n        if (mField == null) {\n            if (!ignoreFieldNoExist) {\n                throw new NoSuchFieldException(\"Method \" + mFieldName + \" is not exists.\");\n            }\n            MatrixLog.w(TAG, String.format(\"Field %s is no exists.\", mFieldName));\n            return false;\n        }\n        mField.set(instance, val);\n        return true;\n    }\n\n\n    public synchronized boolean setWithoutThrow(Object instance, Type val) {\n        boolean result = false;\n        try {\n            result = set(instance, val, true);\n        } catch (NoSuchFieldException e) {\n            MatrixLog.i(TAG, \"setWithoutThrow, exception occur :%s\", e);\n        } catch (IllegalAccessException e) {\n            MatrixLog.i(TAG, \"setWithoutThrow, exception occur :%s\", e);\n        } catch (IllegalArgumentException e) {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/util/ReflectFiled.java#L109-L145","documentation":"ReflectFiled.set() throws NoSuchFieldException with the (mis-worded) message \"Method <fieldName> is not exists.\" when prepare() failed to resolve the requested field and ignoreFieldNoExist is false. It signals that the target class does not declare a field with the configured name.","triggerScenarios":"Calling set(instance, value, false) where mFieldName does not exist on the target class — wrong field name, field removed by ProGuard/R8 obfuscation, or field renamed between versions.","commonSituations":"Typo'd field names; reflecting on obfuscated classes without keep rules; library upgrades renaming private/internal fields; targeting the wrong class in a hierarchy (field declared only in a subclass/superclass).","solutions":["Correct the field name passed to the ReflectFiled constructor","Add ProGuard keep rules for the target class/field if obfuscation strips it","Pass ignoreFieldNoExist=true when the field is optional, then check the boolean return","Use setWithoutThrow() to swallow the miss and log instead of throwing","Verify the field exists via clazz.getDeclaredField(name) during development/debugging"],"exampleFix":"// before\nReflectFiled<String> f = new ReflectFiled<>(Foo.class, \"namme\");\nf.set(instance, \"x\", false); // throws\n\n// after\nReflectFiled<String> f = new ReflectFiled<>(Foo.class, \"name\");\nboolean ok = f.set(instance, \"x\", true);\nif (!ok) { MatrixLog.w(TAG, \"field missing, skipped\"); }","handlingStrategy":"try-catch","validationCode":"try {\n    clazz.getDeclaredField(fieldName);\n} catch (NoSuchFieldException e) {\n    // field missing: fix the name or add keep rules before using set()\n}","typeGuard":"boolean fieldExists;\ntry { clazz.getDeclaredField(fieldName); fieldExists = true; }\ncatch (NoSuchFieldException e) { fieldExists = false; }","tryCatchPattern":"try {\n    reflectFiled.set(instance, value, false);\n} catch (NoSuchFieldException e) {\n    Log.w(TAG, \"field not found: \" + reflectFiled.getFieldName(), e);\n}","preventionTips":["Pass ignoreFieldNoExist=true for optional fields and check the return value","Use setWithoutThrow() when absence is acceptable","Add ProGuard/R8 keep rules for reflected classes and fields","Verify field names against the exact target class version"],"tags":["reflection","android","field-not-found","proguard"],"backgroundTag":"resource-not-found","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}