{
  "id": "java/compiler-warning-unchecked-cast",
  "signature": "warning: [unchecked] unchecked cast to java.util.List<java.lang.String>",
  "signature_zh": "警告: [unchecked] 未经检查的强制转换为 java.util.List<java.lang.String>",
  "regex": "warning: \\[unchecked\\] unchecked cast to (.*)",
  "domain": "java",
  "category": "compilation_error",
  "subcategory": null,
  "root_cause": "The compiler emits an unchecked cast warning when a generic type cast cannot be verified at runtime due to type erasure, indicating potential ClassCastException risk.",
  "root_cause_type": "generic",
  "root_cause_zh": "编译器在泛型类型转换由于类型擦除无法在运行时验证时发出未经检查的强制转换警告，表明存在 ClassCastException 风险。",
  "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": "Suppression only hides the symptom; the cast remains unchecked and dangerous.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Raw types bypass generic checks entirely, leading to potential heap pollution and runtime errors.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a type-safe pattern with a helper method and @SuppressWarnings(\"unchecked\") only on the minimal scope, with a comment explaining why it's safe: @SuppressWarnings(\"unchecked\") List<String> list = (List<String>) someObject;",
      "success_rate": 0.8,
      "how": "Use a type-safe pattern with a helper method and @SuppressWarnings(\"unchecked\") only on the minimal scope, with a comment explaining why it's safe: @SuppressWarnings(\"unchecked\") List<String> list = (List<String>) someObject;",
      "condition": "",
      "sources": []
    },
    {
      "action": "Refactor the code to avoid unchecked casts by using generic methods or type tokens: public <T> T cast(Object obj, Class<T> clazz) { return clazz.cast(obj); }",
      "success_rate": 0.9,
      "how": "Refactor the code to avoid unchecked casts by using generic methods or type tokens: public <T> T cast(Object obj, Class<T> clazz) { return clazz.cast(obj); }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use a type-safe pattern with a helper method and @SuppressWarnings(\"unchecked\") only on the minimal scope, with a comment explaining why it's safe: @SuppressWarnings(\"unchecked\") List<String> list = (List<String>) someObject;",
    "Refactor the code to avoid unchecked casts by using generic methods or type tokens: public <T> T cast(Object obj, Class<T> clazz) { return clazz.cast(obj); }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/javase/tutorial/java/generics/uncheckedCast.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-02-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}