jshell wrong propagation of constant variable

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Affects Version/s: 24
    • Component/s: tools
    • None

      A narrowing primitive conversion with a constant expression is allowed in the assignment context. Two examples:

      // literal
      jshell> byte b = 42;
      b ==> 42

      // simple name that refers to a constant variable
      jshell> class Test {
         ...> final int i = 42;
         ...> void test() {
         ...> byte b = i;
         ...> }
         ...> }
      | created class Test

      However, in JShell we observe the following erroneous behavior:

      jshell> final int i = 42;
      i ==> 42

      jshell> byte b = i;
      | Error:
      | incompatible types: possible lossy conversion from int to byte
      | byte b = i;
      | ^

            Assignee:
            Angelos Bimpoudis
            Reporter:
            Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: