hotspot/test/compiler/6837094/Test.java
author jlaskey
Tue, 23 Jul 2013 12:00:29 -0300
changeset 19089 51cfdcf21d35
parent 5547 f4b087cbb361
permissions -rw-r--r--
8021130: Comments need to be tokens Reviewed-by: lagergren, attila Contributed-by: james.laskey@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3173
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     1
/*
3269
86f706946453 6861513: correct copyright attribution in test for 6837094 and 6860469
never
parents: 3173
diff changeset
     2
 * Copyright 2009 Google Inc.  All Rights Reserved.
3173
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     4
 *
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     8
 *
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    13
 * accompanied this code).
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    14
 *
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3269
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3269
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3269
diff changeset
    21
 * questions.
3173
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    22
 *
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    23
 */
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    24
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    25
/**
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    26
 * @test
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    27
 * @bug 6837094
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    28
 * @summary False positive for "meet not symmetric" failure
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    29
 *
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    30
 * @run main/othervm -Xbatch -XX:CompileOnly=Test.collectIs,Test$Factory$1.getArray,Test$Factory$2.getArray Test
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    31
 */
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    32
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    33
import java.util.Set;
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    34
import java.util.HashSet;
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    35
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    36
public class Test {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    37
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    38
  private interface Factory<M extends Interface> {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    39
    Factory<Child0> Zero = new Factory<Child0>() {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    40
      public Child0[] getArray() { return new Child0[1]; }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    41
    };
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    42
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    43
    Factory<Child1> One = new Factory<Child1>() {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    44
      public Child1[] getArray() { return new Child1[1]; }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    45
    };
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    46
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    47
    M[] getArray();
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    48
  }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    49
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    50
  /**
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    51
   * C2 asserts when compiling this method. Bimorphic inlining happens at
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    52
   * getArray call site. A Phi in the catch block tries to join the meet type
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    53
   * from he inline site (Parent[]) with the type expected by CI (Interface[]).
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    54
   *
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    55
   * C2 throws an assert when it doesn't need to.
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    56
   */
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    57
  private static <I extends Interface> void collectIs(
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    58
      Factory<I> factory, Set<Interface> s) {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    59
    for (I i : factory.getArray()) {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    60
      try {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    61
        s.add(i);
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    62
      } catch (Exception e) {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    63
      }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    64
    }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    65
  }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    66
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    67
  static public void main(String argv[]) {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    68
    Set<Interface> s = new HashSet();
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    69
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    70
    for (int i = 0; i < 25000; i++) {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    71
      collectIs(Factory.Zero, s);
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    72
      collectIs(Factory.One, s);
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    73
    }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    74
  }
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    75
}
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    76
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    77
/**
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    78
 * Establish necessary class hierarchy
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    79
 */
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    80
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    81
interface Interface {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    82
}
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    83
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    84
class Parent {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    85
}
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    86
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    87
class Child0 extends Parent implements Interface {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    88
}
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    89
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    90
class Child1 extends Parent implements Interface {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    91
}
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    92
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    93
class Child2 extends Parent implements Interface {
c15503e54406 6837094: False positive for "meet not symmetric" failure
kvn
parents:
diff changeset
    94
}