This commit is contained in:
@@ -49,7 +49,7 @@ public interface Creator<T> {
|
||||
}
|
||||
Constructor<T> constructor = null;
|
||||
for (Constructor c : clazz.getConstructors()) {
|
||||
if (c.getParameterCount() == 0) {
|
||||
if (c.getParameterTypes().length == 0) { //为了兼容android 而不使用 getParameterCount()
|
||||
constructor = c;
|
||||
break;
|
||||
}
|
||||
@@ -93,8 +93,8 @@ public interface Creator<T> {
|
||||
mv.visitTypeInsn(NEW, interName);
|
||||
mv.visitInsn(DUP);
|
||||
//---------------------------------------
|
||||
Class[] params = constructor.getParameterTypes();
|
||||
{
|
||||
Parameter[] params = constructor.getParameters();
|
||||
final int[] iconsts = {ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5};
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
mv.visitVarInsn(ALOAD, 1);
|
||||
@@ -104,7 +104,7 @@ public interface Creator<T> {
|
||||
mv.visitIntInsn(BIPUSH, i);
|
||||
}
|
||||
mv.visitInsn(AALOAD);
|
||||
final Class ct = params[i].getType();
|
||||
final Class ct = params[i];
|
||||
if (ct.isPrimitive()) {
|
||||
final Class bigct = Array.get(Array.newInstance(ct, 1), 0).getClass();
|
||||
mv.visitTypeInsn(CHECKCAST, bigct.getName().replace('.', '/'));
|
||||
@@ -122,7 +122,7 @@ public interface Creator<T> {
|
||||
//---------------------------------------
|
||||
mv.visitMethodInsn(INVOKESPECIAL, interName, "<init>", Type.getConstructorDescriptor(constructor), false);
|
||||
mv.visitInsn(ARETURN);
|
||||
mv.visitMaxs((constructor.getParameterCount() > 0 ? (constructor.getParameterCount() + 3) : 2), 2);
|
||||
mv.visitMaxs((params.length > 0 ? (params.length + 3) : 2), 2);
|
||||
mv.visitEnd();
|
||||
}
|
||||
{ //虚拟 create 方法
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface Reproduce<D, S> {
|
||||
|
||||
for (java.lang.reflect.Method getter : srcClass.getMethods()) {
|
||||
if (Modifier.isStatic(getter.getModifiers())) continue;
|
||||
if (getter.getParameterCount() > 0) continue;
|
||||
if (getter.getParameterTypes().length > 0) continue; //为了兼容android 而不使用 getParameterCount()
|
||||
if ("getClass".equals(getter.getName())) continue;
|
||||
if (!getter.getName().startsWith("get") && !getter.getName().startsWith("is")) continue;
|
||||
java.lang.reflect.Method setter;
|
||||
|
||||
@@ -116,7 +116,7 @@ public abstract class TypeToken<T> {
|
||||
boolean first = true;
|
||||
for (Type t : actualTypeArguments) {
|
||||
if (!first) sb.append(", ");
|
||||
sb.append(t.getTypeName());
|
||||
sb.append(t);
|
||||
first = false;
|
||||
}
|
||||
sb.append(">");
|
||||
|
||||
Reference in New Issue
Block a user