{"record":{"id":"7fba583cf73de834","repo":"stanfordnlp/CoreNLP","slug":"next-not-implemented-for-arg1-arg1-getclass","errorCode":null,"errorMessage":"NEXT not implemented for arg1=${arg1.getClass()}, arg2=${arg2.getClass()}","messagePattern":"NEXT not implemented for arg1=(.+?), arg2=(.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/SUTime.java","lineNumber":1017,"sourceCode":"    // tuesday of this week\n\n    // (successor) Next week/day/...\n    NEXT {\n      @Override\n      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {\n        if (arg2 == null) {\n          return arg1;\n        }\n        Temporal arg2Next = arg2.next();\n        if (arg1 == null || arg2Next == null) {\n          return arg2Next;\n        }\n        if (arg1 instanceof Time) {\n          // TODO: flags?\n          Temporal resolved = arg2Next.resolve((Time) arg1, 0 /* RESOLVE_TO_FUTURE */);\n          return resolved;\n        } else {\n          throw new UnsupportedOperationException(\"NEXT not implemented for arg1=\" + arg1.getClass() + \", arg2=\" + arg2.getClass());\n        }\n      }\n    },\n    // This coming week/friday\n    NEXT_IMMEDIATE {\n      @Override\n      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {\n        if (arg1 == null) {\n          return new RelativeTime(NEXT_IMMEDIATE, arg2);\n        }\n        if (arg2 == null) {\n          return arg1;\n        }\n        // Temporal arg2Next = arg2.next();\n        // if (arg1 == null || arg2Next == null) { return arg2Next; }\n        if (arg1 instanceof Time) {\n          Time t = (Time) arg1;\n          if (arg2 instanceof Duration) {","sourceCodeStart":999,"sourceCodeEnd":1035,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/SUTime.java#L999-L1035","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the first argument is a SUTime.Time (resolve it to a Time before calling apply)","Check the exception message to see which classes were passed and fix the calling rule/pipeline ordering","Guard the call with an instanceof Time check and handle the else branch yourself","Report to CoreNLP if the failing combination comes from a stock rule and seems legitimately supported"],"exampleFix":"// before\nSUTime.TemporalOp.NEXT.apply(arg1, arg2, 0);\n// after\nif (arg1 instanceof SUTime.Time) {\n  SUTime.TemporalOp.NEXT.apply(arg1, arg2, 0);\n} else {\n  arg1 = ((SUTime.Duration) arg1).toTime(); // or resolve to a Time first\n}\n","handlingStrategy":"type-guard","validationCode":"if (!(arg1 instanceof SUTime.Time)) { throw new IllegalArgumentException(\"NEXT requires arg1 to be a Time\"); }","typeGuard":"boolean canApplyNext(SUTime.Temporal arg1) { return arg1 instanceof SUTime.Time; }","tryCatchPattern":"try { result = TemporalOp.NEXT.apply(arg1, arg2, flags); } catch (UnsupportedOperationException e) { /* resolve arg1 to a Time and retry */ }","preventionTips":["Always anchor NEXT/PREV operators with a Time reference","Validate temporal argument types in custom TokensRegex rules","Log argument classes at rule call sites for debugging"],"tags":["java","unsupported-operation","sutime","temporal"],"backgroundTag":"unsupported-operation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}