harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulex Yang (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-618) [classlib][nio]java.nio.channels.nio.SelectorProvider should not use thread's context classloader to load provider class defined in property file
Date Mon, 19 Jun 2006 07:57:29 GMT
[classlib][nio]java.nio.channels.nio.SelectorProvider should not use thread's context classloader
to load provider class defined in property file
-------------------------------------------------------------------------------------------------------------------------------------------------

         Key: HARMONY-618
         URL: http://issues.apache.org/jira/browse/HARMONY-618
     Project: Harmony
        Type: Bug

  Components: Classlib  
    Reporter: Paulex Yang
    Priority: Minor


SelectorProvider.provider() should not use the Thread.currentThread().getContextClassLoader()
to load the provider class defined in property file, test shows RI doesn't uses it.

Run the test below, and 
RI prints: pass
while Harmony prints: fail

public class SelectorProviderTest {

    private static final Class CLASS1 = MockSelectorProvider1.class;
    private static final Class CLASS2 = MockSelectorProvider2.class;
    private static final String KEY = "java.nio.channels.spi.SelectorProvider";

    public static void main(String[] args) {
        System.setProperty(KEY, CLASS1.getName());
        Thread.currentThread().setContextClassLoader(new MockClassLoader());
        SelectorProvider provider = SelectorProvider.provider();
        if (provider.getClass() == CLASS1) {
            System.out.println("pass");
        } else {
            System.out.println("fail");
        }
    }

    private static class MockClassLoader extends ClassLoader {
        public Class<?> loadClass(String name) throws ClassNotFoundException {
            return CLASS2;
        }
    }
    
    public static class MockSelectorProvider2 extends SelectorProvider{
        public DatagramChannel openDatagramChannel() throws IOException {
            return null;
        }
        public Pipe openPipe() throws IOException {
            return null;
        }
        public AbstractSelector openSelector() throws IOException {
            return null;
        }
        public ServerSocketChannel openServerSocketChannel() throws IOException {
            return null;
        }
        public SocketChannel openSocketChannel() throws IOException {
            return null;
        }
    }

    public static class MockSelectorProvider1 extends SelectorProvider{
        public DatagramChannel openDatagramChannel() throws IOException {
            return null;
        }
        public Pipe openPipe() throws IOException {
            return null;
        }
        public AbstractSelector openSelector() throws IOException {
            return null;
        }
        public ServerSocketChannel openServerSocketChannel() throws IOException {
            return null;
        }
        public SocketChannel openSocketChannel() throws IOException {
            return null;
        }
    }
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message