Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java @ 7044:34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 27 Nov 2012 16:09:05 +0100 |
parents | 62818f156081 |
children | 6a16788a29a6 |
rev | line source |
---|---|
5509
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.api.meta; |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5535
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
25 import java.lang.reflect.*; |
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
26 |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
27 /** |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
28 * Interface implemented by the runtime to allow access to its metadata. |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
29 */ |
5509
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 public interface MetaAccessProvider { |
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
32 /** |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
33 * Returns the resolved Java type representing a given Java class. |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
34 * |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
35 * @param clazz the Java class object |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
36 * @return the resolved Java type object |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6328
diff
changeset
|
37 */ |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
38 ResolvedJavaType lookupJavaType(Class< ? > clazz); |
5535
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
39 |
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
40 /** |
6442
45f682f7fea8
Add MetaAccessProvider.getResolvedJavaField to convert from reflection field to metadata field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6329
diff
changeset
|
41 * Provides the {@link ResolvedJavaMethod} for a {@link Method} obtained via reflection. |
5535
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
42 */ |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
43 ResolvedJavaMethod lookupJavaMethod(Method reflectionMethod); |
5535
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
44 |
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
45 /** |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7015
diff
changeset
|
46 * Provides the {@link ResolvedJavaMethod} for a {@link Constructor} obtained via reflection. |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7015
diff
changeset
|
47 */ |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7015
diff
changeset
|
48 ResolvedJavaMethod lookupJavaConstructor(Constructor reflectionConstructor); |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7015
diff
changeset
|
49 |
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7015
diff
changeset
|
50 /** |
6442
45f682f7fea8
Add MetaAccessProvider.getResolvedJavaField to convert from reflection field to metadata field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6329
diff
changeset
|
51 * Provides the {@link ResolvedJavaField} for a {@link Field} obtained via reflection. |
45f682f7fea8
Add MetaAccessProvider.getResolvedJavaField to convert from reflection field to metadata field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6329
diff
changeset
|
52 */ |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
53 ResolvedJavaField lookupJavaField(Field reflectionField); |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
54 |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
55 /** |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
56 * Returns the resolved Java type of the given {@link Constant} object. |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
57 * |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
58 * @return {@code null} if {@code constant.isNull() || !constant.kind.isObject()} |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
59 */ |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
60 ResolvedJavaType lookupJavaType(Constant constant); |
6442
45f682f7fea8
Add MetaAccessProvider.getResolvedJavaField to convert from reflection field to metadata field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6329
diff
changeset
|
61 |
45f682f7fea8
Add MetaAccessProvider.getResolvedJavaField to convert from reflection field to metadata field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6329
diff
changeset
|
62 /** |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
63 * Compares two constants for equality. |
7015
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
64 * This is used instead of {@link Constant#equals(Object)} in case the runtime |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
65 * has an interpretation for object equality other than {@code x.asObject() == y.asObject()}. |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
66 * For primitive constants, this is equivalent to calling {@code x.equals(y)}. |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
67 * The equality relationship is symmetric. |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
68 * |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
69 * @return {@code true} if the two parameters represent the same runtime object, {@code false} otherwise |
5535
e624cded7986
Moving methods from RiRuntime to MetaAccessProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5509
diff
changeset
|
70 */ |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
71 boolean constantEquals(Constant x, Constant y); |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
72 |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
73 /** |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
74 * Returns the length of an array that is wrapped in a {@link Constant} object. |
7015
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
75 * |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
76 * @throws IllegalArgumentException if {@code array} is not an array |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
77 */ |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6442
diff
changeset
|
78 int lookupArrayLength(Constant array); |
5509
6ed763809de7
Added new projects graal.api.code and graal.api.interpreter
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 } |