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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • tools
    • generic
    • generic

      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)

            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: