On Fri, Oct 13, 2006 at 10:28:04PM +0930, Trevor Glen wrote:
> Hi All,
> 
> I've been trying to get Java 1.5 running on a hppa box running ubuntu.
> So far I haven't had much luck.
> 
> Currently, I'm seeing the behaviour as described in
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28652
> 
> Has anyone had any luck with a 1.5 vm and/or classpath on a hppa linux box?

Hi!

Hm, we really should get my paperwork done...

I had a look at this, and at least the reported Exception is a pure Java
problem. (/me, vm developer, relaxes with a sly grin ;)

I attach three patches which (on top of each other) make JBoss start
without exceptions with CACAO. Unfortunately the Web console applet
still does not work.

Some comments about the patches: I actually think that in some of these
cases the callers (JBoss and Tomcat code) make invalid assumptions:

    ObjectName.toString() is assumed to return the canonical name by
    Tomcat, which is not specified according to what I found.

    javax.management.modelmbean.ModelMBeanInfoSupport assumes that
    all kinds of arrays retrieved from its superclass can be cast to
    a specific derived type. I saw that many places in GNU Classpath use
    the "new array - arraycopy" idiom to copy arrays, which probably is
    the right thing, as you end up with the most general array type that
    makes sense. JBoss code in this case assumes that array _cloning_ is
    used in the superclass constructor, so the more derived type of the
    arrays is preserved. Aaaargh! How much I like C! ;)

The third patch fixes some missing initializations, and a cast in
getKeyPropertyList which I'm not sure how to get around.

CAUTION! Take all these patches with a heap of salt. I don't know what
I'm doing in Java. ;)

-Edwin

Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.8677
diff -u -p -r1.8677 ChangeLog
--- ChangeLog   13 Oct 2006 14:41:13 -0000      1.8677
+++ ChangeLog   14 Oct 2006 10:42:04 -0000
@@ -1,3 +1,9 @@
+2006-10-14  Edwin Steiner  <[EMAIL PROTECTED]>
+
+       PR 28652
+       * javax/management/MBeanInfo.java (MBeanInfo): Use clone to
+       duplicate the arrays in order to preserve the array type.
+
 2006-10-13  Tania Bento  <[EMAIL PROTECTED]>
 
        * java/awt/ScrollPaneAdjustable.java
Index: javax/management/MBeanInfo.java
===================================================================
RCS file: /sources/classpath/classpath/javax/management/MBeanInfo.java,v
retrieving revision 1.5
diff -u -p -r1.5 MBeanInfo.java
--- javax/management/MBeanInfo.java     2 Aug 2006 21:38:08 -0000       1.5
+++ javax/management/MBeanInfo.java     14 Oct 2006 10:42:05 -0000
@@ -160,34 +160,26 @@ public class MBeanInfo
   {
     className = name;
     description = desc;
+
     if (attribs == null)
       attributes = new MBeanAttributeInfo[0];
     else
-      {
-       attributes = new MBeanAttributeInfo[attribs.length];
-       System.arraycopy(attribs, 0, attributes, 0, attribs.length);
-      }
+      attributes = (MBeanAttributeInfo[]) attribs.clone();
+
     if (cons == null)
       constructors = new MBeanConstructorInfo[0];
     else
-      {
-       constructors = new MBeanConstructorInfo[cons.length];
-       System.arraycopy(cons, 0, constructors, 0, cons.length);
-      }
+      constructors = (MBeanConstructorInfo[]) cons.clone();
+
     if (ops == null)
       operations = new MBeanOperationInfo[0];
     else
-      {
-       operations = new MBeanOperationInfo[ops.length];
-       System.arraycopy(ops, 0, operations, 0, ops.length);
-      }
+      operations = (MBeanOperationInfo[]) ops.clone();
+
     if (notifs == null)
       notifications = new MBeanNotificationInfo[0];
     else
-      {
-       notifications = new MBeanNotificationInfo[notifs.length];
-       System.arraycopy(notifs, 0, notifications, 0, notifs.length);
-      }
+      notifications = (MBeanNotificationInfo[]) notifs.clone();
   }
 
   /**
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.8677
diff -u -p -r1.8677 ChangeLog
--- ChangeLog   13 Oct 2006 14:41:13 -0000      1.8677
+++ ChangeLog   14 Oct 2006 10:42:04 -0000
@@ -1,3 +1,13 @@
+2006-10-14  Edwin Steiner  <[EMAIL PROTECTED]>
+
+       * javax/management/MBeanConstructorInfo.java
+       (MBeanConstructorInfo(String, String, MBeanParameterInfo[]): Use
+       clone to duplicate the array in order to preserve the array
+       type.
+       * javax/management/MBeanOperationInfo.java
+       (MBeanOperationInfo(String, String, MBeanParameterInfo[], ...)):
+       Likewise.
+
 2006-10-14  Edwin Steiner  <[EMAIL PROTECTED]>
 
        PR 28652
Index: javax/management/MBeanConstructorInfo.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/management/MBeanConstructorInfo.java,v
retrieving revision 1.4
diff -u -p -r1.4 MBeanConstructorInfo.java
--- javax/management/MBeanConstructorInfo.java  2 Aug 2006 21:38:08 -0000       
1.4
+++ javax/management/MBeanConstructorInfo.java  14 Oct 2006 10:42:05 -0000
@@ -105,10 +105,7 @@ public class MBeanConstructorInfo
     if (sig == null)
       signature = new MBeanParameterInfo[0];
     else
-      {
-       signature = new MBeanParameterInfo[sig.length];
-       System.arraycopy(sig, 0, signature, 0, sig.length);
-      }
+      signature = (MBeanParameterInfo[]) sig.clone();
   }
 
   /**
Index: javax/management/MBeanOperationInfo.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/management/MBeanOperationInfo.java,v
retrieving revision 1.3
diff -u -p -r1.3 MBeanOperationInfo.java
--- javax/management/MBeanOperationInfo.java    2 Aug 2006 21:38:08 -0000       
1.3
+++ javax/management/MBeanOperationInfo.java    14 Oct 2006 10:42:05 -0000
@@ -159,10 +159,7 @@ public class MBeanOperationInfo
     if (sig == null)
       signature = new MBeanParameterInfo[0];
     else
-      {
-       signature = new MBeanParameterInfo[sig.length];
-       System.arraycopy(sig, 0, signature, 0, sig.length);
-      }
+      signature = (MBeanParameterInfo[]) sig.clone();
     this.type = type;
     this.impact = impact;
   }
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.8677
diff -u -p -r1.8677 ChangeLog
--- ChangeLog   13 Oct 2006 14:41:13 -0000      1.8677
+++ ChangeLog   14 Oct 2006 10:42:04 -0000
@@ -1,3 +1,18 @@
+2006-10-14  Edwin Steiner  <[EMAIL PROTECTED]>
+
+       * javax/management/ObjectName.java (properties): Initialize in
+       all cases to avoid NullPointerExceptions.
+       (ObjectName(String)): Removed initialization of properties.
+       (ObjectName(String, String, String)): Likewise.
+       (getKeyPropertyList): Do not assume that any Map can be cast to
+       Hashtable. This had caused ClassCastExceptions.
+       (toString): Return the canonical name. Some callers expect this.
+
+       * javax/management/MBeanServerDelegate.java (listeners):
+       Initialize to avoid NullPointerExceptions.
+       (addNotificationListener): Removed obsolete check (listeners ==
+       null).
+
 2006-10-14  Edwin Steiner  <[EMAIL PROTECTED]>
 
        * javax/management/MBeanConstructorInfo.java
Index: javax/management/MBeanServerDelegate.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/management/MBeanServerDelegate.java,v
retrieving revision 1.1
diff -u -p -r1.1 MBeanServerDelegate.java
--- javax/management/MBeanServerDelegate.java   2 Oct 2006 18:28:11 -0000       
1.1
+++ javax/management/MBeanServerDelegate.java   14 Oct 2006 10:42:05 -0000
@@ -69,7 +69,7 @@ public class MBeanServerDelegate
   /**
    * The listeners registered with the delegate.
    */
-  private List listeners;
+  private List listeners = new ArrayList();
 
   /**
    * The sequence identifier used by the delegate.
@@ -120,8 +120,6 @@ public class MBeanServerDelegate
   {
     if (listener == null)
       throw new IllegalArgumentException("A null listener was supplied.");
-    if (listeners == null)
-      listeners = new ArrayList();
     listeners.add(new ListenerData(listener, filter, passback));
   }
 
Index: javax/management/ObjectName.java
===================================================================
RCS file: /sources/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.2
diff -u -p -r1.2 ObjectName.java
--- javax/management/ObjectName.java    27 Sep 2006 23:52:42 -0000      1.2
+++ javax/management/ObjectName.java    14 Oct 2006 10:42:05 -0000
@@ -105,7 +105,7 @@ public class ObjectName
   /**
    * The properties, as key-value pairs.
    */
-  private TreeMap properties;
+  private TreeMap properties = new TreeMap();
 
   /**
    * The properties as a string (stored for ordering).
@@ -164,7 +164,6 @@ public class ObjectName
          throw new MalformedObjectNameException("A name that is not a " +
                                                 "pattern must contain at " +
                                                 "least one key-value pair.");
-       properties = new TreeMap();
        for (int a = 0; a < pairs.length; ++a)
          {
            int sep = pairs[a].indexOf('=');
@@ -197,7 +196,6 @@ public class ObjectName
     throws MalformedObjectNameException
   {
     this.domain = domain;
-    properties = new TreeMap();
     properties.put(key, value);
     checkComponents();
   }
@@ -574,7 +572,7 @@ public class ObjectName
    */
   public Hashtable getKeyPropertyList()
   {
-    return (Hashtable) Collections.unmodifiableMap(new Hashtable(properties));
+    return new Hashtable(properties);
   }
 
   /**
@@ -723,11 +721,7 @@ public class ObjectName
    */
   public String toString()
   {
-    return getClass().toString() +
-      "[domain = " + domain +
-      ",properties = " + properties +
-      ",propertyPattern = " + propertyPattern +
-      "]";
+    return getCanonicalName();
   }
 
   /**

Reply via email to