/[classpath]/classpath/java/rmi/server/RMIClassLoader.java
ViewVC logotype

Diff of /classpath/java/rmi/server/RMIClassLoader.java

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

revision 1.2 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.3 by ericb, Sat Feb 9 23:22:05 2002 UTC
# Line 1  Line 1 
1  /*  /* RMIClassLoader.java
2    Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.    Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  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)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 44  import java.io.DataInputStream; Line 44  import java.io.DataInputStream;
44  import java.net.MalformedURLException;  import java.net.MalformedURLException;
45  import java.util.StringTokenizer;  import java.util.StringTokenizer;
46    
47  public class RMIClassLoader {  public class RMIClassLoader
48    {
 static private class MyClassLoader extends ClassLoader {  
   
 Class defineClass(String name, byte[] data) {  
         return (defineClass(name, data, 0, data.length));  
 }  
 }  
 static private MyClassLoader loader = new MyClassLoader();  
   
 /**  
  * @deprecated  
  */  
 public static Class loadClass(String name) throws MalformedURLException, ClassNotFoundException {  
         return (loadClass(System.getProperty("java.rmi.server.codebase"), name));  
 }  
   
 public static Class loadClass(URL codebase, String name) throws MalformedURLException, ClassNotFoundException {  
         URL u = new URL(codebase, name + ".class");  
         try {  
                 URLConnection conn = u.openConnection();  
                 DataInputStream strm = new DataInputStream(conn.getInputStream());  
                 byte data[] = new byte[conn.getContentLength()];  
                 strm.readFully(data);  
                 return (loader.defineClass(name, data));  
         }  
         catch (IOException _) {  
                 throw new ClassNotFoundException(name);  
         }  
 }  
   
 public static Class loadClass(String codebase, String name) throws MalformedURLException, ClassNotFoundException {  
         StringTokenizer tok = new StringTokenizer(codebase, ":");  
         while (tok.hasMoreTokens()) {  
                 try {  
                         return (loadClass(new URL(tok.nextToken()), name));  
                 }  
                 catch (ClassNotFoundException _) {  
                         // Ignore - try the next one.  
                 }  
         }  
         throw new ClassNotFoundException(name);  
 }  
49    
50  public static String getClassAnnotation(Class cl) {    static private class MyClassLoader extends ClassLoader
51          return (null);  // We don't yet do this.    {
52  }      Class defineClass(String name, byte[] data)
53        {
54  /**        return defineClass(name, data, 0, data.length);
55   * @deprecated      }
56   */    }
57  public static Object getSecurityContext(ClassLoader loader) {  
58          throw new Error("Not implemented");    static private MyClassLoader loader = new MyClassLoader();
59  }  
60      /**
61       * @deprecated
62       */
63      public static Class loadClass(String name)
64        throws MalformedURLException, ClassNotFoundException
65      {
66        return loadClass(System.getProperty("java.rmi.server.codebase"), name);
67      }
68    
69      public static Class loadClass(URL codebase, String name)
70        throws MalformedURLException, ClassNotFoundException
71      {
72        URL u = new URL(codebase, name + ".class");
73        try
74          {
75            URLConnection conn = u.openConnection();
76            DataInputStream strm = new DataInputStream(conn.getInputStream());
77            byte data[] = new byte[conn.getContentLength()];
78            strm.readFully(data);
79            return loader.defineClass(name, data);
80          }
81        catch (IOException _)
82          {
83            throw new ClassNotFoundException(name);
84          }
85      }
86    
87      public static Class loadClass(String codebase, String name)
88        throws MalformedURLException, ClassNotFoundException
89      {
90        StringTokenizer tok = new StringTokenizer(codebase, ":");
91        while (tok.hasMoreTokens())
92          {
93            try
94              {
95                return loadClass(new URL(tok.nextToken()), name);
96              }
97            catch (ClassNotFoundException _)
98              {
99                // Ignore - try the next one.
100              }
101          }
102        throw new ClassNotFoundException(name);
103      }
104    
105      public static String getClassAnnotation(Class cl)
106      {
107        return null; // We don't yet do this.
108      }
109    
110      /**
111       * @deprecated
112       */
113      public static Object getSecurityContext(ClassLoader loader)
114      {
115        throw new Error("Not implemented");
116      }
117    
118  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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