All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.util.JRubyObjectInputStream Maven / Gradle / Ivy

There is a newer version: 9.4.7.0
Show newest version
package org.jruby.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import org.jruby.Ruby;

public class JRubyObjectInputStream extends ObjectInputStream {
    private final Ruby runtime;

    public JRubyObjectInputStream(Ruby runtime, InputStream input) throws IOException {
        super(input);
        this.runtime = runtime;
    }

    protected Class resolveClass(ObjectStreamClass desc)
        throws IOException, ClassNotFoundException
    {
        String name = desc.getName();
        try {
            return Class.forName(name, false, runtime.getJRubyClassLoader());
        } catch (ClassNotFoundException ex) {
            return super.resolveClass(desc);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy