OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [vm/] [reference/] [java/] [lang/] [VMClass.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* VMClass.java -- VM Specific Class methods
2
   Copyright (C) 2003, 2004 Free Software Foundation
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package java.lang;
39
 
40
import java.lang.reflect.Constructor;
41
import java.lang.reflect.Field;
42
import java.lang.reflect.Method;
43
 
44
/*
45
 * This class is a reference version, mainly for compiling a class library
46
 * jar.  It is likely that VM implementers replace this with their own
47
 * version that can communicate effectively with the VM.
48
 */
49
 
50
/**
51
 *
52
 * @author Etienne Gagnon <etienne.gagnon@uqam.ca>
53
 * @author Archie Cobbs <archie@dellroad.org>
54
 * @author C. Brian Jones <cbj@gnu.org>
55
 */
56
final class VMClass
57
{
58
 
59
  // Only static methods. Cannot be instantiated.
60
  private VMClass()
61
  {
62
  }
63
 
64
  /**
65
   * Discover whether an Object is an instance of this Class.  Think of it
66
   * as almost like <code>o instanceof (this class)</code>.
67
   *
68
   * @param klass the Class object that's calling us
69
   * @param o the Object to check
70
   * @return whether o is an instance of this class
71
   * @since 1.1
72
   */
73
  static native boolean isInstance(Class klass, Object o);
74
 
75
  /**
76
   * Discover whether an instance of the Class parameter would be an
77
   * instance of this Class as well.  Think of doing
78
   * <code>isInstance(c.newInstance())</code> or even
79
   * <code>c.newInstance() instanceof (this class)</code>. While this
80
   * checks widening conversions for objects, it must be exact for primitive
81
   * types.
82
   *
83
   * @param klass the Class object that's calling us
84
   * @param c the class to check
85
   * @return whether an instance of c would be an instance of this class
86
   *         as well
87
   * @throws NullPointerException if c is null
88
   * @since 1.1
89
   */
90
  static native boolean isAssignableFrom(Class klass, Class c);
91
 
92
  /**
93
   * Check whether this class is an interface or not.  Array types are not
94
   * interfaces.
95
   *
96
   * @param klass the Class object that's calling us
97
   * @return whether this class is an interface or not
98
   */
99
  static native boolean isInterface(Class klass);
100
 
101
  /**
102
   * Return whether this class is a primitive type.  A primitive type class
103
   * is a class representing a kind of "placeholder" for the various
104
   * primitive types, or void.  You can access the various primitive type
105
   * classes through java.lang.Boolean.TYPE, java.lang.Integer.TYPE, etc.,
106
   * or through boolean.class, int.class, etc.
107
   *
108
   * @param klass the Class object that's calling us
109
   * @return whether this class is a primitive type
110
   * @see Boolean#TYPE
111
   * @see Byte#TYPE
112
   * @see Character#TYPE
113
   * @see Short#TYPE
114
   * @see Integer#TYPE
115
   * @see Long#TYPE
116
   * @see Float#TYPE
117
   * @see Double#TYPE
118
   * @see Void#TYPE
119
   * @since 1.1
120
   */
121
  static native boolean isPrimitive(Class klass);
122
 
123
  /**
124
   * Get the name of this class, separated by dots for package separators.
125
   * Primitive types and arrays are encoded as:
126
   * <pre>
127
   * boolean             Z
128
   * byte                B
129
   * char                C
130
   * short               S
131
   * int                 I
132
   * long                J
133
   * float               F
134
   * double              D
135
   * void                V
136
   * array type          [<em>element type</em>
137
   * class or interface, alone: &lt;dotted name&gt;
138
   * class or interface, as element type: L&lt;dotted name&gt;;
139
   *
140
   * @param klass the Class object that's calling us
141
   * @return the name of this class
142
   */
143
  static native String getName(Class klass);
144
 
145
  /**
146
   * Get the direct superclass of this class.  If this is an interface,
147
   * Object, a primitive type, or void, it will return null. If this is an
148
   * array type, it will return Object.
149
   *
150
   * @param klass the Class object that's calling us
151
   * @return the direct superclass of this class
152
   */
153
  static native Class getSuperclass(Class klass);
154
 
155
  /**
156
   * Get the interfaces this class <EM>directly</EM> implements, in the
157
   * order that they were declared. This returns an empty array, not null,
158
   * for Object, primitives, void, and classes or interfaces with no direct
159
   * superinterface. Array types return Cloneable and Serializable.
160
   *
161
   * @param klass the Class object that's calling us
162
   * @return the interfaces this class directly implements
163
   */
164
  static native Class[] getInterfaces(Class klass);
165
 
166
  /**
167
   * If this is an array, get the Class representing the type of array.
168
   * Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and
169
   * calling getComponentType on that would give "java.lang.String".  If
170
   * this is not an array, returns null.
171
   *
172
   * @param klass the Class object that's calling us
173
   * @return the array type of this class, or null
174
   * @see Array
175
   * @since 1.1
176
   */
177
  static native Class getComponentType(Class klass);
178
 
179
  /**
180
   * Get the modifiers of this class.  These can be decoded using Modifier,
181
   * and is limited to one of public, protected, or private, and any of
182
   * final, static, abstract, or interface. An array class has the same
183
   * public, protected, or private modifier as its component type, and is
184
   * marked final but not an interface. Primitive types and void are marked
185
   * public and final, but not an interface.
186
   *
187
   * @param klass the Class object that's calling us
188
   * @param ignoreInnerClassesAttrib if set, return the real modifiers, not
189
   * the ones specified in the InnerClasses attribute.
190
   * @return the modifiers of this class
191
   * @see Modifer
192
   * @since 1.1
193
   */
194
  static native int getModifiers(Class klass, boolean ignoreInnerClassesAttrib);
195
 
196
  /**
197
   * If this is a nested or inner class, return the class that declared it.
198
   * If not, return null.
199
   *
200
   * @param klass the Class object that's calling us
201
   * @return the declaring class of this class
202
   * @since 1.1
203
   */
204
  static native Class getDeclaringClass(Class klass);
205
 
206
  /**
207
   * Like <code>getDeclaredClasses()</code> but without the security checks.
208
   *
209
   * @param klass the Class object that's calling us
210
   * @param pulicOnly Only public classes should be returned
211
   */
212
  static native Class[] getDeclaredClasses(Class klass, boolean publicOnly);
213
 
214
  /**
215
   * Like <code>getDeclaredFields()</code> but without the security checks.
216
   *
217
   * @param klass the Class object that's calling us
218
   * @param pulicOnly Only public fields should be returned
219
   */
220
  static native Field[] getDeclaredFields(Class klass, boolean publicOnly);
221
 
222
  /**
223
   * Like <code>getDeclaredMethods()</code> but without the security checks.
224
   *
225
   * @param klass the Class object that's calling us
226
   * @param pulicOnly Only public methods should be returned
227
   */
228
  static native Method[] getDeclaredMethods(Class klass, boolean publicOnly);
229
 
230
  /**
231
   * Like <code>getDeclaredConstructors()</code> but without
232
   * the security checks.
233
   *
234
   * @param klass the Class object that's calling us
235
   * @param pulicOnly Only public constructors should be returned
236
   */
237
  static native Constructor[] getDeclaredConstructors(Class klass, boolean publicOnly);
238
 
239
  /**
240
   * Return the class loader of this class.
241
   *
242
   * @param klass the Class object that's calling us
243
   * @return the class loader
244
   */
245
  static native ClassLoader getClassLoader(Class klass);
246
 
247
  /**
248
   * Load the requested class and record the specified loader as the
249
   * initiating class loader.
250
   *
251
   * @param name the name of the class to find
252
   * @param initialize should the class initializer be run?
253
   * @param loader the class loader to use (or null for the bootstrap loader)
254
   * @return the Class object representing the class or null for noop
255
   * @throws ClassNotFoundException if the class was not found by the
256
   *         class loader
257
   * @throws LinkageError if linking the class fails
258
   * @throws ExceptionInInitializerError if the class loads, but an exception
259
   *         occurs during initialization
260
   */
261
  static native Class forName(String name, boolean initialize,
262
                              ClassLoader loader)
263
    throws ClassNotFoundException;
264
 
265
  /**
266
   * Return whether this class is an array type.
267
   *
268
   * @param klass the Class object that's calling us
269
   * @return true if this class is an array type
270
   * operation
271
   */
272
  static native boolean isArray(Class klass);
273
 
274
  /**
275
   * Throw a checked exception without declaring it.
276
   */
277
  static native void throwException(Throwable t);
278
 
279
} // class VMClass

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.