调整生成动态字节码时的ClassLoader

This commit is contained in:
redkale
2024-10-11 12:26:13 +08:00
parent 1dc07638e5
commit f86f82db8d
48 changed files with 550 additions and 564 deletions

View File

@@ -10,7 +10,7 @@ import java.util.*;
import org.junit.jupiter.api.*;
import org.redkale.convert.ConvertCoder;
import org.redkale.convert.ConvertColumn;
import org.redkale.convert.ext.BigIntegerSimpledCoder.BigIntegerHexJsonSimpledCoder;
import org.redkale.convert.json.JsonCoders.BigIntegerHexJsonSimpledCoder;
import org.redkale.convert.json.JsonConvert;
import org.redkale.convert.pb.ProtobufConvert;

View File

@@ -17,6 +17,7 @@ import java.util.function.Supplier;
import org.junit.jupiter.api.*;
import org.redkale.convert.ConvertColumn;
import org.redkale.convert.json.JsonConvert;
import org.redkale.convert.json.JsonFactory;
import org.redkale.convert.pb.ProtobufConvert;
import org.redkale.util.TypeToken;
import org.redkale.util.Utility;
@@ -43,6 +44,8 @@ public class GenericEntityTest {
@Test
public void runJson1() throws Exception {
System.out.println("-------------------- runJson1 ---------------------------------");
JsonFactory.root().loadEncoder(TreeNode.class);
JsonFactory.root().loadEncoder(TreeNode2.class);
JsonConvert convert = JsonConvert.root();
GenericEntity<Long, String, SimpleEntity> bean = createBean();
String json = convert.convertTo(ENTITY_TYPE, bean);
@@ -76,6 +79,8 @@ public class GenericEntityTest {
@Test
public void runPb1() throws Exception {
System.out.println("-------------------- runPb1 ---------------------------------");
JsonFactory.root().loadEncoder(TreeNode.class);
JsonFactory.root().loadEncoder(TreeNode2.class);
ProtobufConvert convert = ProtobufConvert.root();
GenericEntity<Long, String, SimpleEntity> bean = createBean();
byte[] bs = convert.convertTo(ENTITY_TYPE, bean);
@@ -137,6 +142,22 @@ public class GenericEntityTest {
return bean;
}
public static class TreeNode {
@ConvertColumn(index = 1)
public String name;
@ConvertColumn(index = 2)
public TreeNode next;
}
public static class TreeNode2 {
@ConvertColumn(index = 1)
public String name;
@ConvertColumn(index = 2)
public List<TreeNode2> next;
}
public static class GenericEntity<T, K, V> {
@ConvertColumn(index = 1)

View File

@@ -53,4 +53,6 @@ public class TinyTest {
public int id;
}
}

View File

@@ -50,7 +50,7 @@ public class SncpSleepService extends AbstractService {
getExecutor());
}
public String test(Serializable id, String[] names, Collection<File> files) {
public String test(Serializable id, String[] names, Collection<File> files, int time) {
return "ok";
}
}

View File

@@ -65,7 +65,7 @@ public class SncpSleepTest {
CompletableFuture.allOf(futures).join();
long e = System.currentTimeMillis() - s;
System.out.println("耗时: " + e + " ms");
remoteCService.test(333L, new String[] {"aaa", "bbb"}, List.of(new File("D:/a.txt"), new File("D:/b.txt")));
remoteCService.test(333L, new String[] {"aaa", "bbb"}, List.of(new File("D:/a.txt"), new File("D:/b.txt")), 2);
server.shutdown();
workExecutor.shutdown();
Assertions.assertTrue(e < 600);

View File

@@ -37,9 +37,9 @@ public class DynActionTestService_insert extends SncpActionServlet {
Convert<Reader, Writer> convert = request.getConvert();
Reader in = request.getReader();
DynSncpActionParamBean_TestService_insert bean = convert.convertFrom(paramComposeBeanType, in);
bean.arg0 = response.getParamAsyncHandler();
bean.arg1 = response.getParamAsyncHandler();
TestService serviceObj = (TestService) service();
serviceObj.insert(bean.arg0, bean.arg1, bean.arg2, bean.arg3);
serviceObj.insert(bean.arg1, bean.arg2, bean.arg3, bean.arg4);
response.finishVoid();
}
@@ -48,22 +48,22 @@ public class DynActionTestService_insert extends SncpActionServlet {
public DynSncpActionParamBean_TestService_insert() {}
public DynSncpActionParamBean_TestService_insert(Object[] params) {
this.arg0 = (BooleanHandler) params[0];
this.arg1 = (TestBean) params[1];
this.arg2 = (String) params[2];
this.arg3 = (int) params[3];
this.arg1 = (BooleanHandler) params[0];
this.arg2 = (TestBean) params[1];
this.arg3 = (String) params[2];
this.arg4 = (int) params[3];
}
@ConvertColumn(index = 1)
public BooleanHandler arg0;
public BooleanHandler arg1;
@ConvertColumn(index = 2)
public TestBean arg1;
public TestBean arg2;
@ConvertColumn(index = 3)
public String arg2;
public String arg3;
@ConvertColumn(index = 4)
public int arg3;
public int arg4;
}
}