Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8042735

javac compiler does not detect unchecked cast

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: tbd_major
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Compiling the provided java snippet should yield a unchecked cast warning

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile code code using javac

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      unchecked cast warning
      ACTUAL -
      no warning

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package a;

      public class CastTest {
      public interface BaseInterface<T> {

      }

      public interface SubInterfaceA<T> extends BaseInterface<T> {

      }

      public interface SubInterfaceB<T> extends BaseInterface<T> {

      }

      public static void main(String[] args) {
      SubInterfaceA<String> a = null;
      SubInterfaceB<String> b = (SubInterfaceB<String>) a; // javac does not warn
      b = (SubInterfaceB<String>)(BaseInterface<String>)a;

      }
      }
      ---------- END SOURCE ----------

      also discussed in compiler-dev: http://mail.openjdk.java.net/pipermail/compiler-dev/2014-May/008747.html

        Attachments

          Activity

            People

            • Assignee:
              jlahoda Jan Lahoda
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: