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

[Lworld] Javac generates bad code for value constructors when expressions with side effects are involved

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The following fails to verify:

      // ---
      public class X {

      static __ByValue class V {
              int x;
      V() {
                  int l = 0;
                  l += x = 1234;
      }
      }

      public static void main(String[] args) {
      V v = new V();
      System.out.println(v);
      }
      }


      When run I get:
      Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          X$V.$makeValue$()LX$V; @16: i2b
        Reason:
          Type 'X$V' (current frame, stack[1]) is not assignable to integer
        Current Frame:
          bci: @16
          flags: { }
          locals: { 'X$V', integer }
          stack: { integer, 'X$V' }
        Bytecode:
          0000000: cb00 064b 033c 1b2a 1104 d2cc 0007 594b
          0000010: 9160 3c2a b0

      at X.main(X.java:12)

        Attachments

          Activity

            People

            • Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              sadayapalam Srikanth Adayapalam
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: