{
  "id": "java/negative-array-size-exception",
  "signature": "java.lang.NegativeArraySizeException: -1",
  "signature_zh": "java.lang.NegativeArraySizeException: -1",
  "regex": "java\\.lang\\.NegativeArraySizeException",
  "domain": "java",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "An attempt to create an array with a negative size, typically caused by an integer overflow, a bug in size calculation, or malformed input data.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试创建大小为负数的数组，通常由整数溢出、大小计算错误或格式错误的输入数据引起。",
  "versions": [
    {
      "version": "Java 8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 11",
      "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": "",
      "why_fails": "The issue is not about memory limits but a negative value; increasing heap does not fix the logic error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This masks the underlying bug, potentially leading to data corruption or silent failures.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Validate the array size before creation: if (size < 0) throw new IllegalArgumentException(\"Size must be non-negative: \" + size);",
      "success_rate": 0.95,
      "how": "Validate the array size before creation: if (size < 0) throw new IllegalArgumentException(\"Size must be non-negative: \" + size);",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use Math.max(0, size) to clamp the size to a non-negative value as a temporary fix, but investigate the root cause.",
      "success_rate": 0.7,
      "how": "Use Math.max(0, size) to clamp the size to a non-negative value as a temporary fix, but investigate the root cause.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Validate the array size before creation: if (size < 0) throw new IllegalArgumentException(\"Size must be non-negative: \" + size);",
    "Use Math.max(0, size) to clamp the size to a non-negative value as a temporary fix, but investigate the root cause."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/NegativeArraySizeException.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-08-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}