private void generateStaticInitializer() { if (staticInitializerChunks.size() > 0) { MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null); if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { mv.visitCode(); InstructionAdapter v = new InstructionAdapter(mv); for (CodeChunk chunk : staticInitializerChunks) { chunk.generate(v); } mv.visitInsn(RETURN); FunctionCodegen.endVisit(v, "static initializer", myClass); } } }
@DataProvider(name = "memberTestCase") public Object[][] memberTestCaseGenerator() { List<Object[]> list = new ArrayList<>(); for (AccessModifier accessModifier : AccessModifier.values()) { for (Static isStaticMember : Static.values()) { for (Static isStaticReference : Static.values()) { for (CodeChunk codeChunk : CodeChunk.values()) { if (codeChunk == CodeChunk.CONSTRUCTOR && isStaticMember == Static.STATIC) { continue; } list.add(new Object[] {accessModifier, codeChunk, isStaticMember, isStaticReference}); } } } } return list.toArray(new Object[list.size()][]); }
public String generateSource() { return getSourceTemplate() .replace("#MEMBER#", codeChunk.generateSource(accessModifier, isStaticMember)); }