{"record":{"id":"dc5f434eca7fb7ef","repo":"Anuken/Mindustry","slug":"type-getsimplename-not-found-name","errorCode":null,"errorMessage":"${type.getSimpleName()}: not found: '${name}'","messagePattern":"(.+?): not found: '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/mod/ContentParser.java","lineNumber":1231,"sourceCode":"            throw new RuntimeException(e);\n        }\n    }\n\n    Prov<UnitController> resolveController(String type){\n        //this is used as a captured value to avoid parsing it multiple times\n        var controller = supply(resolve(type, FlyingAI.class));\n        return controller::get;\n    }\n\n    Object field(Class<?> type, JsonValue value){\n        return field(type, value.asString());\n    }\n\n    /** Gets a field from a static class by name, throwing a descriptive exception if not found. */\n    private Object field(Class<?> type, String name){\n        try{\n            Object b = type.getField(name).get(null);\n            if(b == null) throw new IllegalArgumentException(type.getSimpleName() + \": not found: '\" + name + \"'\");\n            return b;\n        }catch(Exception e){\n            throw new RuntimeException(e);\n        }\n    }\n    Object fieldOpt(Class<?> type, JsonValue value){\n        try{\n            return type.getField(value.asString()).get(null);\n        }catch(Exception e){\n            return null;\n        }\n    }\n\n    void checkNullFields(Object object){\n        if(object == null || object instanceof Number || object instanceof String || toBeParsed.contains(object) || object.getClass().getName().startsWith(\"arc.\")) return;\n\n        parser.getFields(object.getClass()).values().toSeq().each(field -> {\n            try{","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/mod/ContentParser.java#L1213-L1249","documentation":"field(Class, name) reads a static field by reflection via type.getField(name).get(null). If the field is absent or resolves to null, it throws IllegalArgumentException with the class and field name. Note: because the catch(Exception) wraps NoSuchFieldException too, the message ('not found') can be emitted either by the explicit null check or by the wrapped reflection exception.","triggerScenarios":"A JSON reference names a static field that does not exist on the target class (e.g. an item/block/color constant), or exists but holds null.","commonSituations":"Referencing a color constant, item, or block by a name that isn't a public static field on the resolved class; typo; using a field from the wrong class.","solutions":["Verify the field name is a public static member of the target class.","Correct typos against the class's source.","Ensure the field is non-null at parse time."],"exampleFix":"// before\nfield(Items.class, \"coper\")\n// after\nfield(Items.class, \"copper\")","handlingStrategy":"try-catch","validationCode":"// Check the static field exists and is non-null before reading.\ntry {\n    java.lang.reflect.Field f = type.getField(name);\n    if(f.get(null) == null) throw new IllegalStateException(type.getSimpleName() + \".\" + name + \" is null\");\n} catch(NoSuchFieldException e){\n    throw new IllegalStateException(type.getSimpleName() + \" has no field '\" + name + \"'\");\n}","typeGuard":"boolean hasStaticField(Class<?> type, String name){\n    try { return type.getField(name).get(null) != null; }\n    catch(Exception e){ return false; }\n}","tryCatchPattern":"try { Object v = field(MyClass.class, \"NAME\"); }\ncatch(RuntimeException e){ /* field() wraps NoSuchFieldException; log and degrade */ Log.err(e); }","preventionTips":["Reference only public static non-null fields.","Use fieldOpt() when a missing field should not be fatal."],"tags":["mindustry","modding","json","content-parser","reflection","missing-field"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}