[kaffe] CVS kaffe (dalibor): Fixes to get Tomcat 4.1.27 to load

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Sat Sep 13 14:32:02 2003


PatchSet 4031 
Date: 2003/09/13 21:30:13
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Fixes to get Tomcat 4.1.27 to load

It doesn't load completely: it gets a NullPointerException trying
to parse the definition file for the examples. Running it under
gdb with VM debugging enabled crashes at interesting execution
points. But at least the web server seems to work well enough

Members: 
	ChangeLog:1.1627->1.1628 
	libraries/javalib/java/net/URLClassLoader.java:1.11->1.12 
	libraries/javalib/javax/naming/spi/NamingManager.java:1.2->1.3 
	libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java:1.5->1.6 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1627 kaffe/ChangeLog:1.1628
--- kaffe/ChangeLog:1.1627	Sat Sep 13 12:30:46 2003
+++ kaffe/ChangeLog	Sat Sep 13 21:30:13 2003
@@ -1,3 +1,20 @@
+2003-09-13  Dalibor Topic <robilad@kaffe.org>,
+            Helmer Kraemer  <hkraemer@freenet.de>
+
+	* libraries/javalib/javax/naming/spi/NamingManager.java:
+	(getURLContext, getObjectInstance, getStateToBind) Always use
+	current thread's context class loader when calling Class.forName.
+
+2003-09-13  Dalibor Topic <robilad@kaffe.org>
+	
+	* libraries/javalib/java/net/URLClassLoader.java
+	(findResourceInternal) Only attempt to call diconnect if
+	URLConnection u is a HttpURLConnection to avoid creating
+	unnecessary exceptions.
+
+	* libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java:
+	(connect) Improved exception message.
+	
 2003-09-13  Dalibor Topic <robilad@kaffe.org>
 
 	* libraries/clib/native/Runtime.c:
Index: kaffe/libraries/javalib/java/net/URLClassLoader.java
diff -u kaffe/libraries/javalib/java/net/URLClassLoader.java:1.11 kaffe/libraries/javalib/java/net/URLClassLoader.java:1.12
--- kaffe/libraries/javalib/java/net/URLClassLoader.java:1.11	Mon Jul  7 13:46:35 2003
+++ kaffe/libraries/javalib/java/net/URLClassLoader.java	Sat Sep 13 21:30:14 2003
@@ -185,12 +185,10 @@
 
 				// Try to get it, to see if it's really there
 				URLConnection u = url.openConnection();
-
-				// Try not to leave a lingering connection
-				try {
-					u.getClass().getMethod("disconnect",
-					    null).invoke(u, new Object[0]);
-				} catch (Exception e) {
+			      
+				// Try not to leave a lingering HTTP connection
+				if (u instanceof HttpURLConnection) {
+				  ((HttpURLConnection) u).disconnect();
 				}
 			
 				if (v != null) {
@@ -199,8 +197,10 @@
 					return url;
 				}
 			} catch (IOException e) {	// resource not found
+				// e.printStackTrace();
 			}
 		}
+
 		return null; 
 	}
 
Index: kaffe/libraries/javalib/javax/naming/spi/NamingManager.java
diff -u kaffe/libraries/javalib/javax/naming/spi/NamingManager.java:1.2 kaffe/libraries/javalib/javax/naming/spi/NamingManager.java:1.3
--- kaffe/libraries/javalib/javax/naming/spi/NamingManager.java:1.2	Sun Aug 10 18:47:57 2003
+++ kaffe/libraries/javalib/javax/naming/spi/NamingManager.java	Sat Sep 13 21:30:14 2003
@@ -129,7 +129,9 @@
 	String aTry = tokens.nextToken ();
 	try
 	  {
-	    Class factoryClass = Class.forName (aTry + "." + scheme);
+	    Class factoryClass = Class.forName (aTry + "." + scheme,
+						true,
+						Thread.currentThread().getContextClassLoader());
 	    ObjectFactory factory =
 	      (ObjectFactory) factoryClass.newInstance ();
 	    Object obj = factory.getObjectInstance (refInfo, name,
@@ -231,7 +233,9 @@
 	    if (fClass != null)
 	      {
 		// Exceptions here are passed to the caller.
-		Class k = Class.forName (fClass);
+		Class k = Class.forName (fClass,
+					 true,
+					 Thread.currentThread().getContextClassLoader());
 		factory = (ObjectFactory) k.newInstance ();
 	      }
 	    else
@@ -275,7 +279,9 @@
 	    while (tokens.hasMoreTokens ())
 	      {
 		String klassName = tokens.nextToken ();
-		Class k = Class.forName (klassName);
+		Class k = Class.forName (klassName,
+					 true,
+					 Thread.currentThread().getContextClassLoader());
 		factory = (ObjectFactory) k.newInstance ();
 		Object obj = factory.getObjectInstance (refInfo, name,
 							nameCtx, environment);
@@ -341,7 +347,9 @@
 	String klassName = tokens.nextToken ();
 	try
 	  {
-	    Class k = Class.forName (klassName);
+	    Class k = Class.forName (klassName,
+				     true,
+				     Thread.currentThread().getContextClassLoader());
 	    StateFactory factory = (StateFactory) k.newInstance ();
 	    Object o = factory.getStateToBind (obj, name, nameCtx,
 					       environment);
Index: kaffe/libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java
diff -u kaffe/libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java:1.5 kaffe/libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java:1.6
--- kaffe/libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java:1.5	Thu Nov 22 06:21:25 2001
+++ kaffe/libraries/javalib/kaffe/net/www/protocol/jar/JarURLConnection.java	Sat Sep 13 21:30:15 2003
@@ -87,7 +87,9 @@
 			jarEntry = jarFile.getEntry(jarEntryName);
 			if (jarEntry == null) {
 				throw new IOException("JAR entry \""
-				    + jarEntryName + "\" not found");
+						      + jarEntryName
+						      + "\" not found in JAR file "
+						      + jarFile.getName());
 			}
 		}
 		connected = true;