beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romain Manni-Bucau (JIRA)" <j...@apache.org>
Subject [jira] [Created] (BEAM-2701) use a custom implementation of java.io.ObjectInputStream
Date Mon, 31 Jul 2017 16:54:00 GMT
Romain Manni-Bucau created BEAM-2701:
----------------------------------------

             Summary: use a custom implementation of java.io.ObjectInputStream
                 Key: BEAM-2701
                 URL: https://issues.apache.org/jira/browse/BEAM-2701
             Project: Beam
          Issue Type: Bug
          Components: sdk-java-core
            Reporter: Romain Manni-Bucau
            Assignee: Davor Bonaci


java.io.ObjectInputStream should override resolve[Proxy]Class using the TCCL to support any
classloader and not fallback into some JVM pitfall using another classloader (default). This
will enable beam to use any classloader instead of requiring to run in the JVM using java
serialization.

{code}
    @Override
    protected Class<?> resolveClass(final ObjectStreamClass classDesc) throws IOException,
ClassNotFoundException {
        final String n = classDesc.getName();
        final ClassLoader classloader = getClassloader();
        try {
            return Class.forName(n, false, classloader);
        } catch (ClassNotFoundException e) {

            if (n.equals("boolean")) {
                return boolean.class;
            }
            if (n.equals("byte")) {
                return byte.class;
            }
            if (n.equals("char")) {
                return char.class;
            }
            if (n.equals("short")) {
                return short.class;
            }
            if (n.equals("int")) {
                return int.class;
            }
            if (n.equals("long")) {
                return long.class;
            }
            if (n.equals("float")) {
                return float.class;
            }
            if (n.equals("double")) {
                return double.class;
            }

            //Last try - Let runtime try and find it.
            return Class.forName(n, false, null);
        }
    }

    @Override
    protected Class resolveProxyClass(final String[] interfaces) throws IOException, ClassNotFoundException
{
        final Class[] cinterfaces = new Class[interfaces.length];
        for (int i = 0; i < interfaces.length; i++) {
            cinterfaces[i] = getClassloader().loadClass(interfaces[i]);
        }

        try {
            return Proxy.getProxyClass(getClassloader(), cinterfaces);
        } catch (IllegalArgumentException e) {
            throw new ClassNotFoundException(null, e);
        }
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message