harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Beyer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1944) [classlib][rmi] default RMIClassLoader provider should not sort codebase URLs
Date Wed, 25 Oct 2006 03:07:17 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-1944?page=comments#action_12444556 ] 
            
Nathan Beyer commented on HARMONY-1944:
---------------------------------------

Is there anyway to create a proper test case out of this? The Jetty classes are part of the
available dependencies now, so an inline HttpServer could be started. An alternative might
be to just use "file:" URLs.

> [classlib][rmi] default RMIClassLoader provider should not sort codebase URLs
> -----------------------------------------------------------------------------
>
>                 Key: HARMONY-1944
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1944
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: IA32, WinXP
>            Reporter: Mikhail Markov
>         Assigned To: Nathan Beyer
>         Attachments: DefaultRMIClassLoaderSpi.2.patch
>
>
> Default RMIClassLoader provider (org.apache.harmony.rmi.DefaultRMIClassLoaderSpi) should
retain the order of incoming codebase URLs. Currently it sorts the list, which is demonstrated
by the test below (note: TestClass.class should be put to testClasses.jar file and should
be accessible through http server on localhost and 8080 port ):
> Output on RI:
> Test passed.
> Output on Harmony:
> URL[0].getPath() = /fake.jar, expected: /testClasses.jar
> URL[1].getPath() = /testClasses.jar, expected: /fake.jar
> Test failed.
> ------------Test.java-------------
> import java.net.URL;
> import java.net.URLClassLoader;
> import java.rmi.server.RMIClassLoader;
> public class Test {
>     public static void main(String[] args) throws Exception {
>         System.setProperty("java.security.policy", "policy.all");
>         System.setSecurityManager(new SecurityManager());
>         String[] pathes = new String[] { "/testClasses.jar", "/fake.jar" };
>         Class c = RMIClassLoader.loadClass("http://localhost:8080"
>                 + pathes[0] + " http://localhost:8080" + pathes[1],
>                 "TestClass", null);
>         ClassLoader cl = c.getClassLoader();
>         if (cl instanceof URLClassLoader) {
>             URL[] urls = ((URLClassLoader) cl).getURLs();
>             if (urls.length != 2) {
>                 System.out.println("Test failed, unexpected number of URLs: " + urls.length);
>                 return;
>             }
>             boolean failed = false;
>             for (int i = 0; i < urls.length; ++i) {
>                 if (!urls[i].getPath().equals(pathes[i])) {
>                     System.out.println("URL[" + i + "].getPath() = "
>                             + urls[i].getPath() +", expected: " + pathes[i]);
>                     failed = true;
>                 }
>             }
>             if (failed) {
>                 System.out.println("Test failed.");
>             } else {
>                 System.out.println("Test passes.");
>             }
>         } else {
>             System.out.println("Test failed, class is loaded by non-URLClassLoader");
>         }
>     }
> }
> ------------TestClass.java---------------
> public class TestClass {
> }

-- 
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