summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/ObjectInputStream.java
blob: 761c45f3450a76828422a8123ec94524393118c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// **********************************************************************
//
// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

package IceInternal;

//
// We need to override the resolveClass method of ObjectInputStream so
// that we can use the same class-lookup mechanism as elsewhere in the
// Ice run time.
//

public class ObjectInputStream extends java.io.ObjectInputStream
{
    public
    ObjectInputStream(Instance instance, java.io.InputStream in)
        throws java.io.IOException
    {
        super(in);
        _instance = instance;
    }

    protected Class<?>
    resolveClass(java.io.ObjectStreamClass cls)
        throws java.io.IOException, ClassNotFoundException
    {
        try
        {
            Class<?> c = _instance.findClass(cls.getName());
            if(c != null)
            {
                return c;
            }
            throw new ClassNotFoundException("unable to resolve class" + cls.getName());
        }
        catch(Exception ex)
        {
            throw new ClassNotFoundException("unable to resolve class " + cls.getName(), ex);
        }
    }

    private Instance _instance;
}