This commit is contained in:
kamhung
2015-12-08 17:04:06 +08:00
parent 63d16ca602
commit c7ec4b3201
3 changed files with 22 additions and 14 deletions

View File

@@ -382,7 +382,15 @@ public abstract class Sncp {
}
{ // _方法
mv = new DebugMethodVisitor(cw.visitMethod(ACC_PUBLIC + (method.isVarArgs() ? ACC_VARARGS : 0), "_" + method.getName(), "(ZZZ" + methodDesc.substring(1), null, null));
//mv.setDebug(true);
//mv.setDebug(true);
{ //给参数加上 Annotation
final Annotation[][] anns = method.getParameterAnnotations();
for (int k = 0; k < anns.length; k++) {
for (Annotation ann : anns[k]) {
visitAnnotation(mv.visitParameterAnnotation(k, Type.getDescriptor(ann.annotationType()), true), ann);
}
}
}
av0 = mv.visitAnnotation(sncpDynDesc, true);
av0.visit("index", index);
av0.visitEnd();

View File

@@ -202,7 +202,7 @@ public final class SncpClient {
try {
final SncpAction action = actions[index];
in.setBytes(future.get(5, TimeUnit.SECONDS));
byte i = 0;
byte i;
while ((i = in.readByte()) != 0) {
final Attribute attr = action.paramAttrs[i];
attr.set(params[i - 1], convert.convertFrom(in, attr.type()));

View File

@@ -16,7 +16,7 @@ import java.util.concurrent.*;
* @param <T>
* @param <F>
*/
public final class EntityCallAttribute<T, F> implements Attribute<T[], F[]> {
public final class EntityCallAttribute<T, F> implements Attribute<T[], F> {
public static final EntityCallAttribute instance = new EntityCallAttribute();
@@ -46,37 +46,37 @@ public final class EntityCallAttribute<T, F> implements Attribute<T[], F[]> {
}
@Override
public Class<? extends F[]> type() {
return (Class<F[]>) (Class) Serializable[].class;
public Class<? extends F> type() {
return (Class<F>) Object.class;
}
@Override
public Class<T[]> declaringClass() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (Class<T[]>) (Class) Object[].class;
}
@Override
public String field() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return "";
}
@Override
public F[] get(final T[] objs) {
public F get(final T[] objs) {
if (objs == null || objs.length == 0) return null;
final Attribute<T, F> attr = (Attribute<T, F>) load(objs[0].getClass());
final F[] keys = (F[]) Array.newInstance(attr.type(), objs.length);
final Attribute<T, Serializable> attr = (Attribute<T, Serializable>) load(objs[0].getClass());
final Object keys = Array.newInstance(attr.type(), objs.length);
for (int i = 0; i < objs.length; i++) {
keys[i] = attr.get(objs[i]);
Array.set(keys, i, attr.get(objs[i]));
}
return keys;
return (F) keys;
}
@Override
public void set(final T[] objs, final F[] keys) {
public void set(final T[] objs, final F keys) {
if (objs == null || objs.length == 0) return;
final Attribute<T, F> attr = (Attribute<T, F>) load(objs[0].getClass());
for (int i = 0; i < objs.length; i++) {
attr.set(objs[i], (F) keys[i]);
attr.set(objs[i], (F) Array.get(keys, i));
}
}