1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 package compiler.jvmci.common.testcases; |
24 package compiler.jvmci.common.testcases; |
25 |
25 |
|
26 import java.util.HashMap; |
|
27 import java.util.Map; |
|
28 |
26 public abstract class MultipleAbstractImplementer |
29 public abstract class MultipleAbstractImplementer |
27 implements MultipleImplementersInterface { |
30 implements MultipleImplementersInterface { |
|
31 |
|
32 // Different access levels on the fields of this class are used on purpose. |
|
33 // It is needed to verify jdk.vm.ci.CompilerToVM constant pool related |
|
34 // methods, e.g. resolveFieldInPool. |
|
35 |
|
36 private static int intStaticField = INT_CONSTANT; |
|
37 final static long longStaticField = LONG_CONSTANT; |
|
38 volatile static float floatStaticField = FLOAT_CONSTANT; |
|
39 static double doubleStaticField = DOUBLE_CONSTANT; |
|
40 public static String stringStaticField = STRING_CONSTANT; |
|
41 protected static Object objectStaticField = OBJECT_CONSTANT; |
|
42 |
|
43 public int intField = INT_CONSTANT; |
|
44 private long longField = LONG_CONSTANT; |
|
45 protected float floatField = FLOAT_CONSTANT; |
|
46 transient double doubleField = DOUBLE_CONSTANT; |
|
47 volatile String stringField = STRING_CONSTANT; |
|
48 String stringFieldEmpty = ""; |
|
49 final Object objectField; |
|
50 |
|
51 public MultipleAbstractImplementer() { |
|
52 intField = Integer.MAX_VALUE; |
|
53 longField = Long.MAX_VALUE; |
|
54 floatField = Float.MAX_VALUE; |
|
55 doubleField = Double.MAX_VALUE; |
|
56 stringField = "Message"; |
|
57 objectField = new Object(); |
|
58 } |
28 |
59 |
29 public abstract void abstractMethod(); |
60 public abstract void abstractMethod(); |
30 |
61 |
31 @Override |
62 @Override |
32 public void finalize() throws Throwable { |
63 public void finalize() throws Throwable { |
33 super.finalize(); |
64 super.finalize(); |
34 } |
65 } |
|
66 |
|
67 public void lambdaUsingMethod2() { |
|
68 Thread t = new Thread(this::testMethod); |
|
69 t.start(); |
|
70 } |
|
71 |
|
72 /** |
|
73 * This method is needed to have "getstatic" and "getfield" instructions |
|
74 * in the class. These instructions are needed to test |
|
75 * resolveFieldInPool method, because it needs a bytecode as one of its arguments. |
|
76 */ |
|
77 public void printFileds() { |
|
78 System.out.println(intStaticField); |
|
79 System.out.println(longStaticField); |
|
80 System.out.println(floatStaticField); |
|
81 System.out.println(doubleStaticField); |
|
82 System.out.println(stringStaticField); |
|
83 System.out.println(objectStaticField); |
|
84 System.out.println(intField); |
|
85 System.out.println(longField); |
|
86 System.out.println(floatField); |
|
87 System.out.println(doubleField); |
|
88 System.out.println(stringField); |
|
89 System.out.println(stringFieldEmpty); |
|
90 System.out.println(objectField); |
|
91 } |
|
92 |
|
93 public static void staticMethod() { |
|
94 System.getProperties(); // calling some static method |
|
95 Map map = new HashMap(); // calling some constructor |
|
96 map.put(OBJECT_CONSTANT, OBJECT_CONSTANT); // calling some interface method |
|
97 map.remove(OBJECT_CONSTANT); // calling some default interface method |
|
98 } |
|
99 |
|
100 @Override |
|
101 public void instanceMethod() { |
|
102 toString(); // calling some virtual method |
|
103 super.toString(); // calling some special method |
|
104 } |
|
105 |
|
106 @Override |
|
107 public void anonClassMethod() { |
|
108 new Runnable() { |
|
109 @Override |
|
110 public void run() { |
|
111 System.out.println("Running"); |
|
112 } |
|
113 }.run(); |
|
114 } |
35 } |
115 } |