Prevent typecast errors beans
authorJaroslav Tulach <jtulach@netbeans.org>
Mon, 04 Aug 2014 06:21:37 +0200
branchbeans
changeset 8033e33ca8c039b
parent 802 2beb865bdc54
child 804 c9774f95da96
Prevent typecast errors
json-beans/src/main/java/net/java/html/beans/JSONBeans.java
     1.1 --- a/json-beans/src/main/java/net/java/html/beans/JSONBeans.java	Sun Aug 03 22:41:36 2014 +0200
     1.2 +++ b/json-beans/src/main/java/net/java/html/beans/JSONBeans.java	Mon Aug 04 06:21:37 2014 +0200
     1.3 @@ -104,8 +104,8 @@
     1.4      }
     1.5      
     1.6      @SuppressWarnings("unchecked")
     1.7 -    static <E extends Throwable> E toRuntime(Throwable ex) {
     1.8 -        return (E)ex;
     1.9 +    static <E extends Throwable> E toRuntime(Throwable ex, Class<E> type) throws E {
    1.10 +        throw (E)ex;
    1.11      }
    1.12      
    1.13      private static final class Html4JavaType extends Proto.Type {
    1.14 @@ -144,7 +144,7 @@
    1.15                      throw ex.getCause();
    1.16                  }
    1.17              } catch (Throwable t) {
    1.18 -                throw (RuntimeException)toRuntime(t);
    1.19 +                throw toRuntime(t, RuntimeException.class);
    1.20              }
    1.21          }
    1.22  
    1.23 @@ -153,7 +153,7 @@
    1.24              try {
    1.25                  return properties[index].getReadMethod().invoke(model);
    1.26              } catch (Exception ex) {
    1.27 -                throw (RuntimeException)toRuntime(ex);
    1.28 +                throw toRuntime(ex, RuntimeException.class);
    1.29              }
    1.30          }
    1.31  
    1.32 @@ -186,7 +186,7 @@
    1.33                  findProto(clone, this, ctx);
    1.34                  return clone;
    1.35              } catch (Exception ex) {
    1.36 -                throw (RuntimeException)toRuntime(ex);
    1.37 +                throw toRuntime(ex, RuntimeException.class);
    1.38              }
    1.39          }
    1.40  
    1.41 @@ -252,7 +252,7 @@
    1.42              try {
    1.43                  addPCL.invoke(object, this);
    1.44              } catch (Exception ex) {
    1.45 -                throw (RuntimeException)toRuntime(ex);
    1.46 +                throw toRuntime(ex, RuntimeException.class);
    1.47              }
    1.48          }
    1.49