apache/beam · critical · IllegalStateException
No code generation strategy available
Error message
No code generation strategy available
What it means
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.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/ByteBuddyDoFnInvokerFactory.java:714
checkStateNotNull(
methodHandles.getMethod("lookup").invoke(nullObjectForStaticMethodInvocation),
"'MethodHandles.lookup' declared available, but lookup returned null");
Method privateLookupIn =
methodHandles.getMethod(
"privateLookupIn",
Class.class,
Class.forName("java.lang.invoke.MethodHandles$Lookup"));
Object privateLookup =
checkStateNotNull(
privateLookupIn.invoke(nullObjectForStaticMethodInvocation, targetClass, lookup),
"MethodHandles.Lookup.privateLookupIn not available");
strategy = ClassLoadingStrategy.UsingLookup.of(privateLookup);
} else if (ClassInjector.UsingReflection.isAvailable()) {
strategy = ClassLoadingStrategy.Default.INJECTION;
} else {
throw new IllegalStateException("No code generation strategy available");
}
return strategy;
} catch (ReflectiveOperationException e) {
throw new LinkageError(e.getMessage(), e);
}
}
private static Implementation getRestrictionCoderDelegation(
TypeDescription doFnType, DoFnSignature signature) {
if (signature.processElement().isSplittable()) {
if (signature.getRestrictionCoder() == null) {
checkStateNotNull(
signature.getInitialRestriction(),
"@GetRestrictionCoder provided but @GetInitialRestriction not provided:"
+ " please add @GetInitialRestriction");
return MethodDelegation.to(
new DefaultRestrictionCoder(signature.getInitialRestriction().restrictionT()));
} else {View on GitHub (pinned to 12126d8942)
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.
Example fix
// before // GraalVM native-image: IllegalStateException: No code generation strategy available // after // run on a standard JVM instead of native-image java -jar app.jar
Defensive patterns
Strategy: fallback
Validate before calling
boolean canGenerate = ClassInjector.UsingReflection.isAvailable();
Try / catch
try {
invoker = ByteBuddyDoFnInvokerFactory.newByteBuddyInvoker(fn);
} catch (IllegalStateException e) {
if ("No code generation strategy available".equals(e.getMessage())) {
throw new UnsupportedOperationException("Runtime requires a JVM with class generation support", e);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: Running on a JVM where privateLookupIn is unavailable AND ClassInjector.UsingReflection.isAvailable() returns false — heavily restricted or AOT environments.
Common situations: GraalVM native-image or other AOT compilation where runtime class generation is disabled; exotic JVMs; sandboxed serverless runtimes.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- Unable to bind invoker for ${fnClass}
- ${e.getMessage()}
- Failed to locate required method ${className}.${methodName}
- Failed to locate ProcessContinuation.stop()
- No code generation strategy available
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8f0ff426d6b9cb26.
Report an issue: GitHub.