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

cast from object to primitive should be for source >= 1.7

XMLWordPrintable

    • b142
    • generic
    • generic
    • Verified

      From Jan Lahoda:
      Hi,
          in JDK7's javac, casts like:
      Object o = 42;
      int i = (int) o;

      are allowed, but these were not allowed in JDK6's javac. This is causing problems in NetBeans, as we are proposing "Add cast" fix and not showing an error for such casts, although the code is not compilable using pre-JDK6 compiler. This is a NetBeans bug:
      http://netbeans.org/bugzilla/show_bug.cgi?id=197164

      I think that such casts should be source level >= 1.7 only, which I tried to achieve in the attached patch.

      Thanks,
          Jan

            jjg Jonathan Gibbons
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: