axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Jordahl <>
Subject RE: deserialization of final fields
Date Fri, 03 May 2002 17:41:39 GMT


I have a fix for this that ignores final fields in JavaBeans when constructing the BeanPropertyDescriptors.
 I believe this will prevent the fields from getting serialized in the first place, so Axis
will not attempt to Deserialize them.

Please try out either the latest CVS build or Mondays nightly build and let me know if this
solves your issue.


Tom Jordahl

-----Original Message-----
From: Narve Saetre []
Sent: Friday, May 03, 2002 12:34 PM
Subject: deserialization of final fields

It seems the BeanDeserializer does not take into account that fields may 
be final (you get a java.lang.IllegalAccessException when you try to set 
the value). I see that several people (well, at least two) have asked 
about this in the user mailing list.

An easy fix is to add

             } catch (java.lang.IllegalAccessException ex) {
             	// Final field - Ignore

on line 113 of (From beta-2, that is, the 
complete method is shown at the bottom).

This is probably not the best solution (one should check whether the 
field is final before one even try to set the value), and it may not 
even be suitable for all purposes, but it works for me and I'll keep the 
change locally until this issue is resolved.

Please, if anybody has better solutions post them here (or update the 



--- from ---

     public void set(Object value) throws SAXException {
         try {
             if (index < 0)
                 pd.set(object, value);
                 pd.set(object, index, value);
         } catch (Exception e) {
             Class type = pd.getType();
             value = JavaUtils.convert(value, type);
             try {
                 if (index < 0)
                     pd.set(object, value);
                     pd.set(object, index, value);
             } catch (java.lang.IllegalAccessException ex) {
             	// Final field - Ignore
             } catch (Exception ex) {
                 String field= pd.getName();
                 int i = 0;
                 if (index >=0) {
                     field += "[" + index + "]";
                     i = 1;
                 if (log.isErrorEnabled()) {
                     String valueType = "null";
                     if (value != null)
                         valueType = value.getClass().getName();
                                                    new String[] {
                 throw new SAXException(ex);

View raw message