aoqi@0: /* aoqi@0: * Copyright 2009 Google Inc. All Rights Reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: /** aoqi@0: * @test aoqi@0: * @bug 6837094 aoqi@0: * @summary False positive for "meet not symmetric" failure aoqi@0: * aoqi@0: * @run main/othervm -Xbatch -XX:CompileOnly=Test.collectIs,Test$Factory$1.getArray,Test$Factory$2.getArray Test aoqi@0: */ aoqi@0: aoqi@0: import java.util.Set; aoqi@0: import java.util.HashSet; aoqi@0: aoqi@0: public class Test { aoqi@0: aoqi@0: private interface Factory { aoqi@0: Factory Zero = new Factory() { aoqi@0: public Child0[] getArray() { return new Child0[1]; } aoqi@0: }; aoqi@0: aoqi@0: Factory One = new Factory() { aoqi@0: public Child1[] getArray() { return new Child1[1]; } aoqi@0: }; aoqi@0: aoqi@0: M[] getArray(); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * C2 asserts when compiling this method. Bimorphic inlining happens at aoqi@0: * getArray call site. A Phi in the catch block tries to join the meet type aoqi@0: * from he inline site (Parent[]) with the type expected by CI (Interface[]). aoqi@0: * aoqi@0: * C2 throws an assert when it doesn't need to. aoqi@0: */ aoqi@0: private static void collectIs( aoqi@0: Factory factory, Set s) { aoqi@0: for (I i : factory.getArray()) { aoqi@0: try { aoqi@0: s.add(i); aoqi@0: } catch (Exception e) { aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: static public void main(String argv[]) { aoqi@0: Set s = new HashSet(); aoqi@0: aoqi@0: for (int i = 0; i < 25000; i++) { aoqi@0: collectIs(Factory.Zero, s); aoqi@0: collectIs(Factory.One, s); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Establish necessary class hierarchy aoqi@0: */ aoqi@0: aoqi@0: interface Interface { aoqi@0: } aoqi@0: aoqi@0: class Parent { aoqi@0: } aoqi@0: aoqi@0: class Child0 extends Parent implements Interface { aoqi@0: } aoqi@0: aoqi@0: class Child1 extends Parent implements Interface { aoqi@0: } aoqi@0: aoqi@0: class Child2 extends Parent implements Interface { aoqi@0: }