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

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

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

revision 1.18 by ericb, Fri Feb 22 20:07:40 2002 UTC revision 1.19 by ericb, Sat Feb 23 09:19:52 2002 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38  package java.lang;  package java.lang;
39    
40  import java.io.Serializable;  import java.io.Serializable;
41    import java.io.InputStream;
42  import java.lang.reflect.*;  import java.lang.reflect.*;
43  import java.security.*;  import java.security.*;
44  import java.net.URL;  import java.net.URL;
# Line 117  public final class Class implements Seri Line 118  public final class Class implements Seri
118     */     */
119    public String toString()    public String toString()
120    {    {
121      //XXX Fix for primitive types.      if (isPrimitive())
122          return getName();
123      return (isInterface() ? "interface " : "class ") + getName();      return (isInterface() ? "interface " : "class ") + getName();
124    }    }
125    
# Line 134  public final class Class implements Seri Line 136  public final class Class implements Seri
136     * @throws ExceptionInInitializerError if the class loads, but an exception     * @throws ExceptionInInitializerError if the class loads, but an exception
137     *         occurs during initialization     *         occurs during initialization
138     */     */
139    //XXX This does not need to be native.    public static Class forName(String name) throws ClassNotFoundException
   public static native Class forName(String name)  
     throws ClassNotFoundException;  
   /*  
140    {    {
141      return forName(name, true,      return forName(name, true,
142                     VMSecurityManager.getClassContext()[1].getClassLoader());                     VMSecurityManager.getClassContext()[1].getClassLoader());
143    }    }
   */  
144    
145    /**    /**
146     * Use the specified classloader to load and link a class. If the loader     * Use the specified classloader to load and link a class. If the loader
# Line 211  public final class Class implements Seri Line 209  public final class Class implements Seri
209    {    {
210      try      try
211        {        {
212          //XXX What about getConstructor(null).newInstance(null)?          return getConstructor(null).newInstance(null);
         return getConstructor(new Class[0]).newInstance(new Object[0]);  
       }  
     catch(SecurityException e)  
       {  
         //XXX Why is this trapped?  
         throw new IllegalAccessException("Cannot access no-arg constructor");  
213        }        }
214      catch(IllegalArgumentException e)      catch(IllegalArgumentException e)
215        {        {
216          throw new UnknownError("IllegalArgumentException thrown from Constructor.newInstance().  Something is rotten in Denmark.");          throw (Error) new InternalError("Should not happen").initCause(e);
217        }        }
218      catch(InvocationTargetException e)      catch(InvocationTargetException e)
219        {        {
220          //XXX Chain this.          throw (InstantiationException)
221          throw new InstantiationException("Target threw an exception.");            new InstantiationException(e.toString()).initCause(e);
222        }        }
223      catch(NoSuchMethodException e)      catch(NoSuchMethodException e)
224        {        {
225          //XXX Chain this.          throw (InstantiationException)
226          throw new InstantiationException("Method not found");            new InstantiationException(e.toString()).initCause(e);
227        }        }
228    }    }
229    
# Line 387  public final class Class implements Seri Line 379  public final class Class implements Seri
379      if(isArray())      if(isArray())
380        try        try
381          {          {
382            //XXX This should not initialize the component type.            return Class.forName(getName().substring(1), false,
383            return Class.forName(getName().substring(1));                                 getClassLoader());
384          }          }
385        catch(ClassNotFoundException e)        catch(ClassNotFoundException e)
386          {          {
# Line 772  public final class Class implements Seri Line 764  public final class Class implements Seri
764     * @see ClassLoader#setPackageAssertionStatus(String, boolean)     * @see ClassLoader#setPackageAssertionStatus(String, boolean)
765     * @see ClassLoader#setDefaultAssertionStatus(boolean)     * @see ClassLoader#setDefaultAssertionStatus(boolean)
766     * @since 1.4     * @since 1.4
767     * @XXX For 1.4 compliance, implement this method.     */
768    public boolean desiredAssertionStatus()    public boolean desiredAssertionStatus()
769    {    {
770      ClassLoader c = getClassLoader();      ClassLoader c = getClassLoader();
# Line 825  public final class Class implements Seri Line 817  public final class Class implements Seri
817        }        }
818      return c.defaultAssertionStatus;      return c.defaultAssertionStatus;
819    }    }
   */  
820  }  }
821    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

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