xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util ReflectionUtils.java
Date Tue, 20 Apr 2004 02:32:31 GMT
zieg        2004/04/19 19:32:31

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        MarshalResult.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal/util
                        ReflectionUtils.java
  Log:
  better error reporting for reflection errors and marshalling errors
  
  Revision  Changes    Path
  1.27      +4 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java
  
  Index: MarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- MarshalResult.java	16 Apr 2004 00:59:06 -0000	1.26
  +++ MarshalResult.java	20 Apr 2004 02:32:31 -0000	1.27
  @@ -123,7 +123,10 @@
               return (currentEventType = advanceToNext());
           }
           catch (XmlException e) {
  -            throw new XMLStreamException(e);
  +            //TODO: consider passing Location to exception ctor
  +            XMLStreamException xse = new XMLStreamException(e);
  +            xse.initCause(e);
  +            throw xse;
           }
       }
   
  
  
  
  1.6       +14 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java
  
  Index: ReflectionUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReflectionUtils.java	19 Apr 2004 06:30:36 -0000	1.5
  +++ ReflectionUtils.java	20 Apr 2004 02:32:31 -0000	1.6
  @@ -38,6 +38,7 @@
   //
   //        assert decl.isAssignableFrom(got) : "DECL=" + decl + " GOT:" + got;
   
  +        assert (checkParams(method, params));
   
           try {
               return method.invoke(target, params);
  @@ -51,6 +52,19 @@
           catch (InvocationTargetException ite) {
               throw new XmlException(ite.getTargetException());
           }
  +    }
  +
  +    private static boolean checkParams(Method method, Object[] params)
  +    {
  +        final int expected_len = method.getParameterTypes().length;
  +        final int actual_len = params == null ? 0 : params.length;
  +
  +        if (actual_len != expected_len) {
  +            String msg = "Method " + method + " expects " + expected_len +
  +                " parameters -- got " + actual_len;
  +            throw new AssertionError(msg);
  +        }
  +        return true;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message