Mercurial > hg > graal-jvmci-8
annotate jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaMethod.java @ 22012:53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Thu, 18 Jun 2015 17:44:47 +0200 |
parents | 4c9d4fe1cbd8 |
children | 547ae53182bf |
rev | line source |
---|---|
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
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:
21629
diff
changeset
|
23 package com.oracle.jvmci.runtime.test; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static org.junit.Assert.*; |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
27 import java.lang.annotation.*; |
22012
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
28 import java.lang.invoke.*; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import java.lang.reflect.*; |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import java.util.*; |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import org.junit.*; |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
34 import com.oracle.jvmci.meta.*; |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
35 |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 /** |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 * Tests for {@link ResolvedJavaMethod}. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 */ |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
39 public class TestResolvedJavaMethod extends MethodUniverse { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 public TestResolvedJavaMethod() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 /** |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 * @see ResolvedJavaMethod#getCode() |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 */ |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 public void getCodeTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 byte[] code = m.getCode(); |
7914
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
52 if (code == null) { |
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
53 assertTrue(m.getCodeSize() == 0); |
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
54 } else { |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15267
diff
changeset
|
55 if (m.isAbstract()) { |
7914
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
56 assertTrue(code.length == 0); |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15267
diff
changeset
|
57 } else if (!m.isNative()) { |
7914
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
58 assertTrue(code.length > 0); |
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
59 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 /** |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 * @see ResolvedJavaMethod#getCodeSize() |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 */ |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 public void getCodeSizeTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 int codeSize = m.getCodeSize(); |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15267
diff
changeset
|
72 if (m.isAbstract()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 assertTrue(codeSize == 0); |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15267
diff
changeset
|
74 } else if (!m.isNative()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 assertTrue(codeSize > 0); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 public void getModifiersTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 ResolvedJavaMethod m = e.getValue(); |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
84 int expected = e.getKey().getModifiers(); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 int actual = m.getModifiers(); |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
86 assertEquals(String.format("%s: 0x%x != 0x%x", m, expected, actual), expected, actual); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
87 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
88 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
89 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
90 int expected = e.getKey().getModifiers(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
91 int actual = m.getModifiers(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
92 assertEquals(String.format("%s: 0x%x != 0x%x", m, expected, actual), expected, actual); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 /** |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 * @see ResolvedJavaMethod#isClassInitializer() |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 */ |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 public void isClassInitializerTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 // Class initializers are hidden from reflection |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 assertFalse(m.isClassInitializer()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
106 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 assertFalse(m.isClassInitializer()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 public void isConstructorTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 assertFalse(m.isConstructor()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
118 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 assertTrue(m.isConstructor()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 @Test |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
125 public void isSyntheticTest() { |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
126 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
127 ResolvedJavaMethod m = e.getValue(); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
128 assertEquals(e.getKey().isSynthetic(), m.isSynthetic()); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
129 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
130 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
131 ResolvedJavaMethod m = e.getValue(); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
132 assertEquals(e.getKey().isSynthetic(), m.isSynthetic()); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
133 } |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
134 } |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
135 |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
136 @Test |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
137 public void isBridgeTest() { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
138 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
139 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
140 assertEquals(e.getKey().isBridge(), m.isBridge()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
141 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
142 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
143 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
144 assertEquals(false, m.isBridge()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
145 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
146 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
147 |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
148 @Test |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
149 public void isVarArgsTest() { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
150 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
151 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
152 assertEquals(e.getKey().isVarArgs(), m.isVarArgs()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
153 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
154 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
155 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
156 assertEquals(e.getKey().isVarArgs(), m.isVarArgs()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
157 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
158 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
159 |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
160 @Test |
15267
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
161 public void isSynchronizedTest() { |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
162 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
163 ResolvedJavaMethod m = e.getValue(); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
164 assertEquals(Modifier.isSynchronized(e.getKey().getModifiers()), m.isSynchronized()); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
165 } |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
166 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
167 ResolvedJavaMethod m = e.getValue(); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
168 assertEquals(Modifier.isSynchronized(e.getKey().getModifiers()), m.isSynchronized()); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
169 } |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
170 } |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
171 |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
172 @Test |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 public void canBeStaticallyBoundTest() { |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
174 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
175 ResolvedJavaMethod m = e.getValue(); |
15102
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
176 assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey())); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
177 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
178 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
179 ResolvedJavaMethod m = e.getValue(); |
15102
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
180 assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey())); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
181 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 |
15102
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
184 private static boolean canBeStaticallyBound(Member method) { |
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
185 int modifiers = method.getModifiers(); |
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
186 return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isFinal(method.getDeclaringClass().getModifiers())) && |
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
187 !Modifier.isAbstract(modifiers); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
188 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
189 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
190 private static String methodWithExceptionHandlers(String p1, Object o2) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
191 try { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
192 return p1.substring(100) + o2.toString(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
193 } catch (IndexOutOfBoundsException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
194 e.printStackTrace(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
195 } catch (NullPointerException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
196 e.printStackTrace(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
197 } catch (RuntimeException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
198 e.printStackTrace(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
199 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
200 return null; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
204 public void getExceptionHandlersTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
205 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithExceptionHandlers", String.class, Object.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
206 ExceptionHandler[] handlers = method.getExceptionHandlers(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
207 assertNotNull(handlers); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
208 assertEquals(handlers.length, 3); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
209 handlers[0].getCatchType().equals(metaAccess.lookupJavaType(IndexOutOfBoundsException.class)); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
210 handlers[1].getCatchType().equals(metaAccess.lookupJavaType(NullPointerException.class)); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
211 handlers[2].getCatchType().equals(metaAccess.lookupJavaType(RuntimeException.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
212 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
213 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
214 private static String nullPointerExceptionOnFirstLine(Object o, String ignored) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
215 return o.toString() + ignored; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
219 public void asStackTraceElementTest() throws NoSuchMethodException { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
220 try { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
221 nullPointerExceptionOnFirstLine(null, "ignored"); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
222 Assert.fail("should not reach here"); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
223 } catch (NullPointerException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
224 StackTraceElement expected = e.getStackTrace()[0]; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
225 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
226 StackTraceElement actual = method.asStackTraceElement(0); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
227 assertEquals(expected, actual); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
228 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
229 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
230 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
231 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
232 public void getConstantPoolTest() { |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
233 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
234 ResolvedJavaMethod m = e.getValue(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
235 ConstantPool cp = m.getConstantPool(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
236 assertTrue(cp.length() > 0); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
237 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
238 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
239 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
240 @Test(timeout = 1000L) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
241 public void getAnnotationTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
242 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationTest")); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
243 Test annotation = method.getAnnotation(Test.class); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
244 assertNotNull(annotation); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
245 assertEquals(1000L, annotation.timeout()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
246 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
247 |
17141
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
248 @Test(timeout = 1000L) |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
249 public void getAnnotationsTest() throws NoSuchMethodException { |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
250 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationsTest")); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
251 Annotation[] annotations = method.getAnnotations(); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
252 assertNotNull(annotations); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
253 assertEquals(1, annotations.length); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
254 assertEquals(1000L, ((Test) annotations[0]).timeout()); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
255 } |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
256 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
257 @Retention(RetentionPolicy.RUNTIME) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
258 @Target(ElementType.PARAMETER) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
259 @interface NonNull { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
260 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
261 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
262 @Retention(RetentionPolicy.RUNTIME) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
263 @Target(ElementType.PARAMETER) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
264 @interface Special { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
265 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
266 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
267 private static native void methodWithAnnotatedParameters(@NonNull HashMap<String, String> p1, @Special @NonNull Class<? extends Annotation> p2); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
268 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
269 @Test |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
270 public void getParameterAnnotationsTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
271 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
272 Annotation[][] annotations = method.getParameterAnnotations(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
273 assertEquals(2, annotations.length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
274 assertEquals(1, annotations[0].length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
275 assertEquals(NonNull.class, annotations[0][0].annotationType()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
276 assertEquals(2, annotations[1].length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
277 assertEquals(Special.class, annotations[1][0].annotationType()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
278 assertEquals(NonNull.class, annotations[1][1].annotationType()); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
279 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
280 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
281 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
282 public void getGenericParameterTypesTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
283 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
284 Type[] genericParameterTypes = method.getGenericParameterTypes(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
285 assertEquals(2, genericParameterTypes.length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
286 assertEquals("java.util.HashMap<java.lang.String, java.lang.String>", genericParameterTypes[0].toString()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
287 assertEquals("java.lang.Class<? extends java.lang.annotation.Annotation>", genericParameterTypes[1].toString()); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
288 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
289 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
290 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
291 public void getMaxLocalsTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
292 ResolvedJavaMethod method1 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
293 ResolvedJavaMethod method2 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
294 assertEquals(0, method1.getMaxLocals()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
295 assertEquals(2, method2.getMaxLocals()); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
296 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
297 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
300 public void getMaxStackSizeTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
301 ResolvedJavaMethod method1 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
302 ResolvedJavaMethod method2 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
303 assertEquals(0, method1.getMaxStackSize()); |
9869
17e31cfaf037
TestResolvedJavaMethod: relax check for max stack size
Bernhard Urban <bernhard.urban@jku.at>
parents:
9806
diff
changeset
|
304 // some versions of javac produce bytecode with a stacksize of 2 for this method |
11718
f679f5411fd7
Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9984
diff
changeset
|
305 // JSR 292 also sometimes need one more stack slot |
f679f5411fd7
Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9984
diff
changeset
|
306 int method2StackSize = method2.getMaxStackSize(); |
f679f5411fd7
Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9984
diff
changeset
|
307 assertTrue(2 <= method2StackSize && method2StackSize <= 4); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
308 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
309 |
16485
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
310 @Test |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
311 public void isDefaultTest() { |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
312 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
313 ResolvedJavaMethod m = e.getValue(); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
314 assertEquals(e.getKey().isDefault(), m.isDefault()); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
315 } |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
316 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
317 ResolvedJavaMethod m = e.getValue(); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
318 assertFalse(m.isDefault()); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
319 } |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
320 } |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
321 |
18830
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
322 @Test |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
323 public void hasReceiverTest() { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
324 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
325 ResolvedJavaMethod m = e.getValue(); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
326 assertTrue(m.hasReceiver() != Modifier.isStatic(e.getKey().getModifiers())); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
327 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
328 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
329 ResolvedJavaMethod m = e.getValue(); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
330 assertTrue(m.hasReceiver()); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
331 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
332 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
333 |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
334 @Test |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
335 public void hasBytecodesTest() { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
336 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
337 ResolvedJavaMethod m = e.getValue(); |
18835
f679e2e2ed32
Fix unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18830
diff
changeset
|
338 assertTrue(m.hasBytecodes() == (m.isConcrete() && !m.isNative())); |
18830
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
339 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
340 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
341 ResolvedJavaMethod m = e.getValue(); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
342 assertTrue(m.hasBytecodes()); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
343 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
344 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
345 |
21276
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
346 @Test |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
347 public void isJavaLangObjectInitTest() throws NoSuchMethodException { |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
348 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Object.class.getConstructor()); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
349 assertTrue(method.isJavaLangObjectInit()); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
350 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
351 ResolvedJavaMethod m = e.getValue(); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
352 assertFalse(m.isJavaLangObjectInit()); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
353 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
354 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
355 ResolvedJavaMethod m = e.getValue(); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
356 Constructor<?> key = e.getKey(); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
357 if (key.getDeclaringClass() == Object.class && key.getParameters().length == 0) { |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
358 assertTrue(m.isJavaLangObjectInit()); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
359 } else { |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
360 assertFalse(m.isJavaLangObjectInit()); |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
361 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
362 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
363 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
364 |
22012
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
365 @Test |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
366 public void isSignaturePolymorphicTest() { |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
367 ResolvedJavaType methodHandleType = metaAccess.lookupJavaType(MethodHandle.class); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
368 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "invokeExact", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
369 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "invoke", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
370 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "invokeBasic", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
371 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "linkToVirtual", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
372 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "linkToStatic", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
373 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "linkToSpecial", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
374 assertTrue(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "linkToInterface", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
375 assertFalse(ResolvedJavaMethod.isSignaturePolymorphic(methodHandleType, "type", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
376 assertFalse(ResolvedJavaMethod.isSignaturePolymorphic(metaAccess.lookupJavaType(Object.class), "toString", metaAccess)); |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
377 } |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
378 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
379 private Method findTestMethod(Method apiMethod) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
380 String testName = apiMethod.getName() + "Test"; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
381 for (Method m : getClass().getDeclaredMethods()) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
382 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:
7914
diff
changeset
|
383 return m; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
384 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
385 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
386 return null; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
387 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
388 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
389 // @formatter:off |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
390 private static final String[] untestedApiMethods = { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
391 "invoke", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
392 "newInstance", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
393 "getDeclaringClass", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
394 "getEncoding", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
395 "getProfilingInfo", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
396 "reprofile", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
397 "getCompilerStorage", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
398 "canBeInlined", |
13953
d587baa55dd7
Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13249
diff
changeset
|
399 "shouldBeInlined", |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
400 "getLineNumberTable", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
401 "getLocalVariableTable", |
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
|
402 "isInVirtualMethodTable", |
16489
db92d4a1564a
fixed minor regression
Doug Simon <doug.simon@oracle.com>
parents:
16485
diff
changeset
|
403 "toParameterTypes", |
18694
ec1b0b097d82
Ignore $jacocoInit methods in coverage tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
17141
diff
changeset
|
404 "getParameterAnnotation", |
21629
36cf15e3219e
Move HotSpotResolvedJavaMethod.getSpeculationLog to ResolvedJavaMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21565
diff
changeset
|
405 "getSpeculationLog", |
18694
ec1b0b097d82
Ignore $jacocoInit methods in coverage tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
17141
diff
changeset
|
406 "$jacocoInit" |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
407 }; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
408 // @formatter:on |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
409 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
410 /** |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
411 * 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:
7914
diff
changeset
|
412 * for them or are added to {@link #untestedApiMethods}. |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
413 */ |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
414 @Test |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
415 public void testCoverage() { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
416 Set<String> known = new HashSet<>(Arrays.asList(untestedApiMethods)); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
417 for (Method m : ResolvedJavaMethod.class.getDeclaredMethods()) { |
22012
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
418 if (Modifier.isStatic(m.getModifiers())) { |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
419 continue; |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
420 } |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
421 if (findTestMethod(m) == null) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
422 assertTrue("test missing for " + m, known.contains(m.getName())); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
423 } else { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
424 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:
7914
diff
changeset
|
425 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
426 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
427 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
428 } |