{"record":{"id":"c4e8529c2e2fa31a","repo":"apache/beam","slug":"unable-to-generate-a-getter-for-getter-method","errorCode":null,"errorMessage":"Unable to generate a getter for getter '${method}'","messagePattern":"Unable to generate a getter for getter '(.+?)'","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoByteBuddyUtils.java","lineNumber":564,"sourceCode":"                Visibility.PRIVATE,\n                FieldManifestation.FINAL)\n            .defineConstructor(Modifier.PUBLIC)\n            .withParameters(List.class, OneOfType.class)\n            .intercept(new OneOfGetterConstructor());\n\n    try {\n      return builder\n          .visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))\n          .make()\n          .load(targetClass.getClassLoader(), getClassLoadingStrategy(targetClass))\n          .getLoaded()\n          .getDeclaredConstructor(List.class, OneOfType.class)\n          .newInstance(getters, oneOfType);\n    } catch (InstantiationException\n        | IllegalAccessException\n        | NoSuchMethodException\n        | InvocationTargetException e) {\n      throw new RuntimeException(\n          \"Unable to generate a getter for getter '\" + typeInformation.getMethod() + \"'\");\n    }\n  }\n\n  static <ProtoBuilderT extends MessageLite.Builder>\n      FieldValueSetter<ProtoBuilderT, Object> createOneOfSetter(\n          String name,\n          Map<Integer, FieldValueSetter<ProtoBuilderT, Object>> setterMethodMap,\n          Class<ProtoBuilderT> protoBuilderClass) {\n    Set<Integer> indices = setterMethodMap.keySet();\n    boolean contiguous = isContiguous(indices);\n    int[] keys = setterMethodMap.keySet().stream().mapToInt(Integer::intValue).toArray();\n\n    Class<?> targetClass = getLoadingTarget(protoBuilderClass);\n    @SuppressWarnings(\"unchecked\")\n    DynamicType.Builder<FieldValueSetter<ProtoBuilderT, Object>> builder =\n        (DynamicType.Builder<FieldValueSetter<ProtoBuilderT, Object>>)\n            BYTE_BUDDY","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoByteBuddyUtils.java#L546-L582","documentation":"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).","triggerScenarios":"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.","commonSituations":"Hardened JVMs / security managers or native-image environments blocking bytecode generation; Byte Buddy version incompatibility with the JDK; corrupt or unusual proto classes.","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"],"exampleFix":"// before\nbyteBuddy = new ByteBuddy().with(TypeValidation.DISABLED); // masks generation errors\n// after\nbyteBuddy = new ByteBuddy(); // enable validation & match JDK-compatible Byte Buddy version","handlingStrategy":"try-catch","validationCode":"// verify Byte Buddy can generate on this JVM before building schema\nif (!TypeDescription.ForLoadedType.of(Message.Builder.class).isAssignableTo(TypeDescription.ForLoadedType.of(MessageLite.Builder.class))) throw new IllegalStateException(\"unsupported builder type\");","typeGuard":null,"tryCatchPattern":"try { schema = ProtoSchemaLogicalTypeRegistration... } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unable to generate a getter\")) { /* fall back to reflection-based access */ } throw e; }","preventionTips":["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"],"tags":["protobuf","beam","byte-buddy","reflection"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}