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