Re: Future blog

2010-12-08 Thread Gary Benson
Dr Andrew John Hughes wrote:
 On 23:06 Tue 07 Dec, Mark Wielaard wrote:
  As soon as I am back I would like us to at least start moving to
  mercurial on savannah if people don't mind.
 
 Yes, I do mind.
 
 We already discussed this some time back:
 
 http://developer.classpath.org/pipermail/classpath/2008-June/002629.html
 
 and nothing happened.  I don't particularly see any huge benefit
 to moving the repository to a different version control system.

Seriously?  There's no reason anybody needs to be using CVS these
days.

Cheers,
Gary

-- 
http://gbenson.net/



Re: Future blog

2010-12-08 Thread Gary Benson
Andrew Haley wrote:
 On 12/08/2010 11:23 AM, Pekka Enberg wrote:
  In any case, even if everyone did have commit access, CVS is still
  painful for *local* development.
 
 Not for me.  I mean, it's not great, but it's hardly a big factor in
 the time it takes to develop code.

I think different people use their VCS different amounts as they work.
I use it *constantly*:

  mambo$ awk '{print $1}' ~/.bash_history | sort | uniq -c | sort -nr
  416 hg
   66 bin/thingtest
   53 emacs
   50 cd
   34 chmod
   33 cat
   28 ls
  ...etc...

So for me, how the VCS works is paramount to my getting anything done,
and with CVS specifically I almost can't work offline.  I'm guessing
you use your VCS a lot less than I do...

Cheers,
Gary
   
-- 
http://gbenson.net/



Re: [Devjam] Free Java @ FOSDEM 2011 DevRoom Proposal

2010-10-27 Thread Gary Benson
Andrew Haley wrote:
 On 10/27/2010 12:12 PM, Mario Torre wrote:
  Il giorno mer, 27/10/2010 alle 12.01 +0200, Mark Wielaard ha scritto:
   The event itself will be free (as in beer). See http://fosdem.org/
  
  And the beer? ;)
 
 The beer will be expensive (as in Belgium. :)

I remember free beer last year :)

Cheers,
Gary

-- 
http://gbenson.net/



[cp-patches] [calendar] remove explicitDSTOffset from Calendar

2007-04-13 Thread Gary Benson
Hi all,

This patch removes the explicitDSTOffset stuff from Calendar.
I'm not sure what the final solution to this is but the present
method of locking the DST offset once set is not it.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239.2.1
diff -u -r1.9239.2.1 ChangeLog
--- ChangeLog   12 Apr 2007 15:29:51 -  1.9239.2.1
+++ ChangeLog   13 Apr 2007 07:40:38 -
@@ -1,3 +1,10 @@
+2007-04-13  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/Calendar.java
+   (explicitDSTOffset): Remove.
+   (set(int, int)): Remove explicitDSTOffset stuff.
+   (set(int, int, int)): Likewise.
+
 2007-04-12  Gary Benson  [EMAIL PROTECTED]
 
* java/util/GregorianCalendar.java
Index: java/util/Calendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.52
diff -u -r1.52 Calendar.java
--- java/util/Calendar.java 29 Dec 2006 02:17:58 -  1.52
+++ java/util/Calendar.java 13 Apr 2007 07:40:38 -
@@ -1,5 +1,5 @@
 /* Calendar.java --
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006,  
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 
Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -443,13 +443,6 @@
   private int minimalDaysInFirstWeek;
 
   /**
-   * Is set to true if DST_OFFSET is explicitly set. In that case
-   * it's value overrides the value computed from the current
-   * time and the timezone.
-   */
-  private boolean explicitDSTOffset = false;
-
-  /**
* The version of the serialized data on the stream.
* dldt0 or not present/dt
* dd JDK 1.1.5 or later./dd
@@ -846,12 +839,10 @@
isSet[AM_PM] = true;
isSet[HOUR_OF_DAY] = false;
break;
-  case DST_OFFSET:
-   explicitDSTOffset = true;
   }
 
 // May have crossed over a DST boundary.
-if (! explicitDSTOffset  (field != DST_OFFSET  field != ZONE_OFFSET))
+if (field != DST_OFFSET  field != ZONE_OFFSET)
   isSet[DST_OFFSET] = false;
   }
 
@@ -875,8 +866,7 @@
 isSet[DAY_OF_WEEK_IN_MONTH] = false;
 isSet[ERA] = false;
 
-if (! explicitDSTOffset)
-  isSet[DST_OFFSET] = false; // May have crossed a DST boundary.
+isSet[DST_OFFSET] = false; // May have crossed a DST boundary.
   }
 
   /**


[cp-patches] [calendar] GregorianCalendar.setDefaultFields() tweak

2007-04-13 Thread Gary Benson
Hi again,

This commit changes the default for DAY_OF_WEEK_IN_MONTH to match
Sun's implementation, and adds a couple of comments explaining
what might otherwise look like odd decisions.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239.2.3
diff -u -r1.9239.2.3 ChangeLog
--- ChangeLog   13 Apr 2007 08:12:36 -  1.9239.2.3
+++ ChangeLog   13 Apr 2007 09:17:23 -
@@ -1,3 +1,9 @@
+2007-04-13  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/GregorianCalendar.java
+   (setDefaultFields): Change DAY_OF_WEEK_IN_MONTH default,
+   and add some comments.
+
 2007-04-13  Gary Benson  [EMAIL PROTECTED]
 
* java/util/Calendar.java
Index: java/util/GregorianCalendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.49.4.2
diff -u -r1.49.4.2 GregorianCalendar.java
--- java/util/GregorianCalendar.java13 Apr 2007 08:12:37 -  1.49.4.2
+++ java/util/GregorianCalendar.java13 Apr 2007 09:17:23 -
@@ -500,11 +500,15 @@
*/
   private void setDefaultFields()
   {
+// According to the spec DAY_OF_WEEK_IN_MONTH defaults to 1,
+// but Sun set it to 0 so we do too.
 int[] defaults = {
-  AD, 1970, JANUARY, 0, 0, 1, 0, -1, 1, AM, 0, 0, 0, 0, 0, 0, 0
+  AD, 1970, JANUARY, 0, 0, 1, 0, -1, 0, AM, 0, 0, 0, 0, 0, 0, 0
 };
 System.arraycopy(defaults, 0, fields, 0, FIELD_COUNT);
 fields[DAY_OF_WEEK] = getFirstDayOfWeek();
+// It seems odd that a call to computeTime() should cause
+// areFieldsSet to become true, but that's what Sun do...
 areFieldsSet = true;
   }
   


[cp-patches] [calendar] fix Calendar.setTimeZone()

2007-04-13 Thread Gary Benson
Hi again,

This commit makes Calendar.setTimeZone() simply invalidate the
fields rather than recalculating the entire thing.  There seems
to be a general thing of setters invalidate, getters calculate
going on in Sun's implementation.  At the moment in Classpath
we have a bit of a mixture, which makes things... interesting :)

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239.2.4
diff -u -r1.9239.2.4 ChangeLog
--- ChangeLog   13 Apr 2007 09:18:00 -  1.9239.2.4
+++ ChangeLog   13 Apr 2007 10:48:15 -
@@ -1,3 +1,9 @@
+2007-04-13  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/Calendar.java
+   (setTimeZone): Don't recalculate anything, just invalidate
+   the fields.
+
 2007-04-13  Gary Benson  [EMAIL PROTECTED]
 
* java/util/GregorianCalendar.java
Index: java/util/Calendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.52.4.2
diff -u -r1.52.4.2 Calendar.java
--- java/util/Calendar.java 13 Apr 2007 08:12:37 -  1.52.4.2
+++ java/util/Calendar.java 13 Apr 2007 10:48:15 -
@@ -1088,8 +1088,7 @@
   public void setTimeZone(TimeZone zone)
   {
 this.zone = zone;
-computeTime();
-computeFields();
+areFieldsSet = false;
   }
 
   /**


[cp-patches] [calendar] Reorder Calendar.complete()

2007-04-13 Thread Gary Benson
Hi again,

This commit reorders Calendar.complete() and moves the setting
of isTimeSet in order to match Sun's implementation.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239.2.5
diff -u -r1.9239.2.5 ChangeLog
--- ChangeLog   13 Apr 2007 10:48:41 -  1.9239.2.5
+++ ChangeLog   13 Apr 2007 11:46:29 -
@@ -1,3 +1,10 @@
+2007-04-13  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/Calendar.java
+   (complete): Reorder, and set isTimeSet.
+   * java/util/GregorianCalendar.java
+   (computeTime): Do not set isTimeSet.
+
 2007-04-13  Gary Benson  [EMAIL PROTECTED]
 
* java/util/Calendar.java
Index: java/util/Calendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.52.4.3
diff -u -r1.52.4.3 Calendar.java
--- java/util/Calendar.java 13 Apr 2007 10:48:42 -  1.52.4.3
+++ java/util/Calendar.java 13 Apr 2007 11:46:29 -
@@ -951,10 +951,19 @@
*/
   protected void complete()
   {
-if (! isTimeSet)
-  computeTime();
-if (! areFieldsSet)
-  computeFields();
+// computeFields() sets areFieldsSet, but computeTime()
+// does not set isTimeSet.  This seems odd, but it's what
+// Sun's implementation does.
+if (!isTimeSet)
+  {
+   computeTime();
+   isTimeSet = true;
+   computeFields();
+  }
+else if (!areFieldsSet)
+  {
+   computeFields();
+  }
   }
 
   /**
Index: java/util/GregorianCalendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.49.4.3
diff -u -r1.49.4.3 GregorianCalendar.java
--- java/util/GregorianCalendar.java13 Apr 2007 09:18:00 -  1.49.4.3
+++ java/util/GregorianCalendar.java13 Apr 2007 11:46:29 -
@@ -723,8 +723,6 @@
   - zone.getRawOffset());
 
 time -= rawOffset + dstOffset;
-
-isTimeSet = true;
   }
 
   /**


[cp-patches] [calendar] fix Calendar.clear()

2007-04-13 Thread Gary Benson
Hi again,

This commit removes the call to complete() from Calendar.clear().

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239.2.6
diff -u -r1.9239.2.6 ChangeLog
--- ChangeLog   13 Apr 2007 11:47:12 -  1.9239.2.6
+++ ChangeLog   13 Apr 2007 13:01:16 -
@@ -1,3 +1,8 @@
+2007-04-13  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/Calendar.java
+   (clear): Do not call complete.
+
 2007-04-13  Gary Benson  [EMAIL PROTECTED]
 
* java/util/Calendar.java
Index: java/util/Calendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.52.4.4
diff -u -r1.52.4.4 Calendar.java
--- java/util/Calendar.java 13 Apr 2007 11:47:12 -  1.52.4.4
+++ java/util/Calendar.java 13 Apr 2007 13:01:16 -
@@ -927,7 +927,6 @@
*/
   public final void clear(int field)
   {
-complete();
 isTimeSet = false;
 areFieldsSet = false;
 isSet[field] = false;


[cp-patches] [calendar] Another GregorianCalendar.setDefaultFields() tweak

2007-04-13 Thread Gary Benson
Hi again,

This commit makes GregorianCalendar.setDefaultFields() set only
fields that are undefined.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239.2.7
diff -u -r1.9239.2.7 ChangeLog
--- ChangeLog   13 Apr 2007 13:01:50 -  1.9239.2.7
+++ ChangeLog   13 Apr 2007 13:05:06 -
@@ -1,3 +1,9 @@
+2007-04-13  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/GregorianCalendar.java
+   (defaults): Moved from within setDefaultFields.
+   (setDefaultFields): Only set fields that are undefined.
+
 2007-04-13  Gary Benson  [EMAIL PROTECTED]
 
* java/util/Calendar.java
Index: java/util/GregorianCalendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.49.4.4
diff -u -r1.49.4.4 GregorianCalendar.java
--- java/util/GregorianCalendar.java13 Apr 2007 11:47:12 -  1.49.4.4
+++ java/util/GregorianCalendar.java13 Apr 2007 13:05:06 -
@@ -495,18 +495,30 @@
   throw new IllegalArgumentException(Illegal DST_OFFSET.);
   }
 
+  // Default values for all fields, except DAY_OF_WEEK which
+  // defaults to getFirstDayOfWeek().  Note that according to
+  // the spec DAY_OF_WEEK_IN_MONTH defaults to 1, but Sun set
+  // it to 0 so we do too.
+  private int[] defaults = {
+AD, 1970, JANUARY, 0, 0, 1, 0, -1, 0, AM, 0, 0, 0, 0, 0, 0, 0
+  };
+
   /**
* Set all fields to their default values.
*/
   private void setDefaultFields()
   {
-// According to the spec DAY_OF_WEEK_IN_MONTH defaults to 1,
-// but Sun set it to 0 so we do too.
-int[] defaults = {
-  AD, 1970, JANUARY, 0, 0, 1, 0, -1, 0, AM, 0, 0, 0, 0, 0, 0, 0
-};
-System.arraycopy(defaults, 0, fields, 0, FIELD_COUNT);
-fields[DAY_OF_WEEK] = getFirstDayOfWeek();
+for (int i = 0; i  FIELD_COUNT; i++)
+  {
+   if (isSet[i])
+ continue;
+
+   if (i == DAY_OF_WEEK)
+ fields[i] = getFirstDayOfWeek();
+   else
+ fields[i] = defaults[i];
+  }
+
 // It seems odd that a call to computeTime() should cause
 // areFieldsSet to become true, but that's what Sun do...
 areFieldsSet = true;


[cp-patches] [calendar] Make computeTime() sometimes update fields

2007-04-13 Thread Gary Benson
Hi again,

This commit makes GregorianCalendar.computeTime() sometimes update
the fields.  The more weird logic I put in to make us match Sun the
less happy I am, but I'm hoping that something's suddenly going to
click and it's all going to become clear.  Til then... well, that's
why I'm working on a branch, no?

Cheers,
Gary




[commit-cp] classpath ChangeLog java/util/Calendar.java [gbenson-calendar-branch]

2007-04-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/13 07:54:29

Modified files:
.  : ChangeLog 
java/util  : Calendar.java 

Log message:
2007-04-13  Gary Benson  [EMAIL PROTECTED]

* java/util/Calendar.java
(explicitDSTOffset): Remove.
(set(int, int)): Remove explicitDSTOffset stuff.
(set(int, int, int)): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239.2.1r2=1.9239.2.2
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Calendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.52r2=1.52.4.1




[commit-cp] classpath ChangeLog java/util/Calendar.java jav... [gbenson-calendar-branch]

2007-04-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/13 08:12:37

Modified files:
.  : ChangeLog 
java/util  : Calendar.java GregorianCalendar.java 

Log message:
2007-04-13  Gary Benson  [EMAIL PROTECTED]

* java/util/Calendar.java
(clear()): Zero cleared fields rather than using a default.
(clear(int)): Likewise.
* java/util/GregorianCalendar.java
(setDefaultFields): New method.
(computeTime): Call setDefaultFields if fields are not set.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239.2.2r2=1.9239.2.3
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Calendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.52.4.1r2=1.52.4.2
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.49.4.1r2=1.49.4.2




[commit-cp] classpath ChangeLog java/util/GregorianCalendar... [gbenson-calendar-branch]

2007-04-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/13 09:18:01

Modified files:
.  : ChangeLog 
java/util  : GregorianCalendar.java 

Log message:
2007-04-13  Gary Benson  [EMAIL PROTECTED]

* java/util/GregorianCalendar.java
(setDefaultFields): Change DAY_OF_WEEK_IN_MONTH default,
and add some comments.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239.2.3r2=1.9239.2.4
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.49.4.2r2=1.49.4.3




[commit-cp] classpath ChangeLog java/util/Calendar.java [gbenson-calendar-branch]

2007-04-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/13 10:48:42

Modified files:
.  : ChangeLog 
java/util  : Calendar.java 

Log message:
2007-04-13  Gary Benson  [EMAIL PROTECTED]

* java/util/Calendar.java
(setTimeZone): Don't recalculate anything, just invalidate
the fields.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239.2.4r2=1.9239.2.5
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Calendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.52.4.2r2=1.52.4.3




[commit-cp] classpath ChangeLog java/util/GregorianCalendar... [gbenson-calendar-branch]

2007-04-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/13 13:05:40

Modified files:
.  : ChangeLog 
java/util  : GregorianCalendar.java 

Log message:
2007-04-13  Gary Benson  [EMAIL PROTECTED]

* java/util/GregorianCalendar.java
(defaults): Moved from within setDefaultFields.
(setDefaultFields): Only set fields that are undefined.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239.2.7r2=1.9239.2.8
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.49.4.4r2=1.49.4.5




[commit-cp] classpath ChangeLog java/util/GregorianCalendar... [gbenson-calendar-branch]

2007-04-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/13 15:41:31

Modified files:
.  : ChangeLog 
java/util  : GregorianCalendar.java 

Log message:
2007-04-13  Gary Benson  [EMAIL PROTECTED]

* java/util/GregorianCalendar.java
(computeFields): Moved the majority of the logic into...
(internalComputeFields): New method.
(setDefaultFields): Only set areFieldsSet all fields were set.
(computeTime): Sometimes call internalComputeFields.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239.2.8r2=1.9239.2.9
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.49.4.5r2=1.49.4.6




[cp-patches] [calendar] reorder GregorianCalendar.computeTime()

2007-04-12 Thread Gary Benson
Hi all,

This commit reorders the parts of GregorianCalendar.computeTime() that
decide which fields to use into the priority order outlined in
http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#date_resolution.
The previous incarnation was in an odd order and had some fun fallback
cases.  It's not correct yet -- it's not so much a question of which
fields are set as it is a question of which fields were most recently
set -- and this commit breaks a couple of things that relied on the
previous, ordering.  So it's on a branch :)

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9239
diff -u -r1.9239 ChangeLog
--- ChangeLog   12 Apr 2007 15:09:31 -  1.9239
+++ ChangeLog   12 Apr 2007 15:27:00 -
@@ -1,3 +1,8 @@
+2007-04-12  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/GregorianCalendar.java
+   (computeTime): Reorder the cases into priority order.
+
 2007-04-12  Christian Thalinger  [EMAIL PROTECTED]
 
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
Index: java/util/GregorianCalendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.49
diff -u -r1.49 GregorianCalendar.java
--- java/util/GregorianCalendar.java5 Apr 2007 12:52:44 -   1.49
+++ java/util/GregorianCalendar.java12 Apr 2007 15:27:00 -
@@ -510,71 +510,78 @@
 int month = fields[MONTH];
 int day = fields[DAY_OF_MONTH];
 
+int hour = fields[HOUR_OF_DAY];
 int minute = fields[MINUTE];
 int second = fields[SECOND];
 int millis = fields[MILLISECOND];
 int[] month_days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
-int hour = 0;
 
 if (! isLenient())
   nonLeniencyCheck();
 
-if (! isSet[MONTH]  (! isSet[DAY_OF_WEEK] || isSet[WEEK_OF_YEAR]))
+if (isSet[YEAR])
   {
-   // 5: YEAR + DAY_OF_WEEK + WEEK_OF_YEAR
-   if (isSet[WEEK_OF_YEAR])
+   if (isSet[MONTH])
  {
-   int first = getFirstDayOfMonth(year, 0);
-   int offs = 1;
-   int daysInFirstWeek = getFirstDayOfWeek() - first;
-   if (daysInFirstWeek = 0)
- daysInFirstWeek += 7;
-
-   if (daysInFirstWeek  getMinimalDaysInFirstWeek())
- offs += daysInFirstWeek;
-   else
- offs -= 7 - daysInFirstWeek;
-   month = 0;
-   day = offs + 7 * (fields[WEEK_OF_YEAR] - 1);
-   offs = fields[DAY_OF_WEEK] - getFirstDayOfWeek();
-
-   if (offs  0)
- offs += 7;
-   day += offs;
+   if (isSet[DAY_OF_MONTH])
+ {
+   // 1: YEAR + MONTH + DAY_OF_MONTH
+ }
+   else if (isSet[DAY_OF_WEEK])
+ {
+   int first = getFirstDayOfMonth(year, month);
+
+   if (isSet[WEEK_OF_MONTH])
+ {
+   // 2: YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
+   int offs = 1;
+   int daysInFirstWeek = getFirstDayOfWeek() - first;
+   if (daysInFirstWeek = 0)
+ daysInFirstWeek += 7;
+
+   if (daysInFirstWeek  getMinimalDaysInFirstWeek())
+ offs += daysInFirstWeek;
+   else
+ offs -= 7 - daysInFirstWeek;
+
+   day = offs + 7 * (fields[WEEK_OF_MONTH] - 1);
+   offs = fields[DAY_OF_WEEK] - getFirstDayOfWeek();
+   if (offs  0)
+ offs += 7;
+   day += offs;
+ }
+   else if (isSet[DAY_OF_WEEK_IN_MONTH])
+ {
+   // 3: YEAR + MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
+   if (fields[DAY_OF_WEEK_IN_MONTH]  0)
+ {
+   month++;
+   first = getFirstDayOfMonth(year, month);
+   day = 1 + 7 * (fields[DAY_OF_WEEK_IN_MONTH]);
+ }
+   else
+ day = 1 + 7 * (fields[DAY_OF_WEEK_IN_MONTH] - 1);
+
+   int offs = fields[DAY_OF_WEEK] - first;
+   if (offs  0)
+ offs += 7;
+   day += offs;
+ }
+ }
  }
else
  {
-   // 4:  YEAR + DAY_OF_YEAR
-   month = 0;
-   day = fields[DAY_OF_YEAR];
- }
-  }
-else
-  {
-   if (isSet[DAY_OF_WEEK])
- {
-   int first = getFirstDayOfMonth(year, month);
-
-   // 3: YEAR + MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
-   if (isSet[DAY_OF_WEEK_IN_MONTH])
+   if (isSet[DAY_OF_YEAR

[commit-cp] classpath ChangeLog java/util/GregorianCalendar... [gbenson-calendar-branch]

2007-04-12 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: gbenson-calendar-branch
Changes by: Gary Benson gbenson   07/04/12 15:29:51

Modified files:
.  : ChangeLog 
java/util  : GregorianCalendar.java 

Log message:
2007-04-12  Gary Benson  [EMAIL PROTECTED]

* java/util/GregorianCalendar.java
(computeTime): Reorder the cases into priority order.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.9239r2=1.9239.2.1
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathonly_with_tag=gbenson-calendar-branchr1=1.49r2=1.49.4.1




[cp-patches] FYI: GregorianCalendar week of month fix

2007-04-05 Thread Gary Benson
Hi all,

This patch fixes the week of month calculation in GregorianCalendar.
Considering this was broken it's possible the stuff that allows you
to set the date with the day of the week and the week of the month
is also broken.  Not to mention the week of the year stuff.  Damn.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9215
diff -u -r1.9215 ChangeLog
--- ChangeLog   5 Apr 2007 12:41:33 -   1.9215
+++ ChangeLog   5 Apr 2007 12:52:32 -
@@ -1,3 +1,8 @@
+2007-04-05  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/GregorianCalendar.java
+   (computeFields): Fix WEEK_OF_MONTH calculation.
+
 2007-04-05  Christian Thalinger  [EMAIL PROTECTED]
 
PR classpath/22800:
Index: java/util/GregorianCalendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.48
diff -u -r1.48 GregorianCalendar.java
--- java/util/GregorianCalendar.java4 Apr 2007 15:31:55 -   1.48
+++ java/util/GregorianCalendar.java5 Apr 2007 12:52:32 -
@@ -1,5 +1,5 @@
 /* java.util.GregorianCalendar
-   Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004
+   Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2007
Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -841,13 +841,24 @@
 // which day of the week are we (0..6), relative to getFirstDayOfWeek
 int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7;
 
-fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7;
+// which day of the week is the first of this month?
+// nb 35 is the smallest multiple of 7 that ensures that
+// the left hand side of the modulo operator is positive.
+int relativeWeekdayOfFirst = (relativeWeekday - fields[DAY_OF_MONTH]
+ + 1 + 35) % 7;
+
+// which week of the month is the first of this month in?
+int minDays = getMinimalDaysInFirstWeek();
+int weekOfFirst = ((7 - relativeWeekdayOfFirst) = minDays) ? 1 : 0;
+
+// which week of the month is this day in?
+fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH]
++ relativeWeekdayOfFirst - 1) / 7 + weekOfFirst;
 
 int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
 
 // Do the Correction: getMinimalDaysInFirstWeek() is always in the 
 // first week.
-int minDays = getMinimalDaysInFirstWeek();
 int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays)
- getFirstDayOfWeek()) % 7;
 if (minDays - firstWeekday  1)


[commit-cp] classpath ChangeLog java/util/GregorianCalendar...

2007-04-05 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/04/05 12:52:45

Modified files:
.  : ChangeLog 
java/util  : GregorianCalendar.java 

Log message:
2007-04-05  Gary Benson  [EMAIL PROTECTED]

* java/util/GregorianCalendar.java
(computeFields): Fix WEEK_OF_MONTH calculation.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9215r2=1.9216
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathr1=1.48r2=1.49




[cp-patches] FYI: GregorianCalendar tweak

2007-04-04 Thread Gary Benson
Hi all,

This patch removes a redundant call to complete() in one of
java.util.GregorianCalendar's constructors.  setTimeInMillis()
fills in both the time and the fields.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9208
diff -u -r1.9208 ChangeLog
--- ChangeLog   4 Apr 2007 11:38:46 -   1.9208
+++ ChangeLog   4 Apr 2007 15:31:36 -
@@ -1,3 +1,8 @@
+2007-04-04  Gary Benson  [EMAIL PROTECTED]
+
+   * java/util/GregorianCalendar.java
+   (GregorianCalendar(TimeZone, Locale)): Remove redundant complete().
+
 2007-04-04  Roman Kennke  [EMAIL PROTECTED]
 
* java/nio/channels/spi/SelectorProvider.java
Index: java/util/GregorianCalendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.47
diff -u -r1.47 GregorianCalendar.java
--- java/util/GregorianCalendar.java23 Dec 2006 22:32:59 -  1.47
+++ java/util/GregorianCalendar.java4 Apr 2007 15:31:36 -
@@ -223,7 +223,6 @@
   {
 this(zone, locale, false);
 setTimeInMillis(System.currentTimeMillis());
-complete();
   }
 
   /**


[commit-cp] classpath ChangeLog java/util/GregorianCalendar...

2007-04-04 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/04/04 15:31:55

Modified files:
.  : ChangeLog 
java/util  : GregorianCalendar.java 

Log message:
2007-04-04  Gary Benson  [EMAIL PROTECTED]

* java/util/GregorianCalendar.java
(GregorianCalendar(TimeZone, Locale)): Remove redundant 
complete().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9208r2=1.9209
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/GregorianCalendar.java?cvsroot=classpathr1=1.47r2=1.48




[cp-patches] FYI: Another javax.xml bugfix (PR 30983)

2007-03-08 Thread Gary Benson
Hi all,

This commit fixes a bug where the entity resolver (if set) would be
used to open the top-level document when parsing an XML file.  The
spec states that the parser will use the entity resolver before
opening any external entity _except_ the top-level document entity.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9147
diff -u -r1.9147 ChangeLog
--- ChangeLog   8 Mar 2007 11:11:49 -   1.9147
+++ ChangeLog   8 Mar 2007 11:14:53 -
@@ -1,3 +1,9 @@
+2007-03-08  Gary Benson  [EMAIL PROTECTED]
+
+   PR classpath/30983:
+   * gnu/xml/dom/ls/DomLSParser.java (getInputSource):
+   Do not use the entity resolver to resolve the top-level document.
+
 2007-03-07  Tom Tromey  [EMAIL PROTECTED]
 
PR classpath/31057:
Index: gnu/xml/dom/ls/DomLSParser.java
===
RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/ls/DomLSParser.java,v
retrieving revision 1.5
diff -u -r1.5 DomLSParser.java
--- gnu/xml/dom/ls/DomLSParser.java 26 Jan 2007 19:57:43 -  1.5
+++ gnu/xml/dom/ls/DomLSParser.java 8 Mar 2007 11:14:53 -
@@ -372,22 +372,6 @@
 source = new InputSource(in);
 source.setSystemId(systemId);
   }
-if (source == null  entityResolver != null)
-  {
-String publicId = input.getPublicId();
-try
-  {
-source = entityResolver.resolveEntity(publicId, systemId);
-  }
-catch (SAXException e)
-  {
-throw new DomLSException(LSException.PARSE_ERR, e);
-  } 
-catch (IOException e)
-  {
-throw new DomLSException(LSException.PARSE_ERR, e);
-  } 
-  }
 if (source == null)
   {
 URL url = null;


Re: [cp-patches] FYI: Another javax.xml bugfix (PR 30983)

2007-03-08 Thread Gary Benson
Chris Burdess wrote:
 Gary Benson wrote:
  This commit fixes a bug where the entity resolver (if set) would
  be used to open the top-level document when parsing an XML file.
  The spec states that the parser will use the entity resolver
  before opening any external entity _except_ the top-level document
  entity.
 
 I'm not sure which spec says that. The EntityResolver class
 documentation says:
 
 The application can also use this interface to redirect system
 identifiers to local URIs or to look up replacements in a catalog
 (possibly by using the public identifier).

Check the second paragraph of resolveEntity()'s description:

  The parser will call this method before opening any external
   entity except the top-level document entity.

I put a printf into the testcase's resolveEntity() and I can confirm
that it is not called on IBM.

Cheers,
Gary



[commit-cp] classpath ChangeLog

2007-03-08 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/03/08 11:11:50

Modified files:
.  : ChangeLog 

Log message:
Didn't know this one had a PR when I fixed it...

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9146r2=1.9147




[commit-cp] classpath ChangeLog gnu/xml/dom/ls/DomLSParser....

2007-03-08 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/03/08 11:16:32

Modified files:
.  : ChangeLog 
gnu/xml/dom/ls : DomLSParser.java 

Log message:
2007-03-08  Gary Benson  [EMAIL PROTECTED]

PR classpath/30983:
* gnu/xml/dom/ls/DomLSParser.java (getInputSource):
Do not use the entity resolver to resolve the top-level 
document.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9147r2=1.9148
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/ls/DomLSParser.java?cvsroot=classpathr1=1.5r2=1.6




[cp-patches] FYI: javax.xml bugfix

2007-03-07 Thread Gary Benson
Hi all,

This commit fixes a bug which caused
javax.xml.parsers.DocumentBuilderFactory.newDocumentBuilder()
to fail if another JAXP implementation was in the classpath.
The specification allows for the various abstract classes in
javax.xml to be overridden by the endorsed classes override
stuff, but without this parts of other JAXP implementations
would be loaded even without being endorsed.

Note that this is not a fix for PR 30983.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9144
diff -u -r1.9144 ChangeLog
--- ChangeLog   6 Mar 2007 23:24:19 -   1.9144
+++ ChangeLog   7 Mar 2007 13:29:30 -
@@ -1,3 +1,8 @@
+2007-03-07  Gary Benson  [EMAIL PROTECTED]
+
+   * resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList:
+   New file.
+
 2007-03-06  Andrew John Hughes  [EMAIL PROTECTED]
 
* gnu/java/lang/management/BeanImpl.java:
Index: resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList
===
RCS file: resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList
diff -N resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList
--- /dev/null   1 Jan 1970 00:00:00 -
+++ resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList  7 Mar 
2007 13:29:30 -
@@ -0,0 +1 @@
+gnu.xml.dom.ImplementationSource


[commit-cp] classpath ChangeLog resource/META-INF/services/...

2007-03-07 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/03/07 13:30:26

Modified files:
.  : ChangeLog 
Added files:
resource/META-INF/services: 
org.w3c.dom.DOMImplementationSourceList 

Log message:
2007-03-07  Gary Benson  [EMAIL PROTECTED]

* 
resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList:
New file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9144r2=1.9145
http://cvs.savannah.gnu.org/viewcvs/classpath/resource/META-INF/services/org.w3c.dom.DOMImplementationSourceList?cvsroot=classpathrev=1.1




[commit-cp] classpath ChangeLog NEWS java/lang/System.java ...

2007-02-23 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/02/23 15:50:04

Modified files:
.  : ChangeLog NEWS 
java/lang  : System.java 
java/util  : Date.java SimpleTimeZone.java TimeZone.java 
vm/reference/java/util: VMTimeZone.java 
Added files:
gnu/java/util  : ZoneInfo.java 

Log message:
2007-02-23  Gary Benson  [EMAIL PROTECTED]
Jakub Jelinek  [EMAIL PROTECTED]

PR libgcj/17002
PR classpath/28550
* java/util/Date.java (parse): Properly parse 09:01:02 as
hours/minutes/seconds, not as hours/minutes/year.
* java/util/SimpleTimeZone.java (SimpleTimeZone): Simplify
{start,end}TimeMode constructor by calling shorter constructor,
set {start,end}TimeMode fields after it returns.
(setStartRule): Don't adjust startTime into WALL_TIME.  Set
startTimeMode to WALL_TIME.
(endStartRule): Similarly.
(getOffset): Handle properly millis + dstOffset overflowing 
into the
next day.  Adjust startTime resp. endTime based on startTimeMode
resp. endTimeMode.
* java/util/TimeZone.java (zoneinfo_dir, availableIDs, 
aliases0): New
static fields.
(timezones): Remove synchronized keyword.  Set zoneinfo_dir.
If non-null, set up aliases0 and don't put anything into
timezones0.
(defaultZone): Call getTimeZone instead of timezones().get.
(getDefaultTimeZone): Fix parsing of EST5 or EST5EDT6.  Use
getTimeZoneInternal instead of timezones().get.
(parseTime): Parse correctly hour:minute.
(getTimeZoneInternal): New private method.
(getTimeZone): Do the custom ID checking first, canonicalize
ID for custom IDs as required by documentation.  Call
getTimeZoneInternal to handle the rest.
(getAvailableIDs(int)): Add locking.  Handle zoneinfo_dir != 
null.
(getAvailableIDs(File,String,ArrayList)): New private method.
(getAvailableIDs()): Add locking.  Handle zoneinfo_dir != null.
* vm/reference/java/util/VMTimeZone.java (getDefaultTimeZoneId):
To read /etc/localtime, use ZoneInfo.readTZFile instead of
VMTimeZone.readtzFile.  Get better timezone name for
/etc/localtime, either if it is a symlink or through
/etc/sysconfig/clock.
(readSysconfigClockFile): New static method.
(readtzFile): Removed.
* gnu/java/util/ZoneInfo.java: New file.
* java/lang/System.java: Add gnu.java.util.zoneinfo.dir to 
comments.
* NEWS: Documented TimeZone interface changes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9128r2=1.9129
http://cvs.savannah.gnu.org/viewcvs/classpath/NEWS?cvsroot=classpathr1=1.177r2=1.178
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/util/ZoneInfo.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/java/lang/System.java?cvsroot=classpathr1=1.59r2=1.60
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Date.java?cvsroot=classpathr1=1.25r2=1.26
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/SimpleTimeZone.java?cvsroot=classpathr1=1.31r2=1.32
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/TimeZone.java?cvsroot=classpathr1=1.36r2=1.37
http://cvs.savannah.gnu.org/viewcvs/classpath/vm/reference/java/util/VMTimeZone.java?cvsroot=classpathr1=1.4r2=1.5




[commit-cp] classpath ChangeLog javax/management/ObjectName...

2007-02-20 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/02/20 11:17:51

Modified files:
.  : ChangeLog 
javax/management: ObjectName.java 

Log message:
2007-02-20  Gary Benson  [EMAIL PROTECTED]

* javax/management/ObjectName.java
(domainMatches): New method.
(apply): Rearranged to use the above.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9122r2=1.9123
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/management/ObjectName.java?cvsroot=classpathr1=1.7r2=1.8




[cp-patches] FYI: Ensure ObjectName.properties is initialized

2007-02-19 Thread Gary Benson
Hi all,

This commit ensures that javax.management.ObjectName.properties is
always initialized.  Without it there are at least two possible ways
to create an ObjectName with a null properties field.

Cheers,
Gary



[cp-patches] Re: FYI: Ensure ObjectName.properties is initialized

2007-02-19 Thread Gary Benson
Gary Benson wrote:
 This commit ensures that javax.management.ObjectName.properties is
 always initialized.  Without it there are at least two possible ways
 to create an ObjectName with a null properties field.

This commit.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9119
diff -u -r1.9119 ChangeLog
--- ChangeLog   19 Feb 2007 09:27:43 -  1.9119
+++ ChangeLog   19 Feb 2007 13:58:07 -
@@ -1,3 +1,10 @@
+2007-02-19  Gary Benson  [EMAIL PROTECTED]
+
+   * javax/management/ObjectName.java
+   (properties): Initialize when declared.
+   (ObjectName(String)): Don't initialize properties here.
+   (ObjectName(String, String, String): Likewise.
+
 2007-02-19  Chris Burdess  [EMAIL PROTECTED]
 
Fixes #30831
Index: javax/management/ObjectName.java
===
RCS file: /cvsroot/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.6
diff -u -r1.6 ObjectName.java
--- javax/management/ObjectName.java19 Feb 2007 01:34:58 -  1.6
+++ javax/management/ObjectName.java19 Feb 2007 13:58:07 -
@@ -105,7 +105,7 @@
   /**
* The properties, as key-value pairs.
*/
-  private TreeMapString,String properties;
+  private TreeMapString,String properties = new TreeMapString,String();
 
   /**
* The properties as a string (stored for ordering).
@@ -164,7 +164,6 @@
  throw new MalformedObjectNameException(A name that is not a  +
 pattern must contain at  +
 least one key-value pair.);
-   properties = new TreeMapString,String();
for (int a = 0; a  pairs.length; ++a)
  {
int sep = pairs[a].indexOf('=');
@@ -197,7 +196,6 @@
 throws MalformedObjectNameException
   {
 this.domain = domain;
-properties = new TreeMapString,String();
 properties.put(key, value);
 checkComponents();
   }


[commit-cp] classpath ChangeLog javax/management/ObjectName...

2007-02-19 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/02/19 13:58:28

Modified files:
.  : ChangeLog 
javax/management: ObjectName.java 

Log message:
2007-02-19  Gary Benson  [EMAIL PROTECTED]

* javax/management/ObjectName.java
(properties): Initialize when declared.
(ObjectName(String)): Don't initialize properties here.
(ObjectName(String, String, String): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9119r2=1.9120
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/management/ObjectName.java?cvsroot=classpathr1=1.6r2=1.7




[cp-patches] FYI: Another javax.management fix

2007-02-15 Thread Gary Benson
Hi all,

MBeanServer.registerMBean() calls the MBean's preRegister method only
if the name given for the bean is null.  This commit makes it call the
preRegister method regardless of whether a name was supplied or not.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9110
diff -u -r1.9110 ChangeLog
--- ChangeLog   15 Feb 2007 10:38:30 -  1.9110
+++ ChangeLog   15 Feb 2007 14:06:41 -
@@ -1,3 +1,10 @@
+2007-02-15  Gary Benson  [EMAIL PROTECTED]
+
+   * gnu/javax/management/Server.java
+   (registerMBean): Always register objects that implement the
+   MBeanRegistration interface, and check the name returned by
+   preRegister before using it.
+
 2007-02-15  Roman Kennke  [EMAIL PROTECTED]
 
* java/nio/ByteOrder.java
Index: gnu/javax/management/Server.java
===
RCS file: /cvsroot/classpath/classpath/gnu/javax/management/Server.java,v
retrieving revision 1.2
diff -u -r1.2 Server.java
--- gnu/javax/management/Server.java4 Dec 2006 00:10:18 -   1.2
+++ gnu/javax/management/Server.java15 Feb 2007 14:06:41 -
@@ -1657,19 +1657,27 @@
 MBeanRegistration register = null;
 if (obj instanceof MBeanRegistration)
   register = (MBeanRegistration) obj;
-if (name == null)
+if (name == null  register == null)
+  {
+   RuntimeException e =
+ new IllegalArgumentException(The name was null and  +
+  the bean does not implement  +
+  MBeanRegistration.);
+   throw new RuntimeOperationsException(e);
+  }
+if (register != null)
   {
-   if (register == null)
- {
-   RuntimeException e =
- new IllegalArgumentException(The name was null and  +
-  the bean does not implement  +
-  MBeanRegistration.);
-   throw new RuntimeOperationsException(e);
- }
try
  {
-   name = register.preRegister(this, null);
+   name = register.preRegister(this, name);
+   if (name == null)
+ {
+   RuntimeException e =
+ new NullPointerException(The name returned by  +
+  MBeanRegistration.preRegister()  +
+  was null);
+   throw e;
+ }
if (sm != null)
  sm.checkPermission(new MBeanPermission(className, null, name,
 registerMBean));


[commit-cp] classpath ChangeLog gnu/javax/management/Server...

2007-02-15 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/02/15 14:06:58

Modified files:
.  : ChangeLog 
gnu/javax/management: Server.java 

Log message:
2007-02-15  Gary Benson  [EMAIL PROTECTED]

* gnu/javax/management/Server.java
(registerMBean): Always register objects that implement the
MBeanRegistration interface, and check the name returned by
preRegister before using it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9110r2=1.9111
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/management/Server.java?cvsroot=classpathr1=1.2r2=1.3




[cp-patches] FYI: javax.management fix

2007-02-13 Thread Gary Benson
Gary Benson wrote:
 Tomcat is failing with Classpath's javax.management because it
 assumes the result of javax.management.ObjectName.toString() is a
 valid string representation of the item.  Ours isn't, but I guess
 Sun's and MX4J's must or they'd be failing too.  The javadoc does
 not specify the format of the returned string except to say that
 users can expect it to be the same for equivalent ObjectNames.
 
 This patch makes our toString() return the canonical representation.

Committed.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9108
diff -u -r1.9108 ChangeLog
--- ChangeLog   12 Feb 2007 21:39:20 -  1.9108
+++ ChangeLog   13 Feb 2007 14:41:44 -
@@ -1,3 +1,8 @@
+2007-02-13  Gary Benson  [EMAIL PROTECTED]
+
+   * javax/management/ObjectName.java
+   (toString): Return this item's canonical name.
+
 2007-02-12  Francis Kung  [EMAIL PROTECTED]
 
* gnu/java/awt/ClasspathToolkit.java: 
Index: javax/management/ObjectName.java
===
RCS file: /cvsroot/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.4
diff -u -r1.4 ObjectName.java
--- javax/management/ObjectName.java9 Feb 2007 17:23:30 -   1.4
+++ javax/management/ObjectName.java13 Feb 2007 14:41:44 -
@@ -715,19 +715,18 @@
 
   /**
* Returns a textual representation of the object name.
-   * The format is unspecified, but it should be expected that
-   * two equivalent object names will return the same string
-   * from this method.
+   *
+   * pThe format is unspecified beyond that equivalent object
+   * names will return the same string from this method, but note
+   * that Tomcat depends on the string returned by this method
+   * being a valid textual representation of the object name and
+   * will fail to start if it is not.
*
* @return a textual representation of the object name.
*/
   public String toString()
   {
-return getClass().toString() +
-  [domain =  + domain +
-  ,properties =  + properties +
-  ,propertyPattern =  + propertyPattern +
-  ];
+return getCanonicalName();
   }
 
   /**


[commit-cp] classpath ChangeLog javax/management/ObjectName...

2007-02-13 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/02/13 14:41:58

Modified files:
.  : ChangeLog 
javax/management: ObjectName.java 

Log message:
2007-02-13  Gary Benson  [EMAIL PROTECTED]

* javax/management/ObjectName.java
(toString): Return this item's canonical name.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9108r2=1.9109
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/management/ObjectName.java?cvsroot=classpathr1=1.4r2=1.5




[cp-patches] RFC: Proposed javax.management fix

2007-02-12 Thread Gary Benson
Hi all,

Tomcat is failing with Classpath's javax.management because it assumes
the result of javax.management.ObjectName.toString() is a valid string
representation of the item.  Ours isn't, but I guess Sun's and MX4J's
must or they'd be failing too.  The javadoc does not specify the
format of the returned string except to say that users can expect it
to be the same for equivalent ObjectNames.

This patch makes our toString() return the canonical representation.
Can anyone (ie Andrew) see any problems with this?

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9104
diff -u -r1.9104 ChangeLog
--- ChangeLog   12 Feb 2007 00:56:29 -  1.9104
+++ ChangeLog   12 Feb 2007 14:14:37 -
@@ -1,3 +1,8 @@
+2007-02-12  Gary Benson  [EMAIL PROTECTED]
+
+   * javax/management/ObjectName.java
+   (toString): Return this items canonical name.
+
 2007-02-12  Andrew John Hughes  [EMAIL PROTECTED]
 
* javax/management/Query.java:
Index: javax/management/ObjectName.java
===
RCS file: /cvsroot/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.4
diff -u -r1.4 ObjectName.java
--- javax/management/ObjectName.java9 Feb 2007 17:23:30 -   1.4
+++ javax/management/ObjectName.java12 Feb 2007 14:14:37 -
@@ -723,11 +723,7 @@
*/
   public String toString()
   {
-return getClass().toString() +
-  [domain =  + domain +
-  ,properties =  + properties +
-  ,propertyPattern =  + propertyPattern +
-  ];
+return getCanonicalName();
   }
 
   /**


Re: [cp-patches] RFC: Proposed javax.management fix

2007-02-12 Thread Gary Benson
Tom Tromey wrote:
  Gary == Gary Benson [EMAIL PROTECTED] writes:
 
 Gary This patch makes our toString() return the canonical
 Gary representation.  Can anyone (ie Andrew) see any problems
 Gary with this?
 
 I think this method should have a comment explaining why it should
 not be changed.

Good idea :)

Cheers,
Gary



[cp-patches] FYI: javax.management.ObjectName.quote() fix

2007-02-09 Thread Gary Benson
Hi all,

This commit fixes a bug whereby javax.management.ObjectName.quote()
would miss off the leading quote because StringBuilder('') resolves
to StringBuilder(int capacity) with the expected amusing consequences.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.9095
diff -u -r1.9095 ChangeLog
--- ChangeLog   9 Feb 2007 16:24:06 -   1.9095
+++ ChangeLog   9 Feb 2007 17:23:15 -
@@ -1,3 +1,8 @@
+2007-02-09  Gary Benson  [EMAIL PROTECTED]
+
+   * javax/management/ObjectName.java
+   (quote): Initialize StringBuilder correctly.
+
 2007-02-09  Francis Kung  [EMAIL PROTECTED]
 
* java/awt/image/BufferedImage: Reformatted.
Index: javax/management/ObjectName.java
===
RCS file: /cvsroot/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.3
diff -u -r1.3 ObjectName.java
--- javax/management/ObjectName.java22 Dec 2006 17:55:55 -  1.3
+++ javax/management/ObjectName.java9 Feb 2007 17:23:15 -
@@ -1,5 +1,5 @@
 /* ObjectName.java -- Represent the name of a bean, or a pattern for a name.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -673,7 +673,8 @@
*/
   public static String quote(String string)
   {
-StringBuilder builder = new StringBuilder('');
+StringBuilder builder = new StringBuilder();
+builder.append('');
 for (int a = 0; a  string.length(); ++a)
   {
char s = string.charAt(a);


[commit-cp] classpath ChangeLog javax/management/ObjectName...

2007-02-09 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   07/02/09 17:23:30

Modified files:
.  : ChangeLog 
javax/management: ObjectName.java 

Log message:
2007-02-09  Gary Benson  [EMAIL PROTECTED]

* javax/management/ObjectName.java
(quote): Initialize StringBuilder correctly.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9095r2=1.9096
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/management/ObjectName.java?cvsroot=classpathr1=1.3r2=1.4




[cp-patches] FYI: Thread javadoc tweaks

2006-11-30 Thread Gary Benson
Hi all,

This commit adds a couple of notes to java.lang.Thread's
javadoc that were in libgcj but not in Classpath.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8884
diff -u -r1.8884 ChangeLog
--- ChangeLog   29 Nov 2006 20:48:29 -  1.8884
+++ ChangeLog   30 Nov 2006 09:29:54 -
@@ -1,3 +1,7 @@
+2006-11-30  Gary Benson  [EMAIL PROTECTED]
+
+   * java/lang/Thread.java: Javadoc fixes.
+
 2006-11-29  Tania Bento  [EMAIL PROTECTED]
 
* tools/gnu/classpath/tools/appletviewer/TagParser.java:
Index: java/lang/Thread.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/Thread.java,v
retrieving revision 1.31
diff -u -r1.31 Thread.java
--- java/lang/Thread.java   1 Jul 2006 12:56:10 -   1.31
+++ java/lang/Thread.java   30 Nov 2006 09:29:54 -
@@ -850,11 +850,13 @@
* are no guarantees which thread will be next to run, but most VMs will
* choose the highest priority thread that has been waiting longest.
*
-   * @param ms the number of milliseconds to sleep.
+   * @param ms the number of milliseconds to sleep, or 0 for forever
* @throws InterruptedException if the Thread is (or was) interrupted;
* it's iinterrupted status/i will be cleared
* @throws IllegalArgumentException if ms is negative
* @see #interrupt()
+   * @see #notify()
+   * @see #wait(long)
*/
   public static void sleep(long ms) throws InterruptedException
   {
@@ -874,13 +876,15 @@
* immediately when time expires, because some other thread may be
* active.  So don't expect real-time performance.
*
-   * @param ms the number of milliseconds to sleep
+   * @param ms the number of milliseconds to sleep, or 0 for forever
* @param ns the number of extra nanoseconds to sleep (0-99)
* @throws InterruptedException if the Thread is (or was) interrupted;
* it's iinterrupted status/i will be cleared
* @throws IllegalArgumentException if ms or ns is negative
* or ns is larger than 99.
* @see #interrupt()
+   * @see #notify()
+   * @see #wait(long, int)
*/
   public static void sleep(long ms, int ns) throws InterruptedException
   {


Re: SystemProperties secure?

2006-11-28 Thread Gary Benson
Andrew Haley wrote:
 Jeroen Frijters writes:
  Tom Tromey wrote:
   As I recall things in gnu.classpath should not be available
   to application code.  The system class loader, or something,
   has to enforce this.
  
  That's correct. The (default) system class loader calls
  SecurityManager.checkPackageAccess() in loadClass(String,boolean).
  
   I'm having some trouble with the details but I know Jeroen
   knows the details here...
  
  I don't remember the details of the rest of the story, but
  earlier in this thread Casey posted a (very small) patch that
  enables this infrastructure and protects the gnu.classpath.
  package.
 
 I'm sure we don't do the right thing in gcj.  This test case
 (apprended) should do:
 
 Checking class [Lxxx.ttt;
 checkPackageAccess sun.reflect.misc
 checkPackageAccess sun.reflect.misc
 checkPackageAccess xxx
 
 but on gcj does:
 
 Checking class [Lxxx.ttt;
 checkPackageAccess xxx

IIRC several of the relevant classes for this depend on VMStackWalker
and as such are somewhat out of date in gcj.

Cheers,
Gary



[commit-cp] classpath ChangeLog java/net/DatagramSocket.java

2006-11-17 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/11/17 15:09:05

Modified files:
.  : ChangeLog 
java/net   : DatagramSocket.java 

Log message:
2006-11-17  Gary Benson  [EMAIL PROTECTED]

* java/net/DatagramSocket.java (getLocalAddress, connect,
receive): Perform security check on address not hostname.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8810r2=1.8811
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/DatagramSocket.java?cvsroot=classpathr1=1.49r2=1.50




Re: switch to IPv6-only

2006-11-02 Thread Gary Benson
Robert Schuster wrote:
 What I am proposing is that we do all our native interaction as if
 the addresses where IPv6. As IP4v is a subset of IPv6 there should
 be no problem: Prepend 12 zeros before an IP4v address and you're
 done.

It's 10 zeros and 2 0xFFs I think.

Cheers,
Gary



Re: [cp-patches] FYI: SocketPermission tweak

2006-10-31 Thread Gary Benson
Anthony Green wrote:
 On Thu, 2006-08-31 at 12:58 -0600, Tom Tromey wrote:
   Gary == Gary Benson [EMAIL PROTECTED] writes:
  
  Gary This commit makes java.net.SocketPermission()'s constructor
  Gary use localhost when called with an empty hostport argument
  Gary as mandated by the spec.
  
  Do we want this in GCC 4.2?  Or FC6?
 
 We want this in FC-6.  It's causing an exception in Azureus.
 
 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=212739
 
 Jakub - do you have any gcc updates planned for FC-6?

To really fix this issue you need to grab SocketPermission and
Inet*Address from trunk.

Cheers,
Gary



[cp-patches] FYI: ServerSocket security fixes

2006-10-09 Thread Gary Benson
Hi all,

This commit adds some missing security checks to java.net.ServerSocket.
It also adds a check that ensures ServerSocket.setSocketFactory() is
only called once as per the spec.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8656
diff -u -r1.8656 ChangeLog
--- ChangeLog   9 Oct 2006 13:51:43 -   1.8656
+++ ChangeLog   9 Oct 2006 14:03:51 -
@@ -1,3 +1,10 @@
+2006-10-09  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/ServerSocket.java
+   (implAccept): Add security check.
+   (accept): Close socket if security check fails.
+   (setSocketFactory): Add security check and already-set check.
+
 2006-10-09  Roman Kennke  [EMAIL PROTECTED]
 
PR 29325
Index: java/net/ServerSocket.java
===
RCS file: /cvsroot/classpath/classpath/java/net/ServerSocket.java,v
retrieving revision 1.48
diff -u -r1.48 ServerSocket.java
--- java/net/ServerSocket.java  24 Sep 2006 15:49:48 -  1.48
+++ java/net/ServerSocket.java  9 Oct 2006 14:03:51 -
@@ -345,6 +345,19 @@
 
throw e;
   }
+catch (SecurityException e)
+  {
+   try
+ {
+   socket.close();
+ }
+   catch (IOException e2)
+ {
+   // Ignore.
+ }
+
+   throw e;
+  }
 
 return socket;
   }
@@ -367,9 +380,6 @@
 if (isClosed())
   throw new SocketException(ServerSocket is closed);
 
-// FIXME: Add a security check to make sure we're allowed to 
-// connect to the remote host.
-
 // The Sun spec says that if we have an associated channel and
 // it is in non-blocking mode, we throw an IllegalBlockingModeException.
 // However, in our implementation if the channel itself initiated this
@@ -380,6 +390,11 @@
 
 impl.accept(socket.impl);
 socket.bound = true;
+
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkAccept(socket.getInetAddress().getHostAddress(),
+socket.getPort());
   }
 
   /**
@@ -603,6 +618,13 @@
   public static synchronized void setSocketFactory(SocketImplFactory fac)
 throws IOException
   {
+if (factory != null)
+  throw new SocketException(SocketFactory already defined);
+
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkSetFactory();
+
 factory = fac;
   }
 }


[commit-cp] classpath ChangeLog java/net/ServerSocket.java

2006-10-09 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/10/09 14:49:33

Modified files:
.  : ChangeLog 
java/net   : ServerSocket.java 

Log message:
2006-10-09  Gary Benson  [EMAIL PROTECTED]

* java/net/ServerSocket.java
(implAccept): Add security check.
(accept): Close socket if security check fails.
(setSocketFactory): Add security check and already-set check.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8656r2=1.8657
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/ServerSocket.java?cvsroot=classpathr1=1.48r2=1.49




[cp-patches] FYI: Socket security fix

2006-10-05 Thread Gary Benson
Hi all,

This commit fixes Socket's constructors' security checks.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8645
diff -u -r1.8645 ChangeLog
--- ChangeLog   4 Oct 2006 15:35:35 -   1.8645
+++ ChangeLog   5 Oct 2006 14:49:22 -
@@ -1,3 +1,8 @@
+2006-10-05  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/Socket.java
+   (Socket): Perform security check on address not hostname.
+
 2006-10-04  Roman Kennke  [EMAIL PROTECTED]
 
* javax/swing/tree/VariableHeightLayoutCache.java
Index: java/net/Socket.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Socket.java,v
retrieving revision 1.58
diff -u -r1.58 Socket.java
--- java/net/Socket.java19 Sep 2006 05:47:39 -  1.58
+++ java/net/Socket.java5 Oct 2006 14:49:22 -
@@ -291,7 +291,7 @@
 
 SecurityManager sm = System.getSecurityManager();
 if (sm != null)
-  sm.checkConnect(raddr.getHostName(), rport);
+  sm.checkConnect(raddr.getHostAddress(), rport);
 
 // bind socket
 SocketAddress bindaddr =


[commit-cp] classpath ChangeLog java/net/Socket.java

2006-10-05 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/10/05 14:50:04

Modified files:
.  : ChangeLog 
java/net   : Socket.java 

Log message:
2006-10-05  Gary Benson  [EMAIL PROTECTED]

* java/net/Socket.java
(Socket): Perform security check on address not hostname.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8645r2=1.8646
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Socket.java?cvsroot=classpathr1=1.58r2=1.59




[cp-patches] FYI: InetAddress tweaks

2006-10-04 Thread Gary Benson
Hi all,

This commit makes InetAddress throw InternalErrors instead of
RuntimeExceptions when stuff that shouldn't happen happens.
There's also a little javadoc fix in there.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8642
diff -u -r1.8642 ChangeLog
--- ChangeLog   3 Oct 2006 19:47:58 -   1.8642
+++ ChangeLog   4 Oct 2006 10:20:40 -
@@ -1,3 +1,8 @@
+2006-10-04  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/InetAddress.java: Updated javadoc.
+   (clinit, getByLiteral): Throw InternalError on failures.
+
 2006-10-03  Francis Kung  [EMAIL PROTECTED]
 
* gnu/java/awt/peer/gtk/CairoGraphics2D.java
Index: java/net/InetAddress.java
===
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.52
diff -u -r1.52 InetAddress.java
--- java/net/InetAddress.java   19 Sep 2006 08:55:29 -  1.52
+++ java/net/InetAddress.java   4 Oct 2006 10:20:40 -
@@ -59,7 +59,7 @@
  * @author Per Bothner
  * @author Gary Benson ([EMAIL PROTECTED])
  *
- * @specnote This class is not final since JK 1.4
+ * @specnote This class is not final since JDK 1.4
  */
 public class InetAddress implements Serializable
 {
@@ -87,7 +87,7 @@
   }
 catch (UnknownHostException e)
   {
-   throw new RuntimeException(should never happen, e);
+   throw (InternalError) new InternalError().initCause(e);
   }
 ANY_IF.hostName = ANY_IF.getHostName();
   }
@@ -104,7 +104,7 @@
   }
 catch (UnknownHostException e)
   {
-   throw new RuntimeException(should never happen, e);
+   throw (InternalError) new InternalError().initCause(e);
   }
   }
 
@@ -522,7 +522,7 @@
   }
 catch (UnknownHostException e)
   {
-   throw new RuntimeException(should never happen, e);
+   throw (InternalError) new InternalError().initCause(e);
   }
   }
 


[commit-cp] classpath ChangeLog java/net/InetAddress.java

2006-10-04 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/10/04 10:21:10

Modified files:
.  : ChangeLog 
java/net   : InetAddress.java 

Log message:
2006-10-04  Gary Benson  [EMAIL PROTECTED]

* java/net/InetAddress.java: Updated javadoc.
(clinit, getByLiteral): Throw InternalError on failures.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8642r2=1.8643
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/InetAddress.java?cvsroot=classpathr1=1.52r2=1.53




[cp-patches] FYI: SocketPermission tweak

2006-09-22 Thread Gary Benson
Hi all,

This commit fixes a bug whereby IPv6 addresses with a one-digit first
component would caught as errors by SocketPermission's constructor.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8594
diff -u -r1.8594 ChangeLog
--- ChangeLog   22 Sep 2006 12:27:10 -  1.8594
+++ ChangeLog   22 Sep 2006 13:23:56 -
@@ -1,3 +1,9 @@
+2006-09-22  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/SocketPermission.java
+   (processHostport): Cope with IPv6 addresses with a
+   one-digit first component.
+
 2006-09-22  Roman Kennke  [EMAIL PROTECTED]
 
* java/awt/Component.java
Index: java/net/SocketPermission.java
===
RCS file: /cvsroot/classpath/classpath/java/net/SocketPermission.java,v
retrieving revision 1.23
diff -u -r1.23 SocketPermission.java
--- java/net/SocketPermission.java  14 Sep 2006 13:43:40 -  1.23
+++ java/net/SocketPermission.java  22 Sep 2006 13:23:56 -
@@ -193,16 +193,19 @@
 if (hostport.charAt(0) == '[')
   return hostport;
 
-int colons = 0, last_colon = 0;
+int colons = 0;
+boolean colon_allowed = true;
 for (int i = 0; i  hostport.length(); i++)
   {
if (hostport.charAt(i) == ':')
  {
-   if (i - last_colon == 1)
+   if (!colon_allowed)
  throw new IllegalArgumentException(Ambiguous hostport part);
colons++;
-   last_colon = i;
+   colon_allowed = false;
  }
+   else
+ colon_allowed = true;
   }
 
 switch (colons)
@@ -218,6 +221,7 @@
 
   case 8:
// an IPv6 address with ports
+   int last_colon = hostport.lastIndexOf(':');
return [ + hostport.substring(0, last_colon) + ]
  + hostport.substring(last_colon);
 


[commit-cp] classpath ChangeLog java/net/SocketPermission.java

2006-09-22 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/22 13:24:32

Modified files:
.  : ChangeLog 
java/net   : SocketPermission.java 

Log message:
2006-09-22  Gary Benson  [EMAIL PROTECTED]

* java/net/SocketPermission.java
(processHostport): Cope with IPv6 addresses with a
one-digit first component.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8594r2=1.8595
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/SocketPermission.java?cvsroot=classpathr1=1.23r2=1.24




[cp-patches] FYI: InetAddress DNS caching

2006-09-19 Thread Gary Benson
Committed.

Gary Benson wrote:
 Hi all,
 
 The documentation for java.net.InetAddress states that it maintains a
 DNS cache in order to guard against DNS spoofing attacks.  This patch
 adds this, but I wanted to float it for comments before checking it
 in as this has been an issue before: Classpath _had_ a DNS cache, but
 it was removed in January:
 
   http://permalink.gmane.org/gmane.comp.java.classpath.patches/6288
 
 The main difference between that cache and this one is that the old
 cache had its own set of rules for exipry and purging, and its own set
 of system properties for controlling those rules.  This cache does
 exactly what the javadoc for InetAddress says it should, so it should
 defeat whatever attack the it was originally created for.  What that
 attack _is_ exactly is not clear.  One possibility is [1], though it
 seems that that would require the browser to be using the same cache
 for a fix.
 
 Of course, by doing exactly what the javadoc says we also inherit the
 same problems as other JVMs that implement this cache [2, 3, 4].  We
 do have the same solutions, however, so it's not like we'll be leaving
 people out to dry.
 
 Cheers,
 Gary
 
  [1] http://www.cs.princeton.edu/sip/news/sun-02-22-96.html
  [2] http://www.limewire.org/pipermail/codepatch/2004-February/000310.html
  [3] http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=13115e61
  [4] http://www.openldap.org/lists/openldap-devel/200603/msg7.html
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8564
diff -u -r1.8564 ChangeLog
--- ChangeLog   19 Sep 2006 05:47:38 -  1.8564
+++ ChangeLog   19 Sep 2006 08:40:36 -
@@ -1,3 +1,9 @@
+2006-09-19  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/ResolverCache.java: New class (a DNS cache).
+   * java/net/InetAddress.java
+   (internalGetCanonicalHostName, getAllByName): Use the above.
+
 2006-09-19  Jeroen Frijters  [EMAIL PROTECTED]
 
* gnu/java/nio/SocketChannelImpl.java: Removed unused import.
Index: java/net/ResolverCache.java
===
RCS file: java/net/ResolverCache.java
diff -N java/net/ResolverCache.java
--- /dev/null   1 Jan 1970 00:00:00 -
+++ java/net/ResolverCache.java 19 Sep 2006 08:40:36 -
@@ -0,0 +1,269 @@
+/* ResolverCache.java -- A cache of resolver lookups for InetAddress.
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import java.security.Security;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This class provides a cache of name service resolutions.  By
+ * default successful resolutions are cached forever to guard
+ * against DNS spoofing attacks and failed resolutions are cached
+ * for 10 seconds to improve performance.  The length of time that
+ * results remain in the cache is determined by the following
+ * security properties:
+ * dl
+ *   dtcodenetworkaddress.cache.ttl/code/dt
+ *   dd
+ * This property specifies the length of time in seconds that
+ * successful resolutions remain in the cache.  The default is
+ * -1, indicating to cache forever.
+ *   /dd

[commit-cp] classpath ChangeLog java/net/InetAddress.java j...

2006-09-19 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/19 08:55:29

Modified files:
.  : ChangeLog 
java/net   : InetAddress.java 
Added files:
java/net   : ResolverCache.java 

Log message:
2006-09-19  Gary Benson  [EMAIL PROTECTED]

* java/net/ResolverCache.java: New class (a DNS cache).
* java/net/InetAddress.java
(internalGetCanonicalHostName, getAllByName): Use the above.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8564r2=1.8565
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/InetAddress.java?cvsroot=classpathr1=1.51r2=1.52
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/ResolverCache.java?cvsroot=classpathrev=1.1




[cp-patches] RFC: InetAddress DNS caching

2006-09-14 Thread Gary Benson
Hi all,

The documentation for java.net.InetAddress states that it maintains a
DNS cache in order to guard against DNS spoofing attacks.  This patch
adds this, but I wanted to float it for comments before checking it
in as this has been an issue before: Classpath _had_ a DNS cache, but
it was removed in January:

  http://permalink.gmane.org/gmane.comp.java.classpath.patches/6288

The main difference between that cache and this one is that the old
cache had its own set of rules for exipry and purging, and its own set
of system properties for controlling those rules.  This cache does
exactly what the javadoc for InetAddress says it should, so it should
defeat whatever attack the it was originally created for.  What that
attack _is_ exactly is not clear.  One possibility is [1], though it
seems that that would require the browser to be using the same cache
for a fix.

Of course, by doing exactly what the javadoc says we also inherit the
same problems as other JVMs that implement this cache [2, 3, 4].  We
do have the same solutions, however, so it's not like we'll be leaving
people out to dry.

Cheers,
Gary

 [1] http://www.cs.princeton.edu/sip/news/sun-02-22-96.html
 [2] http://www.limewire.org/pipermail/codepatch/2004-February/000310.html
 [3] http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=13115e61
 [4] http://www.openldap.org/lists/openldap-devel/200603/msg7.html
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8543
diff -u -r1.8543 ChangeLog
--- ChangeLog   14 Sep 2006 10:35:48 -  1.8543
+++ ChangeLog   14 Sep 2006 10:42:51 -
@@ -1,3 +1,9 @@
+2006-09-14  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/ResolverCache.java: New class (a DNS cache).
+   * java/net/InetAddress.java
+   (getCanonicalHostName, getAllByName): Use the above.
+
 2006-09-14  David Gilbert  [EMAIL PROTECTED]
 
Fixes PR28699
Index: java/net/ResolverCache.java
===
RCS file: java/net/ResolverCache.java
diff -N java/net/ResolverCache.java
--- /dev/null   1 Jan 1970 00:00:00 -
+++ java/net/ResolverCache.java 14 Sep 2006 10:42:51 -
@@ -0,0 +1,269 @@
+/* ResolverCache.java -- A cache of resolver lookups for InetAddress.
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.net;
+
+import java.security.Security;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This class provides a cache of name service resolutions.  By
+ * default successful resolutions are cached forever to guard
+ * against DNS spoofing attacks and failed resolutions are cached
+ * for 10 seconds to improve performance.  The length of time that
+ * results remain in the cache is determined by the following
+ * security properties:
+ * dl
+ *   dtcodenetworkaddress.cache.ttl/code/dt
+ *   dd
+ * This property specifies the length of time in seconds that
+ * successful resolutions remain in the cache.  The default is
+ * -1, indicating to cache forever.
+ *   /dd
+ *   dtcodenetworkaddress.cache.negative.ttl/code/dt
+ *   dd
+ * This property specifies the length of time in seconds that
+ * unsuccessful

[cp-patches] FYI: SocketPermission host checking rewrite

2006-09-14 Thread Gary Benson
Hi again,

This commit rewrites the host checking in SocketPermission so it does
what the javadoc says it should.  (This is the end result of all my
InetAddress hacking this past couple of weeks.)  We now pass all the
SocketPermission mauve tests.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8543
diff -u -r1.8543 ChangeLog
--- ChangeLog   14 Sep 2006 10:35:48 -  1.8543
+++ ChangeLog   14 Sep 2006 13:37:30 -
@@ -1,3 +1,17 @@
+2006-09-14  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/InetAddress.java
+   (internalGetCanonicalHostName): New method.
+   (getCanonicalHostName): Use internalGetCanonicalHostName.
+   (getByLiteral): New method.
+   (getAllByName): Use getByLiteral.
+   * java/net/SocketPermission.java
+   (host): Replaced with...
+   (hostname, address): New fields.
+   (equals, hashcode): Reflect the above.
+   (setHostPort): Parse host into hostname or address.
+   (implies): Rewrite host checks.
+
 2006-09-14  David Gilbert  [EMAIL PROTECTED]
 
Fixes PR28699
Index: java/net/InetAddress.java
===
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.50
diff -u -r1.50 InetAddress.java
--- java/net/InetAddress.java   8 Sep 2006 14:33:31 -   1.50
+++ java/net/InetAddress.java   14 Sep 2006 13:37:31 -
@@ -311,20 +311,27 @@
 
   /**
* Returns the canonical hostname represented by this InetAddress
-   * 
-   * @since 1.4
*/
-  public String getCanonicalHostName()
+  String internalGetCanonicalHostName()
   {
-String hostname;
 try
   {
-   hostname = VMInetAddress.getHostByAddr(addr);
+   return VMInetAddress.getHostByAddr(addr);
   }
 catch (UnknownHostException e)
   {
return getHostAddress();
   }
+  }
+
+  /**
+   * Returns the canonical hostname represented by this InetAddress
+   * 
+   * @since 1.4
+   */
+  public String getCanonicalHostName()
+  {
+String hostname = internalGetCanonicalHostName();
 
 SecurityManager sm = System.getSecurityManager();
 if (sm != null)
@@ -492,6 +499,34 @@
   }
 
   /**
+   * Returns an InetAddress object representing the IP address of
+   * the given literal IP address in dotted decimal format such as
+   * 127.0.0.1.  This is used by SocketPermission.setHostPort()
+   * to parse literal IP addresses without performing a DNS lookup.
+   *
+   * @param literal The literal IP address to create the InetAddress
+   * object from
+   *
+   * @return The address of the host as an InetAddress object, or
+   * null if the IP address is invalid.
+   */
+  static InetAddress getByLiteral(String literal)
+  {
+byte[] address = VMInetAddress.aton(literal);
+if (address == null)
+  return null;
+
+try
+  {
+   return getByAddress(address);
+  }
+catch (UnknownHostException e)
+  {
+   throw new RuntimeException(should never happen, e);
+  }
+  }
+
+  /**
* Returns an InetAddress object representing the IP address of the given
* hostname.  This name can be either a hostname such as 
www.urbanophile.com
* or an IP address in dotted decimal format such as 127.0.0.1.  If the
@@ -542,9 +577,9 @@
   return new InetAddress[] {LOCALHOST};
 
 // Check if hostname is an IP address
-byte[] address = VMInetAddress.aton(hostname);
+InetAddress address = getByLiteral(hostname);
 if (address != null)
-  return new InetAddress[] {getByAddress(address)};
+  return new InetAddress[] {address};
 
 // Perform security check before resolving
 SecurityManager sm = System.getSecurityManager();
Index: java/net/SocketPermission.java
===
RCS file: /cvsroot/classpath/classpath/java/net/SocketPermission.java,v
retrieving revision 1.22
diff -u -r1.22 SocketPermission.java
--- java/net/SocketPermission.java  31 Aug 2006 12:26:22 -  1.22
+++ java/net/SocketPermission.java  14 Sep 2006 13:37:31 -
@@ -117,11 +117,18 @@
   static final long serialVersionUID = -7204263841984476862L;
 
   /**
-   * A hostname (possibly wildcarded) or IP address (IPv4 or IPv6).
+   * A hostname (possibly wildcarded).  Will be set if and only if
+   * this object was initialized with a hostname.
*/
-  private transient String host;
+  private transient String hostname = null;
 
   /**
+   * An IP address (IPv4 or IPv6).  Will be set if and only if this
+   * object was initialized with a single literal IP address.
+   */  
+  private transient InetAddress address = null;
+  
+  /**
* A range of ports.
*/
   private transient int minport;
@@ -225,7 +232,7 @@
   private void setHostPort(String hostport)
   {
 // Split into host and ports
-String ports;
+String host

[commit-cp] classpath ChangeLog java/net/InetAddress.java j...

2006-09-14 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/14 13:43:40

Modified files:
.  : ChangeLog 
java/net   : InetAddress.java SocketPermission.java 

Log message:
2006-09-14  Gary Benson  [EMAIL PROTECTED]

* java/net/InetAddress.java
(internalGetCanonicalHostName): New method.
(getCanonicalHostName): Use internalGetCanonicalHostName.
(getByLiteral): New method.
(getAllByName): Use getByLiteral.
* java/net/SocketPermission.java
(host): Replaced with...
(hostname, address): New fields.
(equals, hashcode): Reflect the above.
(setHostPort): Parse host into hostname or address.
(implies): Rewrite host checks.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8543r2=1.8544
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/InetAddress.java?cvsroot=classpathr1=1.50r2=1.51
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/SocketPermission.java?cvsroot=classpathr1=1.22r2=1.23




[cp-patches] FYI: NetworkInterface security fix

2006-09-12 Thread Gary Benson
Hi all,

This commit fixes NetworkInterface.getInetAddresses()'s security
check.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8532
diff -u -r1.8532 ChangeLog
--- ChangeLog   12 Sep 2006 14:30:52 -  1.8532
+++ ChangeLog   12 Sep 2006 14:55:05 -
@@ -1,3 +1,8 @@
+2006-09-12  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/NetworkInterface.java (getInetAddresses):
+   Fix port used in security check.
+
 2006-09-12  David Gilbert  [EMAIL PROTECTED]
 
* javax/swing/plaf/metal/DefaultMetalTheme.java
Index: java/net/NetworkInterface.java
===
RCS file: /cvsroot/classpath/classpath/java/net/NetworkInterface.java,v
retrieving revision 1.18
diff -u -r1.18 NetworkInterface.java
--- java/net/NetworkInterface.java  29 Aug 2006 08:25:15 -  1.18
+++ java/net/NetworkInterface.java  12 Sep 2006 14:55:05 -
@@ -1,5 +1,5 @@
 /* NetworkInterface.java --
-   Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -112,7 +112,7 @@
InetAddress addr = (InetAddress) addresses.nextElement();
try
  {
-   s.checkConnect(addr.getHostAddress(), 58000);
+   s.checkConnect(addr.getHostAddress(), -1);
tmpInetAddresses.add(addr);
  }
catch (SecurityException e)


[commit-cp] classpath ChangeLog java/net/NetworkInterface.java

2006-09-12 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/12 14:55:33

Modified files:
.  : ChangeLog 
java/net   : NetworkInterface.java 

Log message:
2006-09-12  Gary Benson  [EMAIL PROTECTED]

* java/net/NetworkInterface.java (getInetAddresses):
Fix port used in security check.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8532r2=1.8533
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/NetworkInterface.java?cvsroot=classpathr1=1.18r2=1.19




[cp-patches] FYI: InetAddress family handling (take 2)

2006-09-11 Thread Gary Benson
Hi all,

This commit renames the constants AF_INET and AF_INET6 that I
introduced in my last commit.  Unfortunatly with gcj they end
up in CNI headers where they conflict with the real AF_INET
and AF_INET6.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8521
diff -u -r1.8521 ChangeLog
--- ChangeLog   10 Sep 2006 21:16:39 -  1.8521
+++ ChangeLog   11 Sep 2006 10:31:14 -
@@ -1,3 +1,12 @@
+2006-09-11  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/Inet4Address.java
+   (AF_INET): Renamed to FAMILY.
+   (init, writeReplace): Reflect the above.
+   * java/net/Inet6Address.java
+   (AF_INET6): Renamed to FAMILY.
+   (init): Reflect the above.
+
 2006-09-10  Ito Kazumitsu  [EMAIL PROTECTED]
 
Fixes bug #28867
Index: java/net/Inet4Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet4Address.java,v
retrieving revision 1.21
diff -u -r1.21 Inet4Address.java
--- java/net/Inet4Address.java  8 Sep 2006 14:33:31 -   1.21
+++ java/net/Inet4Address.java  11 Sep 2006 10:31:14 -
@@ -57,16 +57,16 @@
   static final long serialVersionUID = 3286316764910316507L;
 
   /**
-   * The address family of these addresses.
+   * The address family of these addresses.  Used for serialization.
*/
-  private static final int AF_INET = 2;
+  private static final int FAMILY = 2; // AF_INET
 
   /**
* Inet4Address objects are serialized as InetAddress objects.
*/
   private Object writeReplace() throws ObjectStreamException
   {
-return new InetAddress(addr, hostName, AF_INET);
+return new InetAddress(addr, hostName, FAMILY);
   }
   
   /**
@@ -79,7 +79,7 @@
*/
   Inet4Address(byte[] addr, String host)
   {
-super(addr, host, AF_INET);
+super(addr, host, FAMILY);
   }
 
   /**
Index: java/net/Inet6Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.14
diff -u -r1.14 Inet6Address.java
--- java/net/Inet6Address.java  8 Sep 2006 14:33:31 -   1.14
+++ java/net/Inet6Address.java  11 Sep 2006 10:31:14 -
@@ -93,9 +93,9 @@
   private transient NetworkInterface nif; 
 
   /**
-   * The address family of these addresses.
+   * The address family of these addresses.  Used for serialization.
*/
-  private static final int AF_INET6 = 10;
+  private static final int FAMILY = 10; // AF_INET6
 
   /**
* Create an Inet6Address object
@@ -105,7 +105,7 @@
*/
   Inet6Address(byte[] addr, String host)
   {
-super(addr, host, AF_INET6);
+super(addr, host, FAMILY);
 // Super constructor clones the addr.  Get a reference to the clone.
 this.ipaddress = this.addr;
 ifname = null;


[cp-patches] FYI: InetAddress family handling (take 3)

2006-09-11 Thread Gary Benson
Hi again,

So it turns out that my last commit was unnecessary -- the header
causing the problems should never have been included anyway -- so
since I preferred the original version with AF_INET and AF_INET6
I have reverted to it.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8523
diff -u -r1.8523 ChangeLog
--- ChangeLog   11 Sep 2006 10:45:02 -  1.8523
+++ ChangeLog   11 Sep 2006 11:43:47 -
@@ -1,3 +1,12 @@
+2006-09-11  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/Inet4Address.java
+   (FAMILY): Renamed back to AF_INET.
+   (init, writeReplace): Reflect the above.
+   * java/net/Inet6Address.java
+   (FAMILY): Renamed back to AF_INET6.
+   (init): Reflect the above.
+
 2006-09-11  Cameron McCormack  [EMAIL PROTECTED]
 
Fixes PR29010
Index: java/net/Inet4Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet4Address.java,v
retrieving revision 1.22
diff -u -r1.22 Inet4Address.java
--- java/net/Inet4Address.java  11 Sep 2006 10:39:33 -  1.22
+++ java/net/Inet4Address.java  11 Sep 2006 11:43:47 -
@@ -57,16 +57,16 @@
   static final long serialVersionUID = 3286316764910316507L;
 
   /**
-   * The address family of these addresses.  Used for serialization.
+   * The address family of these addresses (used for serialization).
*/
-  private static final int FAMILY = 2; // AF_INET
+  private static final int AF_INET = 2;
 
   /**
* Inet4Address objects are serialized as InetAddress objects.
*/
   private Object writeReplace() throws ObjectStreamException
   {
-return new InetAddress(addr, hostName, FAMILY);
+return new InetAddress(addr, hostName, AF_INET);
   }
   
   /**
@@ -79,7 +79,7 @@
*/
   Inet4Address(byte[] addr, String host)
   {
-super(addr, host, FAMILY);
+super(addr, host, AF_INET);
   }
 
   /**
Index: java/net/Inet6Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.15
diff -u -r1.15 Inet6Address.java
--- java/net/Inet6Address.java  11 Sep 2006 10:39:33 -  1.15
+++ java/net/Inet6Address.java  11 Sep 2006 11:43:47 -
@@ -93,9 +93,9 @@
   private transient NetworkInterface nif; 
 
   /**
-   * The address family of these addresses.  Used for serialization.
+   * The address family of these addresses (used for serialization).
*/
-  private static final int FAMILY = 10; // AF_INET6
+  private static final int AF_INET6 = 10;
 
   /**
* Create an Inet6Address object
@@ -105,7 +105,7 @@
*/
   Inet6Address(byte[] addr, String host)
   {
-super(addr, host, FAMILY);
+super(addr, host, AF_INET6);
 // Super constructor clones the addr.  Get a reference to the clone.
 this.ipaddress = this.addr;
 ifname = null;


[commit-cp] classpath ChangeLog java/net/Inet4Address.java ...

2006-09-11 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/11 11:44:25

Modified files:
.  : ChangeLog 
java/net   : Inet4Address.java Inet6Address.java 

Log message:
2006-09-11  Gary Benson  [EMAIL PROTECTED]

* java/net/Inet4Address.java
(FAMILY): Renamed back to AF_INET.
(init, writeReplace): Reflect the above.
* java/net/Inet6Address.java
(FAMILY): Renamed back to AF_INET6.
(init): Reflect the above.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8523r2=1.8524
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet4Address.java?cvsroot=classpathr1=1.22r2=1.23
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet6Address.java?cvsroot=classpathr1=1.15r2=1.16




[cp-patches] FYI: InetAddress merge

2006-09-08 Thread Gary Benson
Hi all,

This commit merges a bunch of funky stuff from GCJ's InetAddress
(including all the fixes I've been working on over the past week
or so) and adds a bunch of other stuff I noticed while merging.
Particular hilights are that raw InetAddress objects no longer
exist anywhere (only Inet4Address and Inet6Address objects are
ever created now) and that a couple of excessive security checks
were relaxed.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8513
diff -u -r1.8513 ChangeLog
--- ChangeLog   7 Sep 2006 11:42:13 -   1.8513
+++ ChangeLog   8 Sep 2006 08:23:15 -
@@ -1,3 +1,31 @@
+2006-09-08  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/InetAddress.java
+   (inaddr_any): Removed.
+   (ANY_IF, LOCALHOST): Create using getByAddress.
+   (init): Updated javadoc.
+   (getHostName): Cache hostname even if the lookup failed.
+   (getByAddress): Create Inet4Address objects when passed
+   IPv4-mapped IPv6 addresses.
+   (aton): Removed.
+   (getAllByName): Create address objects using getByAddress.
+   Do not perform security checks unless actually required.
+   Do not strip whitespace from the hostname.
+   (getInaddrAny): Removed.
+   (getLocalHost): Return the loopback address if getByName
+   throws a SecurityException.
+   (readResolve): Updated javadoc.
+   * vm/reference/java/net/VMInetAddress.java (aton): Declared.
+   * include/java_net_VMInetAddress.h
+   (Java_java_net_VMInetAddress_aton): Likewise.
+   * native/jni/java-net/java_net_VMInetAddress.c
+   (Java_java_net_VMInetAddress_aton): New method.
+   * native/jni/native-lib/cpnet.h (cpnet_aton): Declared.
+   * native/jni/native-lib/cpnet.c (cpnet_aton): New method.
+   * configure.ac (AC_CHECK_FUNCS): Checks for cpnet_aton.
+   * java/net/Inet4Address.java (writeReplace): Updated javadoc.
+   * NEWS: Added note about updated VM interface.
+
 2006-09-07  David Gilbert  [EMAIL PROTECTED]
 
* javax/swing/plaf/basic/BasicInternalFrameUI.java
Index: java/net/InetAddress.java
===
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.46
diff -u -r1.46 InetAddress.java
--- java/net/InetAddress.java   6 Feb 2006 12:50:03 -   1.46
+++ java/net/InetAddress.java   8 Sep 2006 08:23:19 -
@@ -1,5 +1,6 @@
 /* InetAddress.java -- Class to model an Internet address
-   Copyright (C) 1998, 1999, 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2002, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -43,7 +44,6 @@
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
-import java.util.StringTokenizer;
 
 /**
  * This class models an Internet address.  It does not have a public
@@ -57,6 +57,7 @@
  *
  * @author Aaron M. Renn ([EMAIL PROTECTED])
  * @author Per Bothner
+ * @author Gary Benson ([EMAIL PROTECTED])
  *
  * @specnote This class is not final since JK 1.4
  */
@@ -65,37 +66,47 @@
   private static final long serialVersionUID = 3286316764910316507L;
 
   /**
-   * The special IP address INADDR_ANY.
-   */
-  private static InetAddress inaddr_any;
-
-  /**
* Dummy InetAddress, used to bind socket to any (all) network interfaces.
*/
   static InetAddress ANY_IF;
-
+  static
+  {
+byte[] addr;
+try
+  {
+   addr = VMInetAddress.lookupInaddrAny();
+  }
+catch (UnknownHostException e)
+  {
+   // Make one up and hope it works.
+   addr = new byte[] {0, 0, 0, 0};
+  }
+try
+  {
+   ANY_IF = getByAddress(addr);
+  }
+catch (UnknownHostException e)
+  {
+   throw new RuntimeException(should never happen, e);
+  }
+ANY_IF.hostName = ANY_IF.getHostName();
+  }
+  
   /**
* Stores static localhost address object.
*/
   static InetAddress LOCALHOST;
-
   static
   {
-// precompute the ANY_IF address
 try
   {
-ANY_IF = getInaddrAny();
-
-   byte[] ip_localhost = { 127, 0, 0, 1 };
-   LOCALHOST = new Inet4Address(ip_localhost, localhost);
+   LOCALHOST = getByAddress(localhost, new byte[] {127, 0, 0, 1});
   }
-catch (UnknownHostException uhe)
+catch (UnknownHostException e)
   {
-// Hmmm, make one up and hope that it works.
-byte[] zeros = { 0, 0, 0, 0 };
-ANY_IF = new Inet4Address(zeros, 0.0.0.0);
+   throw new RuntimeException(should never happen, e);
   }
-  }
+  }
 
   /**
* The Serialized Form specifies that an int 'address' is saved/restored.
@@ -124,9 +135,13 @@
   int family;
 
   /**
-   * Initializes this object's addr instance variable from the passed in
-   * byte array.  Note that this constructor

[cp-patches] FYI: InetAddress reorganisation

2006-09-08 Thread Gary Benson
Hi again,

InetAddress contains a bunch of IPv4-specific methods to which their
equivalents in Inet4Address defer.  This is decidedly non-OO, so this
commit moves the implementations to Inet4Address and makes the methods
in InetAddress throw UnsupportedOperationExceptions.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8514
diff -u -r1.8514 ChangeLog
--- ChangeLog   8 Sep 2006 09:13:27 -   1.8514
+++ ChangeLog   8 Sep 2006 11:00:43 -
@@ -1,3 +1,16 @@
+2006-09-08  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/Inet4Address.java (isMulticastAddress,
+   isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress,
+   isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal,
+   isMCSiteLocal, isMCOrgLocal, getHostAddress): Moved
+   implementations from InetAddress.
+   * java/net/InetAddress.java (isMulticastAddress,
+   isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress,
+   isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal,
+   isMCSiteLocal, isMCOrgLocal, getHostAddress): Replace
+   implementations with UnsupportedOperationExceptions.
+   
 2006-09-08  Gary Benson  [EMAIL PROTECTED]
 
* java/net/InetAddress.java
Index: java/net/Inet4Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet4Address.java,v
retrieving revision 1.19
diff -u -r1.19 Inet4Address.java
--- java/net/Inet4Address.java  8 Sep 2006 08:59:56 -   1.19
+++ java/net/Inet4Address.java  8 Sep 2006 11:00:43 -
@@ -84,7 +84,7 @@
*/
   public boolean isMulticastAddress()
   {
-return super.isMulticastAddress();
+return (addr[0]  0xf0) == 0xe0;
   }
 
   /**
@@ -92,7 +92,7 @@
*/
   public boolean isLoopbackAddress()
   {
-return super.isLoopbackAddress();
+return (addr[0]  0xff) == 0x7f;
   }
 
   /**
@@ -102,7 +102,7 @@
*/
   public boolean isAnyLocalAddress()
   {
-return super.isAnyLocalAddress();
+return equals(InetAddress.ANY_IF);
   }
 
   /**
@@ -112,7 +112,7 @@
*/
   public boolean isLinkLocalAddress()
   {
-return super.isLinkLocalAddress();
+return false;
   }
 
   /**
@@ -122,7 +122,19 @@
*/
   public boolean isSiteLocalAddress()
   {
-return super.isSiteLocalAddress();
+// 10.0.0.0/8
+if ((addr[0]  0xff) == 0x0a)
+  return true;
+
+// 172.16.0.0/12
+if ((addr[0]  0xff) == 0xac  (addr[1]  0xf0) == 0x10)
+  return true;
+
+// 192.168.0.0/16
+if ((addr[0]  0xff) == 0xc0  (addr[1]  0xff) == 0xa8)
+  return true;
+
+return false;
   }
 
   /**
@@ -132,7 +144,7 @@
*/
   public boolean isMCGlobal()
   {
-return super.isMCGlobal();
+return false;
   }
 
   /**
@@ -142,7 +154,7 @@
*/
   public boolean isMCNodeLocal()
   {
-return super.isMCNodeLocal();
+return false;
   }
 
   /**
@@ -152,7 +164,12 @@
*/
   public boolean isMCLinkLocal()
   {
-return super.isMCLinkLocal();
+if (! isMulticastAddress())
+  return false;
+
+return ((addr[0]  0xff) == 0xe0
+(addr[1]  0xff)  == 0x00
+(addr[2]  0xff)  == 0x00);
   }
 
   /**
@@ -162,7 +179,7 @@
*/
   public boolean isMCSiteLocal()
   {
-return super.isMCSiteLocal();
+return false;
   }
 
   /**
@@ -172,7 +189,7 @@
*/
   public boolean isMCOrgLocal()
   {
-return super.isMCOrgLocal();
+return false;
   }
 
   /**
@@ -190,7 +207,23 @@
*/
   public String getHostAddress()
   {
-return super.getHostAddress();
+StringBuffer sb = new StringBuffer(40);
+
+int len = addr.length;
+int i = 0;
+
+for ( ; ; )
+  {
+sb.append(addr[i]  0xff);
+i++;
+   
+if (i == len)
+  break;
+   
+sb.append('.');
+  }
+
+return sb.toString();
   }
 
   /**
Index: java/net/InetAddress.java
===
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.47
diff -u -r1.47 InetAddress.java
--- java/net/InetAddress.java   8 Sep 2006 08:59:56 -   1.47
+++ java/net/InetAddress.java   8 Sep 2006 11:00:43 -
@@ -159,150 +159,144 @@
* An address is multicast if the high four bits are 1110.  These are
* also known as Class D addresses.
*
+   * pThis method cannot be abstract for backward compatibility reasons. By
+   * default it always throws [EMAIL PROTECTED] UnsupportedOperationException} 
unless
+   * overridden./p
+   * 
* @return true if mulitcast, false if not
*
* @since 1.1
*/
   public boolean isMulticastAddress()
   {
-// Mask against high order bits of 1110
-if (addr.length == 4)
-  return (addr[0]  0xf0) == 0xe0;
-
-return false;
+throw new UnsupportedOperationException();
   }
 
   /**
* Utility routine

[cp-patches] FYI: InetAddress.getHostName() reorganisation

2006-09-08 Thread Gary Benson
Hi again,

This commit makes InetAddress.getCanonicalHostName() perform its
security check on the canonical hostname (ie after the lookup).
It also makes getHostname() call getCanonicalHostName() rather than
the other way around, so getHostname() picks up the security check,
and getCanonicalHostName() doesn't have to create throwaway objects.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8515
diff -u -r1.8515 ChangeLog
--- ChangeLog   8 Sep 2006 11:32:34 -   1.8515
+++ ChangeLog   8 Sep 2006 12:54:58 -
@@ -1,3 +1,10 @@
+2006-09-08  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/InetAddress.java
+   (getHostName): Move lookup into getCanonicalHostName.
+   (getCanonicalHostName): Move lookup from getHostName,
+   Perform security check on canonical name (ie after lookup).
+
 2006-09-08  Gary Benson  [EMAIL PROTECTED]
 
* java/net/Inet4Address.java (isMulticastAddress,
Index: java/net/InetAddress.java
===
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.48
diff -u -r1.48 InetAddress.java
--- java/net/InetAddress.java   8 Sep 2006 11:32:34 -   1.48
+++ java/net/InetAddress.java   8 Sep 2006 12:54:58 -
@@ -307,17 +307,8 @@
*/
   public String getHostName()
   {
-if (hostName != null)
-  return hostName;
-
-try
-  {
-   hostName = VMInetAddress.getHostByAddr(addr);
-  }
-catch (UnknownHostException e)
-  {
-   hostName = getHostAddress();
-  }
+if (hostName == null)
+  hostName = getCanonicalHostName();
 
 return hostName;
   }
@@ -329,12 +320,22 @@
*/
   public String getCanonicalHostName()
   {
+String hostname;
+try
+  {
+   hostname = VMInetAddress.getHostByAddr(addr);
+  }
+catch (UnknownHostException e)
+  {
+   return getHostAddress();
+  }
+
 SecurityManager sm = System.getSecurityManager();
 if (sm != null)
   {
 try
  {
-sm.checkConnect(hostName, -1);
+sm.checkConnect(hostname, -1);
  }
catch (SecurityException e)
  {
@@ -342,16 +343,7 @@
  }
   }
 
-// Try to find the FDQN now
-InetAddress address;
-byte[] ipaddr = getAddress();
-
-if (ipaddr.length == 16)
-  address = new Inet6Address(getAddress(), null);
-else
-  address = new Inet4Address(getAddress(), null);
-
-return address.getHostName();
+return hostname;
   }
 
   /**


[cp-patches] FYI: InetAddress family handling

2006-09-08 Thread Gary Benson
Hi again,

This commit updates the javadoc of InetAddress.family to make
clear that it is used only for serialization, and ensures that
it is properly set.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8516
diff -u -r1.8516 ChangeLog
--- ChangeLog   8 Sep 2006 12:58:13 -   1.8516
+++ ChangeLog   8 Sep 2006 14:31:25 -
@@ -1,3 +1,17 @@
+2006-09-08  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/InetAddress.java
+   (family): Updated javadoc and made private.
+   (init): Add an address family argument.
+   (readObject): Don't overwrite family.
+   * java/net/Inet4Address.java
+   (AF_INET): New constant.
+   (init): Use AF_INET as the family.
+   (writeReplace): Likewise.
+   * java/net/Inet6Address.java
+   (AF_INET6): New constant.
+   (init): Use AF_INET6 as the family.
+
 2006-09-08  Gary Benson  [EMAIL PROTECTED]
 
* java/net/InetAddress.java
Index: java/net/InetAddress.java
===
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.49
diff -u -r1.49 InetAddress.java
--- java/net/InetAddress.java   8 Sep 2006 12:58:14 -   1.49
+++ java/net/InetAddress.java   8 Sep 2006 14:31:25 -
@@ -126,13 +126,9 @@
   String hostName;
 
   /**
-   * The field 'family' seems to be the AF_ value.
-   * FIXME: Much of the code in the other java.net classes does not make
-   * use of this family field.  A better implementation would be to make
-   * use of getaddrinfo() and have other methods just check the family
-   * field rather than examining the length of the address each time.
+   * Needed for serialization.
*/
-  int family;
+  private int family;
 
   /**
* Constructor.  Prior to the introduction of IPv6 support in 1.4,
@@ -145,13 +141,13 @@
*
* @param ipaddr The IP number of this address as an array of bytes
* @param hostname The hostname of this IP address.
+   * @param family The address family of this IP address.
*/
-  InetAddress(byte[] ipaddr, String hostname)
+  InetAddress(byte[] ipaddr, String hostname, int family)
   {
 addr = (null == ipaddr) ? null : (byte[]) ipaddr.clone();
 hostName = hostname;
-
-family = 2; /* AF_INET */
+this.family = family;
   }
 
   /**
@@ -607,8 +603,6 @@
 
 for (int i = 2; i = 0; --i)
   addr[i] = (byte) (address = 8);
-
-family = 2; /* AF_INET  */
   }
 
   private void writeObject(ObjectOutputStream oos) throws IOException
Index: java/net/Inet4Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet4Address.java,v
retrieving revision 1.20
diff -u -r1.20 Inet4Address.java
--- java/net/Inet4Address.java  8 Sep 2006 11:32:34 -   1.20
+++ java/net/Inet4Address.java  8 Sep 2006 14:31:25 -
@@ -1,5 +1,5 @@
 /* Inet4Address.java --
-   Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -57,11 +57,16 @@
   static final long serialVersionUID = 3286316764910316507L;
 
   /**
+   * The address family of these addresses.
+   */
+  private static final int AF_INET = 2;
+
+  /**
* Inet4Address objects are serialized as InetAddress objects.
*/
   private Object writeReplace() throws ObjectStreamException
   {
-return new InetAddress(addr, hostName);
+return new InetAddress(addr, hostName, AF_INET);
   }
   
   /**
@@ -74,7 +79,7 @@
*/
   Inet4Address(byte[] addr, String host)
   {
-super(addr, host);
+super(addr, host, AF_INET);
   }
 
   /**
Index: java/net/Inet6Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.13
diff -u -r1.13 Inet6Address.java
--- java/net/Inet6Address.java  19 Jul 2006 16:21:20 -  1.13
+++ java/net/Inet6Address.java  8 Sep 2006 14:31:25 -
@@ -1,5 +1,5 @@
 /* Inet6Address.java --
-   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -93,6 +93,11 @@
   private transient NetworkInterface nif; 
 
   /**
+   * The address family of these addresses.
+   */
+  private static final int AF_INET6 = 10;
+
+  /**
* Create an Inet6Address object
*
* @param addr The IP address
@@ -100,7 +105,7 @@
*/
   Inet6Address(byte[] addr, String host)
   {
-super(addr, host);
+super(addr, host, AF_INET6);
 // Super constructor clones the addr.  Get a reference to the clone.
 this.ipaddress = this.addr;
 ifname = null;


[commit-cp] classpath ChangeLog java/net/Inet4Address.java ...

2006-09-08 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/08 11:32:34

Modified files:
.  : ChangeLog 
java/net   : Inet4Address.java InetAddress.java 

Log message:
2006-09-08  Gary Benson  [EMAIL PROTECTED]

* java/net/Inet4Address.java (isMulticastAddress,
isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress,
isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal,
isMCSiteLocal, isMCOrgLocal, getHostAddress): Moved
implementations from InetAddress.
* java/net/InetAddress.java (isMulticastAddress,
isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress,
isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal,
isMCSiteLocal, isMCOrgLocal, getHostAddress): Replace
implementations with UnsupportedOperationExceptions.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8514r2=1.8515
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet4Address.java?cvsroot=classpathr1=1.19r2=1.20
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/InetAddress.java?cvsroot=classpathr1=1.47r2=1.48




[commit-cp] classpath ChangeLog java/net/InetAddress.java

2006-09-08 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/08 12:58:14

Modified files:
.  : ChangeLog 
java/net   : InetAddress.java 

Log message:
2006-09-08  Gary Benson  [EMAIL PROTECTED]

* java/net/InetAddress.java
(getHostName): Move lookup into getCanonicalHostName.
(getCanonicalHostName): Move lookup from getHostName,
Perform security check on canonical name (ie after lookup).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8515r2=1.8516
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/InetAddress.java?cvsroot=classpathr1=1.48r2=1.49




[commit-cp] classpath ChangeLog java/net/InetAddress.java j...

2006-09-08 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/08 14:33:31

Modified files:
.  : ChangeLog 
java/net   : InetAddress.java Inet4Address.java 
 Inet6Address.java 

Log message:
2006-09-08  Gary Benson  [EMAIL PROTECTED]

* java/net/InetAddress.java
(family): Updated javadoc and made private.
(init): Add an address family argument.
(readObject): Don't overwrite family.
* java/net/Inet4Address.java
(AF_INET): New constant.
(init): Use AF_INET as the family.
(writeReplace): Likewise.
* java/net/Inet6Address.java
(AF_INET6): New constant.
(init): Use AF_INET6 as the family.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8516r2=1.8517
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/InetAddress.java?cvsroot=classpathr1=1.49r2=1.50
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet4Address.java?cvsroot=classpathr1=1.20r2=1.21
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet6Address.java?cvsroot=classpathr1=1.13r2=1.14




[commit-cp] classpath ChangeLog

2006-09-08 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/09/08 09:13:28

Modified files:
.  : ChangeLog 

Log message:
2006-09-08  Gary Benson  [EMAIL PROTECTED]

* java/net/InetAddress.java
(inaddr_any): Removed.
(ANY_IF, LOCALHOST): Create using getByAddress.
(init): Updated javadoc.
(getHostName): Cache hostname even if the lookup failed.
(getByAddress): Create Inet4Address objects when passed
IPv4-mapped IPv6 addresses.
(aton): Removed.
(getAllByName): Create address objects using getByAddress.
Do not perform security checks unless actually required.
Do not strip whitespace from the hostname.
(getInaddrAny): Removed.
(getLocalHost): Return the loopback address if getByName
throws a SecurityException.
(readResolve): Updated javadoc.
* vm/reference/java/net/VMInetAddress.java (aton): Declared.
* include/java_net_VMInetAddress.h
(Java_java_net_VMInetAddress_aton): Likewise.
* native/jni/java-net/java_net_VMInetAddress.c
(Java_java_net_VMInetAddress_aton): New method.
* native/jni/native-lib/cpnet.h (cpnet_aton): Declared.
* native/jni/native-lib/cpnet.c (cpnet_aton): New method.
* configure.ac (AC_CHECK_FUNCS): Checks for cpnet_aton.
* java/net/Inet4Address.java (writeReplace): Updated javadoc.
* NEWS: Added note about updated VM interface.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8513r2=1.8514




Re: [cp-patches] FYI: SocketPermission tweak

2006-09-01 Thread Gary Benson
Tom Tromey wrote:
  Gary == Gary Benson [EMAIL PROTECTED] writes:
 
  This commit makes java.net.SocketPermission()'s constructor
  use localhost when called with an empty hostport argument
  as mandated by the spec.
 
 Do we want this in GCC 4.2?  Or FC6?

This particular one probably doesn't matter much, but I'm working on
some more SocketPermission stuff which probably will need to go in.
I'll merge them into gcc in one go when they're done.

Cheers,
Gary




[cp-patches] FYI: SocketPermission tweak

2006-08-31 Thread Gary Benson
Hi all,

This commit makes java.net.SocketPermission()'s constructor use
localhost when called with an empty hostport argument as mandated
by the spec.  

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8476
diff -u -r1.8476 ChangeLog
--- ChangeLog   31 Aug 2006 10:50:56 -  1.8476
+++ ChangeLog   31 Aug 2006 12:25:06 -
@@ -1,3 +1,11 @@
+2006-08-31  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/SocketPermission.java
+   (maybeBracketIPv6Address): Renamed to processHostport.
+   (processHostport): Also translate  to localhost.
+   (setHostPort): Remove special cases for empty hostport and for
+   extra colons in hostport (processHostport handles these now).
+
 2006-08-31  Mark Wielaard  [EMAIL PROTECTED]
 
* javax/swing/text/ZoneView.java (Zone): Make static class.
Index: java/net/SocketPermission.java
===
RCS file: /cvsroot/classpath/classpath/java/net/SocketPermission.java,v
retrieving revision 1.21
diff -u -r1.21 SocketPermission.java
--- java/net/SocketPermission.java  29 Aug 2006 08:25:15 -  1.21
+++ java/net/SocketPermission.java  31 Aug 2006 12:25:06 -
@@ -164,21 +164,26 @@
*/
   public SocketPermission(String hostport, String actions)
   {
-super(maybeBracketIPv6Address(hostport));
+super(processHostport(hostport));
 
 setHostPort(getName());
 setActions(actions);
   }
 
   /**
-   * IPv6 addresses in the hostport must either be enclosed by
-   * [ and ] or be specified in the full uncompressed form.
-   * In the latter case proprietary JVMs will quote the address
-   * with [ and ], so we do to.
+   * There are two cases in which hostport needs rewriting before
+   * being passed to the superclass constructor.  If hostport is an
+   * empty string then it is substituted with localhost.  And if
+   * the host part of hostport is a literal IPv6 address in the full
+   * uncompressed form not enclosed with [ and ] then we enclose
+   * it with them.
*/
-  private static String maybeBracketIPv6Address(String hostport)
+  private static String processHostport(String hostport)
   {
-if (hostport.length() == 0 || hostport.charAt(0) == '[')
+if (hostport.length() == 0)
+  return localhost;
+
+if (hostport.charAt(0) == '[')
   return hostport;
 
 int colons = 0, last_colon = 0;
@@ -221,11 +226,7 @@
   {
 // Split into host and ports
 String ports;
-if (hostport.length() == 0)
-  {
-   host = ports = ;
-  }
-else if (hostport.charAt(0) == '[')
+if (hostport.charAt(0) == '[')
   {
// host is a bracketed IPv6 address
int end = hostport.indexOf(]);
@@ -255,8 +256,6 @@
ports = hostport.substring(sep + 1);
  }
   }
-if (ports.indexOf(:) != -1)
-  throw new IllegalArgumentException(Unexpected ':');
 
 // Parse and validate the ports
 if (ports.length() == 0)


[commit-cp] classpath ChangeLog java/net/SocketPermission.java

2006-08-31 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/08/31 12:26:22

Modified files:
.  : ChangeLog 
java/net   : SocketPermission.java 

Log message:
2006-08-31  Gary Benson  [EMAIL PROTECTED]

* java/net/SocketPermission.java
(maybeBracketIPv6Address): Renamed to processHostport.
(processHostport): Also translate  to localhost.
(setHostPort): Remove special cases for empty hostport and for
extra colons in hostport (processHostport handles these now).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8476r2=1.8477
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/SocketPermission.java?cvsroot=classpathr1=1.21r2=1.22




[cp-patches] FYI: SocketPermission fix

2006-08-29 Thread Gary Benson
Hi all,

This commit makes java.net.SocketPermission() accept unbracketed IPv6
addresses when specified in the full uncompressed form.  The way it
does this (by intercepting the argument to the constructor) seems odd,
but I had a play with a couple of proprietary JVMs and it seems that
this is what they do.  This commit also reverts my previous commit to
NetworkInterface.getInetAddresses() which is now unnecessary.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8469
diff -u -r1.8469 ChangeLog
--- ChangeLog   28 Aug 2006 21:41:57 -  1.8469
+++ ChangeLog   29 Aug 2006 08:23:49 -
@@ -1,3 +1,12 @@
+2006-08-29  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/SocketPermission.java
+   (maybeBracketIPv6Address): New method.
+   (init): Pass the hostport argument through the above.
+
+   * java/net/NetworkInterface.java (getInetAddresses):
+   Don't bracket IPv6 addresses.
+
 2006-08-28  Roman Kennke  [EMAIL PROTECTED]
 
* javax/swing/text/BoxView.java
Index: java/net/SocketPermission.java
===
RCS file: /cvsroot/classpath/classpath/java/net/SocketPermission.java,v
retrieving revision 1.20
diff -u -r1.20 SocketPermission.java
--- java/net/SocketPermission.java  29 Jan 2006 18:55:59 -  1.20
+++ java/net/SocketPermission.java  29 Aug 2006 08:23:49 -
@@ -164,13 +164,57 @@
*/
   public SocketPermission(String hostport, String actions)
   {
-super(hostport);
+super(maybeBracketIPv6Address(hostport));
 
-setHostPort(hostport);
+setHostPort(getName());
 setActions(actions);
   }
 
   /**
+   * IPv6 addresses in the hostport must either be enclosed by
+   * [ and ] or be specified in the full uncompressed form.
+   * In the latter case proprietary JVMs will quote the address
+   * with [ and ], so we do to.
+   */
+  private static String maybeBracketIPv6Address(String hostport)
+  {
+if (hostport.length() == 0 || hostport.charAt(0) == '[')
+  return hostport;
+
+int colons = 0, last_colon = 0;
+for (int i = 0; i  hostport.length(); i++)
+  {
+   if (hostport.charAt(i) == ':')
+ {
+   if (i - last_colon == 1)
+ throw new IllegalArgumentException(Ambiguous hostport part);
+   colons++;
+   last_colon = i;
+ }
+  }
+
+switch (colons)
+  {
+  case 0:
+  case 1:
+   // a hostname or IPv4 address
+   return hostport;
+   
+  case 7:
+   // an IPv6 address with no ports
+   return [ + hostport + ];
+
+  case 8:
+   // an IPv6 address with ports
+   return [ + hostport.substring(0, last_colon) + ]
+ + hostport.substring(last_colon);
+
+  default:
+   throw new IllegalArgumentException(Ambiguous hostport part);
+  }
+  }
+  
+  /**
* Parse the hostport argument to the constructor.
*/
   private void setHostPort(String hostport)
Index: java/net/NetworkInterface.java
===
RCS file: /cvsroot/classpath/classpath/java/net/NetworkInterface.java,v
retrieving revision 1.17
diff -u -r1.17 NetworkInterface.java
--- java/net/NetworkInterface.java  24 Aug 2006 10:58:55 -  1.17
+++ java/net/NetworkInterface.java  29 Aug 2006 08:23:49 -
@@ -112,10 +112,7 @@
InetAddress addr = (InetAddress) addresses.nextElement();
try
  {
-   String hostAddress = addr.getHostAddress();
-   if (addr instanceof Inet6Address)
- hostAddress = [ + hostAddress + ];
-   s.checkConnect(hostAddress, 58000);
+   s.checkConnect(addr.getHostAddress(), 58000);
tmpInetAddresses.add(addr);
  }
catch (SecurityException e)


[commit-cp] classpath ChangeLog java/net/SocketPermission.j...

2006-08-29 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/08/29 08:25:15

Modified files:
.  : ChangeLog 
java/net   : SocketPermission.java NetworkInterface.java 

Log message:
2006-08-29  Gary Benson  [EMAIL PROTECTED]

* java/net/SocketPermission.java
(maybeBracketIPv6Address): New method.
(init): Pass the hostport argument through the above.

* java/net/NetworkInterface.java (getInetAddresses):
Don't bracket IPv6 addresses.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8469r2=1.8470
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/SocketPermission.java?cvsroot=classpathr1=1.20r2=1.21
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/NetworkInterface.java?cvsroot=classpathr1=1.17r2=1.18




[cp-patches] FYI: NetworkInterface.getInetAddresses() fix

2006-08-24 Thread Gary Benson
Hi all,

This commit makes NetworkInterface.getInetAddresses() bracket IPv6
addresses before calling SecurityManager.checkConnect() with them.
This fixes http://gcc.gnu.org/ml/java/2006-08/msg00082.html.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8447
diff -u -r1.8447 ChangeLog
--- ChangeLog   24 Aug 2006 06:40:04 -  1.8447
+++ ChangeLog   24 Aug 2006 10:57:43 -
@@ -1,3 +1,8 @@
+2006-08-24  Gary Benson  [EMAIL PROTECTED]
+
+   * java/net/NetworkInterface.java (getInetAddresses): Bracket IPv6
+   addresses.
+
 2006-08-24  Jeroen Frijters  [EMAIL PROTECTED]
 
* java/lang/ref/Reference.java
Index: java/net/NetworkInterface.java
===
RCS file: /cvsroot/classpath/classpath/java/net/NetworkInterface.java,v
retrieving revision 1.16
diff -u -r1.16 NetworkInterface.java
--- java/net/NetworkInterface.java  7 Aug 2005 21:42:40 -   1.16
+++ java/net/NetworkInterface.java  24 Aug 2006 10:57:43 -
@@ -112,7 +112,10 @@
InetAddress addr = (InetAddress) addresses.nextElement();
try
  {
-   s.checkConnect(addr.getHostAddress(), 58000);
+   String hostAddress = addr.getHostAddress();
+   if (addr instanceof Inet6Address)
+ hostAddress = [ + hostAddress + ];
+   s.checkConnect(hostAddress, 58000);
tmpInetAddresses.add(addr);
  }
catch (SecurityException e)


[commit-cp] classpath ChangeLog java/net/NetworkInterface.java

2006-08-24 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/08/24 10:58:55

Modified files:
.  : ChangeLog 
java/net   : NetworkInterface.java 

Log message:
2006-08-24  Gary Benson  [EMAIL PROTECTED]

* java/net/NetworkInterface.java (getInetAddresses): Bracket 
IPv6
addresses.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8447r2=1.8448
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/NetworkInterface.java?cvsroot=classpathr1=1.16r2=1.17




[cp-patches] FYI: AccessControlContext speedup

2006-08-10 Thread Gary Benson
Hi all,

This commit avoids calling AccessController.getContext() twice when
creating an AccessControlContext with a security manager enabled.
I've been using BC-compiled Tomcat on gcj to benchmark the security
stuff, and this commit improves gcj's performance from 2200 to 2400
requests per second.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8357
diff -u -r1.8357 ChangeLog
--- ChangeLog   9 Aug 2006 22:25:51 -   1.8357
+++ ChangeLog   10 Aug 2006 14:33:06 -
@@ -1,3 +1,8 @@
+2006-08-10  Gary Benson  [EMAIL PROTECTED]
+
+   * java/security/AccessControlContext.java (init):
+   Avoid a duplicated AccessController.getContext() call.
+
 2006-08-09  Mark Wielaard  [EMAIL PROTECTED]
 
* NEWS: Add updates for 0.92 release.
Index: java/security/AccessControlContext.java
===
RCS file: /cvsroot/classpath/classpath/java/security/AccessControlContext.java,v
retrieving revision 1.13
diff -u -r1.13 AccessControlContext.java
--- java/security/AccessControlContext.java 23 Oct 2005 17:04:46 -  
1.13
+++ java/security/AccessControlContext.java 10 Aug 2006 14:33:06 -
@@ -89,12 +89,30 @@
   public AccessControlContext(AccessControlContext acc,
  DomainCombiner combiner)
   {
+AccessControlContext acc2 = null;
 SecurityManager sm = System.getSecurityManager ();
 if (sm != null)
   {
-sm.checkPermission (new SecurityPermission 
(createAccessControlContext));
+   Permission perm =
+ new SecurityPermission (createAccessControlContext);
+
+   // The default SecurityManager.checkPermission(perm) just calls 
+   // AccessController.checkPermission(perm) which in turn just
+   // calls AccessController.getContext().checkPermission(perm).
+   // This means AccessController.getContext() is called twice,
+   // once for the security check and once by us.  It's a very
+   // expensive call (on gcj at least) so if we're using the
+   // default security manager we avoid this duplication.
+   if (sm.getClass() == SecurityManager.class)
+ {
+   acc2 = AccessController.getContext ();
+   acc2.checkPermission (perm);
+ }
+   else
+ sm.checkPermission (perm);
   }
-AccessControlContext acc2 = AccessController.getContext();
+if (acc2 == null)
+  acc2 = AccessController.getContext ();
 protectionDomains = combiner.combine (acc2.protectionDomains,
   acc.protectionDomains);
 this.combiner = combiner;


Re: Running JOnAS 4.7.4 that uses 1.5 features

2006-08-10 Thread Gary Benson
Andrew Haley wrote:
 Tom Tromey writes:
   Gary == Gary Benson [EMAIL PROTECTED] writes:
  
  Gary I wonder if this is what was not happening in gcj.  The
  Gary patch I wrote basically added the contents of
  Gary java.endorsed.dirs to one of JOnAS's many classloaders.
  
  We implemented endorsed dirs specifically for jonas -- as I recall
  this was needed not only for jacorb but also for loading
  xerces/xalan.  My recollection is that with the FC5 gcc (aka 4.1)
  we didn't need any special jonas hacks in this area... if I'm
  wrong, I'd like to know so we can fix it :-)
 
 OK, but I had to unload jonas and all its deps to build jboss.
 
 If gary can tell me exactly which classpath hack he's talking about
 I'll try to remove it.  But I'll have to remove all the jboss stuff
 first, becasue it's an incompatible set of packages.  Sigh.

jonas-classpath.patch fixes two class loading issues which might be
separate but might be the same thing.  The attached patch is without
the endorsed hack, so replacing jonas-classpath.patch in the rpm with
this one should expose whatever error it fixed.

Cheers,
Gary

The endorsed directories and the bootstrap jarfile don't seem to end
up on the classpath, despite all of JOnAS seemingly assuming they are.

--- jonas/src/org/objectweb/jonas/server/LoaderManager.java~2004-08-04 
11:03:14.0 +0100
+++ jonas/src/org/objectweb/jonas/server/LoaderManager.java 2005-06-23 
11:28:09.0 +0100
@@ -366,6 +366,10 @@
 // Load $JONAS_ROOT/lib/commons/**/*.jar
 jurls.add(jonasCommonsDir, .jar);
 
+// pick up bootstrap classes if running under libgcj
+if (System.getProperty(java.vm.name).equals(GNU libgcj))
+jurls.add(new File(jonasLib, common/ow_jonas_bootstrap.jar));
+
 // add jonas.base/lib/ext only if jonas.base != jonas.root
 // jonas.base/lib/ext is added before jonas.root/lib/ext
 if 
(!System.getProperty(install.root).toLowerCase().equals(jonasBase.toLowerCase()))
 {
--- jonas_tests/conformance/build.xml~  2005-10-13 17:07:00.0 +0100
+++ jonas_tests/conformance/build.xml   2005-10-14 17:29:22.0 +0100
@@ -111,6 +111,7 @@
   pathelement location=${rajar.dir}/JtestResourceAdapter.jar /
   fileset dir=${lib.dir}
 include name=client.jar /
+include name=common/ow_jonas_bootstrap.jar /
   /fileset
 /path
 available file=${rajar.dir}/JtestResourceAdapter.jar


[commit-cp] classpath ChangeLog java/security/AccessControl...

2006-08-10 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/08/10 14:48:32

Modified files:
.  : ChangeLog 
java/security  : AccessControlContext.java 

Log message:
2006-08-10  Gary Benson  [EMAIL PROTECTED]

* java/security/AccessControlContext.java (init):
Avoid a duplicated AccessController.getContext() call.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8357r2=1.8358
http://cvs.savannah.gnu.org/viewcvs/classpath/java/security/AccessControlContext.java?cvsroot=classpathr1=1.13r2=1.14




Re: Running JOnAS 4.7.4 that uses 1.5 features

2006-08-09 Thread Gary Benson
Audrius Meskauskas wrote:
 JOnAS also failed to load the JacORB CORBA implementation via our
 org.omg classes. Despite our ObjectCreator.forName searches the
 thread context class loader and then walks through the stack, trying
 the class loader of every class there, the jacorb.jar is still
 missing in the path of all tried loaders (I have checked with the
 .toString() method of our class loader - is lists all files in the
 path). I have no idea from where the JacORB classes should be loaded
 (the jacorb.jar itself is present in JOnAS distribution).

I think I hit something similar in the never-released Fedora JOnAS:
I had to write a little a hack to ram jacorb.jar onto the classpath.
I suspect we're missing something in the way we deal with endorsed
classes.

Cheers,
Gary




Re: Running JOnAS 4.7.4 that uses 1.5 features

2006-08-09 Thread Gary Benson
Robert Lougher wrote:
 On 8/9/06, Gary Benson [EMAIL PROTECTED] wrote:
  Audrius Meskauskas wrote:
   JOnAS also failed to load the JacORB CORBA implementation via
   our org.omg classes. Despite our ObjectCreator.forName searches
   the thread context class loader and then walks through the
   stack, trying the class loader of every class there, the
   jacorb.jar is still missing in the path of all tried loaders (I
   have checked with the .toString() method of our class loader -
   is lists all files in the path). I have no idea from where the
   JacORB classes should be loaded (the jacorb.jar itself is
   present in JOnAS distribution).
  
  I think I hit something similar in the never-released Fedora
  JOnAS: I had to write a little a hack to ram jacorb.jar onto the
  classpath.  I suspect we're missing something in the way we deal
  with endorsed classes.
 
 Can you check JOnAS's startup scripts to see whether it is setting
 java.endorsed.dirs on the command line passed to the VM?

It does.

 If it is, the contents of the directory (or directories) should be
 added to the bootclasspath, and loaded via the boot loader.

I wonder if this is what was not happening in gcj.  The patch I wrote
basically added the contents of java.endorsed.dirs to one of JOnAS's
many classloaders.

Cheers,
Gary



Re: Running JOnAS 4.7.4 that uses 1.5 features

2006-08-09 Thread Gary Benson
Andrew Haley wrote:
 Gary Benson writes:
  Robert Lougher wrote:
   On 8/9/06, Gary Benson [EMAIL PROTECTED] wrote:
Audrius Meskauskas wrote:
 JOnAS also failed to load the JacORB CORBA implementation
 via our org.omg classes. Despite our ObjectCreator.forName
 searches the thread context class loader and then walks
 through the stack, trying the class loader of every class
 there, the jacorb.jar is still missing in the path of all
 tried loaders (I have checked with the .toString() method of
 our class loader - is lists all files in the path). I have
 no idea from where the JacORB classes should be loaded (the
 jacorb.jar itself is present in JOnAS distribution).

I think I hit something similar in the never-released Fedora
JOnAS: I had to write a little a hack to ram jacorb.jar onto
the classpath.  I suspect we're missing something in the way
we deal with endorsed classes.
   
   Can you check JOnAS's startup scripts to see whether it is
   setting java.endorsed.dirs on the command line passed to the VM?
   If it is, the contents of the directory (or directories) should
   be added to the bootclasspath, and loaded via the boot loader.
  
  I wonder if this is what was not happening in gcj.  The patch I
  wrote basically added the contents of java.endorsed.dirs to one
  of JOnAS's many classloaders.

 Mmm, but if I recall correctly that got fixed, and it was no longer
 necessary.

I don't know.  It was still necessary the last time I built JOnAS.
Do you have a working JOnAS build environment?  The hack is in
jonas-classpath.patch, though you can't remove the whole patch (it
does something else too).

Cheers,
Gary



Re: Howto generate configure?

2006-07-21 Thread Gary Benson
Clemens Eisserer wrote:
 Well as far as I know to be able to make dist I guess I have to
 run the generated configure-script first, however it fails saying
 GConf2 is missing.
 However I've GConf2 installed, I even updated it to 2.14 to make
 sure I use an up-to-date version and its installed in default
 location ...  will gconf2 also be needed for my embedded build?!

You need to install the GConf2 development headers.  On Fedora 
that's the package GConf2-devel, on Debian I'm guessing it's
libgconf2-dev.

Cheers,
Gary



Re: Howto generate configure?

2006-07-20 Thread Gary Benson
Hi Clemens,

Clemens Eisserer wrote:
 I would like to try out Classpath-CVS to experiment a bit with Roman's
 great xawt-implementation.
 However in CVS there are no scripts like configure available

The script autogen.sh will generate the configure script for you.

Cheers,
Gary



Re: Internet Banking

2006-07-12 Thread Gary Benson
Hi Koh,

The banks I use work with only free software (in my case Fedora and
Firefox) though neither of them use Java (as opposed to JavaScript,
which they do).  I'm not sure if that's what you were after, but they
are:

  http://www.barclays.co.uk/
  http://www.barclaycard.co.uk/ (credit card arm of the above)
  http://www.nationwide.co.uk/

The places that manage my pension and stock options also work with
free software, though considering who I work for I'd expect nothing
less!

  http://www.scottishequitable.co.uk/
  http://www.friendsprovident.co.uk/
  http://www.fidelity.com/

Again, none of them use Java itself.  And none of the sites I've
mentioned actively support free software, but they don't actively
block it either, which is an important step forward IMO.

Cheers,
Gary

Uncle Koh wrote:
 Hi there!
 
 I am a journalist in south east Asia, currently writing an article
 on free java implementation. I had been to a few banking sites to
 test out their Internet banking systems (which depended on Java) and
 found that none of them works with the gcjwebplugin on my system
 (which has only free software).
 
 My request is to find out if there is any bank in the world whose
 Internet banking system works on a system with only free software
 installed. This includes those sites that do not use Java at all.
 By Internet banking, I mean I can transfer money using the bank's
 online site and check my account balance.
 
 Can any kind soul send to me, if you know, the name of the bank and
 its URL.
 
 Thanks you very much and best regards
 Koh



[cp-patches] FYI: Fix FilePermission on root directory

2006-06-29 Thread Gary Benson
Hi all,

This commit fixes a bug whereby FilePermission(/) did not imply
itself.  There was some old (and broken) code for compensating for
paths with trailing separators.  Nowadays paths are canonicalized;
canonical paths never have trailing separators, so I just junked
the old code.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7965
diff -u -r1.7965 ChangeLog
--- ChangeLog   28 Jun 2006 20:10:25 -  1.7965
+++ ChangeLog   29 Jun 2006 09:01:35 -
@@ -1,3 +1,7 @@
+2006-06-29  Gary Benson  [EMAIL PROTECTED]
+
+   * java/io/FilePermission.java (implies): Work when path is /.
+
 2006-06-28  Andrew John Hughes  [EMAIL PROTECTED]
 
* java/lang/Thread.java:
Index: java/io/FilePermission.java
===
RCS file: /cvsroot/classpath/classpath/java/io/FilePermission.java,v
retrieving revision 1.21
diff -u -r1.21 FilePermission.java
--- java/io/FilePermission.java 29 Mar 2006 15:33:24 -  1.21
+++ java/io/FilePermission.java 29 Jun 2006 09:01:35 -
@@ -274,12 +274,7 @@
break;
 
   default:
-   if (f2.charAt(f2.length() - 1) == File.separatorChar)
- {
-   if (! f1.equals(f2.substring(0, f2.length() - 1)))
- return false;
- }
-   else if (!f1.equals(f2))
+   if (!f1.equals(f2))
  return false;
break;
   }


[cp-patches] FYI: Merge File.listRoots security checks from libgcj

2006-06-29 Thread Gary Benson
Hi again,

This commit merges security checks for File.listRoots from libgcj.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7966
diff -u -r1.7966 ChangeLog
--- ChangeLog   29 Jun 2006 09:02:49 -  1.7966
+++ ChangeLog   29 Jun 2006 09:59:31 -
@@ -1,3 +1,7 @@
+2006-06-29  Gary Benson  [EMAIL PROTECTED]
+
+   * java/io/File.java (listRoots): Merge security checks from libgcj.
+
 2006-06-29  Gary Benson  [EMAIL PROTECTED]
 
* java/io/FilePermission.java (implies): Work when path is /.
Index: java/io/File.java
===
RCS file: /cvsroot/classpath/classpath/java/io/File.java,v
retrieving revision 1.64
diff -u -r1.64 File.java
--- java/io/File.java   14 Jun 2006 14:47:46 -  1.64
+++ java/io/File.java   29 Jun 2006 09:59:31 -
@@ -1200,7 +1200,38 @@
*/
   public static File[] listRoots()
   {
-return VMFile.listRoots();
+File[] roots = VMFile.listRoots();
+
+SecurityManager s = System.getSecurityManager();
+if (s != null)
+  {
+   // Only return roots to which the security manager permits read access.
+   int count = roots.length;
+   for (int i = 0; i  roots.length; i++)
+ {
+   try
+ {
+   s.checkRead (roots[i].path);
+ }
+   catch (SecurityException sx)
+ {
+   roots[i] = null;
+   count--;
+ }
+ }
+   if (count != roots.length)
+ {
+   File[] newRoots = new File[count];
+   int k = 0;
+   for (int i = 0; i  roots.length; i++)
+ {
+   if (roots[i] != null)
+ newRoots[k++] = roots[i];
+ }
+   roots = newRoots;
+ }
+  }
+return roots;
   }
 
   /**


[commit-cp] classpath ChangeLog java/io/FilePermission.java

2006-06-29 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/06/29 09:02:50

Modified files:
.  : ChangeLog 
java/io: FilePermission.java 

Log message:
2006-06-29  Gary Benson  [EMAIL PROTECTED]

* java/io/FilePermission.java (implies): Work when path is /.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7965r2=1.7966
http://cvs.savannah.gnu.org/viewcvs/classpath/java/io/FilePermission.java?cvsroot=classpathr1=1.21r2=1.22




[cp-patches] FYI: Add Graphics2D security checks

2006-06-21 Thread Gary Benson
Morning all,

No one objected, so I committed this patch that adds security
checks to all Graphics2D peers.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7888
diff -u -r1.7888 ChangeLog
--- ChangeLog   20 Jun 2006 21:46:37 -  1.7888
+++ ChangeLog   21 Jun 2006 08:05:19 -
@@ -1,3 +1,9 @@
+2006-06-21  Gary Benson  [EMAIL PROTECTED]
+
+   * gnu/java/awt/peer/gtk/CairoGraphics2D.java: Add security check.
+   * gnu/java/awt/peer/qt/QtGraphics.java: Likewise.
+   * gnu/java/awt/java2d/AbstractGraphics2D.java: Likewise.
+
 2006-06-20  Thomas Fitzsimmons  [EMAIL PROTECTED]
 
* native/plugin/Makefile.am (libgcjwebplugin_la_CXXFLAGS): Define
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.27
diff -u -r1.27 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java  20 Jun 2006 13:57:51 -  
1.27
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java  21 Jun 2006 08:05:20 -
@@ -41,6 +41,7 @@
 import gnu.java.awt.ClasspathToolkit;
 
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -886,6 +887,12 @@
   }
 else
   {
+// FIXME: this check is only required if this Graphics2D
+// context is drawing to a Component on the display screen.
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPermission(new AWTPermission(readDisplayPixels));
+
 // FIXME: implement general Composite support
 throw new java.lang.UnsupportedOperationException();
   }
Index: gnu/java/awt/peer/qt/QtGraphics.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/qt/QtGraphics.java,v
retrieving revision 1.3
diff -u -r1.3 QtGraphics.java
--- gnu/java/awt/peer/qt/QtGraphics.java23 Aug 2005 02:13:48 -  
1.3
+++ gnu/java/awt/peer/qt/QtGraphics.java21 Jun 2006 08:05:20 -
@@ -38,6 +38,7 @@
 package gnu.java.awt.peer.qt;
 
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -605,8 +606,16 @@
composite = comp;
   }
 else
-  throw new UnsupportedOperationException(We don't support custom+
-  composites yet.);
+  {
+   // FIXME: this check is only required if this Graphics2D
+   // context is drawing to a Component on the display screen.
+   SecurityManager sm = System.getSecurityManager();
+   if (sm != null)
+ sm.checkPermission(new AWTPermission(readDisplayPixels));
+
+   throw new UnsupportedOperationException(We don't support custom+
+composites yet.);
+  }
   }
 
   public Composite getComposite()
Index: gnu/java/awt/java2d/AbstractGraphics2D.java
===
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,v
retrieving revision 1.9
diff -u -r1.9 AbstractGraphics2D.java
--- gnu/java/awt/java2d/AbstractGraphics2D.java 9 Jun 2006 20:49:51 -   
1.9
+++ gnu/java/awt/java2d/AbstractGraphics2D.java 21 Jun 2006 08:05:21 -
@@ -39,6 +39,7 @@
 
 import java.awt.AWTError;
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -539,6 +540,15 @@
*/
   public void setComposite(Composite comp)
   {
+if (! (comp instanceof AlphaComposite))
+  {
+// FIXME: this check is only required if this Graphics2D
+// context is drawing to a Component on the display screen.
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPermission(new AWTPermission(readDisplayPixels));
+  }
+
 composite = comp;
 if (! (comp.equals(AlphaComposite.SrcOver)))
   isOptimized = false;


[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Cairo...

2006-06-21 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/06/21 08:06:29

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: CairoGraphics2D.java 
gnu/java/awt/peer/qt: QtGraphics.java 
gnu/java/awt/java2d: AbstractGraphics2D.java 

Log message:
2006-06-21  Gary Benson  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoGraphics2D.java: Add security 
check.
* gnu/java/awt/peer/qt/QtGraphics.java: Likewise.
* gnu/java/awt/java2d/AbstractGraphics2D.java: Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7888r2=1.7889
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java?cvsroot=classpathr1=1.27r2=1.28
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/qt/QtGraphics.java?cvsroot=classpathr1=1.3r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java?cvsroot=classpathr1=1.9r2=1.10

Patches:
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7888
retrieving revision 1.7889
diff -u -b -r1.7888 -r1.7889
--- ChangeLog   20 Jun 2006 21:46:37 -  1.7888
+++ ChangeLog   21 Jun 2006 08:06:28 -  1.7889
@@ -1,3 +1,9 @@
+2006-06-21  Gary Benson  [EMAIL PROTECTED]
+
+   * gnu/java/awt/peer/gtk/CairoGraphics2D.java: Add security check.
+   * gnu/java/awt/peer/qt/QtGraphics.java: Likewise.
+   * gnu/java/awt/java2d/AbstractGraphics2D.java: Likewise.
+
 2006-06-20  Thomas Fitzsimmons  [EMAIL PROTECTED]
 
* native/plugin/Makefile.am (libgcjwebplugin_la_CXXFLAGS): Define

Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java  20 Jun 2006 13:57:51 -  
1.27
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java  21 Jun 2006 08:06:28 -  
1.28
@@ -41,6 +41,7 @@
 import gnu.java.awt.ClasspathToolkit;
 
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -886,6 +887,12 @@
   }
 else
   {
+// FIXME: this check is only required if this Graphics2D
+// context is drawing to a Component on the display screen.
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPermission(new AWTPermission(readDisplayPixels));
+
 // FIXME: implement general Composite support
 throw new java.lang.UnsupportedOperationException();
   }

Index: gnu/java/awt/peer/qt/QtGraphics.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/qt/QtGraphics.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gnu/java/awt/peer/qt/QtGraphics.java23 Aug 2005 02:13:48 -  
1.3
+++ gnu/java/awt/peer/qt/QtGraphics.java21 Jun 2006 08:06:29 -  
1.4
@@ -38,6 +38,7 @@
 package gnu.java.awt.peer.qt;
 
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -605,9 +606,17 @@
composite = comp;
   }
 else
+  {
+   // FIXME: this check is only required if this Graphics2D
+   // context is drawing to a Component on the display screen.
+   SecurityManager sm = System.getSecurityManager();
+   if (sm != null)
+ sm.checkPermission(new AWTPermission(readDisplayPixels));
+
   throw new UnsupportedOperationException(We don't support custom+
   composites yet.);
   }
+  }
 
   public Composite getComposite()
   {

Index: gnu/java/awt/java2d/AbstractGraphics2D.java
===
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gnu/java/awt/java2d/AbstractGraphics2D.java 9 Jun 2006 20:49:51 -   
1.9
+++ gnu/java/awt/java2d/AbstractGraphics2D.java 21 Jun 2006 08:06:29 -  
1.10
@@ -39,6 +39,7 @@
 
 import java.awt.AWTError;
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -539,6 +540,15 @@
*/
   public void setComposite(Composite comp)
   {
+if (! (comp instanceof AlphaComposite))
+  {
+// FIXME: this check is only required if this Graphics2D
+// context is drawing to a Component

[cp-patches] FYI: Add printing security checks

2006-06-20 Thread Gary Benson
Hi all,

This commit adds security checks to all AWT peers' getPrintJob
methods.  None of the methods actually do anything yet, but having
the checks there means the Mauve tests pass.

Cheers,
Gary
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7880
diff -u -r1.7880 ChangeLog
--- ChangeLog   20 Jun 2006 11:24:41 -  1.7880
+++ ChangeLog   20 Jun 2006 11:35:39 -
@@ -1,3 +1,9 @@
+2006-06-20  Gary Benson  [EMAIL PROTECTED]
+
+   * java/awt/Toolkit.java: Add security check.
+   * gnu/java/awt/peer/gtk/GtkToolkit.java: Likewise.
+   * gnu/java/awt/peer/qt/QtToolkit.java: Likewise.
+
 2006-06-20  Raif S. Naffah  [EMAIL PROTECTED]
 
* gnu/java/security/key/dss/DSSKey.java: Source formatting.
Index: java/awt/Toolkit.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Toolkit.java,v
retrieving revision 1.41
diff -u -r1.41 Toolkit.java
--- java/awt/Toolkit.java   15 May 2006 16:11:48 -  1.41
+++ java/awt/Toolkit.java   20 Jun 2006 11:35:39 -
@@ -695,6 +695,14 @@
   public PrintJob getPrintJob(Frame frame, String title,
   JobAttributes jobAttr, PageAttributes pageAttr)
   {
+// FIXME: it is possible this check may be removed
+// if this method, when written, always delegates to
+// getPrintJob(Frame, String, Properties).
+SecurityManager sm;
+sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPrintJobAccess();
+
 return null;
   }
 
Index: gnu/java/awt/peer/gtk/GtkToolkit.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,v
retrieving revision 1.87
diff -u -r1.87 GtkToolkit.java
--- gnu/java/awt/peer/gtk/GtkToolkit.java   5 Jun 2006 13:47:04 -   
1.87
+++ gnu/java/awt/peer/gtk/GtkToolkit.java   20 Jun 2006 11:35:39 -
@@ -310,6 +310,11 @@
 
   public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props) 
   {
+SecurityManager sm;
+sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPrintJobAccess();
+
 return null;
   }
 
Index: gnu/java/awt/peer/qt/QtToolkit.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/qt/QtToolkit.java,v
retrieving revision 1.6
diff -u -r1.6 QtToolkit.java
--- gnu/java/awt/peer/qt/QtToolkit.java 7 Jun 2006 22:00:01 -   1.6
+++ gnu/java/awt/peer/qt/QtToolkit.java 20 Jun 2006 11:35:39 -
@@ -402,6 +402,11 @@
  String jobtitle,
  Properties props)
   {
+SecurityManager sm;
+sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPrintJobAccess();
+
 throw new RuntimeException(Not implemented);
   }
 


[commit-cp] classpath ChangeLog java/awt/Toolkit.java gnu/j...

2006-06-20 Thread Gary Benson
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Gary Benson gbenson   06/06/20 11:36:23

Modified files:
.  : ChangeLog 
java/awt   : Toolkit.java 
gnu/java/awt/peer/gtk: GtkToolkit.java 
gnu/java/awt/peer/qt: QtToolkit.java 

Log message:
2006-06-20  Gary Benson  [EMAIL PROTECTED]

* java/awt/Toolkit.java: Add security check.
* gnu/java/awt/peer/gtk/GtkToolkit.java: Likewise.
* gnu/java/awt/peer/qt/QtToolkit.java: Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7880r2=1.7881
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Toolkit.java?cvsroot=classpathr1=1.41r2=1.42
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java?cvsroot=classpathr1=1.87r2=1.88
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/qt/QtToolkit.java?cvsroot=classpathr1=1.6r2=1.7

Patches:
Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7880
retrieving revision 1.7881
diff -u -b -r1.7880 -r1.7881
--- ChangeLog   20 Jun 2006 11:24:41 -  1.7880
+++ ChangeLog   20 Jun 2006 11:36:22 -  1.7881
@@ -1,3 +1,9 @@
+2006-06-20  Gary Benson  [EMAIL PROTECTED]
+
+   * java/awt/Toolkit.java: Add security check.
+   * gnu/java/awt/peer/gtk/GtkToolkit.java: Likewise.
+   * gnu/java/awt/peer/qt/QtToolkit.java: Likewise.
+
 2006-06-20  Raif S. Naffah  [EMAIL PROTECTED]
 
* gnu/java/security/key/dss/DSSKey.java: Source formatting.

Index: java/awt/Toolkit.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Toolkit.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- java/awt/Toolkit.java   15 May 2006 16:11:48 -  1.41
+++ java/awt/Toolkit.java   20 Jun 2006 11:36:23 -  1.42
@@ -695,6 +695,14 @@
   public PrintJob getPrintJob(Frame frame, String title,
   JobAttributes jobAttr, PageAttributes pageAttr)
   {
+// FIXME: it is possible this check may be removed
+// if this method, when written, always delegates to
+// getPrintJob(Frame, String, Properties).
+SecurityManager sm;
+sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPrintJobAccess();
+
 return null;
   }
 

Index: gnu/java/awt/peer/gtk/GtkToolkit.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -b -r1.87 -r1.88
--- gnu/java/awt/peer/gtk/GtkToolkit.java   5 Jun 2006 13:47:04 -   
1.87
+++ gnu/java/awt/peer/gtk/GtkToolkit.java   20 Jun 2006 11:36:23 -  
1.88
@@ -310,6 +310,11 @@
 
   public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props) 
   {
+SecurityManager sm;
+sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPrintJobAccess();
+
 return null;
   }
 

Index: gnu/java/awt/peer/qt/QtToolkit.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/qt/QtToolkit.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gnu/java/awt/peer/qt/QtToolkit.java 7 Jun 2006 22:00:01 -   1.6
+++ gnu/java/awt/peer/qt/QtToolkit.java 20 Jun 2006 11:36:23 -  1.7
@@ -402,6 +402,11 @@
  String jobtitle,
  Properties props)
   {
+SecurityManager sm;
+sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPrintJobAccess();
+
 throw new RuntimeException(Not implemented);
   }
 




[cp-patches] RFC: Add security checks to Graphics2D peers

2006-06-19 Thread Gary Benson
Hi all,

Does anyone mind if I commit the following patch to add security
checks to all Graphics2D peers?  The reason I ask is that the checks
might be overly restrictive, but at the moment the stuff after the
checks isn't implemented anywhere.  I just wanted to get them in so
they don't get lost.

Cheers,
Gary

Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7878
diff -u -r1.7878 ChangeLog
--- ChangeLog   19 Jun 2006 12:43:48 -  1.7878
+++ ChangeLog   19 Jun 2006 16:00:44 -
@@ -1,3 +1,9 @@
+2006-06-19  Gary Benson  [EMAIL PROTECTED]
+
+   * gnu/java/awt/peer/gtk/CairoGraphics2D.java: Add security check.
+   * gnu/java/awt/peer/qt/QtGraphics.java: Likewise.
+   * gnu/java/awt/java2d/AbstractGraphics2D.java: Likewise.
+
 2006-06-19  Raif S. Naffah  [EMAIL PROTECTED]
 
* gnu/java/security/jce/hash/HavalSpi.java: Source formatting.
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.25
diff -u -r1.25 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java  16 Jun 2006 10:27:29 -  
1.25
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java  19 Jun 2006 16:00:44 -
@@ -41,6 +41,7 @@
 import gnu.java.awt.ClasspathToolkit;
 
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -886,6 +887,12 @@
   }
 else
   {
+// FIXME: this check is only required if this Graphics2D
+// context is drawing to a Component on the display screen.
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPermission(new AWTPermission(readDisplayPixels));
+
 // FIXME: implement general Composite support
 throw new java.lang.UnsupportedOperationException();
   }
Index: gnu/java/awt/peer/qt/QtGraphics.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/qt/QtGraphics.java,v
retrieving revision 1.3
diff -u -r1.3 QtGraphics.java
--- gnu/java/awt/peer/qt/QtGraphics.java23 Aug 2005 02:13:48 -  
1.3
+++ gnu/java/awt/peer/qt/QtGraphics.java19 Jun 2006 16:00:44 -
@@ -38,6 +38,7 @@
 package gnu.java.awt.peer.qt;
 
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -605,8 +606,16 @@
composite = comp;
   }
 else
-  throw new UnsupportedOperationException(We don't support custom+
-  composites yet.);
+  {
+   // FIXME: this check is only required if this Graphics2D
+   // context is drawing to a Component on the display screen.
+   SecurityManager sm = System.getSecurityManager();
+   if (sm != null)
+ sm.checkPermission(new AWTPermission(readDisplayPixels));
+
+   throw new UnsupportedOperationException(We don't support custom+
+composites yet.);
+  }
   }
 
   public Composite getComposite()
Index: gnu/java/awt/java2d/AbstractGraphics2D.java
===
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,v
retrieving revision 1.9
diff -u -r1.9 AbstractGraphics2D.java
--- gnu/java/awt/java2d/AbstractGraphics2D.java 9 Jun 2006 20:49:51 -   
1.9
+++ gnu/java/awt/java2d/AbstractGraphics2D.java 19 Jun 2006 16:00:45 -
@@ -39,6 +39,7 @@
 
 import java.awt.AWTError;
 import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Composite;
@@ -539,6 +540,15 @@
*/
   public void setComposite(Composite comp)
   {
+if (! (comp instanceof AlphaComposite))
+  {
+// FIXME: this check is only required if this Graphics2D
+// context is drawing to a Component on the display screen.
+SecurityManager sm = System.getSecurityManager();
+if (sm != null)
+  sm.checkPermission(new AWTPermission(readDisplayPixels));
+  }
+
 composite = comp;
 if (! (comp.equals(AlphaComposite.SrcOver)))
   isOptimized = false;


Re: [Gcjwebplugin-devel] Re: NSAPI/ OJI/ Applet plugin

2006-06-19 Thread Gary Benson
Casey Marshall wrote:
 I don't think anyone has gone through Classpath to see what
 permission checks are missing, and nor has anyone audited the
 code paths that implement these permissions. So the answer is
 that we can't say for sure if Classpath is secure or not.

Over the past few months I've been writing Mauve checks to ensure
that every permission check listed in http://tinyurl.com/o2ttz is
checked in Classpath for PR 21891.  Look for the testcases called
security.java.

Cheers,
Gary




Re: gconf needs ORBit?!

2006-06-19 Thread Gary Benson
Norman Hendrich wrote:
 Obviously, classpath cvs now depends on gconf, which depends on
 something called ORBit that I have never heard of, and that I
 don't have.

For Fedora you need to yum install ORBit2-devel.
Can't speak for other distros though.

Cheers,
Gary



Re: Graphics2D security check

2006-06-13 Thread Gary Benson
David Daney wrote:
 Roman Kennke wrote:
  Hi Gary,
  
 The setComposite method of anything that extends java.awt.
 Graphics2D is supposed to do a permisson check if ...this
 Graphics2D context is drawing to a Component on the display
 screen and the Composite is a custom object rather than an
 instance of the AlphaComposite class.  The latter is easy
 to check, but how do I tell whether the context is drawing
 to a Component on the display screen?

Only one subclass of CairoGraphics2D draws on the screen, I
think this is ComponentGraphics.
   
   Ok.  Do you know about its subclass, VolatileImageGraphics?
  
  VolatileImage doesn't draw on the screen. It draws on a backbuffer
  (an XImage really). I don't know if that counts as drawing on
  screen though.  Because the backbuffer should be synced with the
  screen sooner or later.  But maybe you try against the JDK
  (Component.createVolatileImage() gives you a VolatileImage
  instance).
 
 The check is for readDisplayPixels, so something that is not
 visible would seem to be exempt.

Yeah.  The problem is that AWT is complex enough that it's not obvious
to me which classes of which peers might allow code to get at the
pixels and which can not.  Any help in that area is much appreciated.

Cheers,
Gary




Graphics2D security check

2006-06-12 Thread Gary Benson
Hi all,

The setComposite method of anything that extends java.awt.Graphics2D
is supposed to do a permisson check if ...this Graphics2D context is
drawing to a Component on the display screen and the Composite is a
custom object rather than an instance of the AlphaComposite class.
The latter is easy to check, but how do I tell whether the context is
drawing to a Component on the display screen?

Cheers,
Gary



  1   2   >