You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Markov (JIRA)" <ji...@apache.org> on 2006/10/24 09:37:16 UTC
[jira] Created: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase 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
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
[jira] Resolved: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=all ]
Nathan Beyer resolved HARMONY-1944.
-----------------------------------
Resolution: Fixed
I applied the patch and a modified version of the test class patch. I tweaked the test class to use relative loading of the JAR resource and I tweaked the SecurityManager setup, so that the SecurityManager can be reset and so that the test runs on the RI.
Please verify the committed changes. Thanks.
> [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, RMIClassLoaderTest.patch, testClass.jar
>
>
> 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
[jira] Updated: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=all ]
Mikhail Markov updated HARMONY-1944:
------------------------------------
Attachment: DefaultRMIClassLoaderSpi.2.patch
Here is the patch fixing the problem. It's based on proposed fix in HARMONY-1936.
> [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
> 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
[jira] Commented: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=comments#action_12444863 ]
Nathan Beyer commented on HARMONY-1944:
---------------------------------------
If you can make that into a JUnit test, that would perfect. I'd just like to have a regression test in the module for the fix.
> [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
[jira] Updated: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=all ]
Mikhail Markov updated HARMONY-1944:
------------------------------------
Attachment: RMIClassLoaderTest.patch
Ok - here is the patch for the tests.
> [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, RMIClassLoaderTest.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
[jira] Commented: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=comments#action_12445564 ]
Mikhail Markov commented on HARMONY-1944:
-----------------------------------------
Everything is OK, Nathan. Thanks!
The only thing i'm thinking of is: perhaps it makes sense to put empty "all-allowing" SecurityManager outside the test so other RMI tests coud use it (as RMI requires SecurityManager be always set during the run)? One of candidates for such and improvement is org.apache.harmony.rmi.RegistryTest, for example.
> [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, RMIClassLoaderTest.patch, testClass.jar
>
>
> 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
[jira] Commented: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ 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
[jira] Commented: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=comments#action_12444710 ]
Mikhail Markov commented on HARMONY-1944:
-----------------------------------------
Do you mean the modification for this stand alone test or the patch for the junit test against RMIClassLoader?
If for the stand alone test then here is the modified version (with file:/ protocol usage) - also fails on Harmony:
------------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[] {
"/jdk/my/test/harmony/dl/testClasses.jar", "/jdk/my/test/harmony/dl/fake.jar" };
Class c = RMIClassLoader.loadClass("file://" + pathes[0] + " file://" + 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 {
}
> [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
[jira] Updated: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=all ]
Mikhail Markov updated HARMONY-1944:
------------------------------------
Attachment: testClass.jar
This jar should be put into /src/test/resources directory in rmi module.
> [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, RMIClassLoaderTest.patch, testClass.jar
>
>
> 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
[jira] Assigned: (HARMONY-1944) [classlib][rmi] default
RMIClassLoader provider should not sort codebase URLs
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1944?page=all ]
Nathan Beyer reassigned HARMONY-1944:
-------------------------------------
Assignee: Nathan Beyer
> [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