Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java @ 24225:a2dbb6fcc923
Added tag jvmci-0.33 for changeset 3aed4cb813f4
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 18 Aug 2017 22:47:33 +0200 |
parents | 6d2c72b822b0 |
children |
rev | line source |
---|---|
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
22518
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
7044
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 */ |
22518
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
23 |
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
24 /** |
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
25 * @test |
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
26 * @compile TestResolvedJavaMethod.java MethodUniverse.java TypeUniverse.java TestMetaAccessProvider.java |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22648
diff
changeset
|
27 * @run junit jdk.vm.ci.runtime.test.TestResolvedJavaMethod |
22518
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
28 */ |
37d2643aa69a
Add jtreg annotations to some tests
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
29 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22648
diff
changeset
|
30 package jdk.vm.ci.runtime.test; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 |
23789
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
32 import static org.junit.Assert.assertArrayEquals; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
33 import static org.junit.Assert.assertEquals; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
34 import static org.junit.Assert.assertFalse; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
35 import static org.junit.Assert.assertNotNull; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
36 import static org.junit.Assert.assertTrue; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
38 import java.lang.annotation.Annotation; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
39 import java.lang.annotation.ElementType; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
40 import java.lang.annotation.Retention; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
41 import java.lang.annotation.RetentionPolicy; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
42 import java.lang.annotation.Target; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
43 import java.lang.reflect.Constructor; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
44 import java.lang.reflect.Member; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
45 import java.lang.reflect.Method; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
46 import java.lang.reflect.Modifier; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
47 import java.lang.reflect.Type; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
48 import java.util.Arrays; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
49 import java.util.HashMap; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
50 import java.util.HashSet; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
51 import java.util.Map; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22518
diff
changeset
|
52 import java.util.Set; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 |
23741
6542cd8da2da
include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents:
23728
diff
changeset
|
54 import org.junit.Assert; |
6542cd8da2da
include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents:
23728
diff
changeset
|
55 import org.junit.Test; |
6542cd8da2da
include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents:
23728
diff
changeset
|
56 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22648
diff
changeset
|
57 import jdk.vm.ci.meta.ConstantPool; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22648
diff
changeset
|
58 import jdk.vm.ci.meta.ExceptionHandler; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22648
diff
changeset
|
59 import jdk.vm.ci.meta.ResolvedJavaMethod; |
23789
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
60 import jdk.vm.ci.meta.ResolvedJavaMethod.Parameter; |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22648
diff
changeset
|
61 import jdk.vm.ci.meta.ResolvedJavaType; |
7044
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 * Tests for {@link ResolvedJavaMethod}. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 */ |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
66 public class TestResolvedJavaMethod extends MethodUniverse { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 public TestResolvedJavaMethod() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 /** |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 * @see ResolvedJavaMethod#getCode() |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 */ |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 public void getCodeTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 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
|
77 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 byte[] code = m.getCode(); |
7914
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
79 if (code == null) { |
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
80 assertTrue(m.getCodeSize() == 0); |
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
81 } 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
|
82 if (m.isAbstract()) { |
7914
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
83 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
|
84 } else if (!m.isNative()) { |
7914
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
85 assertTrue(code.length > 0); |
3b5578749256
fixed API and test for ResolvedJavaMethod.getCode()
Doug Simon <doug.simon@oracle.com>
parents:
7044
diff
changeset
|
86 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 /** |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 * @see ResolvedJavaMethod#getCodeSize() |
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 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 public void getCodeSizeTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 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
|
97 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 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
|
99 if (m.isAbstract()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 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
|
101 } else if (!m.isNative()) { |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 assertTrue(codeSize > 0); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 public void getModifiersTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 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
|
110 ResolvedJavaMethod m = e.getValue(); |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
111 int expected = e.getKey().getModifiers(); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 int actual = m.getModifiers(); |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
113 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
|
114 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
115 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
|
116 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
117 int expected = e.getKey().getModifiers(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
118 int actual = m.getModifiers(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
119 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
|
120 } |
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 * @see ResolvedJavaMethod#isClassInitializer() |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 */ |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 public void isClassInitializerTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 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
|
129 // Class initializers are hidden from reflection |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 assertFalse(m.isClassInitializer()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
133 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
|
134 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 assertFalse(m.isClassInitializer()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 public void isConstructorTest() { |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 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
|
142 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 assertFalse(m.isConstructor()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
145 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
|
146 ResolvedJavaMethod m = e.getValue(); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 assertTrue(m.isConstructor()); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 @Test |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
152 public void isSyntheticTest() { |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
153 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
154 ResolvedJavaMethod m = e.getValue(); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
155 assertEquals(e.getKey().isSynthetic(), m.isSynthetic()); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
156 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
157 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
|
158 ResolvedJavaMethod m = e.getValue(); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
159 assertEquals(e.getKey().isSynthetic(), m.isSynthetic()); |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
160 } |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
161 } |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
162 |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9869
diff
changeset
|
163 @Test |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
164 public void isBridgeTest() { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
165 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
|
166 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
167 assertEquals(e.getKey().isBridge(), m.isBridge()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
168 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
169 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
|
170 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
171 assertEquals(false, m.isBridge()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
172 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
173 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
174 |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
175 @Test |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
176 public void isVarArgsTest() { |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
177 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
|
178 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
179 assertEquals(e.getKey().isVarArgs(), m.isVarArgs()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
180 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
181 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
|
182 ResolvedJavaMethod m = e.getValue(); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
183 assertEquals(e.getKey().isVarArgs(), m.isVarArgs()); |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
184 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
185 } |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
186 |
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
187 @Test |
15267
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
188 public void isSynchronizedTest() { |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
189 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
190 ResolvedJavaMethod m = e.getValue(); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
191 assertEquals(Modifier.isSynchronized(e.getKey().getModifiers()), m.isSynchronized()); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
192 } |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
193 for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) { |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
194 ResolvedJavaMethod m = e.getValue(); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
195 assertEquals(Modifier.isSynchronized(e.getKey().getModifiers()), m.isSynchronized()); |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
196 } |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
197 } |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
198 |
98d45600222c
Add ResolvedJavaMethod.isSynchronized
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15102
diff
changeset
|
199 @Test |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 public void canBeStaticallyBoundTest() { |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
201 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
|
202 ResolvedJavaMethod m = e.getValue(); |
15102
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
203 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
|
204 } |
13249
ff43107fd697
addressed compilation issue in Eclipse with JDT BETA_JAVA8
Doug Simon <doug.simon@oracle.com>
parents:
13183
diff
changeset
|
205 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
|
206 ResolvedJavaMethod m = e.getValue(); |
15102
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
207 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
|
208 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 |
15102
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
211 private static boolean canBeStaticallyBound(Member method) { |
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
212 int modifiers = method.getModifiers(); |
175111728365
improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14545
diff
changeset
|
213 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
|
214 !Modifier.isAbstract(modifiers); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
215 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
216 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
217 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
|
218 try { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
219 return p1.substring(100) + o2.toString(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
220 } catch (IndexOutOfBoundsException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
221 e.printStackTrace(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
222 } catch (NullPointerException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
223 e.printStackTrace(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
224 } catch (RuntimeException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
225 e.printStackTrace(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
226 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
227 return null; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
228 } |
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 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
231 public void getExceptionHandlersTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
232 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
|
233 ExceptionHandler[] handlers = method.getExceptionHandlers(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
234 assertNotNull(handlers); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
235 assertEquals(handlers.length, 3); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
240 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
241 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
|
242 return o.toString() + ignored; |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
246 public void asStackTraceElementTest() throws NoSuchMethodException { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
247 try { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
248 nullPointerExceptionOnFirstLine(null, "ignored"); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
249 Assert.fail("should not reach here"); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
250 } catch (NullPointerException e) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
251 StackTraceElement expected = e.getStackTrace()[0]; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
252 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
|
253 StackTraceElement actual = method.asStackTraceElement(0); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
254 assertEquals(expected, actual); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
255 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
256 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
258 @Test |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 public void getConstantPoolTest() { |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
260 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
|
261 ResolvedJavaMethod m = e.getValue(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
262 ConstantPool cp = m.getConstantPool(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
263 assertTrue(cp.length() > 0); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
264 } |
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 |
23789
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
267 @Test |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
268 public void getParametersTest() { |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
269 for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) { |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
270 java.lang.reflect.Parameter[] expected = e.getKey().getParameters(); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
271 Parameter[] actual = e.getValue().getParameters(); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
272 assertEquals(actual.length, expected.length); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
273 for (int i = 0; i < actual.length; i++) { |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
274 java.lang.reflect.Parameter exp = expected[i]; |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
275 Parameter act = actual[i]; |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
276 assertEquals(exp.getName(), act.getName()); |
23790
224f43824e2b
incomplete API to MethodParameters attribute (JDK-8169331)
Doug Simon <doug.simon@oracle.com>
parents:
23789
diff
changeset
|
277 assertEquals(exp.isNamePresent(), act.isNamePresent()); |
23789
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
278 assertEquals(exp.getModifiers(), act.getModifiers()); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
279 assertArrayEquals(exp.getAnnotations(), act.getAnnotations()); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
280 assertEquals(exp.getType().getName(), act.getType().toClassName()); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
281 assertEquals(exp.getParameterizedType(), act.getParameterizedType()); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
282 assertEquals(metaAccess.lookupJavaMethod(exp.getDeclaringExecutable()), act.getDeclaringMethod()); |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
283 } |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
284 } |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
285 } |
0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
Doug Simon <doug.simon@oracle.com>
parents:
23749
diff
changeset
|
286 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
287 @Test(timeout = 1000L) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
288 public void getAnnotationTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
289 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
|
290 Test annotation = method.getAnnotation(Test.class); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
291 assertNotNull(annotation); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
292 assertEquals(1000L, annotation.timeout()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
293 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
294 |
17141
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
295 @Test(timeout = 1000L) |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
296 public void getAnnotationsTest() throws NoSuchMethodException { |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
297 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationsTest")); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
298 Annotation[] annotations = method.getAnnotations(); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
299 assertNotNull(annotations); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
300 assertEquals(1, annotations.length); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
301 assertEquals(1000L, ((Test) annotations[0]).timeout()); |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
302 } |
2d01369ee234
Add unit test
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16489
diff
changeset
|
303 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
304 @Retention(RetentionPolicy.RUNTIME) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
305 @Target(ElementType.PARAMETER) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
306 @interface NonNull { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
307 } |
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 @Retention(RetentionPolicy.RUNTIME) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
310 @Target(ElementType.PARAMETER) |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
311 @interface Special { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
312 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
313 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
314 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
|
315 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
316 @Test |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
317 public void getParameterAnnotationsTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
318 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
|
319 Annotation[][] annotations = method.getParameterAnnotations(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
320 assertEquals(2, annotations.length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
321 assertEquals(1, annotations[0].length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
322 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
|
323 assertEquals(2, annotations[1].length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
324 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
|
325 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
|
326 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
327 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
328 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
329 public void getGenericParameterTypesTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
330 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
|
331 Type[] genericParameterTypes = method.getGenericParameterTypes(); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
332 assertEquals(2, genericParameterTypes.length); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
333 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
|
334 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
|
335 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
336 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
337 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
338 public void getMaxLocalsTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
339 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
|
340 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
|
341 assertEquals(0, method1.getMaxLocals()); |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
342 assertEquals(2, method2.getMaxLocals()); |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
343 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
344 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
345 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
346 @Test |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
347 public void getMaxStackSizeTest() throws NoSuchMethodException { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11718
diff
changeset
|
348 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
|
349 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
|
350 assertEquals(0, method1.getMaxStackSize()); |
9869
17e31cfaf037
TestResolvedJavaMethod: relax check for max stack size
Bernhard Urban <bernhard.urban@jku.at>
parents:
9806
diff
changeset
|
351 // 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
|
352 // 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
|
353 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
|
354 assertTrue(2 <= method2StackSize && method2StackSize <= 4); |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
355 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
356 |
16485
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
357 @Test |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
358 public void isDefaultTest() { |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
359 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
|
360 ResolvedJavaMethod m = e.getValue(); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
361 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
|
362 } |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
363 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
|
364 ResolvedJavaMethod m = e.getValue(); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
365 assertFalse(m.isDefault()); |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
366 } |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
367 } |
d6604020da93
removed com.oracle.graal.api.meta.jdk8.test project
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
368 |
18830
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
369 @Test |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
370 public void hasReceiverTest() { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
371 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
|
372 ResolvedJavaMethod m = e.getValue(); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
373 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
|
374 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
375 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
|
376 ResolvedJavaMethod m = e.getValue(); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
377 assertTrue(m.hasReceiver()); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
378 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
379 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
380 |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
381 @Test |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
382 public void hasBytecodesTest() { |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
383 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
|
384 ResolvedJavaMethod m = e.getValue(); |
18835
f679e2e2ed32
Fix unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18830
diff
changeset
|
385 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
|
386 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
387 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
|
388 ResolvedJavaMethod m = e.getValue(); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
389 assertTrue(m.hasBytecodes()); |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
390 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
391 } |
c50e5292d366
Add tests for new public API in ResolvedJavaMethod.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18694
diff
changeset
|
392 |
21276
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
393 @Test |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 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
|
400 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
401 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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 } else { |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
407 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
|
408 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
409 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
410 } |
9f6733155647
ensure RegisterFinalizerNode is created when Object::<init> is the compilation root
Doug Simon <doug.simon@oracle.com>
parents:
18835
diff
changeset
|
411 |
23728
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
412 /** |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
413 * All public non-final methods should be available in the vtable. |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
414 */ |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
415 @Test |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
416 public void testVirtualMethodTableAccess() { |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
417 for (Class<?> c : classes) { |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
418 if (c.isPrimitive() || c.isInterface()) { |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
419 continue; |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
420 } |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
421 ResolvedJavaType receiverType = metaAccess.lookupJavaType(c); |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
422 for (Method m : c.getMethods()) { |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
423 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m); |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
424 if (!method.isStatic() && !method.isFinal() && !method.getDeclaringClass().isLeaf() && !method.getDeclaringClass().isInterface()) { |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
425 assertTrue(method + " not available in " + receiverType, method.isInVirtualMethodTable(receiverType)); |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
426 } |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
427 } |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
428 } |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
429 } |
995af926c06b
Fixed vtable size computation in HotSpotVMConfig and add test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22672
diff
changeset
|
430 |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
431 private Method findTestMethod(Method apiMethod) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
432 String testName = apiMethod.getName() + "Test"; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
433 for (Method m : getClass().getDeclaredMethods()) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
434 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
|
435 return m; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
436 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
437 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
438 return null; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
439 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
440 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
441 // @formatter:off |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
442 private static final String[] untestedApiMethods = { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
443 "newInstance", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
444 "getDeclaringClass", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
445 "getEncoding", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
446 "getProfilingInfo", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
447 "reprofile", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
448 "getCompilerStorage", |
23986
6d2c72b822b0
add ResolvedJavaMethod.hasNeverInlineDirective (JDK-8172733)
Doug Simon <doug.simon@oracle.com>
parents:
23790
diff
changeset
|
449 "hasNeverInlineDirective", |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
450 "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
|
451 "shouldBeInlined", |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
452 "getLineNumberTable", |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
453 "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
|
454 "isInVirtualMethodTable", |
16489
db92d4a1564a
fixed minor regression
Doug Simon <doug.simon@oracle.com>
parents:
16485
diff
changeset
|
455 "toParameterTypes", |
18694
ec1b0b097d82
Ignore $jacocoInit methods in coverage tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
17141
diff
changeset
|
456 "getParameterAnnotation", |
21629
36cf15e3219e
Move HotSpotResolvedJavaMethod.getSpeculationLog to ResolvedJavaMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21565
diff
changeset
|
457 "getSpeculationLog", |
22033
547ae53182bf
Add test for isLeaf
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22012
diff
changeset
|
458 "isFinal", |
18694
ec1b0b097d82
Ignore $jacocoInit methods in coverage tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
17141
diff
changeset
|
459 "$jacocoInit" |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
460 }; |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
461 // @formatter:on |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
462 |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
463 /** |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
464 * 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
|
465 * 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
|
466 */ |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
467 @Test |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
468 public void testCoverage() { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
469 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
|
470 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
|
471 if (Modifier.isStatic(m.getModifiers())) { |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
472 continue; |
53b4acee50f1
Add ResolvedJavaMethod.isSignaturePolymorphic and ResolvedJavaType.findMethod
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22011
diff
changeset
|
473 } |
9806
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
474 if (findTestMethod(m) == null) { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
475 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
|
476 } else { |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
477 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
|
478 } |
21b8cd853b2b
cleaned up api.meta tests (GRAAL-59)
Doug Simon <doug.simon@oracle.com>
parents:
7914
diff
changeset
|
479 } |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
480 } |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
481 } |