From b9796e039756732b69515a1a383ebea9cfcbfe61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Fri, 15 May 2020 17:56:21 +0800 Subject: [PATCH] fix generated static new class structure --- .../alibaba/testable/generator/StaticNewClassGenerator.java | 1 - .../alibaba/testable/translator/TestableClassTranslator.java | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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(); }