01: package org.drools.objenesis.instantiator.gcj;
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 GCJ private methods. It is only supposed to
08: * work on GCJ JVMs. This instantiator will create classes in a way compatible with serialization,
09: * 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 GCJSerializationInstantiator extends GCJInstantiatorBase {
15: private Class super Type;
16:
17: public GCJSerializationInstantiator(final Class type) {
18: super (type);
19: this .super Type = SerializationInstantiatorHelper
20: .getNonSerializableSuperClass(type);
21: }
22:
23: public Object newInstance() {
24: try {
25: return newObjectMethod.invoke(dummyStream, new Object[] {
26: this .type, this .super Type });
27: } catch (final Exception e) {
28: throw new ObjenesisException(e);
29: }
30: }
31:
32: }
|