{"record":{"id":"a37cf5f21a31790c","repo":"apache/beam","slug":"e-getmessage","errorCode":null,"errorMessage":"${e.getMessage()}","messagePattern":"\\$\\{e\\.getMessage\\(\\)\\}","errorType":"exception","errorClass":"LinkageError","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java","lineNumber":718,"sourceCode":"        Method privateLookupIn =\n            methodHandles.getMethod(\n                \"privateLookupIn\",\n                Class.class,\n                Class.forName(\"java.lang.invoke.MethodHandles$Lookup\"));\n\n        Object privateLookup =\n            checkStateNotNull(\n                privateLookupIn.invoke(nullObjectForStaticMethodInvocation, targetClass, lookup),\n                \"MethodHandles.Lookup.privateLookupIn not available\");\n        strategy = ClassLoadingStrategy.UsingLookup.of(privateLookup);\n      } else if (ClassInjector.UsingReflection.isAvailable()) {\n        strategy = ClassLoadingStrategy.Default.INJECTION;\n      } else {\n        throw new IllegalStateException(\"No code generation strategy available\");\n      }\n      return strategy;\n    } catch (ReflectiveOperationException e) {\n      throw new LinkageError(e.getMessage(), e);\n    }\n  }\n\n  private static Implementation getRestrictionCoderDelegation(\n      TypeDescription doFnType, DoFnSignature signature) {\n    if (signature.processElement().isSplittable()) {\n      if (signature.getRestrictionCoder() == null) {\n        checkStateNotNull(\n            signature.getInitialRestriction(),\n            \"@GetRestrictionCoder provided but @GetInitialRestriction not provided:\"\n                + \" please add @GetInitialRestriction\");\n        return MethodDelegation.to(\n            new DefaultRestrictionCoder(signature.getInitialRestriction().restrictionT()));\n      } else {\n        return new DowncastingParametersMethodDelegation(\n            doFnType, signature.getRestrictionCoder().targetMethod());\n      }\n    } else {","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java#L700-L736","documentation":"While selecting a class-loading strategy for the generated invoker, any ReflectiveOperationException (e.g. from Lookup.privateLookupIn) is wrapped in a LinkageError whose message is just the original exception's message. It signals the JVM could not perform the reflective lookup needed to enable code generation.","triggerScenarios":"Lookup.privateLookupIn(targetClass, lookup) throws due to module access denial, or another reflective step in strategy selection fails on the current JVM.","commonSituations":"Java 9+ strong encapsulation without --add-opens; DoFn classes in a named module without the required --add-reads; container security managers.","solutions":["Add --add-opens / --add-reads JVM flags granting access to the relevant module/package (e.g. --add-opens java.base/java.lang=ALL-UNNAMED).","Move the DoFn classes to the classpath (unnamed module) instead of a named module.","Read e.getMessage() in the LinkageError to identify which reflective call failed and fix access for it."],"exampleFix":"// before\njava --module-path mods -m app/Main // LinkageError: access denied\n// after\njava --module-path mods --add-reads app=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -m app/Main","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  invoker = ByteBuddyDoFnInvokerFactory.newByteBuddyInvoker(fn);\n} catch (LinkageError e) {\n  LOG.error(\"Reflective lookup failed: \" + e.getMessage(), e);\n  throw e;\n}","preventionTips":["Add --add-opens/--add-reads flags when DoFns live in named modules on Java 9+.","Keep Beam classes on the classpath (unnamed module) rather than in named modules.","Read the LinkageError's message — it names the failing reflective operation."],"tags":["java","apache-beam","bytebuddy","jpms","reflection"],"backgroundTag":"module-init-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}