-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
sparc
-
solaris_7
Name: sdR10048 Date: 01/15/2001
public static Class loadClass(String name)
does not look at property "java.rmi.server.codebase" if it is
changed. For example if loadClass(String) has been called 2 times and
before the second time property "java.rmi.server.codebase" has been
changed - it will still be attempted to load class from codebase URL
specified by the "old" property.
See example:
=== T.java ===
import java.rmi.*;
import java.rmi.server.*;
import java.net.MalformedURLException;
public class T {
static String root = "file:///home/dsv/tmp/";
// should be changed ^^^^^^^^^^^^^^^^^^^^^^
static String property = "java.rmi.server.codebase";
static Class cl = null;
static void loadLoadMe(String from) {
try {
System.setProperty(property, from);
System.out.println(property+"="+System.getProperty(property));
cl = RMIClassLoader.loadClass("LoadMe");
Object obj = cl.newInstance();
System.out.println("LoadMe object says: " + obj.toString());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] argv) {
System.setSecurityManager(new RMISecurityManager());
loadLoadMe(root+"LoadMe1/");
loadLoadMe(root+"LoadMe2/");
}
}
=== LoadMe.java #1 === (should be in subdir LoadMe1/)
public class LoadMe {
public String toString() {
return "LoadMe1";
}
}
=== LoadMe.java #2 === (should be in subdir LoadMe2/)
public class LoadMe {
public String toString() {
return "LoadMe2";
}
}
=== output ===
] dsv@sword ~/tmp
] java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
Java HotSpot(TM) Client VM (build 1.4beta-B45, mixed mode)
] dsv@sword ~/tmp
] javac T.java
Note: T.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
] dsv@sword ~/tmp
] cd LoadMe1/
] dsv@sword ~/tmp/LoadMe1
] javac LoadMe.java
] dsv@sword ~/tmp/LoadMe1
] cd ../LoadMe2/
] dsv@sword ~/tmp/LoadMe2
] javac LoadMe.java
] dsv@sword ~/tmp/LoadMe2
] cd ../
] dsv@sword ~/tmp
] java T
java.rmi.server.codebase=file:///home/dsv/tmp/LoadMe1/
LoadMe object says: LoadMe1
java.rmi.server.codebase=file:///home/dsv/tmp/LoadMe2/
LoadMe object says: LoadMe1
--------------------------------------------------
======================================================================
- duplicates
-
JDK-4417552 java.rmi.server.codebase can not be dynamically assigned
- Closed
- relates to
-
JDK-4508160 (spec) RMIClassLoader.loadClass() doesn't work if codebase changed dynamically
- Closed