[PATCH] small fix for ServerSocket close

2003-11-13 Thread Dalibor Topic
Hi all,

attached is a small fix for ServerSocket's close method. It fixes a 
NullPointerException when attempting to close a ServerSocket twice.

2003-11-13  Guilhem Lavaux [EMAIL PROTECTED]
* java/net/ServerSocket.java:
(close) Check if server socket has already been released,
before attepting to close it.
--- /var/tmp/PROJECTS/classpath//./java/net/ServerSocket.java   Fri Oct 17 19:05:29 
2003
+++ java/net/ServerSocket.java  Wed Oct 22 21:32:21 2003
@@ -339,7 +339,8 @@
*/
   public void close () throws IOException
   {
-impl.close ();
+if (impl != null)
+  impl.close ();
 
 if (getChannel() != null)
   getChannel().close ();
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: [PATCH] Small fix for Jetty 4.2.14

2003-11-13 Thread Mark Wielaard
Hi,

On Thu, 2003-11-13 at 01:29, Dalibor Topic wrote:
 Hi,
 
 attached is a small fix for Jetty 4.2.14 that is needed to get Jetty to 
 work with Classpath's file URL Connection. Jetty otherwise breaks on 
 startup and complains that webapps/templates can not be found, despite 
 that it exists. Jetty wants to access the path of the file permission on 
 a file URL connection to determine the existence of a file, apparently.
 
 The fix overwrites getPermission the file URL connection to return a 
 FilePermission with the file path and a read permission.

Thanks. I also wrote a Mauve test for this.
(The test still fails because our file Handler.parseURL() seem broken.
But if that is fixed, your patch makes the new Mauve test succeed.)

2003-11-13  Dalibor Topic [EMAIL PROTECTED]
 
 * libraries/javalib/gnu/java/net/protocol/file/Connection.java:
 Added imports for java.io.FilePermission and
 java.security.Permission.
 (permission) New field.
 (DEFAULT_PERMISSION) New constant.
 (Connection) Create a FilePermission with permission to read
 from file.
 (getPermission) Overwrite getPermission to return a
 FilePermission.
 

Applied as follows:

2003-11-13  Dalibor Topic [EMAIL PROTECTED]

   * gnu/java/net/protocol/file/Connection.java (permission): New field.
   (DEFAULT_PERMISSION): New constant.
   (Connection): Create a FilePermission with permission to read file.
   (getPermission): Overwrite getPermission to return a FilePermission.

You don't need to mention really trivial changes such as new imports.
Note the placement of the ':' between what was changed and the
description of the change.

Maybe kaffe could in the long run switch to a separate ChangeLog file in
the libraries/javalib directory so that we can even share the complete
ChangeLog messages between the projects as we already do with gcj
libjava.

Cheers,

Mark


signature.asc
Description: This is a digitally signed message part
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: [PATCH] small fix for ServerSocket close

2003-11-13 Thread Mark Wielaard
Hi,

On Thu, 2003-11-13 at 15:35, Dalibor Topic wrote:
 attached is a small fix for ServerSocket's close method. It fixes a 
 NullPointerException when attempting to close a ServerSocket twice.

Thanks. Checked in as obvious. Only slightly reformatted the ChangeLog
entry.

2003-11-13  Guilhem Lavaux [EMAIL PROTECTED]

   * java/net/ServerSocket.java (close): Check if server socket has
   already been released, before attepting to close it.

Cheers,

Mark


signature.asc
Description: This is a digitally signed message part
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: [PATCH] small fix for ServerSocket close

2003-11-13 Thread Michael Koch
On Thu, Nov 13, 2003 at 06:47:30PM +0100, Mark Wielaard wrote:
 Hi,
 
 On Thu, 2003-11-13 at 15:35, Dalibor Topic wrote:
  attached is a small fix for ServerSocket's close method. It fixes a 
  NullPointerException when attempting to close a ServerSocket twice.
 
 Thanks. Checked in as obvious. Only slightly reformatted the ChangeLog
 entry.
 
 2003-11-13  Guilhem Lavaux [EMAIL PROTECTED]
 
* java/net/ServerSocket.java (close): Check if server socket has
already been released, before attepting to close it.

I think it would be really nice i you could commit this to libgcj too.
This class is totally merged.


Michael


___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: URL's fix

2003-11-13 Thread Mark Wielaard
Hi,

On Wed, 2003-10-29 at 19:29, Guilhem Lavaux wrote:

 I noticed some misbehaviour of classpath's URL compared to 
 Sun's JDK while merging these classes in kaffe's library. 
 Kaffe's regression test URLTest was failing nearly 
 completely.

I turned that kaffe test into a new Mauve test.

 BTW, there was an error when url of the type 
 http://anonymous:[EMAIL PROTECTED]/ was entered: URL reports 
 to detect anonymous as the host.

I also added that to the new Mauve test and saw that your patch indeed
fixes the parsing, but that we also had a bug in the toExternalForm() of
such URLs. Fix as follows:

2003-11-13  Guilhem Lavaux  [EMAIL PROTECTED]
Mark Wielaard  [EMAIL PROTECTED]

* java/net/URLStreamHandler (parseUrl): Fixed URL parsing
('@' should be checked to distinguish port from userinfo).
(toExternalForm): Add @ userInfo if necessary.

 This patch fixes all these things.

It is easier when patches are split up into small parts.
That makes reviewing them much easier. Will review the rest of you patch
later.

Cheers,

Mark

Index: java/net/URLStreamHandler.java
===
RCS file: /cvsroot/classpath/classpath/java/net/URLStreamHandler.java,v
retrieving revision 1.19
diff -u -r1.19 URLStreamHandler.java
--- java/net/URLStreamHandler.java	19 Sep 2003 06:19:42 -	1.19
+++ java/net/URLStreamHandler.java	13 Nov 2003 22:51:54 -
@@ -129,11 +129,12 @@
 
 if (spec.regionMatches (start, //, 0, 2))
   {
+	String genuineHost;
 	int hostEnd;
-	int colon;
+	int colon, at_host;
 
 	start += 2;
-	int slash = spec.indexOf('/', start);
+	int slash = spec.indexOf ('/', start);
 	if (slash = 0) 
 	  hostEnd = slash;
 else
@@ -141,24 +142,37 @@
 
 	host = spec.substring (start, hostEnd);
 	
+	// We first need a genuine host name (with userinfo).
+	// So we check for '@': if it's present check the port in the
+	// section after '@' in the other case check it in the full string.
+	// P.S.: We don't care having '@' at the beginning of the string.
+	if ((at_host = host.indexOf ('@')) = 0)
+	  genuineHost = host.substring (at_host);
+	else
+	  genuineHost = host;
+
 	// Look for optional port number.  It is valid for the non-port
 	// part of the host name to be null (e.g. a URL http://:80;).
 	// TBD: JDK 1.2 in this case sets host to null rather than ;
 	// this is undocumented and likely an unintended side effect in 1.2
 	// so we'll be simple here and stick with . Note that
 	// http://; or http:///; produce a  host in JDK 1.2.
-	if ((colon = host.indexOf(':')) = 0)
+	if ((colon = genuineHost.indexOf (':')) = 0)
 	  {
 	try
 	  {
-		port = Integer.parseInt(host.substring(colon + 1));
+		port = Integer.parseInt (genuineHost.substring (colon + 1));
 	  }
 	catch (NumberFormatException e)
 	  {
 		; // Ignore invalid port values; port is already set to u's
 		  // port.
 	  }
-	host = host.substring(0, colon);
+	// Now we must cut the port number in the original string.
+	if (at_host = 0)
+	  host = host.substring (0, at_host + colon);
+	else
+	  host = host.substring (0, colon);
 	  }
 	file = null;
 	start = hostEnd;
@@ -451,7 +465,7 @@
*/
   protected String toExternalForm(URL u)
   {
-String protocol, host, file, ref;
+String protocol, host, file, ref, user;
 int port;
 
 protocol = u.getProtocol();
@@ -465,6 +479,7 @@
 port = u.getPort();
 file = u.getFile();
 ref = u.getRef();
+user = u.getUserInfo();
 
 // Guess a reasonable size for the string buffer so we have to resize
 // at most once.
@@ -478,7 +493,12 @@
   }
 
 if (host.length() != 0)
-  sb.append(//).append(host);
+  {
+	sb.append(//);
+	if (user != null  !.equals(user))
+	  sb.append(user).append('@');
+	sb.append(host);
+  }
 
 // Note that this produces different results from JDK 1.2 as JDK 1.2
 // ignores a non-default port if host is null or .  That is inconsistent


signature.asc
Description: This is a digitally signed message part
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


reformatting: hacked jalopy available

2003-11-13 Thread Tom Tromey
I've hacked jalopy a bit to generate output that conforms more
closely to what we'd like.

You can get it here:

ftp://sources.redhat.com/pub/java/jalopy-console-1.0.4.tar.gz

Also in that directory is GNU.xml, my attempt at a GNU-like style
file.

I don't have anywhere to check in my changes; in the meantime they're
living here in an eclipse workspace.  I can generate a patch for
anybody who wants it.

A few caveats:

* I didn't add a GUI for the new options I added; I just set up their
  defaults to be what we'd like.  This is easy enough to change later
  if needed.

* jalopy always uses spaces for everything; the tab options don't do
  what we'd like.  Do we want tabs in the source?  If so, we can run
  the output through unexpand easily enough (or write a simple output
  filter that tabifies).  If not, we can all adjust our .emacs files
  to cope.

* Sometimes jalopy adds blank lines where we probably wouldn't.  See
  the attached Point.java patch.  I requested the deletion before
  package and the addition after the imports, but the other changes
  are jalopy's idea.  I'll try to look at this soon-ish.  It also
  adds blank lines around abstract methods, see the second patch.

* I disabled interpretation of javadoc (via a setting, not in the
  source), since our javadoc confuses jalopy.  So javadoc is never
  reformatted.

* I'd like to have it be able to delete closing comments after the
  final brace of a method or class (I usually remove these when I see
  them), but I haven't added this feature yet... not sure if we
  really wanted it.

* Bonus points for anybody who changes jalopy to remove redundant
  modifiers, like public in an interface.


Please try it out and let me know what you think.  I've only
spot-checked a few files in java.awt and javax.swing, we need more
eyes on this before we can use it in earnest.

I think we're pretty close to being able to use this.

Tom

Index: Point.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Point.java,v
retrieving revision 1.7
diff -u -r1.7 Point.java
--- Point.java  21 Mar 2002 07:58:00 -  1.7
+++ Point.java  14 Nov 2003 03:56:44 -
@@ -35,12 +35,12 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
-
 package java.awt;
 
 import java.awt.geom.Point2D;
 import java.io.Serializable;
 
+
 /**
  * This class represents a point on the screen using cartesian coordinates.
  * Remember that in screen coordinates, increasing x values go from left to
@@ -228,7 +228,9 @@
   {
 if (! (obj instanceof Point2D))
   return false;
+
 Point2D p = (Point2D) obj;
+
 return x == p.getX()  y == p.getY();
   }
 

Index: MenuPeer.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/peer/MenuPeer.java,v
retrieving revision 1.10
diff -u -r1.10 MenuPeer.java
--- MenuPeer.java   12 Oct 2003 13:53:40 -  1.10
+++ MenuPeer.java   14 Nov 2003 04:13:42 -
@@ -35,15 +35,16 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
-
 package java.awt.peer;
 
 import java.awt.MenuItem;
 
+
 public interface MenuPeer extends MenuItemPeer
 {
-  void addItem (MenuItem item);
-  void addSeparator ();
-  void delItem (int index);
-}
+  void addItem(MenuItem item);
 
+  void addSeparator();
+
+  void delItem(int index);
+}


___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: [PATCH] small fix for ServerSocket close

2003-11-13 Thread Brian Jones
Michael Koch [EMAIL PROTECTED] writes:

 I think it would be really nice i you could commit this to libgcj too.
 This class is totally merged.

Just out of my curiosity, how does that whole process work?  

Brian
-- 
Brian Jones [EMAIL PROTECTED]


___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: reformatting: hacked jalopy available

2003-11-13 Thread Brian Jones
Tom Tromey [EMAIL PROTECTED] writes:

 * I didn't add a GUI for the new options I added; I just set up their
   defaults to be what we'd like.  This is easy enough to change later
   if needed.

Ok, I think we should make the GNU option do what we like if someone
does hack on the config piece.

-- 
Brian Jones [EMAIL PROTECTED]


___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath