{"record":{"id":"f0789458b6c9ebd8","repo":"NationalSecurityAgency/ghidra","slug":"type-does-not-have-a-default-codec-please-speci","errorCode":null,"errorMessage":"{type} does not have a default codec. Please specify a codec.","messagePattern":"(.+?) does not have a default codec\\. Please specify a codec\\.","errorType":"exception","errorClass":"NoDefaultCodecException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStoreFactory.java","lineNumber":1263,"sourceCode":"\t\t\treturn IntDBFieldCodec.class;\n\t\t}\n\t\tif (type == long.class || type == Long.class) {\n\t\t\treturn LongDBFieldCodec.class;\n\t\t}\n\t\tif (type == String.class) {\n\t\t\treturn StringDBFieldCodec.class;\n\t\t}\n\t\tif (type == byte[].class) {\n\t\t\treturn ByteArrayDBFieldCodec.class;\n\t\t}\n\t\t// TODO: Other primitive arrays?\n\t\tif (type == long[].class) {\n\t\t\treturn LongArrayDBFieldCodec.class;\n\t\t}\n\t\tif (Enum.class.isAssignableFrom(type)) {\n\t\t\treturn EnumDBByteFieldCodec.class;\n\t\t}\n\t\tthrow new NoDefaultCodecException(\n\t\t\ttype + \" does not have a default codec. Please specify a codec.\");\n\t}\n\n\t/**\n\t * Construct the codec for the given field\n\t * \n\t * <p>\n\t * This adheres to the custom codec, if specified on the fields annotation.\n\t * \n\t * @param <OT> the type of objects being described\n\t * @param objectType the class describing {@link OT}\n\t * @param field the field to encode and decode\n\t * @param column the column number in the record\n\t * @return the codec\n\t * @throws IllegalArgumentException if the selected codec's constructor does not have the\n\t *             required signature\n\t */\n\t@SuppressWarnings({ \"unchecked\" })","sourceCodeStart":1245,"sourceCodeEnd":1281,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStoreFactory.java#L1245-L1281","documentation":"getDefaultCodecClass returns a built-in DBFieldCodec for a fixed set: boolean/Boolean, byte/Byte, short/Short, int/Integer, long/Long, String, byte[], long[], and Enum subtypes. Any other field type has no default codec, so the factory throws NoDefaultCodecException (a RuntimeException) telling you to supply one via @DBAnnotatedField(codec=...).","triggerScenarios":"A @DBAnnotatedField whose Java type is outside the supported set AND whose annotation codec() is still the DefaultCodec sentinel. Common offenders: double/Double, float/Float, char[], other primitive arrays, BigDecimal/BigInteger, a custom POJO, or nested collections.","commonSituations":"Adding a double or custom-type field to a DBAnnotatedObject; using a primitive array other than byte[]/long[]; storing a complex object without writing a codec.","solutions":["Specify a codec explicitly: @DBAnnotatedField(column=\"x\", codec=YourCodec.class).","If a matching DBFieldCodec already exists in the codebase, reuse it.","Implement a new DBFieldCodec for the custom type and reference it.","Alternatively, change the field to a supported type (e.g. encode a double as long bits, or store a custom object as byte[])."],"exampleFix":"// before\n@DBAnnotatedField(column=\"amt\")\ndouble amt;\n// after (illustrative; use a real DBFieldCodec for double)\n@DBAnnotatedField(column=\"amt\", codec=DoubleAsLongCodec.class)\ndouble amt;","handlingStrategy":"validation","validationCode":"Set<Class<?>> supported = Set.of(boolean.class, Boolean.class, byte.class, Byte.class,\n    short.class, Short.class, int.class, Integer.class, long.class, Long.class,\n    String.class, byte[].class, long[].class);\nfor (Field f : objectType.getDeclaredFields()) {\n    DBAnnotatedField a = f.getAnnotation(DBAnnotatedField.class);\n    if (a == None) continue;\n    boolean isEnum = Enum.class.isAssignableFrom(f.getType());\n    if (a.codec() == DefaultCodec.class && !supported.contains(f.getType()) && !isEnum) {\n        throw new IllegalStateException(\"Field needs an explicit codec: \" + f);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    factory.getStore(MyObj.class);\n} catch (NoDefaultCodecException e) {\n    // set an explicit codec on the offending @DBAnnotatedField, then retry\n}","preventionTips":["Audit new @DBAnnotatedField types against the supported set; add an explicit codec for anything outside it.","Centralize custom DBFieldCodec implementations and reference them by class."],"tags":["database","codec","serialization","types"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}