|
From: <php...@li...> - 2007-06-21 11:08:27
|
Hi,
the following code may show the problem. It is written in PHP, but it could have been written in Java as well, as it demonstrates a problem with Java's URLClassLoader:
xtest.java:
public class xtest { public static String f() { return "12"; } }
xtest.php:
<?php
// The following code shows a bug in Java's URLClassLoader
// While running this script, modify xtest.jar, so that f() returns
// "123" instead of "12".
// You will see that the jar file is fetched (its size changes)
// but the URLClassLoader discards it and uses the cached
// jar file from the previous request.
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
while(true) {
$url = new java("java.net.URL", "http://localhost/xtest.jar");
$conn = $url->openConnection();
echo $conn->getContentLength(); echo "->";
$conn->disconnect();
$loader = java("java.net.URLClassLoader")->newInstance(array($url));
$clazz = $loader->loadClass("xtest");
echo $clazz->f(); echo "<br>\n";
sleep(1);
}
?>
---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out.
|