NationalSecurityAgency/ghidra · error · NoDefaultCodecException

{type} does not have a default codec. Please specify a codec

Error message

{type} does not have a default codec. Please specify a codec.

What it means

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=...).

Source

Thrown at Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStoreFactory.java:1263

			return IntDBFieldCodec.class;
		}
		if (type == long.class || type == Long.class) {
			return LongDBFieldCodec.class;
		}
		if (type == String.class) {
			return StringDBFieldCodec.class;
		}
		if (type == byte[].class) {
			return ByteArrayDBFieldCodec.class;
		}
		// TODO: Other primitive arrays?
		if (type == long[].class) {
			return LongArrayDBFieldCodec.class;
		}
		if (Enum.class.isAssignableFrom(type)) {
			return EnumDBByteFieldCodec.class;
		}
		throw new NoDefaultCodecException(
			type + " does not have a default codec. Please specify a codec.");
	}

	/**
	 * Construct the codec for the given field
	 * 
	 * <p>
	 * This adheres to the custom codec, if specified on the fields annotation.
	 * 
	 * @param <OT> the type of objects being described
	 * @param objectType the class describing {@link OT}
	 * @param field the field to encode and decode
	 * @param column the column number in the record
	 * @return the codec
	 * @throws IllegalArgumentException if the selected codec's constructor does not have the
	 *             required signature
	 */
	@SuppressWarnings({ "unchecked" })

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Specify a codec explicitly: @DBAnnotatedField(column="x", codec=YourCodec.class).
  2. If a matching DBFieldCodec already exists in the codebase, reuse it.
  3. Implement a new DBFieldCodec for the custom type and reference it.
  4. Alternatively, change the field to a supported type (e.g. encode a double as long bits, or store a custom object as byte[]).

Example fix

// before
@DBAnnotatedField(column="amt")
double amt;
// after (illustrative; use a real DBFieldCodec for double)
@DBAnnotatedField(column="amt", codec=DoubleAsLongCodec.class)
double amt;
Defensive patterns

Strategy: validation

Validate before calling

Set<Class<?>> supported = Set.of(boolean.class, Boolean.class, byte.class, Byte.class,
    short.class, Short.class, int.class, Integer.class, long.class, Long.class,
    String.class, byte[].class, long[].class);
for (Field f : objectType.getDeclaredFields()) {
    DBAnnotatedField a = f.getAnnotation(DBAnnotatedField.class);
    if (a == None) continue;
    boolean isEnum = Enum.class.isAssignableFrom(f.getType());
    if (a.codec() == DefaultCodec.class && !supported.contains(f.getType()) && !isEnum) {
        throw new IllegalStateException("Field needs an explicit codec: " + f);
    }
}

Try / catch

try {
    factory.getStore(MyObj.class);
} catch (NoDefaultCodecException e) {
    // set an explicit codec on the offending @DBAnnotatedField, then retry
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/f0789458b6c9ebd8. Report an issue: GitHub.