Improvements in comments.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6553 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -459,18 +459,17 @@ public abstract class Streamer
|
|||||||
|
|
||||||
// obtain the constructor we'll use to create instances
|
// obtain the constructor we'll use to create instances
|
||||||
if (!isClosure) {
|
if (!isClosure) {
|
||||||
// local our zero argument constructor
|
// locate our zero argument constructor
|
||||||
_ctorArgs = ArrayUtil.EMPTY_OBJECT;
|
|
||||||
for (Constructor<?> ctor : _target.getDeclaredConstructors()) {
|
for (Constructor<?> ctor : _target.getDeclaredConstructors()) {
|
||||||
if (ctor.getParameterTypes().length == 0) {
|
if (ctor.getParameterTypes().length == 0) {
|
||||||
_ctor = ctor;
|
_ctor = ctor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ctorArgs = ArrayUtil.EMPTY_OBJECT;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// a closure should have only one constructor, and we're going to pass bogus
|
// a closure should have only one constructor
|
||||||
// arguments to it (because unstreaming will take care of further initialization)
|
|
||||||
Constructor<?>[] ctors = _target.getDeclaredConstructors();
|
Constructor<?>[] ctors = _target.getDeclaredConstructors();
|
||||||
if (ctors.length > 1) {
|
if (ctors.length > 1) {
|
||||||
throw new RuntimeException("Streamable closure classes must have only " +
|
throw new RuntimeException("Streamable closure classes must have only " +
|
||||||
@@ -478,6 +477,9 @@ public abstract class Streamer
|
|||||||
}
|
}
|
||||||
_ctor = ctors[0];
|
_ctor = ctors[0];
|
||||||
_ctor.setAccessible(true);
|
_ctor.setAccessible(true);
|
||||||
|
|
||||||
|
// we pass bogus arguments to it (because unstreaming will overwrite our bogus
|
||||||
|
// values with the real values)
|
||||||
Class<?>[] ptypes = _ctor.getParameterTypes();
|
Class<?>[] ptypes = _ctor.getParameterTypes();
|
||||||
_ctorArgs = new Object[ptypes.length];
|
_ctorArgs = new Object[ptypes.length];
|
||||||
for (int ii = 0; ii < ptypes.length; ii++) {
|
for (int ii = 0; ii < ptypes.length; ii++) {
|
||||||
@@ -485,6 +487,8 @@ public abstract class Streamer
|
|||||||
_ctorArgs[ii] = ZEROS.get(ptypes[ii]);
|
_ctorArgs[ii] = ZEROS.get(ptypes[ii]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure we found a constructor
|
||||||
if (_ctor == null) {
|
if (_ctor == null) {
|
||||||
throw new RuntimeException("Unable to find applicable ctor " +
|
throw new RuntimeException("Unable to find applicable ctor " +
|
||||||
"[class=" + _target.getName() + "]");
|
"[class=" + _target.getName() + "]");
|
||||||
|
|||||||
Reference in New Issue
Block a user