alibaba/COLA · error · ExtensionException

EXTENSION_INTERFACE_NAME_ILLEGAL

EXTENSION_INTERFACE_NAME_ILLEGAL

Error message

Your name of ExtensionPoint for ${targetClz} is not valid, must be end of ExtPt

What it means

Thrown by ExtensionRegister.calculateExtensionPoint when the @Extension class implements interfaces, but none of their simple names contain 'ExtPt' (EXTENSION_EXTPT_NAMING). The registry identifies extension points by this naming convention. ExtensionException carries code EXTENSION_INTERFACE_NAME_ILLEGAL.

Source

Thrown at cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/register/ExtensionRegister.java:105

    /**
     * @param targetClz
     * @return
     */
    private String calculateExtensionPoint(Class<?> targetClz) {
        Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(targetClz);
        if (interfaces == null || interfaces.length == 0) {
            throw new ExtensionException(EXTENSION_ILLEGAL, "Please assign a extension point interface for " + targetClz);
        }
        for (Class intf : interfaces) {
            String extensionPoint = intf.getSimpleName();
            if (extensionPoint.contains(EXTENSION_EXTPT_NAMING)) {
                return intf.getName();
            }
        }
        String errMessage = "Your name of ExtensionPoint for " + targetClz +
                " is not valid, must be end of " + EXTENSION_EXTPT_NAMING;
        throw new ExtensionException(EXTENSION_INTERFACE_NAME_ILLEGAL, errMessage);
    }

}

View on GitHub (pinned to 352e1a8675)

Solutions

  1. Rename the extension point interface so its simple name contains 'ExtPt' (e.g. PayExtPt)
  2. Implement the correct ExtPt interface instead of a plain interface
  3. Confirm EXTENSION_EXTPT_NAMING constant matches your project's naming convention

Example fix

// before
public interface PayExtension { void pay(); }
public class AlipayExt implements PayExtension {...}
// after
public interface PayExtPt { void pay(); }
public class AlipayExt implements PayExtPt {...}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasExtPt = Arrays.stream(ClassUtils.getAllInterfacesForClass(clazz))
    .anyMatch(i -> i.getSimpleName().contains("ExtPt"));
if (!hasExtPt) throw new IllegalStateException(clazz + " must implement a *ExtPt interface");

Type guard

boolean hasValidExtPt(Class<?> clz) {
    Class<?>[] ifaces = ClassUtils.getAllInterfacesForClass(clz);
    return ifaces != null && Arrays.stream(ifaces)
        .anyMatch(i -> i.getSimpleName().contains("ExtPt"));
}

Try / catch

try {
    register(extension);
} catch (ExtensionException e) {
    if ("EXTENSION_INTERFACE_NAME_ILLEGAL".equals(e.getErrorCode())) {
        log.error("Rename extension point interface of {} to end with ExtPt", extension.getClass(), e);
    }
}

Prevention

When it happens

Trigger: Registering an @Extension class whose implemented interfaces exist but none end with/contain 'ExtPt' in the simple name.

Common situations: Naming the extension point interface 'PayExtension' or 'IPay' instead of 'PayExtPt'; implementing only generic interfaces like Serializable; team convention drift after renaming.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of alibaba/COLA@352e1a8675 (2026-09-08). Data as JSON: /api/errors/45d37c4aae6ed9f2. Report an issue: GitHub.