home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / java / lang / Class.java < prev    next >
Encoding:
Java Source  |  1997-01-27  |  3.7 KB  |  114 lines

  1. /*
  2.  * @(#)Class.java    1.26 95/12/21  
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.lang;
  21.  
  22. /**
  23.  * Class objects contain runtime representations of classes.  Every
  24.  * object in the system is an instance of some Class, and for each Class
  25.  * there is one of these descriptor objects. A Class descriptor is not 
  26.  * modifiable at runtime.<p>
  27.  * The following example uses a Class object to print the Class name
  28.  * of an object:
  29.  * <pre>
  30.  *    void printClassName(Object obj) {
  31.  *        System.out.println("The class of " + obj +
  32.  *                   " is " + obj.getClass().getName());
  33.  *    }
  34.  * </pre>
  35.  * @version     1.26, 12/21/95
  36.  */
  37. public final
  38. class Class {
  39.     /** 
  40.      * Handle to internal class representation.
  41.      */
  42.     private int internal;
  43.  
  44.     /**
  45.      * Make sure nobody instantiates this class
  46.      */
  47.     private Class() {}
  48.     
  49.     /**
  50.      * Returns the runtime Class descriptor for the specified Class.
  51.      * For example, the following code fragment returns the runtime
  52.      * Class descriptor for the Class named java.lang.Thread:
  53.      * <pre>
  54.      *        Class t = Class.forName("java.lang.Thread")
  55.      * </pre>
  56.      * @param className    the fully qualified name of the desired Class
  57.      * @exception    ClassNotFoundException If the Class could not be found.
  58.      */
  59.     public static native Class forName(String className) throws ClassNotFoundException;
  60.  
  61.     /**
  62.      * Creates a new instance of this Class.
  63.      * @return         the new instance of this Class.
  64.      * @exception    InstantiationException If you try to instantiate
  65.      *                  an abstract class or an interface, or if
  66.      *            the instantiation fails for some other reason.
  67.      * @exception       IllegalAccessException If the class or initializer
  68.      *                  is not accessible.
  69.      */
  70.     public native Object newInstance() 
  71.      throws InstantiationException, IllegalAccessException;
  72.  
  73.     /**
  74.      * Returns the name of this Class.
  75.      */
  76.     public native String getName();
  77.  
  78.     /**
  79.      * Returns the superclass of this Class.
  80.      */
  81.     public native Class getSuperclass();
  82.  
  83.     /**
  84.      * Returns the interfaces of this Class. An array 
  85.      * of length 0 is returned if this Class implements no interfaces.
  86.      */
  87.     public native Class getInterfaces()[];
  88.  
  89.     /**
  90.      * Returns the Class loader of this Class.  Returns null
  91.      *        if this Class does not have a Class loader.
  92.      * @see    ClassLoader
  93.      */
  94.     public native ClassLoader getClassLoader();
  95.  
  96.     /**
  97.      * Returns a boolean indicating whether or not this Class is an 
  98.      * interface.
  99.      */
  100.     public native boolean isInterface();
  101.  
  102.     /**
  103.      * Returns the name of this class or interface. The word 
  104.      * "class" is prepended if it is a Class; the word "interface"
  105.      * is prepended if it is an interface.
  106.      */
  107.     public String toString() {
  108.     return (isInterface() ? "interface " : "class ") + getName();
  109.     }
  110.       
  111.     protected native void finalize();
  112. }
  113.  
  114.