dyn
This commit is contained in:
@@ -169,9 +169,9 @@ public class MethodDebugVisitor extends MethodVisitor {
|
|||||||
if (index == null) {
|
if (index == null) {
|
||||||
index = labels.size();
|
index = labels.size();
|
||||||
labels.put(var, index);
|
labels.put(var, index);
|
||||||
System.out.println("Label l" + index + " = new Label();");
|
System.out.println("Label label" + index + " = new Label();");
|
||||||
}
|
}
|
||||||
System.out.println("mv.visitLabel(l" + index + ");");
|
System.out.println("mv.visitLabel(label" + index + ");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -487,8 +487,8 @@ public final class Rest {
|
|||||||
sb1.append(Type.getDescriptor(field.getType()));
|
sb1.append(Type.getDescriptor(field.getType()));
|
||||||
sb2.append(Utility.getTypeDescriptor(field.getGenericType()));
|
sb2.append(Utility.getTypeDescriptor(field.getGenericType()));
|
||||||
}
|
}
|
||||||
final String resourceDescriptor = sb1.toString();
|
final String resourceDesc = sb1.toString();
|
||||||
final String resourceGenericDescriptor = sb1.length() == sb2.length() ? null : sb2.toString();
|
final String resourceGenericDesc = sb1.length() == sb2.length() ? null : sb2.toString();
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||||
@@ -628,8 +628,7 @@ public final class Rest {
|
|||||||
"_redkale_resource_" + i,
|
"_redkale_resource_" + i,
|
||||||
Type.getDescriptor(resourcesFields.get(i).getType()));
|
Type.getDescriptor(resourcesFields.get(i).getType()));
|
||||||
}
|
}
|
||||||
mv.visitMethodInsn(
|
mv.visitMethodInsn(INVOKESPECIAL, newDynWebSokcetFullName, "<init>", "(" + resourceDesc + ")V", false);
|
||||||
INVOKESPECIAL, newDynWebSokcetFullName, "<init>", "(" + resourceDescriptor + ")V", false);
|
|
||||||
mv.visitInsn(ARETURN);
|
mv.visitInsn(ARETURN);
|
||||||
mv.visitMaxs(2 + resourcesFields.size(), 1);
|
mv.visitMaxs(2 + resourcesFields.size(), 1);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
@@ -767,6 +766,8 @@ public final class Rest {
|
|||||||
"(Ljava/lang/String;)Ljava/lang/Object;",
|
"(Ljava/lang/String;)Ljava/lang/Object;",
|
||||||
"<T:Ljava/lang/Object;>(Ljava/lang/String;)TT;",
|
"<T:Ljava/lang/Object;>(Ljava/lang/String;)TT;",
|
||||||
null));
|
null));
|
||||||
|
Label label0 = new Label();
|
||||||
|
mv.visitLabel(label0);
|
||||||
for (Map.Entry<String, Parameter> en : paramap.entrySet()) {
|
for (Map.Entry<String, Parameter> en : paramap.entrySet()) {
|
||||||
Class paramType = en.getValue().getType();
|
Class paramType = en.getValue().getType();
|
||||||
mv.visitLdcInsn(en.getKey());
|
mv.visitLdcInsn(en.getKey());
|
||||||
@@ -790,6 +791,11 @@ public final class Rest {
|
|||||||
}
|
}
|
||||||
mv.visitInsn(ACONST_NULL);
|
mv.visitInsn(ACONST_NULL);
|
||||||
mv.visitInsn(ARETURN);
|
mv.visitInsn(ARETURN);
|
||||||
|
Label label2 = new Label();
|
||||||
|
mv.visitLabel(label2);
|
||||||
|
mv.visitLocalVariable(
|
||||||
|
"this", "L" + newDynSuperMessageFullName + ";", null, label0, label2, 0);
|
||||||
|
mv.visitLocalVariable("name", "Ljava/lang/String;", null, label0, label2, 1);
|
||||||
mv.visitMaxs(2, 2);
|
mv.visitMaxs(2, 2);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
@@ -825,6 +831,8 @@ public final class Rest {
|
|||||||
{ // execute
|
{ // execute
|
||||||
mv = new MethodDebugVisitor(
|
mv = new MethodDebugVisitor(
|
||||||
cw2.visitMethod(ACC_PUBLIC, "execute", "(L" + newDynWebSokcetFullName + ";)V", null, null));
|
cw2.visitMethod(ACC_PUBLIC, "execute", "(L" + newDynWebSokcetFullName + ";)V", null, null));
|
||||||
|
Label label0 = new Label();
|
||||||
|
mv.visitLabel(label0);
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitVarInsn(ALOAD, 1);
|
mv.visitVarInsn(ALOAD, 1);
|
||||||
mv.visitFieldInsn(
|
mv.visitFieldInsn(
|
||||||
@@ -843,6 +851,10 @@ public final class Rest {
|
|||||||
"(Ljava/lang/String;" + wsParamDesc + "Ljava/lang/Runnable;)V",
|
"(Ljava/lang/String;" + wsParamDesc + "Ljava/lang/Runnable;)V",
|
||||||
false);
|
false);
|
||||||
mv.visitInsn(RETURN);
|
mv.visitInsn(RETURN);
|
||||||
|
Label label2 = new Label();
|
||||||
|
mv.visitLabel(label2);
|
||||||
|
mv.visitLocalVariable("this", "L" + newDynSuperMessageFullName + ";", null, label0, label2, 0);
|
||||||
|
mv.visitLocalVariable("websocket", "L" + newDynWebSokcetFullName + ";", null, label0, label2, 1);
|
||||||
mv.visitMaxs(4, 2);
|
mv.visitMaxs(4, 2);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
@@ -969,12 +981,11 @@ public final class Rest {
|
|||||||
cw2.visitInnerClass(
|
cw2.visitInnerClass(
|
||||||
newDynWebSokcetFullName, newDynName, newDynWebSokcetSimpleName, ACC_PUBLIC + ACC_STATIC);
|
newDynWebSokcetFullName, newDynName, newDynWebSokcetSimpleName, ACC_PUBLIC + ACC_STATIC);
|
||||||
{
|
{
|
||||||
mv = new MethodDebugVisitor(cw2.visitMethod(
|
String resSignature = resourceGenericDesc == null ? null : ("(" + resourceGenericDesc + ")V");
|
||||||
ACC_PUBLIC,
|
mv = new MethodDebugVisitor(
|
||||||
"<init>",
|
cw2.visitMethod(ACC_PUBLIC, "<init>", "(" + resourceDesc + ")V", resSignature, null));
|
||||||
"(" + resourceDescriptor + ")V",
|
Label sublabel0 = new Label();
|
||||||
resourceGenericDescriptor == null ? null : ("(" + resourceGenericDescriptor + ")V"),
|
mv.visitLabel(sublabel0);
|
||||||
null));
|
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitMethodInsn(INVOKESPECIAL, webSocketInternalName, "<init>", "()V", false);
|
mv.visitMethodInsn(INVOKESPECIAL, webSocketInternalName, "<init>", "()V", false);
|
||||||
for (int i = 0; i < resourcesFields.size(); i++) {
|
for (int i = 0; i < resourcesFields.size(); i++) {
|
||||||
@@ -985,6 +996,12 @@ public final class Rest {
|
|||||||
PUTFIELD, newDynWebSokcetFullName, field.getName(), Type.getDescriptor(field.getType()));
|
PUTFIELD, newDynWebSokcetFullName, field.getName(), Type.getDescriptor(field.getType()));
|
||||||
}
|
}
|
||||||
mv.visitInsn(RETURN);
|
mv.visitInsn(RETURN);
|
||||||
|
Label sublabel2 = new Label();
|
||||||
|
mv.visitLabel(sublabel2);
|
||||||
|
mv.visitLocalVariable("this", "L" + newDynWebSokcetFullName + ";", null, sublabel0, sublabel2, 0);
|
||||||
|
if (!resourceDesc.isEmpty()) {
|
||||||
|
mv.visitLocalVariable("service", resourceDesc, resSignature, sublabel0, sublabel2, 1);
|
||||||
|
}
|
||||||
mv.visitMaxs(2, 1 + resourcesFields.size());
|
mv.visitMaxs(2, 1 + resourcesFields.size());
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
@@ -1033,13 +1050,20 @@ public final class Rest {
|
|||||||
{ // accept函数
|
{ // accept函数
|
||||||
mv = new MethodDebugVisitor(
|
mv = new MethodDebugVisitor(
|
||||||
cw2.visitMethod(ACC_PUBLIC, "accept", "(" + wsDesc + "Ljava/lang/Object;)V", null, null));
|
cw2.visitMethod(ACC_PUBLIC, "accept", "(" + wsDesc + "Ljava/lang/Object;)V", null, null));
|
||||||
|
Label label0 = new Label();
|
||||||
|
mv.visitLabel(label0);
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 1);
|
mv.visitVarInsn(ALOAD, 1);
|
||||||
mv.visitTypeInsn(CHECKCAST, newDynWebSokcetFullName);
|
mv.visitTypeInsn(CHECKCAST, newDynWebSokcetFullName);
|
||||||
mv.visitVarInsn(ASTORE, 3);
|
mv.visitVarInsn(ASTORE, 3);
|
||||||
|
Label label3 = new Label();
|
||||||
|
mv.visitLabel(label3);
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 2);
|
mv.visitVarInsn(ALOAD, 2);
|
||||||
mv.visitTypeInsn(CHECKCAST, newDynMessageFullName);
|
mv.visitTypeInsn(CHECKCAST, newDynMessageFullName);
|
||||||
mv.visitVarInsn(ASTORE, 4);
|
mv.visitVarInsn(ASTORE, 4);
|
||||||
|
Label label4 = new Label();
|
||||||
|
mv.visitLabel(label4);
|
||||||
|
|
||||||
for (int i = 0; i < messageMethods.size(); i++) {
|
for (int i = 0; i < messageMethods.size(); i++) {
|
||||||
final Method method = messageMethods.get(i);
|
final Method method = messageMethods.get(i);
|
||||||
@@ -1079,6 +1103,13 @@ public final class Rest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mv.visitInsn(RETURN);
|
mv.visitInsn(RETURN);
|
||||||
|
Label label2 = new Label();
|
||||||
|
mv.visitLabel(label2);
|
||||||
|
mv.visitLocalVariable("this", "L" + newDynConsumerFullName + ";", null, label0, label2, 0);
|
||||||
|
mv.visitLocalVariable("websocket", wsDesc, null, label0, label2, 1);
|
||||||
|
mv.visitLocalVariable("message", "Ljava/lang/Object;", null, label0, label2, 2);
|
||||||
|
mv.visitLocalVariable("ws", "L" + newDynWebSokcetFullName + ";", null, label3, label2, 3);
|
||||||
|
mv.visitLocalVariable("msg", "L" + newDynMessageFullName + ";", null, label4, label2, 4);
|
||||||
mv.visitMaxs(3, 3 + messageMethods.size());
|
mv.visitMaxs(3, 3 + messageMethods.size());
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ public abstract class EntityFullFunc<T> {
|
|||||||
"(Ljava/lang/Class<" + entityDesc + ">;L" + creatorName + "<" + entityDesc + ">;[L" + attrName + "<"
|
"(Ljava/lang/Class<" + entityDesc + ">;L" + creatorName + "<" + entityDesc + ">;[L" + attrName + "<"
|
||||||
+ entityDesc + "Ljava/io/Serializable;>;)V",
|
+ entityDesc + "Ljava/io/Serializable;>;)V",
|
||||||
null);
|
null);
|
||||||
|
Label label0 = new Label();
|
||||||
|
mv.visitLabel(label0);
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitVarInsn(ALOAD, 1);
|
mv.visitVarInsn(ALOAD, 1);
|
||||||
mv.visitVarInsn(ALOAD, 2);
|
mv.visitVarInsn(ALOAD, 2);
|
||||||
@@ -122,6 +124,12 @@ public abstract class EntityFullFunc<T> {
|
|||||||
"(Ljava/lang/Class;" + creatorDesc + "[" + attrDesc + ")V",
|
"(Ljava/lang/Class;" + creatorDesc + "[" + attrDesc + ")V",
|
||||||
false);
|
false);
|
||||||
mv.visitInsn(RETURN);
|
mv.visitInsn(RETURN);
|
||||||
|
Label label2 = new Label();
|
||||||
|
mv.visitLabel(label2);
|
||||||
|
mv.visitLocalVariable("this", "L" + newDynName + ";", null, label0, label2, 0);
|
||||||
|
mv.visitLocalVariable("type", "Ljava/lang/Class;", null, label0, label2, 1);
|
||||||
|
mv.visitLocalVariable("creator", creatorDesc, null, label0, label2, 2);
|
||||||
|
mv.visitLocalVariable("attrs", "[" + attrDesc, null, label0, label2, 3);
|
||||||
mv.visitMaxs(4, 4);
|
mv.visitMaxs(4, 4);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user