annotate jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java @ 24137:6523380966cd

Merge.
author Doug Simon <doug.simon@oracle.com>
date Fri, 19 May 2017 14:05:50 +0200
parents 1bbd4a7c274b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
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.
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
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 TestJavaField.java FieldUniverse.java TypeUniverse.java
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22569
diff changeset
27 * @run junit jdk.vm.ci.runtime.test.TestJavaField
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: 22569
diff changeset
30 package jdk.vm.ci.runtime.test;
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31
22569
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
32 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: 22536
diff changeset
33 import static org.junit.Assert.assertTrue;
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
34
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
35 import java.lang.reflect.Field;
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
36 import java.util.Map;
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22569
diff changeset
38 import jdk.vm.ci.meta.JavaField;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22569
diff changeset
39 import jdk.vm.ci.meta.JavaKind;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22569
diff changeset
40 import jdk.vm.ci.meta.JavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22569
diff changeset
41 import jdk.vm.ci.meta.ResolvedJavaField;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22569
diff changeset
42 import jdk.vm.ci.meta.ResolvedJavaType;
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43
22569
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
44 import org.junit.Test;
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 /**
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 * Tests for {@link JavaField}.
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 */
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 public class TestJavaField extends FieldUniverse {
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 @Test
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 public void getNameTest() {
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 for (Map.Entry<Field, ResolvedJavaField> e : fields.entrySet()) {
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 String expected = e.getKey().getName();
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 String actual = e.getValue().getName();
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 assertEquals(expected, actual);
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 @Test
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 public void getTypeTest() {
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 for (Map.Entry<Field, ResolvedJavaField> e : fields.entrySet()) {
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 // Must resolve types first as a resolved types != unresolved types
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 ResolvedJavaField rf = e.getValue();
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 JavaType expected = metaAccess.lookupJavaType(e.getKey().getType()).resolve(rf.getDeclaringClass());
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 JavaType actual = rf.getType().resolve(rf.getDeclaringClass());
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 assertEquals(expected, actual);
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 @Test
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22518
diff changeset
72 public void getJavaKindTest() {
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 for (Map.Entry<Field, ResolvedJavaField> e : fields.entrySet()) {
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22518
diff changeset
74 JavaKind expected = metaAccess.lookupJavaType(e.getKey().getType()).getJavaKind();
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22518
diff changeset
75 JavaKind actual = e.getValue().getJavaKind();
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76 assertEquals(expected, actual);
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 @Test
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 public void getDeclaringClassTest() {
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 for (Map.Entry<Field, ResolvedJavaField> e : fields.entrySet()) {
15040
288c23143d47 Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents: 13818
diff changeset
83 Class<?> expected = e.getKey().getDeclaringClass();
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 ResolvedJavaType actual = e.getValue().getDeclaringClass();
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 assertTrue(actual.equals(metaAccess.lookupJavaType(expected)));
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 }
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88 }