home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / lang / Class.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  6.0 KB  |  281 lines

  1. package java.lang;
  2.  
  3. import java.io.InputStream;
  4. import java.io.ObjectStreamClass;
  5. import java.io.ObjectStreamField;
  6. import java.io.Serializable;
  7. import java.lang.reflect.Constructor;
  8. import java.lang.reflect.Field;
  9. import java.lang.reflect.Method;
  10. import java.net.URL;
  11. import java.security.AccessController;
  12. import java.security.AllPermission;
  13. import java.security.CodeSource;
  14. import java.security.Permissions;
  15. import java.security.ProtectionDomain;
  16.  
  17. public final class Class implements Serializable {
  18.    private static RuntimePermission getPDperm;
  19.    private static ProtectionDomain allPermDomain;
  20.    private static final long serialVersionUID = 3206093459760846163L;
  21.    private static final ObjectStreamField[] serialPersistentFields;
  22.  
  23.    private static native void registerNatives();
  24.  
  25.    private Class() {
  26.    }
  27.  
  28.    public String toString() {
  29.       return (this.isInterface() ? "interface " : (this.isPrimitive() ? "" : "class ")) + this.getName();
  30.    }
  31.  
  32.    public static Class forName(String var0) throws ClassNotFoundException {
  33.       return forName0(var0, true, ClassLoader.getCallerClassLoader());
  34.    }
  35.  
  36.    public static Class forName(String var0, boolean var1, ClassLoader var2) throws ClassNotFoundException {
  37.       if (var2 == null) {
  38.          SecurityManager var3 = System.getSecurityManager();
  39.          if (var3 != null) {
  40.             ClassLoader var4 = ClassLoader.getCallerClassLoader();
  41.             if (var4 != null) {
  42.                var3.checkPermission(ClassLoader.getGetClassLoaderPerm());
  43.             }
  44.          }
  45.       }
  46.  
  47.       return forName0(var0, var1, var2);
  48.    }
  49.  
  50.    private static native Class forName0(String var0, boolean var1, ClassLoader var2) throws ClassNotFoundException;
  51.  
  52.    public Object newInstance() throws InstantiationException, IllegalAccessException {
  53.       if (System.getSecurityManager() != null) {
  54.          this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  55.       }
  56.  
  57.       return this.newInstance0();
  58.    }
  59.  
  60.    private native Object newInstance0() throws InstantiationException, IllegalAccessException;
  61.  
  62.    public native boolean isInstance(Object var1);
  63.  
  64.    public native boolean isAssignableFrom(Class var1);
  65.  
  66.    public native boolean isInterface();
  67.  
  68.    public native boolean isArray();
  69.  
  70.    public native boolean isPrimitive();
  71.  
  72.    public native String getName();
  73.  
  74.    public ClassLoader getClassLoader() {
  75.       ClassLoader var1 = this.getClassLoader0();
  76.       if (var1 == null) {
  77.          return null;
  78.       } else {
  79.          SecurityManager var2 = System.getSecurityManager();
  80.          if (var2 != null) {
  81.             ClassLoader var3 = ClassLoader.getCallerClassLoader();
  82.             if (var3 != null && var3 != var1 && !var1.isAncestor(var3)) {
  83.                var2.checkPermission(ClassLoader.getGetClassLoaderPerm());
  84.             }
  85.          }
  86.  
  87.          return var1;
  88.       }
  89.    }
  90.  
  91.    private native ClassLoader getClassLoader0();
  92.  
  93.    public native Class getSuperclass();
  94.  
  95.    public Package getPackage() {
  96.       return Package.getPackage(this);
  97.    }
  98.  
  99.    public native Class[] getInterfaces();
  100.  
  101.    public native Class getComponentType();
  102.  
  103.    public native int getModifiers();
  104.  
  105.    public native Object[] getSigners();
  106.  
  107.    native void setSigners(Object[] var1);
  108.  
  109.    public native Class getDeclaringClass();
  110.  
  111.    public Class[] getClasses() {
  112.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  113.       Class[] var1 = (Class[])AccessController.doPrivileged(new 1(this));
  114.       return var1;
  115.    }
  116.  
  117.    public Field[] getFields() throws SecurityException {
  118.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  119.       return this.getFields0(0);
  120.    }
  121.  
  122.    public Method[] getMethods() throws SecurityException {
  123.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  124.       return this.getMethods0(0);
  125.    }
  126.  
  127.    public Constructor[] getConstructors() throws SecurityException {
  128.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  129.       return this.getConstructors0(0);
  130.    }
  131.  
  132.    public Field getField(String var1) throws NoSuchFieldException, SecurityException {
  133.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  134.       return this.getField0(var1, 0);
  135.    }
  136.  
  137.    public Method getMethod(String var1, Class[] var2) throws NoSuchMethodException, SecurityException {
  138.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  139.       return this.getMethod0(var1, var2, 0);
  140.    }
  141.  
  142.    public Constructor getConstructor(Class[] var1) throws NoSuchMethodException, SecurityException {
  143.       this.checkMemberAccess(0, ClassLoader.getCallerClassLoader());
  144.       return this.getConstructor0(var1, 0);
  145.    }
  146.  
  147.    public Class[] getDeclaredClasses() throws SecurityException {
  148.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  149.       return this.getDeclaredClasses0();
  150.    }
  151.  
  152.    public Field[] getDeclaredFields() throws SecurityException {
  153.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  154.       return this.getFields0(1);
  155.    }
  156.  
  157.    public Method[] getDeclaredMethods() throws SecurityException {
  158.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  159.       return this.getMethods0(1);
  160.    }
  161.  
  162.    public Constructor[] getDeclaredConstructors() throws SecurityException {
  163.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  164.       return this.getConstructors0(1);
  165.    }
  166.  
  167.    public Field getDeclaredField(String var1) throws NoSuchFieldException, SecurityException {
  168.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  169.       return this.getField0(var1, 1);
  170.    }
  171.  
  172.    public Method getDeclaredMethod(String var1, Class[] var2) throws NoSuchMethodException, SecurityException {
  173.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  174.       return this.getMethod0(var1, var2, 1);
  175.    }
  176.  
  177.    public Constructor getDeclaredConstructor(Class[] var1) throws NoSuchMethodException, SecurityException {
  178.       this.checkMemberAccess(1, ClassLoader.getCallerClassLoader());
  179.       return this.getConstructor0(var1, 1);
  180.    }
  181.  
  182.    public InputStream getResourceAsStream(String var1) {
  183.       var1 = this.resolveName(var1);
  184.       ClassLoader var2 = this.getClassLoader0();
  185.       return var2 == null ? ClassLoader.getSystemResourceAsStream(var1) : var2.getResourceAsStream(var1);
  186.    }
  187.  
  188.    public URL getResource(String var1) {
  189.       var1 = this.resolveName(var1);
  190.       ClassLoader var2 = this.getClassLoader0();
  191.       return var2 == null ? ClassLoader.getSystemResource(var1) : var2.getResource(var1);
  192.    }
  193.  
  194.    public ProtectionDomain getProtectionDomain() {
  195.       SecurityManager var1 = System.getSecurityManager();
  196.       if (var1 != null) {
  197.          if (getPDperm == null) {
  198.             getPDperm = new RuntimePermission("getProtectionDomain");
  199.          }
  200.  
  201.          var1.checkPermission(getPDperm);
  202.       }
  203.  
  204.       ProtectionDomain var2 = this.getProtectionDomain0();
  205.       if (var2 == null) {
  206.          if (allPermDomain == null) {
  207.             Permissions var3 = new Permissions();
  208.             var3.add(new AllPermission());
  209.             allPermDomain = new ProtectionDomain((CodeSource)null, var3);
  210.          }
  211.  
  212.          var2 = allPermDomain;
  213.       }
  214.  
  215.       return var2;
  216.    }
  217.  
  218.    private native ProtectionDomain getProtectionDomain0();
  219.  
  220.    native void setProtectionDomain0(ProtectionDomain var1);
  221.  
  222.    static native Class getPrimitiveClass(String var0);
  223.  
  224.    private void checkMemberAccess(int var1, ClassLoader var2) {
  225.       SecurityManager var3 = System.getSecurityManager();
  226.       if (var3 != null) {
  227.          var3.checkMemberAccess(this, var1);
  228.          ClassLoader var4 = this.getClassLoader0();
  229.          if (var2 != null && var2 != var4 && (var4 == null || !var4.isAncestor(var2))) {
  230.             String var5 = this.getName();
  231.             int var6 = var5.lastIndexOf(46);
  232.             if (var6 != -1) {
  233.                var3.checkPackageAccess(var5.substring(0, var6));
  234.             }
  235.          }
  236.       }
  237.  
  238.    }
  239.  
  240.    private String resolveName(String var1) {
  241.       if (var1 == null) {
  242.          return var1;
  243.       } else {
  244.          if (!var1.startsWith("/")) {
  245.             Class var2;
  246.             for(var2 = this; var2.isArray(); var2 = var2.getComponentType()) {
  247.             }
  248.  
  249.             String var3 = var2.getName();
  250.             int var4 = var3.lastIndexOf(46);
  251.             if (var4 != -1) {
  252.                var1 = var3.substring(0, var4).replace('.', '/') + "/" + var1;
  253.             }
  254.          } else {
  255.             var1 = var1.substring(1);
  256.          }
  257.  
  258.          return var1;
  259.       }
  260.    }
  261.  
  262.    private native Field[] getFields0(int var1);
  263.  
  264.    private native Method[] getMethods0(int var1);
  265.  
  266.    private native Constructor[] getConstructors0(int var1);
  267.  
  268.    private native Field getField0(String var1, int var2);
  269.  
  270.    private native Method getMethod0(String var1, Class[] var2, int var3);
  271.  
  272.    private native Constructor getConstructor0(Class[] var1, int var2);
  273.  
  274.    private native Class[] getDeclaredClasses0();
  275.  
  276.    static {
  277.       registerNatives();
  278.       serialPersistentFields = ObjectStreamClass.NO_FIELDS;
  279.    }
  280. }
  281.