提交 85fbafb2 authored 作者: Thomas Mueller's avatar Thomas Mueller

assertThrows

上级 c2678bb4
...@@ -1355,7 +1355,7 @@ public abstract class TestBase { ...@@ -1355,7 +1355,7 @@ public abstract class TestBase {
} }
}; };
Class<?>[] interfaces = c.getInterfaces(); Class<?>[] interfaces = c.getInterfaces();
if (Modifier.isFinal(c.getModifiers()) || interfaces.length > 0) { if (Modifier.isFinal(c.getModifiers()) || (interfaces.length > 0 && getClass() != c)) {
// interface class proxies // interface class proxies
if (interfaces.length == 0) { if (interfaces.length == 0) {
throw new RuntimeException("Can not create a proxy for the class " + throw new RuntimeException("Can not create a proxy for the class " +
......
...@@ -36,6 +36,9 @@ public class ProxyCodeGenerator { ...@@ -36,6 +36,9 @@ public class ProxyCodeGenerator {
if (p != null) { if (p != null) {
return p; return p;
} }
// TODO how to extend a class with private constructor
// TODO call right constructor
// TODO use the right package
ProxyCodeGenerator cg = new ProxyCodeGenerator(); ProxyCodeGenerator cg = new ProxyCodeGenerator();
cg.setPackageName("bytecode"); cg.setPackageName("bytecode");
cg.generateClassProxy(c); cg.generateClassProxy(c);
...@@ -44,6 +47,7 @@ public class ProxyCodeGenerator { ...@@ -44,6 +47,7 @@ public class ProxyCodeGenerator {
String code = sw.toString(); String code = sw.toString();
String proxy = "bytecode."+ c.getSimpleName() + "Proxy"; String proxy = "bytecode."+ c.getSimpleName() + "Proxy";
compiler.setSource(proxy, code); compiler.setSource(proxy, code);
// System.out.println(code);
Class<?> px = compiler.getClass(proxy); Class<?> px = compiler.getClass(proxy);
proxyMap.put(c, px); proxyMap.put(c, px);
return px; return px;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论