1715
|
1 /*
|
|
2 * @test
|
|
3 * @bug 6894807
|
|
4 * @summary No ClassCastException for HashAttributeSet constructors if run with -Xcomp
|
|
5 * @compile IsInstanceTest.java
|
|
6 * @run shell Test6894807.sh
|
|
7 */
|
|
8
|
|
9 public class IsInstanceTest {
|
|
10
|
|
11 public static void main(String[] args) {
|
|
12 BaseInterface baseInterfaceImpl = new BaseInterfaceImpl();
|
|
13 for (int i = 0; i < 100000; i++) {
|
|
14 if (isInstanceOf(baseInterfaceImpl, ExtendedInterface.class)) {
|
|
15 System.out.println("Failed at index:" + i);
|
|
16 System.out.println("Arch: "+System.getProperty("os.arch", "")+
|
|
17 " OS: "+System.getProperty("os.name", "")+
|
|
18 " OSV: "+System.getProperty("os.version", "")+
|
|
19 " Cores: "+Runtime.getRuntime().availableProcessors()+
|
|
20 " JVM: "+System.getProperty("java.version", "")+" "+System.getProperty("sun.arch.data.model", ""));
|
|
21 break;
|
|
22 }
|
|
23 }
|
|
24 System.out.println("Done!");
|
|
25 }
|
|
26
|
|
27 public static boolean isInstanceOf(BaseInterface baseInterfaceImpl, Class... baseInterfaceClasses) {
|
|
28 for (Class baseInterfaceClass : baseInterfaceClasses) {
|
|
29 if (baseInterfaceClass.isInstance(baseInterfaceImpl)) {
|
|
30 return true;
|
|
31 }
|
|
32 }
|
|
33 return false;
|
|
34 }
|
|
35
|
|
36 private interface BaseInterface {
|
|
37 }
|
|
38
|
|
39 private interface ExtendedInterface extends BaseInterface {
|
|
40 }
|
|
41
|
|
42 private static class BaseInterfaceImpl implements BaseInterface {
|
|
43 }
|
|
44 }
|