{
  "id": "java/invalid-modifier-in-record",
  "signature": "error: illegal combination of modifiers: 'abstract' and 'final' for a record",
  "signature_zh": "错误：记录类型上 'abstract' 和 'final' 修饰符的非法组合",
  "regex": "illegal combination of modifiers: 'abstract' and 'final' for a record",
  "domain": "java",
  "category": "compilation_error",
  "subcategory": null,
  "root_cause": "Java records are implicitly final and cannot be abstract, so declaring a record with both abstract and final modifiers is illegal.",
  "root_cause_type": "generic",
  "root_cause_zh": "Java 记录类型隐式是 final 的，不能是 abstract，因此同时声明 abstract 和 final 修饰符是非法操作。",
  "versions": [
    {
      "version": "Java 16+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Remove the 'final' modifier from the record declaration.",
      "why_fails": "Records are implicitly final; removing 'final' still leaves the record as final, but the abstract modifier remains, which is still illegal.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Add 'abstract' to a non-record class and implement the record's methods manually.",
      "why_fails": "This changes the design entirely and may break serialization or pattern matching that relies on the record's canonical constructor.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'sealed' modifier instead of 'abstract' to allow subclassing.",
      "why_fails": "Sealed records are not supported in Java 17; the compiler will reject 'sealed' on records.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove both 'abstract' and 'final' from the record declaration. A record is implicitly final and cannot be abstract, so simply declare: `public record MyRecord(int x) { }`",
      "success_rate": 0.95,
      "how": "Remove both 'abstract' and 'final' from the record declaration. A record is implicitly final and cannot be abstract, so simply declare: `public record MyRecord(int x) { }`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need abstraction, convert the record to a regular class with fields and methods, and implement equals/hashCode/toString manually.",
      "success_rate": 0.85,
      "how": "If you need abstraction, convert the record to a regular class with fields and methods, and implement equals/hashCode/toString manually.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use an interface with default methods and a record implementing that interface to achieve abstraction without subclassing.",
      "success_rate": 0.8,
      "how": "Use an interface with default methods and a record implementing that interface to achieve abstraction without subclassing.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "从记录声明中移除 'abstract' 和 'final' 修饰符。记录隐式是 final 的，不能是 abstract，只需声明：`public record MyRecord(int x) { }`",
    "如果需要抽象，将记录转换为普通类，包含字段和方法，并手动实现 equals/hashCode/toString。",
    "使用包含默认方法的接口，并由记录实现该接口，以实现抽象而不需要子类化。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/en/java/javase/17/language/records.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-03-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}