stanfordnlp/CoreNLP · error · UnsupportedOperationException

NEXT not implemented for arg1=

Error message

NEXT not implemented for arg1=${arg1.getClass()}, arg2=${arg2.getClass()}

What it means

The SUTime TemporalOp.NEXT operator applies 'next' only when arg1 is a Time (the reference point) and arg2 can be resolved relative to it. When arg1 is not a Time (e.g. a Duration or Range), the operator has no defined semantics and throws UnsupportedOperationException naming the two argument classes.

Solutions

  1. Ensure the first argument is a SUTime.Time (resolve it to a Time before calling apply)
  2. Check the exception message to see which classes were passed and fix the calling rule/pipeline ordering
  3. Guard the call with an instanceof Time check and handle the else branch yourself
  4. Report to CoreNLP if the failing combination comes from a stock rule and seems legitimately supported

Example fix

// before
SUTime.TemporalOp.NEXT.apply(arg1, arg2, 0);
// after
if (arg1 instanceof SUTime.Time) {
  SUTime.TemporalOp.NEXT.apply(arg1, arg2, 0);
} else {
  arg1 = ((SUTime.Duration) arg1).toTime(); // or resolve to a Time first
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(arg1 instanceof SUTime.Time)) { throw new IllegalArgumentException("NEXT requires arg1 to be a Time"); }

Type guard

boolean canApplyNext(SUTime.Temporal arg1) { return arg1 instanceof SUTime.Time; }

Try / catch

try { result = TemporalOp.NEXT.apply(arg1, arg2, flags); } catch (UnsupportedOperationException e) { /* resolve arg1 to a Time and retry */ }

Prevention

When it happens

Trigger: Invoking SUTime.TemporalOp.NEXT.apply(arg1, arg2, flags) where arg1 is not an instance of SUTime.Time — for example NEXT applied with a Duration or Range as the first argument.

Common situations: Custom rule-based temporal extraction (Rules Annotations / TokensRegex rules) that calls apply(NEXT, ...) on temporals parsed from unusual phrases; resolved expressions where the reference time was not extracted as a Time.

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


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/7fba583cf73de834. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/time/SUTime.java:1017

    // tuesday of this week

    // (successor) Next week/day/...
    NEXT {
      @Override
      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {
        if (arg2 == null) {
          return arg1;
        }
        Temporal arg2Next = arg2.next();
        if (arg1 == null || arg2Next == null) {
          return arg2Next;
        }
        if (arg1 instanceof Time) {
          // TODO: flags?
          Temporal resolved = arg2Next.resolve((Time) arg1, 0 /* RESOLVE_TO_FUTURE */);
          return resolved;
        } else {
          throw new UnsupportedOperationException("NEXT not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass());
        }
      }
    },
    // This coming week/friday
    NEXT_IMMEDIATE {
      @Override
      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {
        if (arg1 == null) {
          return new RelativeTime(NEXT_IMMEDIATE, arg2);
        }
        if (arg2 == null) {
          return arg1;
        }
        // Temporal arg2Next = arg2.next();
        // if (arg1 == null || arg2Next == null) { return arg2Next; }
        if (arg1 instanceof Time) {
          Time t = (Time) arg1;
          if (arg2 instanceof Duration) {

View on GitHub (pinned to 1b7edd19c4)