classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: FYI: some beans, Proxy


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: FYI: some beans, Proxy
Date: 09 Oct 2004 18:00:31 -0600

This updates a couple classes in java.beans, plus Proxy.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>
        * java/beans/EventHandler.java (create): Now generic methods.
        * java/beans/Beans.java (getInstanceOf): Updated argument type.
        (isInstanceOf): Likewise.
        * java/beans/BeanDescriptor.java (beanClass, customizerClass):
        Updated type.
        (BeanDescriptor): Updated argument types.
        (getBeanClass, getCustomizerClass): Updated return types.

        * java/lang/reflect/Proxy.java (getProxyClass): Updated argument
        and return types.
        (isProxyClass): Likewise.
        (newProxyInstance): Likewise.

Index: java/beans/BeanDescriptor.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/beans/BeanDescriptor.java,v
retrieving revision 1.7
diff -u -r1.7 BeanDescriptor.java
--- java/beans/BeanDescriptor.java 8 Mar 2004 23:15:49 -0000 1.7
+++ java/beans/BeanDescriptor.java 10 Oct 2004 00:01:04 -0000
@@ -48,14 +48,14 @@
  **/
 
 public class BeanDescriptor extends FeatureDescriptor {
-       Class beanClass;
-       Class customizerClass;
+       Class<?> beanClass;
+       Class<?> customizerClass;
 
        /** Create a new BeanDescriptor with the given beanClass and
         ** no customizer class.
         ** @param beanClass the class of the Bean.
         **/
-       public BeanDescriptor(Class beanClass) {
+       public BeanDescriptor(Class<?> beanClass) {
                this(beanClass,null);
        }
 
@@ -64,7 +64,7 @@
         ** @param beanClass the class of the Bean.
         ** @param customizerClass the class of the Bean's Customizer.
         **/
-       public BeanDescriptor(Class beanClass, Class customizerClass) {
+       public BeanDescriptor(Class beanClass<?>, Class<?> customizerClass) {
                this.beanClass = beanClass;
                this.customizerClass = customizerClass;
 
@@ -78,12 +78,12 @@
        }
 
        /** Get the Bean's class. **/
-       public Class getBeanClass() {
+       public Class<?> getBeanClass() {
                return beanClass;
        }
 
        /** Get the Bean's customizer's class. **/
-       public Class getCustomizerClass() {
+       public Class<?> getCustomizerClass() {
                return customizerClass;
        }
 }
Index: java/beans/Beans.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/beans/Beans.java,v
retrieving revision 1.9
diff -u -r1.9 Beans.java
--- java/beans/Beans.java 17 Mar 2003 16:28:50 -0000 1.9
+++ java/beans/Beans.java 10 Oct 2004 00:01:05 -0000
@@ -1,5 +1,5 @@
 /* java.beans.Beans
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -189,7 +189,7 @@
    * @return the Bean as a new view, or if the operation
    *         could not be performed, the Bean itself.
    */
-  public static Object getInstanceOf(Object bean, Class newClass)
+  public static Object getInstanceOf(Object bean, Class<?> newClass)
   {
     return bean;
   }
@@ -208,7 +208,7 @@
    * @return whether the Bean can be cast to the class type
    *         in question.
    */
-  public static boolean isInstanceOf(Object bean, Class newBeanClass)
+  public static boolean isInstanceOf(Object bean, Class<?> newBeanClass)
   {
     return newBeanClass.isInstance(bean);
   }
Index: java/beans/EventHandler.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/beans/EventHandler.java,v
retrieving revision 1.1
diff -u -r1.1 EventHandler.java
--- java/beans/EventHandler.java 17 Jul 2004 07:24:26 -0000 1.1
+++ java/beans/EventHandler.java 10 Oct 2004 00:01:07 -0000
@@ -301,7 +301,8 @@
    * @param action Target property or method to invoke.
    * @return A constructed proxy object.
    */
-  public static Object create(Class listenerInterface, Object target, String 
action)
+  public static <T> T create(Class<T> listenerInterface, Object target,
+                            String action)
   {
     return create(listenerInterface, target, action, null, null);
   }
@@ -322,8 +323,8 @@
    * @param eventPropertyName Name of property to extract from event.
    * @return A constructed proxy object.
    */
-  public static Object create(Class listenerInterface, Object target,
-                             String action, String eventPropertyName)
+  public static <T> T create(Class<T> listenerInterface, Object target,
+                            String action, String eventPropertyName)
   {
     return create(listenerInterface, target, action, eventPropertyName, null);
   }
@@ -371,9 +372,9 @@
    * @param listenerMethodName Listener method to implement.
    * @return A constructed proxy object.
    */
-  public static Object create(Class listenerInterface, Object target,
-                             String action, String eventPropertyName,
-                             String listenerMethodName)
+  public static <T> T create(Class<T> listenerInterface, Object target,
+                            String action, String eventPropertyName,
+                            String listenerMethodName)
   {
     // Create EventHandler instance
     EventHandler eh = new EventHandler(target, action, eventPropertyName,
@@ -381,10 +382,9 @@
 
     // Create proxy object passing in the event handler
     Object proxy = Proxy.newProxyInstance(listenerInterface.getClassLoader(),
-                                         new Class[] {listenerInterface},
+                                         new Class<?>[] {listenerInterface},
                                          eh);
 
-    return proxy;
+    return (T) proxy;
   }
-
 }
Index: java/lang/reflect/Proxy.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/reflect/Proxy.java,v
retrieving revision 1.13
diff -u -r1.13 Proxy.java
--- java/lang/reflect/Proxy.java 10 Jul 2004 07:54:29 -0000 1.13
+++ java/lang/reflect/Proxy.java 10 Oct 2004 00:01:17 -0000
@@ -1,5 +1,5 @@
 /* Proxy.java -- build a proxy class that implements reflected interfaces
-   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -155,7 +155,7 @@
  * @see Class
  * @author Eric Blake <address@hidden>
  * @since 1.3
- * @status updated to 1.4, except for the use of ProtectionDomain
+ * @status updated to 1.5, except for the use of ProtectionDomain
  */
 public class Proxy implements Serializable
 {
@@ -254,8 +254,8 @@
    */
   // synchronized so that we aren't trying to build the same class
   // simultaneously in two threads
-  public static synchronized Class getProxyClass(ClassLoader loader,
-                                                 Class[] interfaces)
+  public static synchronized Class<?> getProxyClass(ClassLoader loader,
+                                                   Class<?>... interfaces)
   {
     interfaces = (Class[]) interfaces.clone();
     ProxyType pt = new ProxyType(loader, interfaces);
@@ -309,7 +309,7 @@
    * @see Constructor#newInstance(Object[])
    */
   public static Object newProxyInstance(ClassLoader loader,
-                                        Class[] interfaces,
+                                        Class<?>[] interfaces,
                                         InvocationHandler handler)
   {
     try
@@ -357,7 +357,7 @@
    */
   // This is synchronized on the off chance that another thread is
   // trying to add a class to the map at the same time we read it.
-  public static synchronized boolean isProxyClass(Class clazz)
+  public static synchronized boolean isProxyClass(Class<?> clazz)
   {
     if (! Proxy.class.isAssignableFrom(clazz))
       return false;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]