public static void assignField(Field field, Object obj, Object value) throws IOException {
		Class<?> fieldType = field.getType();

		try {
			if (fieldType.isPrimitive() && NUM_CLASSES.contains(value.getClass())) {
				field.set(obj, value);
			}
			else {
				if (!fieldType.isInstance(value)) {
					throw new IOException("Bad conversion from %s to %s.%s:%s".formatted(
						value.getClass().getSimpleName(),
						obj.getClass().getSimpleName(),
						field.getName(),
						fieldType.getSimpleName()));
				}
				field.set(obj, value);
			}
		}
		catch (IllegalArgumentException | IllegalAccessException e) {
			throw new IOException(e);
		}
	}
Write a value to a field in a java class.

@param field reflection {@link Field}
@param obj java instance that contains the field 
@param value value to write
@throws IOException if error accessing field or converting value
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/structmapping/ReflectionHelper.java