[cp-patches] FYI: Genericise gnu.javax.management.Translator

2008-08-25 Thread Andrew John Hughes
This patch fixes generic warnings from the JMX translator.

ChangeLog:

2008-08-26  Andrew John Hughes  <[EMAIL PROTECTED]>

* gnu/javax/management/Translator.java:
Genericised.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: gnu/javax/management/Translator.java
===
RCS file: /sources/classpath/classpath/gnu/javax/management/Translator.java,v
retrieving revision 1.6
diff -u -u -r1.6 Translator.java
--- gnu/javax/management/Translator.java21 Feb 2008 19:59:57 -  
1.6
+++ gnu/javax/management/Translator.java26 Aug 2008 00:15:14 -
@@ -143,14 +143,14 @@
  throw new IllegalArgumentException(jtype + " has a " +
 "non-comparable element " +
 "type, " + elemClass);
-   if (((SortedSet) jtype).comparator() != null)
+   if (((SortedSet) jtype).comparator() != null)
  throw new IllegalArgumentException(jtype + " does not " +
 "use natural ordering.");
  }
-   Collection elems = (Collection) jtype;
+   Collection elems = (Collection) jtype;
int numElems = elems.size();
Object[] celems = new Object[numElems];
-   Iterator i = elems.iterator();
+   Iterator i = elems.iterator();
for (int a = 0; a < numElems; ++a)
  {
Object elem = i.next();
@@ -159,7 +159,7 @@
return makeArraySpecific(celems);
   }
 if (jtype instanceof Enum)
-  return ((Enum) jtype).name();
+  return ((Enum) jtype).name();
 if (jtype instanceof Map || jtype instanceof SortedMap)
   {
int lparam = tName.indexOf("<");
@@ -177,13 +177,13 @@
  throw new IllegalArgumentException(jtype + " has a " +
 "non-comparable element " +
 "type, " + keyClass);
-   if (((SortedMap) jtype).comparator() != null)
+   if (((SortedMap) jtype).comparator() != null)
  throw new IllegalArgumentException(jtype + " does not " +
 "use natural ordering.");
typeName = "java.util.SortedMap" + tName.substring(lparam);
  }
-   OpenType k = translate(key).getOpenType();
-   OpenType v = translate(value).getOpenType(); 
+   OpenType k = translate(key).getOpenType();
+   OpenType v = translate(value).getOpenType(); 
CompositeType rowType = new CompositeType(typeName, typeName,
  new String[] { "key", "value" 
},
  new String[] { "Map key", 
"Map value"},
@@ -191,7 +191,7 @@
TabularType tabType = new TabularType(typeName, typeName, rowType,
  new String[]{"key"});
TabularData data = new TabularDataSupport(tabType);
-   for (Map.Entry entry : (Set) ((Map) jtype).entrySet())
+   for (Map.Entry entry : ((Map) jtype).entrySet())
  {
try 
  {
@@ -258,15 +258,15 @@
 if (returnType.isEnum())
   {
String ename = (String) otype;
-   Enum[] constants = (Enum[]) returnType.getEnumConstants();
-   for (Enum c : constants)
+   Enum[] constants = (Enum[]) returnType.getEnumConstants();
+   for (Enum c : constants)
  if (c.name().equals(ename))
return c;
   }
 if (List.class.isAssignableFrom(returnType))
   {
Object[] elems = (Object[]) otype;
-   List l = new ArrayList(elems.length);
+   List l = new ArrayList(elems.length);
for (Object elem : elems)
  l.add(elem);
return l;
@@ -274,7 +274,7 @@
 if (Map.class.isAssignableFrom(returnType))
   {
TabularData data = (TabularData) otype;
-   Map m = new HashMap(data.size());
+   Map m = new HashMap(data.size());
for (Object val : data.values())
  {
CompositeData vals = (CompositeData) val;
@@ -401,8 +401,8 @@
int comma = type.indexOf(",", lparam);
int rparam = type.indexOf(">", comma);
String key = type.substring(lparam + 1, comma).trim();
-   OpenType k = translate(key).getOpenType();
-   OpenType v = translate(type.substring(comma + 1, 
rparam).trim()).getOpenType(); 
+   OpenType k = translate(key).getOpenType();
+   OpenType v = translate(type.substring(comma + 1, 
rparam).trim()).getOpenType(); 
CompositeType ctype = new CompositeType(Map.class.getName(), 
Map.class.getName(),
new String[] { "

[cp-patches] FYI: More warning fixes

2008-08-25 Thread Andrew John Hughes
As the subject says.

ChangeLog:

2008-08-26  Andrew John Hughes  <[EMAIL PROTECTED]>

* javax/management/DefaultLoaderRepository.java,
* javax/management/JMX.java,
* javax/management/MBeanAttributeInfo.java,
* javax/management/MBeanConstructorInfo.java,
* javax/management/MBeanOperationInfo.java,
* javax/management/MBeanServerDelegate.java:
Fix warnings due to generics.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: javax/management/DefaultLoaderRepository.java
===
RCS file: 
/sources/classpath/classpath/javax/management/DefaultLoaderRepository.java,v
retrieving revision 1.2
diff -u -u -r1.2 DefaultLoaderRepository.java
--- javax/management/DefaultLoaderRepository.java   16 Jan 2007 21:25:28 
-  1.2
+++ javax/management/DefaultLoaderRepository.java   25 Aug 2008 23:28:53 
-
@@ -77,6 +77,8 @@
* @throws ClassNotFoundException if all the class loaders fail
*to load the class.
*/
+  // API issue with lack of  on Class
+  @SuppressWarnings("unchecked")
   public static Class loadClass(String name)
 throws ClassNotFoundException
   {
@@ -124,6 +126,8 @@
* @throws ClassNotFoundException if all the class loaders fail
*to load the class.
*/
+  // API issue with lack of  on Class
+  @SuppressWarnings("unchecked")
   public static Class loadClassWithout(ClassLoader exclude, String name)
 throws ClassNotFoundException
   {
Index: javax/management/JMX.java
===
RCS file: /sources/classpath/classpath/javax/management/JMX.java,v
retrieving revision 1.2
diff -u -u -r1.2 JMX.java
--- javax/management/JMX.java   1 Apr 2007 16:34:14 -   1.2
+++ javax/management/JMX.java   25 Aug 2008 23:28:53 -
@@ -324,6 +324,8 @@
* server using the given name.
* @see #newMXBeanProxy(MBeanServerConnection, ObjectName, Class)
*/
+  // Suppress warnings as we know an instance of T will be returned.
+  @SuppressWarnings("unchecked")
   public static  T newMXBeanProxy(MBeanServerConnection conn,
ObjectName name, Class iface,
boolean bcast)
Index: javax/management/MBeanAttributeInfo.java
===
RCS file: 
/sources/classpath/classpath/javax/management/MBeanAttributeInfo.java,v
retrieving revision 1.5
diff -u -u -r1.5 MBeanAttributeInfo.java
--- javax/management/MBeanAttributeInfo.java6 Apr 2007 21:03:27 -   
1.5
+++ javax/management/MBeanAttributeInfo.java25 Aug 2008 23:28:55 -
@@ -117,7 +117,7 @@
   {
Type t = setter.getGenericParameterTypes()[0];
if (t instanceof Class)
- attributeType = ((Class) t).getName();
+ attributeType = ((Class) t).getName();
else
  attributeType = t.toString();
isRead = false;
@@ -127,7 +127,7 @@
   {
Type t = getter.getGenericReturnType();
if (t instanceof Class)
- attributeType = ((Class) t).getName();
+ attributeType = ((Class) t).getName();
else
  attributeType = t.toString();
isRead = true;
Index: javax/management/MBeanConstructorInfo.java
===
RCS file: 
/sources/classpath/classpath/javax/management/MBeanConstructorInfo.java,v
retrieving revision 1.6
diff -u -u -r1.6 MBeanConstructorInfo.java
--- javax/management/MBeanConstructorInfo.java  11 Dec 2006 01:54:39 -  
1.6
+++ javax/management/MBeanConstructorInfo.java  25 Aug 2008 23:28:55 -
@@ -75,6 +75,8 @@
* @param desc a description of the attribute.
* @param cons the constructor.
*/
+  // API issue with lack of  on Constructor
+  @SuppressWarnings("unchecked")
   public MBeanConstructorInfo(String desc, Constructor cons)
   {
 super(cons.getName(), desc);
@@ -85,7 +87,7 @@
Type t = paramTypes[a];
if (t instanceof Class)
  signature[a] = new MBeanParameterInfo(null,
-   ((Class) t).getName(),
+   ((Class) t).getName(),
null);
else
  signature[a] = new MBeanParameterInfo(null, t.toString(), null);
Index: javax/management/MBeanOperationInfo.java
===
RCS file: 
/sources/classpath/classpath/javax/management/MBeanOperationInfo.java,v
retrieving revision 1.5
diff -u -u -r1.5 MBeanOperationInfo.java
--- javax/management/MBeanOperationInfo.java1

[cp-patches] FYI: Another generic collections fix

2008-08-25 Thread Andrew John Hughes
This patch fixes a number of classes in javax.management, so
they use generic collections:

ChangeLog:

2008-08-25  Andrew John Hughes  <[EMAIL PROTECTED]>

* javax/management/MBeanPermission.java,
* javax/management/MBeanServerDelegate.java,
* javax/management/MBeanServerFactory.java,
* javax/management/MBeanServerInvocationHandler.java,
* javax/management/MBeanServerPermission.java:
Fix warnings due to use of non-generic collections.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: javax/management/MBeanPermission.java
===
RCS file: /sources/classpath/classpath/javax/management/MBeanPermission.java,v
retrieving revision 1.2
diff -u -u -r1.2 MBeanPermission.java
--- javax/management/MBeanPermission.java   7 Jan 2008 21:11:26 -   
1.2
+++ javax/management/MBeanPermission.java   25 Aug 2008 21:25:58 -
@@ -37,6 +37,8 @@
 
 package javax.management;
 
+import gnu.java.lang.CPStringBuilder;
+
 import java.security.Permission;
 
 import java.io.IOException;
@@ -154,19 +156,19 @@
   /**
* The list of actions as an ordered set.
*/
-  private transient Set actionSet;
+  private transient Set actionSet;
 
   /**
* The set of valid actions.
*/
-  private static final Set validSet;
+  private static final Set validSet;
 
   /**
* Initialise the set of valid actions.
*/
   static 
   {
-validSet = new HashSet();
+validSet = new HashSet();
 validSet.add("addNotificationListener");
 validSet.add("getAttribute");
 validSet.add("getClassLoader");
@@ -263,8 +265,8 @@
*/
   public String getActions()
   {
-Iterator it = actionSet.iterator();
-StringBuilder builder = new StringBuilder();
+Iterator it = actionSet.iterator();
+CPStringBuilder builder = new CPStringBuilder();
 while (it.hasNext())
   {
builder.append(it.next());
@@ -323,10 +325,8 @@
NameHolder name = new NameHolder(getName());
if (!(name.equals(pName)))
  return false;
-   Iterator i = mp.getActionSet().iterator();
-   while (i.hasNext())
+   for (String nextAction : mp.actionSet)
  {
-   String nextAction = (String) i.next();
boolean found = actions.contains(nextAction);
if (!found)
  if (nextAction.equals("queryNames"))
@@ -502,23 +502,13 @@
   }
 
   /**
-   * Returns the set of actions.
-   *
-   * @return the actions as an ordered set.
-   */
-  Set getActionSet()
-  {
-return actionSet;
-  }
-
-  /**
* Updates the action set from the current value of
* the actions string.
*/
   private void updateActionSet()
   {
 String[] actionsArray = actions.split(",");
-actionSet = new TreeSet();
+actionSet = new TreeSet();
 for (int a = 0; a < actionsArray.length; ++a)
   actionSet.add(actionsArray[a].trim());
   }
@@ -548,10 +538,8 @@
*/
   private void checkActions()
   {
-Iterator it = actionSet.iterator();
-while (it.hasNext())
+for (String action : actionSet)
   {
-   String action = (String) it.next();
if (!(validSet.contains(action)))
  throw new IllegalArgumentException("Invalid action " 
 + action + " found.");
Index: javax/management/MBeanServerDelegate.java
===
RCS file: 
/sources/classpath/classpath/javax/management/MBeanServerDelegate.java,v
retrieving revision 1.3
diff -u -u -r1.3 MBeanServerDelegate.java
--- javax/management/MBeanServerDelegate.java   16 Feb 2007 17:47:09 -  
1.3
+++ javax/management/MBeanServerDelegate.java   25 Aug 2008 21:25:58 -
@@ -69,7 +69,8 @@
   /**
* The listeners registered with the delegate.
*/
-  private final List listeners = new ArrayList();
+  private final List listeners =
+new ArrayList();
 
   /**
* The sequence identifier used by the delegate.
@@ -293,10 +294,8 @@
   {
 if (notification.getSequenceNumber() <= 0)
   notification.setSequenceNumber(++seqNo);
-Iterator it = listeners.iterator();
-while (it.hasNext())
+for (ListenerData ldata : listeners)
   {
-   ListenerData ldata = (ListenerData) it.next();
NotificationFilter filter = ldata.getFilter();
if (filter == null || filter.isNotificationEnabled(notification))
  ldata.getListener().handleNotification(notification, 
ldata.getPassback());
Index: javax/management/MBeanServerFactory.java
===
RCS file: 
/sources/classpath/classpath/javax/management/MBeanServerFactory.java,v
retrieving revision 1.6
diff -u -u -r1.6 MBeanServerFactory.java
--- java

[cp-patches] FYI: more corba fixlets

2008-08-25 Thread Mario Torre
Hello all!

This patch fix another NPE in our CORBA implementation.

Committed.

Thanks,
Mario


2008-08-25  Mario Torre  <[EMAIL PROTECTED]>

* gnu/javax/rmi/CORBA/RmiUtilities.java (readValue): check if sender is
null to avoid NPE.
### Eclipse Workspace Patch 1.0
#P classpath
Index: gnu/javax/rmi/CORBA/RmiUtilities.java
===
RCS file: /sources/classpath/classpath/gnu/javax/rmi/CORBA/RmiUtilities.java,v
retrieving revision 1.3
diff -u -r1.3 RmiUtilities.java
--- gnu/javax/rmi/CORBA/RmiUtilities.java	5 May 2008 22:21:17 -	1.3
+++ gnu/javax/rmi/CORBA/RmiUtilities.java	25 Aug 2008 15:15:00 -
@@ -702,13 +702,14 @@
 if (in instanceof HeadlessInput)
   ((HeadlessInput) in).subsequentCalls = true;
 
-gnuRuntime g;
+gnuRuntime g = null;
 Serializable object = null;
 
 try
   {
 g = (gnuRuntime) sender;
-object = g.target;
+if (sender != null)
+  object = g.target;
   }
 catch (ClassCastException e)
   {