Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: mucode/MuObjectInputStream.java


1   /* mucode - A lightweight and flexible mobile code toolkit
2    * Copyright (C) 2000, Gian Pietro Picco
3    *  
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 2.1 of the License, or (at your option) any later version.
8    *  
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   * Lesser General Public License for more details.
13   * 
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this library; if not, write to the Free Software
16   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   */
18  package mucode;
19  
20  import java.io.*;
21  
22  class MuObjectInputStream extends ObjectInputStream {
23    private MuClassLoader loader = null;   
24    public MuObjectInputStream(InputStream in, MuClassLoader aLoader) 
25      throws IOException {
26      super(in);
27      loader = aLoader;
28    }
29  
30    public Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException {  
31      Class c = null;
32      
33      // This method is called by the VM right after the descriptor v for a
34      // class has been read from the stream.
35      try {
36        c = loader.loadClass(v.getName(),true);   
37      } catch (ClassNotFoundException e) {
38        c = Class.forName(v.getName());
39        if (c == null) throw new ClassNotFoundException();
40      } 
41      return c;
42    }
43  }
44  
45