This commit is contained in:
@@ -31,7 +31,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
|
||||
protected Creator<T> creator;
|
||||
|
||||
protected DeMember<R, T, ?>[] creatorConstructorMembers;
|
||||
protected DeMember<R, T, ?>[] creatorConstructorMembers = new DeMember[0];
|
||||
|
||||
protected DeMember<R, T, ?>[] members;
|
||||
|
||||
@@ -82,9 +82,10 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
} else {
|
||||
clazz = (Class) type;
|
||||
}
|
||||
this.creator = factory.loadCreator(clazz);
|
||||
if (this.creator == null) throw new ConvertException("Cannot create a creator for " + clazz);
|
||||
|
||||
if (!clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers())) {
|
||||
this.creator = factory.loadCreator(clazz);
|
||||
if (this.creator == null) throw new ConvertException("Cannot create a creator for " + clazz);
|
||||
}
|
||||
final Set<DeMember> list = new HashSet();
|
||||
final String[] cps = ObjectEncoder.findConstructorProperties(this.creator);
|
||||
try {
|
||||
@@ -202,6 +203,13 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.creator == null) {
|
||||
synchronized (lock) {
|
||||
if (this.creator == null) {
|
||||
this.creator = factory.loadCreator(this.typeClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.creatorConstructorMembers == null) { //空构造函数
|
||||
final T result = this.creator.create();
|
||||
while (in.hasNext()) {
|
||||
|
||||
@@ -215,6 +215,7 @@ public final class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T
|
||||
}
|
||||
|
||||
static String[] findConstructorProperties(Creator creator) {
|
||||
if (creator == null) return null;
|
||||
try {
|
||||
ConstructorParameters cps = creator.getClass().getMethod("create", Object[].class).getAnnotation(ConstructorParameters.class);
|
||||
return cps == null ? null : cps.value();
|
||||
|
||||
Reference in New Issue
Block a user