Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaType.java @ 21765:a7a1b9b65bce
Small improvement and clean up of InstanceOfNode.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 07 Jun 2015 00:47:10 +0200 |
parents | 381ab4105afe |
children |
rev | line source |
---|---|
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18183
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
21663
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
23 package com.oracle.jvmci.runtime.test; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static java.lang.reflect.Modifier.*; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import static org.junit.Assert.*; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import java.lang.annotation.*; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import java.lang.reflect.*; |
7831
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
30 import java.net.*; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import java.util.*; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import org.junit.*; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import sun.reflect.ConstantPool; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
21663
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
37 import com.oracle.jvmci.common.*; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21555
diff
changeset
|
38 import com.oracle.jvmci.meta.Assumptions.AssumptionResult; |
21663
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
39 import com.oracle.jvmci.meta.*; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 |
7043
947de43c68d6
improved documentation for ResolvedJavaType.findUniqueConcreteSubtype()
Doug Simon <doug.simon@oracle.com>
parents:
7037
diff
changeset
|
41 /** |
947de43c68d6
improved documentation for ResolvedJavaType.findUniqueConcreteSubtype()
Doug Simon <doug.simon@oracle.com>
parents:
7037
diff
changeset
|
42 * Tests for {@link ResolvedJavaType}. |
947de43c68d6
improved documentation for ResolvedJavaType.findUniqueConcreteSubtype()
Doug Simon <doug.simon@oracle.com>
parents:
7037
diff
changeset
|
43 */ |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
44 public class TestResolvedJavaType extends TypeUniverse { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 public TestResolvedJavaType() { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 @Test |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
50 public void findInstanceFieldWithOffsetTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
51 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
52 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
53 Set<Field> reflectionFields = getInstanceFields(c, true); |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
54 for (Field f : reflectionFields) { |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
55 ResolvedJavaField rf = lookupField(type.getInstanceFields(true), f); |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
56 assertNotNull(rf); |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
57 long offset = isStatic(f.getModifiers()) ? unsafe.staticFieldOffset(f) : unsafe.objectFieldOffset(f); |
18950
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18694
diff
changeset
|
58 ResolvedJavaField result = type.findInstanceFieldWithOffset(offset, rf.getKind()); |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
59 assertNotNull(result); |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
60 assertTrue(fieldsEqual(f, result)); |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
61 } |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
62 } |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
63 } |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
64 |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
65 @Test |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 public void isInterfaceTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
67 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
68 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 boolean expected = c.isInterface(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 boolean actual = type.isInterface(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 assertEquals(expected, actual); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 public void isInstanceClassTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
77 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
78 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 boolean expected = !c.isArray() && !c.isPrimitive() && !c.isInterface(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 boolean actual = type.isInstanceClass(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 assertEquals(expected, actual); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
86 public void isArrayTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
87 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
88 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 boolean expected = c.isArray(); |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
90 boolean actual = type.isArray(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 assertEquals(expected, actual); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 public void getModifiersTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
97 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
98 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 int expected = c.getModifiers(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 int actual = type.getModifiers(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 assertEquals(expected, actual); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
106 public void isAssignableFromTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
107 Class<?>[] all = classes.toArray(new Class[classes.size()]); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 for (int i = 0; i < all.length; i++) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 Class<?> c1 = all[i]; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 for (int j = i; j < all.length; j++) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 Class<?> c2 = all[j]; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
112 ResolvedJavaType t1 = metaAccess.lookupJavaType(c1); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
113 ResolvedJavaType t2 = metaAccess.lookupJavaType(c2); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 boolean expected = c1.isAssignableFrom(c2); |
7097
6644cecbd3a7
Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7096
diff
changeset
|
115 boolean actual = t1.isAssignableFrom(t2); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 assertEquals(expected, actual); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 if (expected && t1 != t2) { |
7097
6644cecbd3a7
Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7096
diff
changeset
|
118 assertFalse(t2.isAssignableFrom(t1)); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 public void isInstanceTest() { |
21663
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
126 for (ConstantValue cv : constants()) { |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
127 JavaConstant c = cv.value; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7097
diff
changeset
|
128 if (c.getKind() == Kind.Object && !c.isNull()) { |
21663
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
129 ResolvedJavaType cType = metaAccess.lookupJavaType(c); |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
130 for (ResolvedJavaType t : javaTypes) { |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
131 if (t.isAssignableFrom(cType)) { |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
132 assertTrue(t.isInstance(c)); |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
133 } else { |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
134 assertFalse(t.isInstance(c)); |
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
135 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
141 private static Class<?> asExactClass(Class<?> c) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 if (c.isArray()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 if (asExactClass(c.getComponentType()) != null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 return c; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 } else { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 if (c.isPrimitive() || Modifier.isFinal(c.getModifiers())) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 return c; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 public void asExactTypeTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
156 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
157 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 ResolvedJavaType exactType = type.asExactType(); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
159 Class<?> expected = asExactClass(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 if (expected == null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 assertTrue("exact(" + c.getName() + ") != null", exactType == null); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 } else { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 assertNotNull(exactType); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
164 assertTrue(exactType.equals(metaAccess.lookupJavaType(expected))); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 public void getSuperclassTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
171 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
172 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
173 Class<?> expected = c.getSuperclass(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 ResolvedJavaType actual = type.getSuperclass(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 if (expected == null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 assertTrue(actual == null); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 } else { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 assertNotNull(actual); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
179 assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 public void getInterfacesTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
186 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
187 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
188 Class<?>[] expected = c.getInterfaces(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 ResolvedJavaType[] actual = type.getInterfaces(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
190 assertEquals(expected.length, actual.length); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 for (int i = 0; i < expected.length; i++) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
192 assertTrue(actual[i].equals(metaAccess.lookupJavaType(expected[i]))); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
193 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
194 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
197 public Class<?> getSupertype(Class<?> c) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
198 assert !c.isPrimitive(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
199 if (c.isArray()) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
200 Class<?> componentType = c.getComponentType(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 if (componentType.isPrimitive() || componentType == Object.class) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 return Object.class; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 return getArrayClass(getSupertype(componentType)); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
206 if (c.isInterface()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 return Object.class; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 return c.getSuperclass(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
212 public Class<?> findLeastCommonAncestor(Class<?> c1Initial, Class<?> c2Initial) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 if (c1Initial.isPrimitive() || c2Initial.isPrimitive()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 } else { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 Class<?> c1 = c1Initial; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 Class<?> c2 = c2Initial; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 while (true) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
219 if (c1.isAssignableFrom(c2)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
220 return c1; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
221 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
222 if (c2.isAssignableFrom(c1)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
223 return c2; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
224 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
225 c1 = getSupertype(c1); |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
226 c2 = getSupertype(c2); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
227 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
228 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
229 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
230 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
231 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
232 public void findLeastCommonAncestorTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
233 Class<?>[] all = classes.toArray(new Class[classes.size()]); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
234 for (int i = 0; i < all.length; i++) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
235 Class<?> c1 = all[i]; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
236 for (int j = i; j < all.length; j++) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 Class<?> c2 = all[j]; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
238 ResolvedJavaType t1 = metaAccess.lookupJavaType(c1); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
239 ResolvedJavaType t2 = metaAccess.lookupJavaType(c2); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
240 Class<?> expected = findLeastCommonAncestor(c1, c2); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 ResolvedJavaType actual = t1.findLeastCommonAncestor(t2); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
242 if (expected == null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 assertTrue(actual == null); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 } else { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 assertNotNull(actual); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
246 assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
247 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
249 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
250 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
252 private static class Base { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
253 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
254 |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
255 abstract static class Abstract1 extends Base { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
256 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
257 |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
258 interface Interface1 { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
259 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
260 |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
261 static class Concrete1 extends Abstract1 { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
262 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
263 |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
264 static class Concrete2 extends Abstract1 implements Interface1 { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
265 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
266 |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
267 static class Concrete3 extends Concrete2 { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
268 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
269 |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
270 static final class Final1 extends Abstract1 { |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
271 } |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
272 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
273 abstract static class Abstract4 extends Concrete3 { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
274 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
275 |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
276 void checkConcreteSubtype(ResolvedJavaType type, ResolvedJavaType expected) { |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
277 AssumptionResult<ResolvedJavaType> leafConcreteSubtype = type.findLeafConcreteSubtype(); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
278 if (leafConcreteSubtype == null) { |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
279 // findLeafConcreteSubtype() is conservative |
7045
7ac6e4c10e37
bug fix for HotSpotReslvedJavaType.findUniqueConcreteSubtype() on arrays of interfaces
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
280 } else { |
7ac6e4c10e37
bug fix for HotSpotReslvedJavaType.findUniqueConcreteSubtype() on arrays of interfaces
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
281 if (expected == null) { |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
282 assertNull(leafConcreteSubtype); |
7045
7ac6e4c10e37
bug fix for HotSpotReslvedJavaType.findUniqueConcreteSubtype() on arrays of interfaces
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
283 } else { |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
284 assertTrue(leafConcreteSubtype.getResult().equals(expected)); |
7045
7ac6e4c10e37
bug fix for HotSpotReslvedJavaType.findUniqueConcreteSubtype() on arrays of interfaces
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
285 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
286 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
287 |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
288 if (!type.isArray()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
289 ResolvedJavaType arrayType = type.getArrayClass(); |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
290 AssumptionResult<ResolvedJavaType> arraySubtype = arrayType.findLeafConcreteSubtype(); |
7043
947de43c68d6
improved documentation for ResolvedJavaType.findUniqueConcreteSubtype()
Doug Simon <doug.simon@oracle.com>
parents:
7037
diff
changeset
|
291 if (arraySubtype != null) { |
19795
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18950
diff
changeset
|
292 assertEquals(arraySubtype.getResult(), arrayType); |
7045
7ac6e4c10e37
bug fix for HotSpotReslvedJavaType.findUniqueConcreteSubtype() on arrays of interfaces
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
293 } else { |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
294 // findLeafConcreteSubtype() method is conservative |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
295 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
296 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
297 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 @Test |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
300 public void findLeafConcreteSubtypeTest() { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
301 ResolvedJavaType base = metaAccess.lookupJavaType(Base.class); |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
302 checkConcreteSubtype(base, base); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
304 ResolvedJavaType a1 = metaAccess.lookupJavaType(Abstract1.class); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
305 ResolvedJavaType c1 = metaAccess.lookupJavaType(Concrete1.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
306 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
307 checkConcreteSubtype(base, null); |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
308 checkConcreteSubtype(a1, c1); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
309 checkConcreteSubtype(c1, c1); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
310 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
311 ResolvedJavaType i1 = metaAccess.lookupJavaType(Interface1.class); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
312 ResolvedJavaType c2 = metaAccess.lookupJavaType(Concrete2.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
313 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
314 checkConcreteSubtype(base, null); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
315 checkConcreteSubtype(a1, null); |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
316 checkConcreteSubtype(c1, c1); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
317 checkConcreteSubtype(i1, c2); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
318 checkConcreteSubtype(c2, c2); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
319 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
320 ResolvedJavaType c3 = metaAccess.lookupJavaType(Concrete3.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
321 checkConcreteSubtype(c2, null); |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
322 checkConcreteSubtype(c3, c3); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
323 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
324 ResolvedJavaType a4 = metaAccess.lookupJavaType(Abstract4.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
325 checkConcreteSubtype(c3, null); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
326 checkConcreteSubtype(a4, null); |
15729
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
327 |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
328 ResolvedJavaType a1a = metaAccess.lookupJavaType(Abstract1[].class); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
329 checkConcreteSubtype(a1a, null); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
330 ResolvedJavaType c1a = metaAccess.lookupJavaType(Concrete1[].class); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
331 checkConcreteSubtype(c1a, null); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
332 ResolvedJavaType f1a = metaAccess.lookupJavaType(Final1[].class); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
333 checkConcreteSubtype(f1a, f1a); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
334 |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
335 ResolvedJavaType obja = metaAccess.lookupJavaType(Object[].class); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
336 checkConcreteSubtype(obja, null); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
337 |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
338 ResolvedJavaType inta = metaAccess.lookupJavaType(int[].class); |
59a85df7a418
Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15722
diff
changeset
|
339 checkConcreteSubtype(inta, inta); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
340 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
341 |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
342 interface NoImplementor { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
343 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
344 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
345 interface SingleImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
346 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
347 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
348 static class SingleConcreteImplementor implements SingleImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
349 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
350 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
351 interface SingleAbstractImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
352 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
353 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
354 abstract static class SingleAbstractImplementor implements SingleAbstractImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
355 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
356 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
357 interface MultiImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
358 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
359 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
360 static class ConcreteImplementor1 implements MultiImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
361 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
362 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
363 static class ConcreteImplementor2 implements MultiImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
364 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
365 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
366 interface MultipleAbstractImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
367 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
368 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
369 abstract static class MultiAbstractImplementor1 implements MultipleAbstractImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
370 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
371 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
372 abstract static class MultiAbstractImplementor2 implements MultipleAbstractImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
373 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
374 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
375 interface SingleAbstractImplementorInterface2 { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
376 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
377 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
378 interface ExtendedSingleImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
379 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
380 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
381 abstract static class SingleAbstractImplementor2 implements SingleAbstractImplementorInterface2 { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
382 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
383 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
384 static class ConcreteTransitiveImplementor1 extends SingleAbstractImplementor2 implements ExtendedSingleImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
385 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
386 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
387 static class ConcreteTransitiveImplementor2 extends SingleAbstractImplementor2 implements ExtendedSingleImplementorInterface { |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
388 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
389 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
390 @Test |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
391 public void getSingleImplementorTest() { |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
392 ResolvedJavaType iNi = metaAccess.lookupJavaType(NoImplementor.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
393 assertNull(iNi.getSingleImplementor()); |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
394 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
395 ResolvedJavaType iSi = metaAccess.lookupJavaType(SingleImplementorInterface.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
396 ResolvedJavaType cSi = metaAccess.lookupJavaType(SingleConcreteImplementor.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
397 assertEquals(cSi, iSi.getSingleImplementor()); |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
398 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
399 ResolvedJavaType iSai = metaAccess.lookupJavaType(SingleAbstractImplementorInterface.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
400 ResolvedJavaType aSai = metaAccess.lookupJavaType(SingleAbstractImplementor.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
401 assertEquals(aSai, iSai.getSingleImplementor()); |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
402 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
403 ResolvedJavaType iMi = metaAccess.lookupJavaType(MultiImplementorInterface.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
404 metaAccess.lookupJavaType(ConcreteImplementor1.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
405 metaAccess.lookupJavaType(ConcreteImplementor2.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
406 assertEquals(iMi, iMi.getSingleImplementor()); |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
407 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
408 ResolvedJavaType iMai = metaAccess.lookupJavaType(MultipleAbstractImplementorInterface.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
409 metaAccess.lookupJavaType(MultiAbstractImplementor1.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
410 metaAccess.lookupJavaType(MultiAbstractImplementor2.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
411 assertEquals(iMai, iMai.getSingleImplementor()); |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
412 |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
413 ResolvedJavaType iSai2 = metaAccess.lookupJavaType(SingleAbstractImplementorInterface2.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
414 ResolvedJavaType aSai2 = metaAccess.lookupJavaType(SingleAbstractImplementor2.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
415 metaAccess.lookupJavaType(ConcreteTransitiveImplementor1.class); |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
416 metaAccess.lookupJavaType(ConcreteTransitiveImplementor2.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
417 assertEquals(aSai2, iSai2.getSingleImplementor()); |
18183
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
418 } |
d3dfd1f9545f
Add TestResolvedJavaType.getImplementorTest().
Josef Eisl <josef.eisl@jku.at>
parents:
17156
diff
changeset
|
419 |
21547
78f0792aa890
fixed expected exception type in some TestResolvedJavaType tests
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
420 @Test(expected = JVMCIError.class) |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
421 public void getSingleImplementorTestClassReceiver() { |
18193
0a17944b7baf
Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
Josef Eisl <josef.eisl@jku.at>
parents:
18192
diff
changeset
|
422 ResolvedJavaType base = metaAccess.lookupJavaType(Base.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
423 base.getSingleImplementor(); |
18193
0a17944b7baf
Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
Josef Eisl <josef.eisl@jku.at>
parents:
18192
diff
changeset
|
424 } |
0a17944b7baf
Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
Josef Eisl <josef.eisl@jku.at>
parents:
18192
diff
changeset
|
425 |
21547
78f0792aa890
fixed expected exception type in some TestResolvedJavaType tests
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
426 @Test(expected = JVMCIError.class) |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
427 public void getSingleImplementorTestPrimitiveReceiver() { |
18193
0a17944b7baf
Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
Josef Eisl <josef.eisl@jku.at>
parents:
18192
diff
changeset
|
428 ResolvedJavaType primitive = metaAccess.lookupJavaType(int.class); |
18194
b7226cb963c3
Rename ResolvedJavaType.getImplementor() to getSingleImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18193
diff
changeset
|
429 primitive.getSingleImplementor(); |
18193
0a17944b7baf
Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
Josef Eisl <josef.eisl@jku.at>
parents:
18192
diff
changeset
|
430 } |
0a17944b7baf
Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
Josef Eisl <josef.eisl@jku.at>
parents:
18192
diff
changeset
|
431 |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
432 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
433 public void getComponentTypeTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
434 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
435 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
436 Class<?> expected = c.getComponentType(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
437 ResolvedJavaType actual = type.getComponentType(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
438 if (expected == null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
439 assertNull(actual); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
440 } else { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
441 assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
442 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
443 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
444 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
445 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
446 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
447 public void getArrayClassTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
448 for (Class<?> c : classes) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
449 if (c != void.class) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
450 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
451 Class<?> expected = getArrayClass(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
452 ResolvedJavaType actual = type.getArrayClass(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
453 assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
454 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
455 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
456 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
457 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
458 static class Declarations { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
459 |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
460 final Method implementation; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
461 final Set<Method> declarations; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
462 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
463 public Declarations(Method impl) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
464 this.implementation = impl; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
465 declarations = new HashSet<>(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
466 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
467 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
468 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
469 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
470 * See <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html#jvms-5.4.5">Method |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
471 * overriding</a>. |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
472 */ |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
473 static boolean isOverriderOf(Method impl, Method m) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
474 if (!isPrivate(m.getModifiers()) && !isFinal(m.getModifiers())) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
475 if (m.getName().equals(impl.getName())) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
476 if (m.getReturnType() == impl.getReturnType()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
477 if (Arrays.equals(m.getParameterTypes(), impl.getParameterTypes())) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
478 if (isPublic(m.getModifiers()) || isProtected(m.getModifiers())) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
479 // m is public or protected |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
480 return isPublic(impl.getModifiers()) || isProtected(impl.getModifiers()); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
481 } else { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
482 // m is package-private |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
483 return impl.getDeclaringClass().getPackage() == m.getDeclaringClass().getPackage(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
484 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
485 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
486 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
487 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
488 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
489 return false; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
490 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
491 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
492 static final Map<Class<?>, VTable> vtables = new HashMap<>(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
493 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
494 static class VTable { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
495 |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7043
diff
changeset
|
496 final Map<NameAndSignature, Method> methods = new HashMap<>(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
497 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
498 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
499 static synchronized VTable getVTable(Class<?> c) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
500 VTable vtable = vtables.get(c); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
501 if (vtable == null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
502 vtable = new VTable(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
503 if (c != Object.class) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
504 VTable superVtable = getVTable(c.getSuperclass()); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
505 vtable.methods.putAll(superVtable.methods); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
506 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
507 for (Method m : c.getDeclaredMethods()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
508 if (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers())) { |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
509 if (isAbstract(m.getModifiers())) { |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
510 // A subclass makes a concrete method in a superclass abstract |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
511 vtable.methods.remove(new NameAndSignature(m)); |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
512 } else { |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
513 vtable.methods.put(new NameAndSignature(m), m); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
514 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
515 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
516 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
517 vtables.put(c, vtable); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
518 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
519 return vtable; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
520 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
521 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
522 static Set<Method> findDeclarations(Method impl, Class<?> c) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
523 Set<Method> declarations = new HashSet<>(); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7043
diff
changeset
|
524 NameAndSignature implSig = new NameAndSignature(impl); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
525 if (c != null) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
526 for (Method m : c.getDeclaredMethods()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7043
diff
changeset
|
527 if (new NameAndSignature(m).equals(implSig)) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
528 declarations.add(m); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
529 break; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
530 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
531 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
532 if (!c.isInterface()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
533 declarations.addAll(findDeclarations(impl, c.getSuperclass())); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
534 } |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
535 for (Class<?> i : c.getInterfaces()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
536 declarations.addAll(findDeclarations(impl, i)); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
537 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
538 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
539 return declarations; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
540 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
541 |
15722
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15040
diff
changeset
|
542 private static void checkResolveMethod(ResolvedJavaType type, ResolvedJavaType context, ResolvedJavaMethod decl, ResolvedJavaMethod expected) { |
18191
839f97696479
Rename ResolvedJavaMethod.resolvedMethod() to resolveConcreteMethod() the reflect its actual behavior.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
543 ResolvedJavaMethod impl = type.resolveConcreteMethod(decl, context); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
544 assertEquals(expected, impl); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
545 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
546 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
547 @Test |
18192
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
548 public void resolveMethodTest() { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
549 ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
550 for (Class<?> c : classes) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
551 if (c.isInterface() || c.isPrimitive()) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
552 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
553 for (Method m : c.getDeclaredMethods()) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
554 if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
555 ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
556 ResolvedJavaMethod impl = type.resolveMethod(resolved, context, true); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
557 ResolvedJavaMethod expected = resolved.isDefault() || resolved.isAbstract() ? resolved : null; |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
558 assertEquals(m.toString(), expected, impl); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
559 } else { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
560 // As of JDK 8, interfaces can have static and private methods |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
561 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
562 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
563 } else { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
564 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
565 VTable vtable = getVTable(c); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
566 for (Method impl : vtable.methods.values()) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
567 Set<Method> decls = findDeclarations(impl, c); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
568 for (Method decl : decls) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
569 ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
570 if (m.isPublic()) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
571 ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
572 checkResolveMethod(type, context, m, i); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
573 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
574 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
575 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
576 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
577 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
578 } |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
579 |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
580 @Test |
18191
839f97696479
Rename ResolvedJavaMethod.resolvedMethod() to resolveConcreteMethod() the reflect its actual behavior.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
581 public void resolveConcreteMethodTest() { |
15722
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15040
diff
changeset
|
582 ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
583 for (Class<?> c : classes) { |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
584 if (c.isInterface() || c.isPrimitive()) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
585 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
586 for (Method m : c.getDeclaredMethods()) { |
13183
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
587 if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) { |
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
588 ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); |
18191
839f97696479
Rename ResolvedJavaMethod.resolvedMethod() to resolveConcreteMethod() the reflect its actual behavior.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
589 ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context); |
13183
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
590 ResolvedJavaMethod expected = resolved.isDefault() ? resolved : null; |
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
591 assertEquals(m.toString(), expected, impl); |
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
592 } else { |
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
593 // As of JDK 8, interfaces can have static and private methods |
0266ac3b26c0
JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
594 } |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
595 } |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
596 } else { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
597 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
598 VTable vtable = getVTable(c); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
599 for (Method impl : vtable.methods.values()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
600 Set<Method> decls = findDeclarations(impl, c); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
601 for (Method decl : decls) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
602 ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); |
15722
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15040
diff
changeset
|
603 if (m.isPublic()) { |
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15040
diff
changeset
|
604 ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); |
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15040
diff
changeset
|
605 checkResolveMethod(type, context, m, i); |
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15040
diff
changeset
|
606 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
607 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
608 } |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
609 for (Method m : c.getDeclaredMethods()) { |
18191
839f97696479
Rename ResolvedJavaMethod.resolvedMethod() to resolveConcreteMethod() the reflect its actual behavior.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
610 ResolvedJavaMethod impl = type.resolveConcreteMethod(metaAccess.lookupJavaMethod(m), context); |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
611 ResolvedJavaMethod expected = isAbstract(m.getModifiers()) ? null : impl; |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
612 assertEquals(type + " " + m.toString(), expected, impl); |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
613 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
614 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
615 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
616 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
617 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
618 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
619 public void findUniqueConcreteMethodTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
620 ResolvedJavaMethod thisMethod = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("findUniqueConcreteMethodTest")); |
19795
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18950
diff
changeset
|
621 ResolvedJavaMethod ucm = metaAccess.lookupJavaType(getClass()).findUniqueConcreteMethod(thisMethod).getResult(); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
622 assertEquals(thisMethod, ucm); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
623 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
624 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
625 public static Set<Field> getInstanceFields(Class<?> c, boolean includeSuperclasses) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
626 if (c.isArray() || c.isPrimitive() || c.isInterface()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
627 return Collections.emptySet(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
628 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
629 Set<Field> result = new HashSet<>(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
630 for (Field f : c.getDeclaredFields()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
631 if (!Modifier.isStatic(f.getModifiers())) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
632 result.add(f); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
633 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
634 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
635 if (includeSuperclasses && c != Object.class) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
636 result.addAll(getInstanceFields(c.getSuperclass(), true)); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
637 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
638 return result; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
639 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
640 |
15841
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
641 public static Set<Field> getStaticFields(Class<?> c) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
642 Set<Field> result = new HashSet<>(); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
643 for (Field f : c.getDeclaredFields()) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
644 if (Modifier.isStatic(f.getModifiers())) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
645 result.add(f); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
646 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
647 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
648 return result; |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
649 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
650 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
651 public boolean fieldsEqual(Field f, ResolvedJavaField rjf) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
652 return rjf.getDeclaringClass().equals(metaAccess.lookupJavaType(f.getDeclaringClass())) && rjf.getName().equals(f.getName()) && |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
653 rjf.getType().resolve(rjf.getDeclaringClass()).equals(metaAccess.lookupJavaType(f.getType())); |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
654 } |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
655 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
656 public ResolvedJavaField lookupField(ResolvedJavaField[] fields, Field key) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
657 for (ResolvedJavaField rf : fields) { |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
658 if (fieldsEqual(key, rf)) { |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
659 return rf; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
660 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
661 } |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
662 return null; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
663 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
664 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
665 public Field lookupField(Set<Field> fields, ResolvedJavaField key) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
666 for (Field f : fields) { |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
667 if (fieldsEqual(f, key)) { |
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
668 return f; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
669 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
670 } |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
671 return null; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
672 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
673 |
21663
381ab4105afe
moved com.oracle.graal.java.test to com.oracle.jvmci.runtime.test
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
674 private static boolean isHiddenFromReflection(ResolvedJavaField f) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
675 if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(Throwable.class)) && f.getName().equals("backtrace")) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
676 return true; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
677 } |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
678 if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(ConstantPool.class)) && f.getName().equals("constantPoolOop")) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
679 return true; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
680 } |
20811
652194a6414f
Class.classloader is hidden from reflection
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19796
diff
changeset
|
681 if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(Class.class)) && f.getName().equals("classLoader")) { |
652194a6414f
Class.classloader is hidden from reflection
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19796
diff
changeset
|
682 return true; |
652194a6414f
Class.classloader is hidden from reflection
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19796
diff
changeset
|
683 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
684 return false; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
685 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
686 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
687 @Test |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
688 public void getInstanceFieldsTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
689 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
690 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7282
diff
changeset
|
691 for (boolean includeSuperclasses : new boolean[]{true, false}) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
692 Set<Field> expected = getInstanceFields(c, includeSuperclasses); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
693 ResolvedJavaField[] actual = type.getInstanceFields(includeSuperclasses); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
694 for (Field f : expected) { |
7056
2841e28b5f41
added test for ResolvedJavaType.findFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
695 assertNotNull(lookupField(actual, f)); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
696 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
697 for (ResolvedJavaField rf : actual) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
698 if (!isHiddenFromReflection(rf)) { |
20811
652194a6414f
Class.classloader is hidden from reflection
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19796
diff
changeset
|
699 assertEquals(rf.toString(), lookupField(expected, rf) != null, !rf.isInternal()); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
700 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
701 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
702 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
703 // Test stability of getInstanceFields |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
704 ResolvedJavaField[] actual2 = type.getInstanceFields(includeSuperclasses); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
705 assertArrayEquals(actual, actual2); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
706 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
707 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
708 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
709 |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
710 @Test |
15841
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
711 public void getStaticFieldsTest() { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
712 for (Class<?> c : classes) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
713 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
714 Set<Field> expected = getStaticFields(c); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
715 ResolvedJavaField[] actual = type.getStaticFields(); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
716 for (Field f : expected) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
717 assertNotNull(lookupField(actual, f)); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
718 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
719 for (ResolvedJavaField rf : actual) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
720 if (!isHiddenFromReflection(rf)) { |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
721 assertEquals(lookupField(expected, rf) != null, !rf.isInternal()); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
722 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
723 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
724 |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
725 // Test stability of getStaticFields |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
726 ResolvedJavaField[] actual2 = type.getStaticFields(); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
727 assertArrayEquals(actual, actual2); |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
728 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
729 } |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
730 |
cb87019df5aa
Add test for getStaticFields()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15729
diff
changeset
|
731 @Test |
11953
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
732 public void getDeclaredMethodsTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
733 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
734 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
11953
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
735 Method[] raw = c.getDeclaredMethods(); |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
736 Set<ResolvedJavaMethod> expected = new HashSet<>(); |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
737 for (Method m : raw) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
738 ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(m); |
11953
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
739 assertNotNull(resolvedMethod); |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
740 expected.add(resolvedMethod); |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
741 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
742 Set<ResolvedJavaMethod> actual = new HashSet<>(Arrays.asList(type.getDeclaredMethods())); |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
743 assertEquals(expected, actual); |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
744 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
745 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
746 |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
747 static class A { |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
748 static String name = "foo"; |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
749 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
750 |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
751 static class B extends A { |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
752 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
753 |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
754 static class C { |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
755 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
756 |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
757 static class D { |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
758 void foo() { |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
759 // use of assertions causes the class to have a <clinit> |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
760 assert getClass() != null; |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
761 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
762 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
763 |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
764 @Test |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
765 public void getClassInitializerTest() { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
766 assertNotNull(metaAccess.lookupJavaType(A.class).getClassInitializer()); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
767 assertNotNull(metaAccess.lookupJavaType(D.class).getClassInitializer()); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
768 assertNull(metaAccess.lookupJavaType(B.class).getClassInitializer()); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
769 assertNull(metaAccess.lookupJavaType(C.class).getClassInitializer()); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
770 assertNull(metaAccess.lookupJavaType(int.class).getClassInitializer()); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
771 assertNull(metaAccess.lookupJavaType(void.class).getClassInitializer()); |
11953
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
772 } |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
773 |
f9f18098479e
added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
774 @Test |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
775 public void getAnnotationTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
776 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
777 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
778 for (Annotation a : c.getAnnotations()) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
779 assertEquals(a, type.getAnnotation(a.annotationType())); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
780 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
781 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
782 } |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
783 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
784 @Test |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
785 public void memberClassesTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
786 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
787 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
788 assertEquals(c.isLocalClass(), type.isLocal()); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
789 assertEquals(c.isMemberClass(), type.isMember()); |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
790 Class<?> enclc = c.getEnclosingClass(); |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
791 ResolvedJavaType enclt = type.getEnclosingType(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
792 assertFalse(enclc == null ^ enclt == null); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
793 if (enclc != null) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
794 assertEquals(enclt, metaAccess.lookupJavaType(enclc)); |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
795 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
796 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
797 } |
7831
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
798 |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
799 @Test |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
800 public void classFilePathTest() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
801 for (Class<?> c : classes) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11953
diff
changeset
|
802 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
7831
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
803 URL path = type.getClassFilePath(); |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
804 if (type.isPrimitive() || type.isArray()) { |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
805 assertEquals(null, path); |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
806 } else { |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
807 assertNotNull(path); |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
808 String pathString = path.getPath(); |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
809 if (type.isLocal() || type.isMember()) { |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
810 assertTrue(pathString.indexOf('$') > 0); |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
811 } |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
812 } |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
813 } |
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
814 } |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
815 |
17156
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
816 @Test |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
817 public void isTrustedInterfaceTypeTest() { |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
818 for (Class<?> c : classes) { |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
819 ResolvedJavaType type = metaAccess.lookupJavaType(c); |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
820 if (TrustedInterface.class.isAssignableFrom(c)) { |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
821 assertTrue(type.isTrustedInterfaceType()); |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
822 } |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
823 } |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
824 } |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16491
diff
changeset
|
825 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
826 private Method findTestMethod(Method apiMethod) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
827 String testName = apiMethod.getName() + "Test"; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
828 for (Method m : getClass().getDeclaredMethods()) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
829 if (m.getName().equals(testName) && m.getAnnotation(Test.class) != null) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
830 return m; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
831 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
832 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
833 return null; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
834 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
835 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
836 // @formatter:off |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
837 private static final String[] untestedApiMethods = { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
838 "initialize", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
839 "isPrimitive", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
840 "newArray", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
841 "getDeclaredConstructors", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
842 "isInitialized", |
11520
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9806
diff
changeset
|
843 "isLinked", |
18361
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18194
diff
changeset
|
844 "getJavaClass", |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18194
diff
changeset
|
845 "getObjectHub", |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
846 "hasFinalizableSubclass", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
847 "hasFinalizer", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
848 "getSourceFileName", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
849 "getClassFilePath", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
850 "isLocal", |
16491
4d7a9829315e
moved isJavaLangObject(ResolvedJavaType type) from MetaUtil to be a default method in ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
16485
diff
changeset
|
851 "isJavaLangObject", |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
852 "isMember", |
16485
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15841
diff
changeset
|
853 "getElementalType", |
18694
ec1b0b097d82
Ignore $jacocoInit methods in coverage tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
18533
diff
changeset
|
854 "getEnclosingType", |
ec1b0b097d82
Ignore $jacocoInit methods in coverage tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
18533
diff
changeset
|
855 "$jacocoInit" |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
856 }; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
857 // @formatter:on |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
858 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
859 /** |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
860 * Ensures that any new methods added to {@link ResolvedJavaMethod} either have a test written |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
861 * for them or are added to {@link #untestedApiMethods}. |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
862 */ |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
863 @Test |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
864 public void testCoverage() { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
865 Set<String> known = new HashSet<>(Arrays.asList(untestedApiMethods)); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
866 for (Method m : ResolvedJavaType.class.getDeclaredMethods()) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
867 if (findTestMethod(m) == null) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
868 assertTrue("test missing for " + m, known.contains(m.getName())); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
869 } else { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
870 assertFalse("test should be removed from untestedApiMethods" + m, known.contains(m.getName())); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
871 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
872 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
8959
diff
changeset
|
873 } |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
874 } |