fix generated static new class structure

This commit is contained in:
金戟 2020-05-15 17:56:21 +08:00
parent 3d98eb4c8a
commit b9796e0397
2 changed files with 3 additions and 3 deletions

View File

@ -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")

View File

@ -58,9 +58,10 @@ public class TestableClassTranslator extends TreeTranslator {
nameTable.fromString("class"), null);
ListBuffer<JCTree.JCExpression> 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();
}