stanfordnlp/CoreNLP · error · UnsupportedOperationException
Unsupported function value
Error message
Unsupported function value ${funcValue} What it means
Function-call evaluation resolves the callee to one of: a ValueFunction, a Value wrapping a function, a Class (constructor call), or an object on which a method is invoked. When the resolved funcValue is none of these types, evaluate() has no dispatch path and throws UnsupportedOperationException with the value's toString.
Solutions
- Bind a ValueFunction (or wrap the callable) under the name instead of a plain object
- Rename the bound variable so it doesn't collide with a function name
- Check what is actually bound: `env.lookup(name)` and confirm it is a ValueFunction or Class
Example fix
// before
env.bind("process", resultList); // plain object
$process(x) // -> UnsupportedOperationException
// after
env.bind("process", new ProcessValueFunction()); Defensive patterns
Strategy: type-guard
Validate before calling
Object f = ValueFunctions.lookupFunctionObject(env, functionName);
if (!(f instanceof ValueFunction) && !(f instanceof Value) && !(f instanceof Class)) {
throw new IllegalStateException("Name is not callable: " + functionName);
} Type guard
boolean isCallable(Object f) {
return f instanceof ValueFunction || f instanceof Value || f instanceof Class;
} Try / catch
try {
Value v = expr.evaluate(env, args);
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("Unsupported function value")) {
// rebind the name to a ValueFunction and retry
} else throw e;
} Prevention
- Namespace function names distinctly from variable names to avoid collisions
- Only bind ValueFunction, Value-wrapping functions, or Class objects under callable names
- Audit env.bind calls for accidental plain-object bindings
When it happens
Trigger: Binding a plain object (e.g. a String, List, or POJO) into the Env under a function-like name and then calling `NAME(args)` — the bound value is not a function, class, or invokable method holder.
Common situations: A rule calls what looks like a function but the env actually holds a data value under that name (name collision, e.g. bound variable shadowing a function name), or a custom binder registered the wrong object type.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- BackRefPatternExpr.transform not implemented yet!!! Please…
- Cannot evaluate type
- Cannot find function matching args
- Expression was not evaluated....
- iterator is not supported for…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/f89a2f5e35986374.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java:1008
for (Constructor cons:constructors) {
Class[] consParamTypes = cons.getParameterTypes();
boolean compatible = isArgTypesCompatible(paramTypes, consParamTypes);
if (compatible) {
constructor = cons;
break;
}
}
if (constructor == null) {
throw new RuntimeException("Cannot instantiate " + c, ex);
}
}
Object obj = constructor.newInstance(objs);
return new PrimitiveValue<>(function, obj);
} catch (InvocationTargetException | InstantiationException | IllegalAccessException ex) {
throw new RuntimeException("Cannot instantiate " + c, ex);
}
} else {
throw new UnsupportedOperationException("Unsupported function value " + funcValue);
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FunctionCallExpression)) return false;
FunctionCallExpression that = (FunctionCallExpression) o;
if (function != null ? !function.equals(that.function) : that.function != null) return false;
if (params != null ? !params.equals(that.params) : that.params != null) return false;
return true;
}
@Override
public int hashCode() {View on GitHub (pinned to 1b7edd19c4)