stanfordnlp/CoreNLP · error · UnsupportedOperationException

THIS not implemented for arg1=

Error message

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

What it means

TemporalOp.THIS ('this week/month') resolves arg2 relative to arg1 taken as the reference Time. When arg1 is not a Time there is no anchoring point, so the operator throws UnsupportedOperationException naming the runtime classes of both arguments.

Solutions

  1. Ensure arg1 is a SUTime.Time (convert via toTime()/resolve before apply)
  2. Check the class names in the message to identify the mis-typed argument and fix the rule
  3. Guard with instanceof Time and handle non-Time cases explicitly
  4. Swap arguments if reference and target were accidentally reversed

Example fix

// before
TemporalOp.THIS.apply(durationArg, target, flags);
// after
TemporalOp.THIS.apply(durationArg.toTime(), target, flags);
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling SUTime.TemporalOp.THIS.apply(arg1, arg2, flags) where arg1 is a Duration/Range instead of a Time — e.g. rules that mis-assign which temporal is the reference.

Common situations: Custom SUTime rules for expressions like 'this quarter' where the reference temporal was parsed as a Duration; argument-order mistakes in programmatic use of the TemporalOp enum.

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/7fb54ad375bd02e0. Report an issue: GitHub.

Appendix: source

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

      }
    },
    // Use arg1 as reference to resolve arg2 (take more general fields from arg1
    // and apply to arg2)
    THIS {
      @Override
      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {
        if (arg1 == null) {
          return new RelativeTime(THIS, arg2, flags);
        }
        if (arg1 instanceof Time) {
          if (arg2 instanceof Duration) {
            return ((Duration) arg2).toTime((Time) arg1, flags);
          } else {
            // TODO: flags?
            return arg2.resolve((Time) arg1, flags | RESOLVE_TO_THIS);
          }
        } else {
          throw new UnsupportedOperationException("THIS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass());
        }
      }
    },
    // (predecessor) Previous week/day/...
    PREV {
      @Override
      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {
        if (arg2 == null) {
          return arg1;
        }
        Temporal arg2Prev = arg2.prev();
        if (arg1 == null || arg2Prev == null) {
          return arg2Prev;
        }
        if (arg1 instanceof Time) {
          // TODO: flags?
          Temporal resolved = arg2Prev.resolve((Time) arg1, 0 /*RESOLVE_TO_PAST */);
          return resolved;

View on GitHub (pinned to 1b7edd19c4)