classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] Patch: improve error handling in String


From: Anthony Green
Subject: [cp-patches] Patch: improve error handling in String
Date: Wed, 14 Sep 2005 18:02:11 -0700

If we get to an impossible situation, then we should throw an Error
instead of silently trying to continue.  This also quiets FindBugs,
which says this method should never return null.

Ok?

AG



2005-09-14  Anthony Green  <address@hidden>

        * java/lang/String.java (getBytes): Throw an Error instead of
        silently returning null.


Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.70
diff -u -r1.70 String.java
--- java/lang/String.java       13 Sep 2005 22:19:15 -0000      1.70
+++ java/lang/String.java       15 Sep 2005 00:19:16 -0000
@@ -641,8 +641,8 @@
          throw new UnsupportedEncodingException("Encoding: "+enc+
                                                 " not found.");
       } catch(CharacterCodingException e){
-         // XXX - Ignore coding exceptions? They shouldn't really happen.
-         return null;
+         // This shouldn't really happen.
+         throw new Error(e);
       }          
   }
 






reply via email to

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