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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b142
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: