{"record":{"id":"8f0ff426d6b9cb26","repo":"apache/beam","slug":"no-code-generation-strategy-available","errorCode":null,"errorMessage":"No code generation strategy available","messagePattern":"No code generation strategy available","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java","lineNumber":714,"sourceCode":"            checkStateNotNull(\n                methodHandles.getMethod(\"lookup\").invoke(nullObjectForStaticMethodInvocation),\n                \"'MethodHandles.lookup' declared available, but lookup returned null\");\n\n        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 {","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java#L696-L732","documentation":"ByteBuddy needs a ClassLoadingStrategy to load the generated invoker class. The factory prefers MethodHandles.Lookup.privateLookupIn, then falls back to reflection-based class injection; if neither is available on the JVM it throws this IllegalStateException.","triggerScenarios":"Running on a JVM where privateLookupIn is unavailable AND ClassInjector.UsingReflection.isAvailable() returns false — heavily restricted or AOT environments.","commonSituations":"GraalVM native-image or other AOT compilation where runtime class generation is disabled; exotic JVMs; sandboxed serverless runtimes.","solutions":["Run on a standard supported JDK (8-17+) where ByteBuddy can use privateLookupIn or reflection injection.","Use a runner/execution path that does not rely on runtime bytecode generation, or pre-generate invokers.","Upgrade Beam/ByteBuddy to a version supporting your runtime; for native-image, configure substitutions or avoid AOT for this code path."],"exampleFix":"// before\n// GraalVM native-image: IllegalStateException: No code generation strategy available\n// after\n// run on a standard JVM instead of native-image\njava -jar app.jar","handlingStrategy":"fallback","validationCode":"boolean canGenerate = ClassInjector.UsingReflection.isAvailable();","typeGuard":null,"tryCatchPattern":"try {\n  invoker = ByteBuddyDoFnInvokerFactory.newByteBuddyInvoker(fn);\n} catch (IllegalStateException e) {\n  if (\"No code generation strategy available\".equals(e.getMessage())) {\n    throw new UnsupportedOperationException(\"Runtime requires a JVM with class generation support\", e);\n  }\n  throw e;\n}","preventionTips":["Run workers on a standard HotSpot/OpenJDK JVM, not GraalVM native-image or AOT environments.","Smoke-test invoker creation at startup before processing data.","For restricted runtimes, pre-generate or cache invoker classes where the API allows."],"tags":["java","apache-beam","bytebuddy","jvm","classloading"],"backgroundTag":"unsupported-platform","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}