pinpoint-apm/pinpoint · error · IllegalArgumentException

Setter interface must have only one method

Error message

Setter interface must have only one method: ${setterType.getName()}

What it means

IllegalArgumentException from SetterAnalyzer.analyze when the supplied setter interface declares more or fewer than exactly one declared method. Setter interfaces in Pinpoint's field-access instrumentation must contain a single method so bytecode generation knows unambiguously which method implements the setter.

Solutions

  1. Reduce the interface to exactly one abstract setter method
  2. Move extra helper methods to a separate interface or make them static
  3. Create a dedicated single-method setter interface for the field

Example fix

// before
interface FooSetter { void setFoo(int v); void clear(); }
// after
interface FooSetter { void setFoo(int v); }
interface FooClearer { void clear(); }
Defensive patterns

Strategy: validation

Validate before calling

if (setterType.isInterface() && setterType.getDeclaredMethods().length != 1) {
    throw new IllegalArgumentException(setterType + " must declare exactly one method");
}

Type guard

boolean isSingleMethodInterface(Class<?> t) {
    return t.isInterface() && t.getDeclaredMethods().length == 1;
}

Try / catch

try {
    SetterDetails d = new SetterAnalyzer().analyze(setterType);
} catch (IllegalArgumentException e) {
    logger.error("invalid setter interface {}: {}", setterType, e.getMessage());
}

Prevention

When it happens

Trigger: Passing an interface with 0 methods (marker interface) or 2+ methods to a field setter definition, e.g. via newSetterType or a plugin's field accessor definition.

Common situations: Plugin authors defining a convenience interface with an extra helper method and using it as a setter interface; accidentally passing a generic callback interface instead of a dedicated setter interface.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/8875fd9e5123aa59. Report an issue: GitHub.

Appendix: source

Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/SetterAnalyzer.java:45

public class SetterAnalyzer {
    private static final SetterAnalyzer INSTANCE = new SetterAnalyzer();

    public static SetterAnalyzer instance() {
        return INSTANCE;
    }

    private SetterAnalyzer() {
    }

    public SetterDetails analyze(Class<?> setterType) {
        Objects.requireNonNull(setterType, "setterType");

        if (!setterType.isInterface()) {
            throw new IllegalArgumentException("setterType " + setterType + "is not an interface");
        }

        final Method[] methods = setterType.getDeclaredMethods();
        if (methods.length != 1) {
            throw new IllegalArgumentException("Setter interface must have only one method: " + setterType.getName());
        }

        final Method setter = methods[0];
        if (setter.getParameterCount() != 1) {
            throw new IllegalArgumentException("Setter interface method must have exactly 1 argument: " + setterType.getName());
        }

        Class<?>[] arguments = setter.getParameterTypes();
        Class<?> fieldType = arguments[0];

        Class<?> returnType = setter.getReturnType();

        if (returnType != void.class) {
            throw new IllegalArgumentException("Setter must have return type void: " + setterType.getName());
        }

        return new SetterDetails(setter, fieldType);

View on GitHub (pinned to 744c3d3075)