Netflix/Hystrix · warning · UnsupportedOperationException
It's prohibited to create instances of the class.
Error message
It's prohibited to create instances of the class.
What it means
AopUtils is a static-only utility class in Javanica, and its private constructor throws UnsupportedOperationException to prevent instantiation (even via reflection-based constructor access within the class itself or by test tooling). This is a deliberate guard, not a runtime failure of library logic — you only see it if something tries to `new AopUtils()`.
Source
Thrown at hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/AopUtils.java:36
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import org.apache.commons.lang3.Validate;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
/**
* Provides common methods to retrieve information from JoinPoint and not only.
*/
public final class AopUtils {
private AopUtils() {
throw new UnsupportedOperationException("It's prohibited to create instances of the class.");
}
/**
* Gets a {@link Method} object from target object (not proxy class).
*
* @param joinPoint the {@link JoinPoint}
* @return a {@link Method} object or null if method doesn't exist or if the signature at a join point
* isn't sub-type of {@link MethodSignature}
*/
public static Method getMethodFromTarget(JoinPoint joinPoint) {
Method method = null;
if (joinPoint.getSignature() instanceof MethodSignature) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
method = getDeclaredMethod(joinPoint.getTarget().getClass(), signature.getName(),
getParameterTypes(joinPoint));
}
return method;
}View on GitHub (pinned to 5ce3bc58c3)
Solutions
- Remove the instantiation — call the static helpers (getMethodFromTarget, etc.) directly
- If a framework is constructing it, exclude the class from scanning/serialization (e.g. @ComponentScan filter, Kryo serializer config)
- If you copied the class into your own package, delete the copy and depend on the artifact instead
Example fix
// before AopUtils utils = new AopUtils(); Method m = utils.getMethodFromTarget(joinPoint); // after Method m = AopUtils.getMethodFromTarget(joinPoint);
Defensive patterns
Strategy: validation
Validate before calling
if (AopUtils.class.equals(clazz)) { throw new IllegalStateException("AopUtils is static-only; do not instantiate"); } Try / catch
catch (UnsupportedOperationException e) { /* remove the instantiation; call static methods directly */ } Prevention
- Keep static utility classes out of component-scan/serialization paths
- Call static helpers via the class name only
- Never copy library utility classes into your own packages
When it happens
Trigger: Explicitly calling new AopUtils(); a reflection framework (XStream, Kryo, certain mocking libs, JSON deserializers) instantiating the class because it appears on a classpath scan; a copy-paste of the class into your source and constructing it.
Common situations: Component scanning (e.g. Spring picking it up after copying the package into your source tree); serializers that require no-arg constructors; accidental instantiation in unit tests.
Related errors
- method cannot be annotated with HystrixCommand and HystrixCo
- Collapser method must have one argument: {}
- batch method is absent: {}
- required batch method for collapser is absent, wrong generic
- Return type of batch method must be java.util.List parametri
AI-assisted analysis of Netflix/Hystrix@5ce3bc58c3 (2026-08-14).
Data as JSON: /api/errors/01c0b1c07c34f2ad.
Report an issue: GitHub.