[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-hotspot-dev
Subject:    Re.: CHA ignores default methods during analysis leading to incorrect code generation
From:       Yann Le Tallec <ylt () letallec ! org>
Date:       2014-02-28 20:27:40
Message-ID: CAOPu7EiB0FwnjO+PfebpAjtvGap-frWpYqB-9WRodbegziGCgw () mail ! gmail ! com
[Download RAW message or body]

Original message:
http://mail.openjdk.java.net/pipermail/hotspot-dev/2014-January/012252.html

The test (DefaultAndConcreteMethodsCHA.java) passes as expected on b129.

However a post on Stackoverflow reports a very similar bug that can still
be reproduced on b129: http://stackoverflow.com/q/22096052/829571

Code copied below for reference - I get the erroneous output for i ~ 260,
i.e. after approximately 25 seconds.

Yann

public class IsolatedBug {
    static int i = 0;
    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(++i + " " +
drawable + " C=" + drawable.isShadowCaster() + "/R=" +
drawable.isShadowReceiver()));
    }

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

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

abstract class Drawable implements DrawableInterface {}

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

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

class Box extends Drawable implements ShadowDrawable {}
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic