use of com.googlecode.d2j.Method 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();
}
}
use of com.googlecode.d2j.Method in project dex2jar by pxb1988.
the class AppWriterTest method test3.
@Test
public void test3() {
DexFileWriter w = new DexFileWriter();
DexClassVisitor cv = w.visit(0x1, "La/c;", null, new String[] { "Ljava/lang/Comparable;" });
cv.visitSource("c.java");
cv.visitAnnotation("LAnn;", Visibility.SYSTEM).visitEnd();
DexFieldVisitor fv = cv.visitField(ACC_PUBLIC | ACC_STATIC, new Field("La/c;", "a", "I"), 55);
fv.visitAnnotation("LE;", Visibility.RUNTIME).visitEnd();
fv.visitEnd();
DexMethodVisitor mv = cv.visitMethod(ACC_STATIC, new Method("La/c;", "bb", new String[] { "I" }, "V"));
mv.visitAnnotation("Laaa;", Visibility.RUNTIME).visitEnd();
DexAnnotationVisitor dav = mv.visitParameterAnnotation(0).visitAnnotation("Laaa;", Visibility.RUNTIME);
dav.visit("abc", true);
DexAnnotationVisitor dav2 = dav.visitArray("efg");
dav2.visit("", "123");
dav2.visit("", "456");
dav2.visitEnd();
dav.visitEnd();
DexCodeVisitor code = mv.visitCode();
code.visitRegister(2);
code.visitStmt0R(Op.RETURN_VOID);
code.visitEnd();
mv.visitEnd();
cv.visitEnd();
w.visitEnd();
w.toByteArray();
}
Aggregations