use of com.googlecode.d2j.visitors.DexFieldVisitor in project dex2jar by pxb1988.
the class AsmfierTest method test.
@Test
public void test() {
ASMifierFileV fv = new ASMifierFileV(new File("target/asmftest").toPath(), "a.b");
DexClassVisitor cv = fv.visit(ACC_PUBLIC, "La/f;", "Ljava/lang/Object;", null);
DexFieldVisitor f2v = cv.visitField(ACC_PUBLIC, new Field("La/f;", "abc", "I"), null);
f2v.visitEnd();
DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La/f;", "zz", new String[0], "I"));
DexAnnotationAble pv = mv.visitParameterAnnotation(2);
DexAnnotationVisitor dav = pv.visitAnnotation("Leeeff;", Visibility.BUILD);
dav.visitEnd();
DexCodeVisitor dcv = mv.visitCode();
dcv.visitConstStmt(Op.FILL_ARRAY_DATA, 0, new int[] { 1, 2, 3 });
dcv.visitStmt0R(Op.RETURN_VOID);
dcv.visitEnd();
mv.visitEnd();
cv.visitEnd();
fv.visitEnd();
}
use of com.googlecode.d2j.visitors.DexFieldVisitor in project dex2jar by pxb1988.
the class DexFieldNode method accept.
public void accept(DexClassVisitor dcv) {
DexFieldVisitor fv = dcv.visitField(access, field, cst);
if (fv != null) {
accept(fv);
fv.visitEnd();
}
}
use of com.googlecode.d2j.visitors.DexFieldVisitor in project dex2jar by pxb1988.
the class AutoCastTest method strict.
/**
* generate code, it works fine on JVM, but fails on Dalvik VM
*
* <pre>
* class a {
* private static short theField;
*
* public a() {
* theField = 0xffFFffFF + theField;// the 0xffFFffFF is not casted
* }
* }
* </pre>
*
* @param cv
*/
public static void strict(DexClassVisitor cv) {
Field f = new Field("La;", "theField", "S");
DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC, new Method("La;", "<init>", new String[] {}, "V"));
if (mv != null) {
DexCodeVisitor code = mv.visitCode();
if (code != null) {
code.visitRegister(3);
code.visitMethodStmt(INVOKE_SUPER, new int[] { 2 }, new Method("Ljava/lang/Object;", "<init>", new String[] {}, "V"));
code.visitFieldStmt(SGET_BOOLEAN, 0, -1, f);
code.visitConstStmt(CONST, 1, 0xffFFffFF);
code.visitStmt3R(ADD_INT, 0, 0, 1);
code.visitFieldStmt(SPUT_SHORT, 0, -1, f);
code.visitStmt0R(RETURN_VOID);
code.visitEnd();
}
mv.visitEnd();
}
DexFieldVisitor fv = cv.visitField(ACC_PRIVATE | ACC_STATIC, f, 0);
if (fv != null) {
fv.visitEnd();
}
}
Aggregations