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

  1. Upgrade/align Byte Buddy with the running JDK version
  2. Run on a standard JVM that permits Byte Buddy bytecode generation (disable restrictive agents/security managers)
  3. Log/diagnose the suppressed reflective exception by reproducing outside the wrapper
  4. 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

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


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_BUDDY

View on GitHub (pinned to 12126d8942)