apache/beam · error · java.lang.RuntimeException
Unable to generate a getter for getter
Error message
Unable to generate a getter for getter '${method}' What it means
ProtoByteBuddyUtils.createOneOfGetter uses Byte Buddy to generate a getter class for a oneof field at runtime. If instantiating the generated class (via its List/OneOfType constructor) fails with InstantiationException, IllegalAccessException, NoSuchMethodException, or InvocationTargetException, a RuntimeException is thrown naming the method. Note the original reflective exception is dropped here (no cause attached).
Solutions
- Upgrade/align Byte Buddy with the running JDK version
- Run on a standard JVM that permits Byte Buddy bytecode generation (disable restrictive agents/security managers)
- Log/diagnose the suppressed reflective exception by reproducing outside the wrapper
- Fall back to a non-ByteBuddy proto schema path or hand-write the field access for the affected message
Example fix
// before byteBuddy = new ByteBuddy().with(TypeValidation.DISABLED); // masks generation errors // after byteBuddy = new ByteBuddy(); // enable validation & match JDK-compatible Byte Buddy version
Defensive patterns
Strategy: try-catch
Validate before calling
// verify Byte Buddy can generate on this JVM before building schema
if (!TypeDescription.ForLoadedType.of(Message.Builder.class).isAssignableTo(TypeDescription.ForLoadedType.of(MessageLite.Builder.class))) throw new IllegalStateException("unsupported builder type"); Try / catch
try { schema = ProtoSchemaLogicalTypeRegistration... } catch (RuntimeException e) { if (e.getMessage().startsWith("Unable to generate a getter")) { /* fall back to reflection-based access */ } throw e; } Prevention
- Keep Byte Buddy updated for the target JDK
- Avoid sandboxed/native runtimes for schema generation
- Smoke-test schema generation in CI on the production JDK
When it happens
Trigger: Building a proto schema for a message with a oneof field where Byte Buddy-generated getter instantiation fails — e.g. restricted JVM environment, Byte Buddy/ByteBuddy agent limitations, or an incompatible generated-constructor signature.
Common situations: Hardened JVMs / security managers or native-image environments blocking bytecode generation; Byte Buddy version incompatibility with the JDK; corrupt or unusual proto classes.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Unable to generate a creator for class
- Unable to generate a setter for setter
- bad decode
- bad encode
- bad type: , want
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/c4e8529c2e2fa31a.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoByteBuddyUtils.java:564
Visibility.PRIVATE,
FieldManifestation.FINAL)
.defineConstructor(Modifier.PUBLIC)
.withParameters(List.class, OneOfType.class)
.intercept(new OneOfGetterConstructor());
try {
return builder
.visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))
.make()
.load(targetClass.getClassLoader(), getClassLoadingStrategy(targetClass))
.getLoaded()
.getDeclaredConstructor(List.class, OneOfType.class)
.newInstance(getters, oneOfType);
} catch (InstantiationException
| IllegalAccessException
| NoSuchMethodException
| InvocationTargetException e) {
throw new RuntimeException(
"Unable to generate a getter for getter '" + typeInformation.getMethod() + "'");
}
}
static <ProtoBuilderT extends MessageLite.Builder>
FieldValueSetter<ProtoBuilderT, Object> createOneOfSetter(
String name,
Map<Integer, FieldValueSetter<ProtoBuilderT, Object>> setterMethodMap,
Class<ProtoBuilderT> protoBuilderClass) {
Set<Integer> indices = setterMethodMap.keySet();
boolean contiguous = isContiguous(indices);
int[] keys = setterMethodMap.keySet().stream().mapToInt(Integer::intValue).toArray();
Class<?> targetClass = getLoadingTarget(protoBuilderClass);
@SuppressWarnings("unchecked")
DynamicType.Builder<FieldValueSetter<ProtoBuilderT, Object>> builder =
(DynamicType.Builder<FieldValueSetter<ProtoBuilderT, Object>>)
BYTE_BUDDYView on GitHub (pinned to 12126d8942)