The patch now uses reflection to keep the current code equivalent for jdk14 and use the old way in case of a jdk1.3 jvm.
That being said - I would assume that the RMI issue your patch addressed would still be an issue in JDK1.3. Can you give me some insight on what it was? If possible I can attempt to make the appropriate fix.
I think commons-dbcp project do some wacky magic on java src files ( poor man's equivalent of c directives for code include/exclude). Is that an alternative to move towards for situations like this? Or is having one and only one binary the a better goal? (So users don't need to choose a 1.3 and 1.4 binary)
-Tim
Remy Maucherat wrote:
Tim Funk wrote:Tomcat5 does not compile with JDK1.3. It does with JDK1.4.
There is only one line of code that prevents it from compiling with JDK1.3.
org.apache.catalina.loader.WebappClassLoader depends on File.toURI() which does not exist on jdk1.3.
I got around this by the performing the following:
OLD CODE:
return realFile.toURI().toURL();
NEW CODE
return new URL("file:" + realFile.toURL().getPath());
My patch also has some spurious stuff because my text editor automatically strips all trailing whitespace from lines and converts tabs to spaces. The important stuff is the last 9 lines of the patch file.
The patch is a bad idea. The change was made to fix RMI related problems.
What should be done is invoke the appropriate methods through reflection, catching any error (and defaulting to the old code if it fails).
Remy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: WebappClassLoader.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v retrieving revision 1.13 diff -u -r1.13 WebappClassLoader.java --- WebappClassLoader.java 13 Nov 2002 00:36:25 -0000 1.13 +++ WebappClassLoader.java 3 Feb 2003 12:59:09 -0000 @@ -65,6 +65,7 @@ import java.io.InputStream; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.lang.reflect.Method; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URL; @@ -109,22 +110,22 @@ /** * Specialized web application class loader. * <p> - * This class loader is a full reimplementation of the + * This class loader is a full reimplementation of the * <code>URLClassLoader</code> from the JDK. It is desinged to be fully * compatible with a normal <code>URLClassLoader</code>, although its internal * behavior may be completely different. * <p> - * <strong>IMPLEMENTATION NOTE</strong> - This class loader faithfully follows - * the delegation model recommended in the specification. The system class - * loader will be queried first, then the local repositories, and only then - * delegation to the parent class loader will occur. This allows the web + * <strong>IMPLEMENTATION NOTE</strong> - This class loader faithfully follows + * the delegation model recommended in the specification. The system class + * loader will be queried first, then the local repositories, and only then + * delegation to the parent class loader will occur. This allows the web * application to override any shared class except the classes from J2SE. * Special handling is provided from the JAXP XML parser interfaces, the JNDI - * interfaces, and the classes from the servlet API, which are never loaded + * interfaces, and the classes from the servlet API, which are never loaded * from the webapp repository. * <p> - * <strong>IMPLEMENTATION NOTE</strong> - Due to limitations in Jasper - * compilation technology, any repository which contains classes from + * <strong>IMPLEMENTATION NOTE</strong> - Due to limitations in Jasper + * compilation technology, any repository which contains classes from * the servlet API will be ignored by the class loader. * <p> * <strong>IMPLEMENTATION NOTE</strong> - The class loader generates source @@ -227,9 +228,9 @@ public WebappClassLoader(ClassLoader parent) { super(new URL[0], parent); - + this.parent = getParent(); - + system = getSystemClassLoader(); securityManager = System.getSecurityManager(); @@ -670,7 +671,7 @@ /** * Return a String array of the current repositories for this class * loader. If there are no repositories, a zero-length array is - * returned.For security reason, returns a clone of the Array (since + * returned.For security reason, returns a clone of the Array (since * String are immutable). */ public String[] findRepositories() { @@ -705,7 +706,7 @@ ((ResourceAttributes) resources.getAttributes(paths[i])) .getLastModified(); if (lastModified != lastModifiedDates[i]) { - if( log.isDebugEnabled() ) + if( log.isDebugEnabled() ) log.debug(" Resource '" + paths[i] + "' was modified; Date is now: " + new java.util.Date(lastModified) + " Was: " @@ -734,7 +735,7 @@ continue; if (!name.equals(jarNames[i])) { // Missing JAR - log.info(" Additional JARs have been added : '" + log.info(" Additional JARs have been added : '" + name + "'"); return (true); } @@ -742,7 +743,7 @@ } if (enum.hasMoreElements()) { while (enum.hasMoreElements()) { - NameClassPair ncPair = + NameClassPair ncPair = (NameClassPair) enum.nextElement(); String name = ncPair.getName(); // Additional non-JAR files are allowed @@ -1388,7 +1389,7 @@ /** - * Get the lifecycle listeners associated with this lifecycle. If this + * Get the lifecycle listeners associated with this lifecycle. If this * Lifecycle has no listeners registered, a zero-length array is returned. */ public LifecycleListener[] findLifecycleListeners() { @@ -1538,7 +1539,7 @@ synchronized (this) { if (entry.loadedClass == null) { clazz = defineClass(name, entry.binaryContent, 0, - entry.binaryContent.length, + entry.binaryContent.length, codeSource); entry.loadedClass = clazz; } else { @@ -1566,10 +1567,10 @@ entry.codeBase = getURL(new File(file, path)); } catch (MalformedURLException e) { return null; - } + } return entry; } - + /** * Find specified resource in local repositories. @@ -1639,7 +1640,7 @@ int j; - long[] result2 = + long[] result2 = new long[lastModifiedDates.length + 1]; for (j = 0; j < lastModifiedDates.length; j++) { result2[j] = lastModifiedDates[j]; @@ -1724,7 +1725,7 @@ entry.binaryContent = binaryContent; - // The certificates are only available after the JarEntry + // The certificates are only available after the JarEntry // associated input stream has been fully read if (jarEntry != null) { entry.certificates = jarEntry.getCertificates(); @@ -1816,8 +1817,8 @@ protected void refreshPolicy() { try { - // The policy file may have been modified to adjust - // permissions, so we're reloading it when loading or + // The policy file may have been modified to adjust + // permissions, so we're reloading it when loading or // reloading a Context Policy policy = Policy.getPolicy(); policy.refresh(); @@ -1831,7 +1832,7 @@ /** * Filter classes. - * + * * @param name class name * @return true if the class should be filtered */ @@ -1859,12 +1860,12 @@ /** - * Validate a classname. As per SRV.9.7.2, we must restict loading of - * classes from J2SE (java.*) and classes of the servlet API + * Validate a classname. As per SRV.9.7.2, we must restict loading of + * classes from J2SE (java.*) and classes of the servlet API * (javax.servlet.*). That should enhance robustness and prevent a number * of user error (where an older version of servlet.jar would be present * in /WEB-INF/lib). - * + * * @param name class name * @return true if the name is valid */ @@ -1912,7 +1913,7 @@ log.debug(" Checking for " + name); JarEntry jarEntry = jarFile.getJarEntry(name); if (jarEntry != null) { - log.info("validateJarFile(" + jarfile + + log.info("validateJarFile(" + jarfile + ") - jar not loaded. See Servlet Spec 2.3, " + "section 9.7.2. Offending class: " + name); jarFile.close(); @@ -1954,7 +1955,28 @@ } catch (IOException e) { // Ignore } - return realFile.toURI().toURL(); + /* + Use reflection to make - JDK14 specific call which is + the equivalent of realFile.toURI().toURL() + On error revert back to old version (pre 1.11) + which is JDK1.3 ok but breaks on an RMI issue according to + http://marc.theaimsgroup.com/?l=tomcat-dev&m=104426178008958&w=2 + */ + try { + Class[] emptyClazz = new Class[0]; + Object[] emptyObject = new Object[0]; + Object toURI; + Method method; + + method = realFile.getClass().getMethod("toURI", emptyClazz); + toURI = method.invoke(realFile, emptyObject); + + method = toURI.getClass().getMethod("toURL", emptyClazz); + return (URL)method.invoke(toURI, emptyObject); + } catch(Throwable e){ + return getURL(file); + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]