/[classpath]/classpath/vm/reference/java/lang/VMClass.java
ViewVC logotype

Diff of /classpath/vm/reference/java/lang/VMClass.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by shalom, Sun Oct 4 17:57:09 1998 UTC revision 1.5 by cbj, Fri Apr 4 03:54:11 2003 UTC
# Line 1  Line 1 
1  /*  /* VMClass.java -- VM Specific Class methods
2   * java.lang.Class: part of the Java Class Libraries project.     Copyright (C) 2003 Free Software Foundation
3   * Copyright (C) 1998 John Keiser  
4   *  This file is part of GNU Classpath.
5   * This library is free software; you can redistribute it and/or  
6   * modify it under the terms of the GNU Library General Public  GNU Classpath is free software; you can redistribute it and/or modify
7   * License as published by the Free Software Foundation; either  it under the terms of the GNU General Public License as published by
8   * version 2 of the License, or (at your option) any later version.  the Free Software Foundation; either version 2, or (at your option)
9   *  any later version.
10   * This library is distributed in the hope that it will be useful,  
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of  GNU Classpath is distributed in the hope that it will be useful, but
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  WITHOUT ANY WARRANTY; without even the implied warranty of
13   * Library General Public License for more details.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  General Public License for more details.
15   * You should have received a copy of the GNU Library General Public  
16   * License along with this library; if not, write to the  You should have received a copy of the GNU General Public License
17   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,  along with GNU Classpath; see the file COPYING.  If not, write to the
18   * Boston, MA  02111-1307, USA.  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19   */  02111-1307 USA.
20    
21  package java.lang;  Linking this library statically or dynamically with other modules is
22    making a combined work based on this library.  Thus, the terms and
23  import java.lang.reflect.*;  conditions of the GNU General Public License cover the whole
24    combination.
25  /**  
26   ** This is a package-private helper class for Class.  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   ** @author John Keiser  executable, regardless of the license terms of these independent
29   ** @version 1.1.0, Aug 6 1998  modules, and to copy and distribute the resulting executable under
30   ** @since JDK1.0  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  class VMClass {  or based on this library.  If you modify this library, you may extend
34          /** Get the name of this class, separated by dots for  this exception to your version of the library, but you are not
35           ** package separators.  obligated to do so.  If you do not wish to do so, delete this
36           ** @return the name of this class.  exception statement from your version. */
37           ** @since JDK1.0  
38           **/  package java.lang;
39          static String getName(Class c) {  
40                  throw new UnsupportedOperationException();  import gnu.classpath.RawData;
41          }  
42    /*
43          /** Get whether this class is an interface or not.  Array   * This class is a reference version, mainly for compiling a class library
44           ** types are not interfaces.   * jar.  It is likely that VM implementers replace this with their own
45           ** @return whether this class is an interface or not.   * version that can communicate effectively with the VM.
46           ** @since JDK1.0   */
47           **/  
48          static boolean isInterface(Class c) {  /**
49                  throw new UnsupportedOperationException();   *
50          }   * @author Etienne Gagnon <etienne.gagnon@uqam.ca>
51     * @author Archie Cobbs <archie@dellroad.org>
52          /** Get the direct superclass of this class.  If this is   * @author C. Brian Jones <cbj@gnu.org>
53           ** an interface, it will get the direct superinterface.   */
54           ** @return the direct superclass of this class.  public final class VMClass
55           ** @since JDK1.0  {
56           **/    /*
57          static Class getSuperclass(Class c) {     * Class initialization mostly-in-Java copied from SableVM.
58                  throw new UnsupportedOperationException();     * The steps below follow the JVM spec, 2nd edition, sec. 2.17.5.
59          }     */
60      private int initializing_thread;
61          /** Get the interfaces this class <EM>directly</EM>    private boolean erroneous_state;
62           ** implements, in the order that they were declared.  
63           ** This method may return an empty array, but will    private native boolean isInitialized();
64           ** never return null.    private native void setInitialized();
65           ** @return the interfaces this class directly implements.    private native void step7();
66           ** @since JDK1.0    private native void step8();
67           **/  
68          static Class[] getInterfaces(Class c) {    /**
69                  throw new UnsupportedOperationException();     * Pointer to VM internal class structure.
70          }     */
71    
72          /** Get the ClassLoader that loaded this class.  If it was    private final RawData vmData;  
73           ** loaded by the system classloader, this method will  
74           ** return null.    private VMClass(RawData vmData)
75           ** @return the ClassLoader that loaded this class.    {
76           ** @since JDK1.0      this.vmData = vmData;
77           **/    }
78          static ClassLoader getClassLoader(Class c) {  
79                  throw new UnsupportedOperationException();    static native VMClass getInstance();
80          }  
81      private void initialize(int thread) throws InterruptedException
82          /** Use the system classloader to load and link a class.    {
83           ** @param name the name of the class to find.      Error error;
84           ** @return the Class object representing the class.  
85           ** @exception ClassNotFoundException if the class was not      /* 1 */
86           **            found by the system classloader.      synchronized (this)
87           ** @since JDK1.0      {
88           **/        /* 2 */
89          static Class forName(String name) throws ClassNotFoundException {        while (initializing_thread != 0 && initializing_thread != thread)
90                  throw new UnsupportedOperationException();          wait();
91          }  
92          /* 3 */
93          /** Discover whether an Object is an instance of this        if (initializing_thread == thread)
94           ** Class.  Think of it as almost like          return;
95           ** <CODE>o instanceof (this class)</CODE>.  
96           ** @param o the Object to check        /* 4 */
97           ** @return whether o is an instance of this class.        if (isInitialized())
98           ** @since JDK1.1          return;
99           **/  
100          static boolean isInstance(Class c, Object o) {        /* 5 */
101                  throw new UnsupportedOperationException();        if (erroneous_state)
102          }          throw new NoClassDefFoundError();
103    
104          /** Discover whether an instance of the Class parameter        /* 6 */
105           ** would be an instance of this Class as well.  Think of        initializing_thread = thread;
106           ** doing <CODE>isInstance(c.newInstance())</CODE> or even      }
107           ** <CODE>c instanceof (this class)</CODE>.  
108           ** @param c the class to check      /* 7 */
109           ** @return whether an instance of c would be an instance      try {
110           **         of this class as well.        step7();
111           ** @since JDK1.1      }
112           **/      catch(Error e) {
113          static boolean isAssignableFrom(Class theClass, Class c) {        synchronized(this) {
114                  throw new UnsupportedOperationException();          erroneous_state = true;
115          }          initializing_thread = 0;
116            notifyAll();
117          /** Return whether this class is a primitive type.  A          throw e;
118           ** primitive type class is a class representing a kind of        }
119           ** "placeholder" for the various primitive types.  You      }
120           ** can access the various primitive type classes through  
121           ** java.lang.Boolean.TYPE, java.lang.Integer.TYPE, etc.      /* 8 */
122           ** @return whether this class is a primitive type.      try {
123           ** @since JDK1.1        step8();
124           **/  
125          static boolean isPrimitive(Class c) {        /* 9 */
126                  throw new UnsupportedOperationException();        synchronized(this) {
127          }          setInitialized();
128            initializing_thread = 0;
129          /** Get the modifiers of this class.  These can be checked          notifyAll();
130           ** against using java.lang.reflect.Modifier.          return;
131           ** @return the modifiers of this class.        }
132           ** @see java.lang.reflect.Modifer      }
133           ** @since JDK1.1  
134           **/      /* 10 */
135          static int getModifiers(Class c) {      catch(Exception e) {
136                  throw new UnsupportedOperationException();        try {
137          }          error = new ExceptionInInitializerError(e);
138          } catch (OutOfMemoryError e2) {
139          /** If this is an inner class, return the class that          error = e2;
140           ** declared it.  If not, return null.        }
141           ** @return the declaring class of this class.      } catch(Error e) {
142           ** @since JDK1.1        error = e;
143           **/      }
144          static Class getDeclaringClass(Class c) {  
145                  throw new UnsupportedOperationException();      /* 11 */
146          }      synchronized(this) {
147          erroneous_state = true;
148          /** Get all the public inner classes, declared in this        initializing_thread = 0;
149           ** class or inherited from superclasses, that are        notifyAll();
150           ** members of this class.        throw error;
151           ** @return all public inner classes in this class.      }
152           **/    }
153          static Class[] getClasses(Class c) {  
154                  throw new UnsupportedOperationException();    /**
155          }     * Discover whether an Object is an instance of this Class.  Think of it
156       * as almost like <code>o instanceof (this class)</code>.
157          /** Get all the inner classes declared in this class.     *
158           ** @return all inner classes declared in this class.     * @param o the Object to check
159           **/     * @return whether o is an instance of this class
160          static Class[] getDeclaredClasses(Class c) {     * @since 1.1
161                  throw new UnsupportedOperationException();     */
162          }    native boolean isInstance(Object o);
163    
164          /** Get a public constructor from this class.    /**
165           ** @param args the argument types for the constructor.     * Discover whether an instance of the Class parameter would be an
166           ** @return the constructor.     * instance of this Class as well.  Think of doing
167           ** @exception NoSuchMethodException if the constructor does     * <code>isInstance(c.newInstance())</code> or even
168           **            not exist.     * <code>c.newInstance() instanceof (this class)</code>. While this
169           **/     * checks widening conversions for objects, it must be exact for primitive
170          static Constructor getConstructor(Class c, Class[] args) throws NoSuchMethodException {     * types.
171                  throw new UnsupportedOperationException();     *
172          }     * @param c the class to check
173       * @return whether an instance of c would be an instance of this class
174          /** Get a constructor declared in this class.     *         as well
175           ** @param args the argument types for the constructor.     * @throws NullPointerException if c is null
176           ** @return the constructor.     * @since 1.1
177           ** @exception NoSuchMethodException if the constructor does     */
178           **            not exist in this class.    native boolean isAssignableFrom(Class c);
179           **/  
180          static Constructor getDeclaredConstructor(Class c, Class[] args) throws NoSuchMethodException {    /**
181                  throw new UnsupportedOperationException();     * Check whether this class is an interface or not.  Array types are not
182          }     * interfaces.
183       *
184          /** Get all public constructors from this class.     * @return whether this class is an interface or not
185           ** @return all public constructors in this class.     */
186           **/    native boolean isInterface();
187          static Constructor[] getConstructors(Class c) {  
188                  throw new UnsupportedOperationException();    /**
189          }     * Return whether this class is a primitive type.  A primitive type class
190       * is a class representing a kind of "placeholder" for the various
191          /** Get all constructors declared in this class.     * primitive types, or void.  You can access the various primitive type
192           ** @return all constructors declared in this class.     * classes through java.lang.Boolean.TYPE, java.lang.Integer.TYPE, etc.,
193           **/     * or through boolean.class, int.class, etc.
194          static Constructor[] getDeclaredConstructors(Class c) {     *
195                  throw new UnsupportedOperationException();     * @return whether this class is a primitive type
196          }     * @see Boolean#TYPE
197       * @see Byte#TYPE
198       * @see Character#TYPE
199          /** Get a public method from this class.     * @see Short#TYPE
200           ** @param name the name of the method.     * @see Integer#TYPE
201           ** @param args the argument types for the method.     * @see Long#TYPE
202           ** @return the method.     * @see Float#TYPE
203           ** @exception NoSuchMethodException if the method does     * @see Double#TYPE
204           **            not exist.     * @see Void#TYPE
205           **/     * @since 1.1
206          static Method getMethod(Class c, String name, Class[] args) throws NoSuchMethodException {     */
207                  throw new UnsupportedOperationException();    native boolean isPrimitive();
208          }  
209      /**
210          /** Get a method declared in this class.     * Get the name of this class, separated by dots for package separators.
211           ** @param name the name of the method.     * Primitive types and arrays are encoded as:
212           ** @param args the argument types for the method.     * <pre>
213           ** @return the method.     * boolean             Z
214           ** @exception NoSuchMethodException if the method does     * byte                B
215           **            not exist in this class.     * char                C
216           **/     * short               S
217          static Method getDeclaredMethod(Class c, String name, Class[] args) throws NoSuchMethodException {     * int                 I
218                  throw new UnsupportedOperationException();     * long                J
219          }     * float               F
220       * double              D
221          /** Get all public methods from this class.     * void                V
222           ** @return all public methods in this class.     * array type          [<em>element type</em>
223           **/     * class or interface, alone: &lt;dotted name&gt;
224          static Method[] getMethods(Class c) {     * class or interface, as element type: L&lt;dotted name&gt;;
225                  throw new UnsupportedOperationException();     *
226          }     * @return the name of this class
227       */
228          /** Get all methods declared in this class.    native String getName();
229           ** @return all methods declared in this class.  
230           **/    /**
231          static Method[] getDeclaredMethods(Class c) {     * Get the direct superclass of this class.  If this is an interface,
232                  throw new UnsupportedOperationException();     * Object, a primitive type, or void, it will return null. If this is an
233          }     * array type, it will return Object.
234       *
235       * @return the direct superclass of this class
236          /** Get a public field from this class.     */
237           ** @param name the name of the field.    native Class getSuperclass();
238           ** @return the field.  
239           ** @exception NoSuchFieldException if the field does    /**
240           **            not exist.     * Get the interfaces this class <EM>directly</EM> implements, in the
241           **/     * order that they were declared. This returns an empty array, not null,
242          static Field getField(Class c, String name) throws NoSuchFieldException {     * for Object, primitives, void, and classes or interfaces with no direct
243                  throw new UnsupportedOperationException();     * superinterface. Array types return Cloneable and Serializable.
244          }     *
245       * @return the interfaces this class directly implements
246          /** Get a field declared in this class.     */
247           ** @param name the name of the field.    native Class[] getInterfaces();
248           ** @return the field.  
249           ** @exception NoSuchFieldException if the field does    /**
250           **            not exist in this class.     * If this is an array, get the Class representing the type of array.
251           **/     * Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and
252          static Field getDeclaredField(Class c, String name) throws NoSuchFieldException {     * calling getComponentType on that would give "java.lang.String".  If
253                  throw new UnsupportedOperationException();     * this is not an array, returns null.
254          }     *
255       * @return the array type of this class, or null
256          /** Get all public fields from this class.     * @see Array
257           ** @return all public fields in this class.     * @since 1.1
258           **/     */
259          static Field[] getFields(Class c) {    native Class getComponentType();
260                  throw new UnsupportedOperationException();  
261          }    /**
262       * Get the modifiers of this class.  These can be decoded using Modifier,
263          /** Get all fields declared in this class.     * and is limited to one of public, protected, or private, and any of
264           ** @return all fieilds declared in this class.     * final, static, abstract, or interface. An array class has the same
265           **/     * public, protected, or private modifier as its component type, and is
266          static Field[] getDeclaredFields(Class c) {     * marked final but not an interface. Primitive types and void are marked
267                  throw new UnsupportedOperationException();     * public and final, but not an interface.
268          }     *
269       * @return the modifiers of this class
270          /** Get a class for Integer.TYPE, Byte.TYPE, etc.     * @see Modifer
271           ** using the name of the primitive type.  This will     * @since 1.1
272           ** only be called once for each time a native class     */
273           ** like java.lang.Integer is initialized.<P>    native int getModifiers();
274           ** <B>Note:</B> if there are multiple classloaders,  
275           ** this method could be called more than once for a    /**
276           ** given type.     * If this is a nested or inner class, return the class that declared it.
277           ** @param name the name of the type, i.e. "int", "byte",     * If not, return null.
278           **             etc.     *
279           **/     * @return the declaring class of this class
280          static Class getPrimitiveClass(String name) {     * @since 1.1
281                  throw new UnsupportedOperationException();     */
282          }    native Class getDeclaringClass();
283  }  
284      /**
285       * Like <code>getDeclaredClasses()</code> but without the security checks.
286       *
287       * @param pulicOnly Only public classes should be returned
288       */
289      native Class[] getDeclaredClasses(boolean publicOnly);
290    
291      /**
292       * Like <code>getDeclaredFields()</code> but without the security checks.
293       *
294       * @param pulicOnly Only public fields should be returned
295       */
296      native Field[] getDeclaredFields(boolean publicOnly);
297    
298      /**
299       * Like <code>getDeclaredMethods()</code> but without the security checks.
300       *
301       * @param pulicOnly Only public methods should be returned
302       */
303      native Method[] getDeclaredMethods(boolean publicOnly);
304    
305      /**
306       * Like <code>getDeclaredConstructors()</code> but without
307       * the security checks.
308       *
309       * @param pulicOnly Only public constructors should be returned
310       */
311      native Constructor[] getDeclaredConstructors(boolean publicOnly);
312    
313      /**
314       * Return the class loader of this class.
315       *
316       * @return the class loader
317       */
318      native ClassLoader getClassLoader();
319    
320      /**
321       * VM implementors are free to make this method a noop if
322       * the default implementation is acceptable.
323       *
324       * @param name the name of the class to find
325       * @return the Class object representing the class or null for noop
326       * @throws ClassNotFoundException if the class was not found by the
327       *         classloader
328       * @throws LinkageError if linking the class fails
329       * @throws ExceptionInInitializerError if the class loads, but an exception
330       *         occurs during initialization
331       */
332      static native Class forName(String name) throws ClassNotFoundException;
333    
334      /**
335       * Return whether this class is an array type.
336       *
337       * @return 1 if this class is an array type, 0 otherwise, -1 if unsupported
338       * operation
339       */
340      native int isArray();
341    
342    } // class VMClass

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26