JDK-8036100 : Default method returns true for a while, and then returns false
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_8
  • CPU: x86
  • Submitted: 2014-02-28
  • Updated: 2014-11-14
  • Resolved: 2014-03-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8Fixed 9Fixed hs25Fixed
Related Reports
Relates :  
Relates :  
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 ----------


Comments
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.
02-03-2014

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
01-03-2014