diff --git a/src/main/java/com/alibaba/testable/generator/StaticNewClassGenerator.java b/src/main/java/com/alibaba/testable/generator/StaticNewClassGenerator.java index a1e2619..e6499b4 100644 --- a/src/main/java/com/alibaba/testable/generator/StaticNewClassGenerator.java +++ b/src/main/java/com/alibaba/testable/generator/StaticNewClassGenerator.java @@ -27,7 +27,6 @@ public class StaticNewClassGenerator { TypeVariableName typeVariable = TypeVariableName.get("T"); MethodSpec.Builder builder = MethodSpec.methodBuilder(ConstPool.SN_METHOD) .addModifiers(Modifier.PUBLIC).addModifiers(Modifier.STATIC) - .addException(Exception.class) .addTypeVariable(typeVariable) .varargs(true) .addParameter(ParameterizedTypeName.get(ClassName.get(Class.class), typeVariable), "type") diff --git a/src/main/java/com/alibaba/testable/translator/TestableClassTranslator.java b/src/main/java/com/alibaba/testable/translator/TestableClassTranslator.java index 0d27970..eb2823d 100644 --- a/src/main/java/com/alibaba/testable/translator/TestableClassTranslator.java +++ b/src/main/java/com/alibaba/testable/translator/TestableClassTranslator.java @@ -58,9 +58,10 @@ public class TestableClassTranslator extends TreeTranslator { nameTable.fromString("class"), null); ListBuffer args = ListBuffer.of(classType); args.addAll(newClassExpr.args); + TestableFieldAccess ne = new TestableFieldAccess(treeMaker.Ident(nameTable.fromString(ConstPool.SN_PKG)), + nameTable.fromString(ConstPool.SN_CLS), null); jcExpressionStatement.expr = new TestableMethodInvocation(null, - new TestableFieldAccess(treeMaker.Ident(nameTable.fromString(ConstPool.SN_PKG_CLS)), - nameTable.fromString(ConstPool.SN_METHOD), null), args.toList()); + new TestableFieldAccess(ne, nameTable.fromString(ConstPool.SN_METHOD), null), args.toList()); } catch (Exception e) { e.printStackTrace(); }