classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] [generics] Enum#valueOf implementation


From: Ewout Prangsma
Subject: [cp-patches] [generics] Enum#valueOf implementation
Date: Sun, 24 Jul 2005 10:06:21 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Thanks Robert for reminding me.
Here's the unified diff.

Again my question if someone can commit this, or give me CVS access rights.

Ewout

Robert Schuster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Ewout,
welcome onboard!

(Looks like Mark should add Savannah user epr to the project.)

Your 'patch' does not really look like a unified diff. What you send to
classpath-patches should be:
- - a unified diff of all the changes source code files, scripts etc (not
the ChangeLog) as an attachment
- - a ChangeLog entry describing all the details (describe what was done
not why)

We have a detailed Patch Submission Guide[0] in our mediation wiki. Have
a look at it.

cu
Robert

[0] -
http://developer.classpath.org/mediation/ClasspathFirstSteps#head-a8b2520531202f1acefb9cb1c8b540999e4eaf21


Ewout Prangsma wrote:
  
I've implemented java.lang.Enum#valueOf in the generics branch.

Can someone with CVS access verify and commit this.

PS. My FSF paperwork is all done.

Thanks
Ewout


 @SuppressWarnings("unchecked")
 public static <S extends Enum<S>> Enum valueOf(Class<S> etype, String s) {
       if (etype == null || s == null)
           throw new NullPointerException();
       try {
           return (S) etype.getDeclaredField(s).get(null);
       } catch (NoSuchFieldException exception) {
           throw new IllegalArgumentException(s);
       } catch (IllegalAccessException exception) {
           throw new Error("Unable to access Enum class");
       }
   }



_______________________________________________
Classpath-patches mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/classpath-patches


    
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFC4ZQwG9cfwmwwEtoRArszAJ0WQprbEl9CLqtPoOVPfMl1Y7ImVACfaAcQ
ZhbgazmSB41BNcRmz3MgQ+0=
=rSv+
-----END PGP SIGNATURE-----
  
--- java\lang\Enum.java Mon Mar 21 14:10:17 2005
+++ ..\jnode\core\src\classpath\5.0\java\lang\Enum.java Fri Jul 22 19:37:59 2005
@@ -38,6 +38,8 @@
 package java.lang;
 
 import java.io.Serializable;
+import java.io.ObjectInputStream.GetField;
+import java.lang.reflect.InvocationTargetException;
 
 /**
  * @since 1.5
@@ -60,12 +62,19 @@
     this.ordinal = ordinal;
   }
 
-  public static <S extends Enum<S>> Enum valueOf(Class<S> etype, String s)
-  {
-    if (etype == null || s == null)
-      throw new NullPointerException();
-    return null;               // FIXME
-  }
+  // @classpath-bugfix   Implemented this method
+  @SuppressWarnings("unchecked")
+  public static <S extends Enum<S>> Enum valueOf(Class<S> etype, String s) {
+        if (etype == null || s == null)
+            throw new NullPointerException();
+        try {
+            return (S) etype.getDeclaredField(s).get(null);
+        } catch (NoSuchFieldException exception) {
+            throw new IllegalArgumentException(s);
+        } catch (IllegalAccessException exception) {
+            throw new Error("Unable to access Enum class");
+        }
+    }
 
   public final boolean equals(Object o)
   {

reply via email to

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