01: package org.drools.objenesis.instantiator.sun;
02:
03: import org.drools.objenesis.ObjenesisException;
04: import org.drools.objenesis.instantiator.SerializationInstantiatorHelper;
05:
06: /**
07: * Instantiates a class by making a call to internal Sun private methods. It is only supposed to
08: * work on Sun HotSpot 1.3 JVM. This instantiator will create classes in a way compatible with
09: * serialization, calling the first non-serializable superclass' no-arg constructor.
10: *
11: * @author Leonardo Mesquita
12: * @see org.drools.objenesis.instantiator.ObjectInstantiator
13: */
14: public class Sun13SerializationInstantiator extends
15: Sun13InstantiatorBase {
16: private final Class super Type;
17:
18: public Sun13SerializationInstantiator(final Class type) {
19: super (type);
20: this .super Type = SerializationInstantiatorHelper
21: .getNonSerializableSuperClass(type);
22: }
23:
24: public Object newInstance() {
25: try {
26: return allocateNewObjectMethod.invoke(null, new Object[] {
27: this .type, this .super Type });
28: } catch (final Exception e) {
29: throw new ObjenesisException(e);
30: }
31: }
32:
33: }
|