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

JShell 'instanceof' method attempting to convert object

XMLWordPrintable

    • x86_64
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The following JShell script shows what I'm seeing.
      I would expect the last statement to simple evaluate to false and not generate an exception

      jshell> Integer a;
      a ==> null

      jshell> Integer b=1;
      b ==> 1

      jshell> a instanceof Integer
      $3 ==> false

      jshell> b instanceof Integer
      $4 ==> true

      jshell> b instanceof Double
      | Error:
      | incompatible types: java.lang.Integer cannot be converted to java.lang.Double
      | b instanceof Double
      | ^



      FREQUENCY : always


            rfield Robert Field (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: