pinpoint-apm/pinpoint · warning
unexpected {} invoke count {}
Error message
unexpected {} invoke count {} What it means
LambdaFactoryClassAdaptor.transform() replaces java/lang/invoke/LambdaMetafactory invocations with Pinpoint's LambdaFactory when instrumenting lambda call sites. It expects exactly one transformed invocation; if methodInstReplacer.getTransformCount() != 1, it warns 'unexpected {} invoke count {}' so the (possibly wrong) bytecode can be inspected. The class is still returned, but the lambda instrumentation may be incomplete or wrong.
Source
Thrown at agent-module/profiler-optional/profiler-optional-jdk8/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaFactoryClassAdaptor.java:72
return new LambdaClassJava8();
}
}
public byte[] transform(byte[] bytes, LambdaClass lambdaClass) {
Objects.requireNonNull(bytes, "bytes");
final ClassReader reader = new ClassReader(bytes);
final ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
final List<MethodInsn> methodInsnList = lambdaClass.getMethodInsnList();
final MethodInstReplacer methodInstReplacer = new MethodInstReplacer(writer, methodInsnList);
reader.accept(methodInstReplacer, 0);
if (!LAMBDA_FACTORY_CLASS_NAME.equals(methodInstReplacer.getClassName())) {
throw new IllegalArgumentException("unexpected class " + methodInstReplacer.getClassName());
}
if (methodInstReplacer.getTransformCount() != 1) {
logger.warn("unexpected {} invoke count {}", methodInsnList, methodInstReplacer.getTransformCount());
// dump bytecode
}
return writer.toByteArray();
}
}
View on GitHub (pinned to 744c3d3075)
Solutions
- Inspect the dumped/original bytecode of the failing class to count LambdaMetafactory invokes
- Restrict the interceptor/transform scope so classes with multiple lambdas are excluded
- Update Pinpoint to a version with multi-lambda handling for lambda instrumentation
- Report the class and bytecode to Pinpoint maintainers if it triggers spuriously
Example fix
// before (transform config applying to a multi-lambda class)
transform("com/example/ManyLambdas")
// after (exclude)
if (className.equals("com/example/ManyLambdas")) return null; // skip lambda instrumentation Defensive patterns
Strategy: validation
Validate before calling
// count lambda factory call sites before transform; int invocations = countInvokeInstructions(bytes, "java/lang/invoke/LambdaMetafactory"); if (invocations != 1) skip or handle multi-lambda;
Try / catch
try { writer = adapt(reader); } catch (Exception e) { logger.warn("lambda transform failed for {}, returning original bytes", className); return null; } Prevention
- Limit lambda instrumentation to single-lambda classes
- Test instrumentation on classes compiled by your project's compiler version
- Keep Pinpoint updated for multi-lambda bytecode fixes
- Log and skip rather than shipping broken bytecode for multi-lambda classes
When it happens
Trigger: Instrumenting a class whose lambda metafactory invoke instruction count is not exactly 1 — e.g. a class with multiple lambdas, zero lambdas matched, or a bytecode pattern the replacer did not anticipate.
Common situations: Newer compiler output (different invokedynamic handling) targeting the JDK8 adapter; a plugin interceptor attaching to a lambda-heavy class; Pinpoint instrumentation classes that contain several lambda factories.
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
- source and advice class node must not be null.
- No methods are intercepted. target:{}, interceptor:{}, metho
- No methods are intercepted. target:{}, interceptor:{}, metho
- unexpected class ${className}
- ${name} define fail Caused by:${e.getMessage()}
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/606af8ff61d93ac1.
Report an issue: GitHub.