Mantis - Resin
Viewing Issue Advanced Details
134 minor always 05-04-05 00:00 02-03-06 09:54
user154  
ferg  
normal  
closed  
3.0.12 fixed  
none    
none 3.0.18  
0000134: Hessian Deserializer and constructors
RSN-125
Hi,

it seems that the deserializer of hessian chooses the constructor undeterminsticily. We have a class with a private default constructor (it's not allowed to call it despite hessian) and a constructor with a pointer argument. On some systems hessian chooses the correct default constructor and on others the wrong constructor with argument. On the faulty systems it helped, if we change the visibility to public, why ever.

I don't understand the code in "com.caucho.hessian.io.JavaDeserializer.java". There I can find:

Constructor []constructors = cl.getDeclaredConstructors();
int bestLength = Integer.MAX_VALUE;

[...]
for (int i = 0; i < constructors.length; i++) {
  if (constructors[i].getParameterTypes().length < bestLength) {
    _constructor = constructors[i];
    bestLength = _constructor.getParameterTypes().length;
  }
}
[...]

This is not deterministic (a new constructor with fewer args will always be choosen), and the constructor arguments are only guessed afterwards (with null).

Why doesn't hessian use "__type.newInstance()" all the time?

Ciao,

  Marc Ewert
JDK 1.4.2

Notes
(0000160)
user154   
05-04-05 00:00   
if there are several constructors with the same number of parameters, than the choosen constructor is indetermistic choosen, depending on plattform and runtime environment (If they are the constructors with the smallest number of parameters).
(0000860)
ferg   
02-03-06 09:54   
ejb/331[7-9]