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

Default method returns true for a while, and then returns false

    Details

    • Subcomponent:
    • Introduced In Build:
      b127
    • Introduced In Version:
      8
    • Resolved In Build:
      b70
    • CPU:
      x86
    • OS:
      windows_8
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0"
        Java(TM) SE Runtime Environment (build 1.8.0-b129)
        Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)

        FULL OS VERSION :
        Microsoft Windows [Version 6.3.9600]

        A DESCRIPTION OF THE PROBLEM :
        For the description, refer to: http://stackoverflow.com/questions/22096052/method-returns-true-for-a-while-and-then-returns-false-possible-jvm-bug

        I have noticed the https://bugs.openjdk.java.net/browse/JDK-8031695
        -> However there it is claimed that the bug has been fixed before the build that I am running, which is not the case.

        THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

        THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the code outlined in the description, and the bug will appear.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        Expected behaviour is that the output for drawable.isShadowReceiver() and drawable.isShadowCaster() is always true.

        Actual behaviour is that it becomes false after a certain number of iterations/invokes.
        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public abstract class Drawable implements DrawableInterface {

        }

        interface DrawableInterface {
            default public boolean isShadowReceiver() {
                return false;
            }

            default public boolean isShadowCaster() {
                return false;
            }
        }

        public interface ShadowDrawable extends DrawableInterface {
            @Override
            default public boolean isShadowReceiver() {
                return true;
            }

            @Override
            default public boolean isShadowCaster() {
                return true;
            }
        }

        public class Box extends Drawable implements ShadowDrawable {

        }

        public class IsolatedBug {
            private final Box box;

            private final List<Drawable> drawables;

            public IsolatedBug() {
                this.box = new Box();
                this.drawables = new ArrayList<>();

                drawables.add(box);
                drawables.forEach(drawable -> System.out.println(drawable + " C=" + drawable.isShadowCaster() + "/R=" + drawable.isShadowReceiver()));
            }

            private void init() throws InterruptedException {
                while (true) {
                    drawables.forEach(drawable -> System.out.println(drawable + " C=" + drawable.isShadowCaster() + "/R=" + drawable.isShadowReceiver()));
                    Thread.sleep(1000);
                }
            }

            public static void main(String[] args) throws InterruptedException {
                new IsolatedBug().init();
            }
        }
        ---------- END SOURCE ----------

          Issue Links

            Activity

            Hide
            ctornqvi Christian Tornqvist added a comment -
            This was introduced with b127, it doesn't reproduce with -Xint or when tiered compilation is turned off.

            ILW HH? = P1
            I: High, exhibiting bad execution behavior, calling the wrong method
            L: High, Reproduces every time
            W: Unknown (High), No known workaround at this time
            Show
            ctornqvi Christian Tornqvist added a comment - This was introduced with b127, it doesn't reproduce with -Xint or when tiered compilation is turned off. ILW HH? = P1 I: High, exhibiting bad execution behavior, calling the wrong method L: High, Reproduces every time W: Unknown (High), No known workaround at this time
            Hide
            vlivanov Vladimir Ivanov added a comment - - edited
            It's a problem with CHA again.

            The hierarchy is the following:
            C1{} --I1 { default m() {} }
             | |
            C2{} --I2 { default m() {} }

            interface I1 { default void m() {}}
            interface I2 extends I1 { default void m() {}}

            class C1 implements I1 {}
            class C2 extends C1 implements I2 {}

            call site: invokevirtual C1.m() C2

            I1.m is erroneously inlined.
            ClassHierarchyWalker fails to find I2.m.
            Show
            vlivanov Vladimir Ivanov added a comment - - edited It's a problem with CHA again. The hierarchy is the following: C1{} --I1 { default m() {} }  | | C2{} --I2 { default m() {} } interface I1 { default void m() {}} interface I2 extends I1 { default void m() {}} class C1 implements I1 {} class C2 extends C1 implements I2 {} call site: invokevirtual C1.m() C2 I1.m is erroneously inlined. ClassHierarchyWalker fails to find I2.m.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/e46f2ee62e78
            User: vlivanov
            Date: 2014-03-04 01:42:30 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/e46f2ee62e78 User: vlivanov Date: 2014-03-04 01:42:30 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/e46f2ee62e78
            User: amurillo
            Date: 2014-03-04 03:14:20 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/e46f2ee62e78 User: amurillo Date: 2014-03-04 03:14:20 +0000

              People

              • Assignee:
                vlivanov Vladimir Ivanov
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: