Java Code Examples for org.objectweb.asm.util.TraceClassVisitor#visitSource()

The following examples show how to use org.objectweb.asm.util.TraceClassVisitor#visitSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InterfaceTest.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void generate(TraceClassVisitor visitor) {
	visitor.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE,
			"soot/asm/backend/targets/Comparable", null, "java/lang/Object",
	new String[] { "soot/asm/backend/targets/Measurable" });
	visitor.visitSource("Comparable.java", null);
	visitor.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "LESS", "I",
	null, new Integer(-1)).visitEnd();
	visitor.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "EQUAL", "I",
	null, new Integer(0)).visitEnd();
	visitor.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "GREATER", "I",
	null, new Integer(1)).visitEnd();
	visitor.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT, "compareTo",
			"(Ljava/lang/Object;)I", null, null).visitEnd();
	visitor.visitEnd();
	
}
 
Example 2
Source File: ExceptionTest.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;

	cw.visit(V1_4, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE,
			"soot/asm/backend/targets/ExceptionMethods", null,
			"java/lang/Object", null);
	
	cw.visitSource("ExceptionMethods.java", null);

	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "foo", "()V", null, new String[] { "java/lang/NullPointerException" });
	mv.visitEnd();
	}

	cw.visitEnd();

}
 
Example 3
Source File: AnnotatedAnnotationTest.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {

	MethodVisitor mv;

	cw.visit(V1_5, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + ACC_INTERFACE,
			"soot/asm/backend/targets/MyAnnotatedAnnotation", null,
			"java/lang/Object", new String[] { "java/lang/annotation/Annotation" }); //TODO V1_1 seems wrong here
	cw.visitSource("MyAnnotatedAnnotation.java", null);
	
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "value",
			"()Lsoot/asm/backend/targets/MyTestAnnotation;", null, null);
	mv.visitEnd();
	}
	cw.visitEnd();

}
 
Example 4
Source File: DupsTest.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;

	cw.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/Dups", null,
			"java/lang/Object", null);
	cw.visitSource("Dups.java", null);

	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "dubl", "()J", null, null);
	mv.visitCode();
	mv.visitLdcInsn(new Long(1234L));
	mv.visitInsn(DUP2);
	mv.visitInsn(LADD);
	mv.visitInsn(LRETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "dup", "()Ljava/lang/Object;", null, null);
	mv.visitCode();
	mv.visitTypeInsn(NEW, "java/lang/Object");
	mv.visitInsn(DUP);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(ARETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();

}
 
Example 5
Source File: InnerClass2Test.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;
	FieldVisitor fv;

	cw.visit(V1_1, ACC_SUPER, "soot/asm/backend/targets/InnerClass$1", null, "java/lang/Object",
			new String[] { "soot/asm/backend/targets/Measurable" });
	
	cw.visitSource("InnerClass.java", null);

	cw.visitOuterClass("soot/asm/backend/targets/InnerClass", "doInner", "()V");

	cw.visitInnerClass("soot/asm/backend/targets/InnerClass$1", null, null, 0);

	{
		fv = cw.visitField(ACC_FINAL + ACC_SYNTHETIC, "this$0",
				"Lsoot/asm/backend/targets/InnerClass;", null, null);
		fv.visitEnd();
	}
	{
		mv = cw.visitMethod(0, "<init>", "(Lsoot/asm/backend/targets/InnerClass;)V", null, null);
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 0);
		mv.visitVarInsn(ALOAD, 1);
		mv.visitFieldInsn(PUTFIELD, "soot/asm/backend/targets/InnerClass$1", "this$0",
				"Lsoot/asm/backend/targets/InnerClass;");
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>",
				"()V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	cw.visitEnd();

}
 
Example 6
Source File: NullTypesTest.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {

    MethodVisitor mv;

    cw.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/nullTypes", null, "java/lang/Object", null);
    cw.visitSource("nullTypes.java", null);

    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(0, "doStuff", "(Ljava/lang/Integer;)Ljava/lang/Integer;", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 1);
        Label l0 = new Label();
        mv.visitJumpInsn(IFNONNULL, l0);
        mv.visitInsn(ACONST_NULL);
        mv.visitInsn(ARETURN);
        mv.visitLabel(l0);
        //mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
        mv.visitInsn(ICONST_1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
        mv.visitInsn(ARETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
}
 
Example 7
Source File: LineNumbersTest.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;

	cw.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/LineNumbers",
			null, "java/lang/Object", null);
	cw.visitSource("LineNumbers.java", null);
	
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	Label l1 = new Label();
	mv.visitLabel(l1);
	mv.visitLineNumber(3, l1);
	mv.visitVarInsn(ALOAD, 0);
	Label l2 = new Label();
	mv.visitLabel(l2);
	mv.visitLineNumber(3, l2);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	Label l3 = new Label();
	mv.visitLabel(l3);
	mv.visitLineNumber(3, l3);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
	mv.visitCode();
	Label l0 = new Label();
	mv.visitLabel(l0);
	mv.visitLineNumber(6, l0);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();

}
 
Example 8
Source File: AnnotatedFieldTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {

	FieldVisitor fv;
	MethodVisitor mv;
	AnnotationVisitor av0;

	cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/AnnotatedField",
			null, "java/lang/Object", null);
	cw.visitSource("AnnotatedField.java", null);
	
	{
	fv = cw.visitField(0, "a", "Ljava/lang/String;", null, null);
	{
	av0 = fv.visitAnnotation("Lsoot/asm/backend/targets/MyTestAnnotation;", true);
	av0.visit("iVal", new Integer(124));
	av0.visit("fVal", new Float("5132.0"));
	av0.visit("lVal", new Long(5123L));
	av0.visit("dVal", new Double("745.0"));
	av0.visit("zVal", Boolean.TRUE);
	av0.visit("bVal", new Byte((byte)1));
	av0.visit("sVal", new Short((short)123));
	av0.visit("strVal", "435243");
	av0.visit("rVal", Type.getType("Lsoot/asm/backend/targets/AnnotatedClass;"));
	av0.visit("iAVal", new int[] {123,234,345,456});
	{
	AnnotationVisitor av1 = av0.visitArray("sAVal");
	av1.visit(null, "A");
	av1.visit(null, "B");
	av1.visit(null, "C");
	av1.visitEnd();
	}
	av0.visitEnd();
	}
	fv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();


}
 
Example 9
Source File: AnnotatedAnnotatedClassTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {

	MethodVisitor mv;
	AnnotationVisitor av0;

	cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/AnnotatedAnnotatedClass",
			null, "java/lang/Object", null);
	cw.visitSource("AnnotatedAnnotatedClass.java", null);
	{
	av0 = cw.visitAnnotation("Lsoot/asm/backend/targets/MyAnnotatedAnnotation;", false);
	{
	AnnotationVisitor av1 = av0.visitAnnotation("value", "Lsoot/asm/backend/targets/MyTestAnnotation;");
	av1.visit("iVal", new Integer(1));
	av1.visit("fVal", new Float("1.0"));
	av1.visit("lVal", new Long(1L));
	av1.visit("dVal", new Double("1.0"));
	av1.visit("zVal", Boolean.TRUE);
	av1.visit("bVal", new Byte((byte)1));
	av1.visit("sVal", new Short((short)1));
	av1.visit("strVal", "1");
	av1.visit("rVal", Type.getType("Lsoot/asm/backend/targets/AnnotatedClass;"));
	av1.visit("iAVal", new int[] {1,2,3,4});
	{
	AnnotationVisitor av2 = av1.visitArray("sAVal");
	av2.visit(null, "A");
	av2.visit(null, "B");
	av2.visit(null, "C");
	av2.visitEnd();
	}
	av1.visitEnd();
	}
	av0.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();


}
 
Example 10
Source File: ReturnsTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor visitor) {
	MethodVisitor mv;

	visitor.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/Returns", null,
			"java/lang/Object", null);
	
	visitor.visitSource("Returns.java", null);

	{
		mv = visitor.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>",
				"()V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	{
		mv = visitor.visitMethod(ACC_PUBLIC, "getIntArray", "()[I", null,
				null);
		mv.visitCode();
		mv.visitInsn(ICONST_4);
		mv.visitIntInsn(NEWARRAY, T_INT);
		mv.visitInsn(ARETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	{
		mv = visitor.visitMethod(ACC_PUBLIC, "getNull",
				"()Ljava/lang/Object;", null, null);
		mv.visitCode();
		mv.visitInsn(ACONST_NULL);
		mv.visitInsn(ARETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	{
		mv = visitor.visitMethod(ACC_PUBLIC, "getObjectArray",
				"()[Ljava/lang/Object;", null, null);
		mv.visitCode();
		mv.visitInsn(ICONST_4);
		mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");
		mv.visitInsn(ARETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	visitor.visitEnd();

}
 
Example 11
Source File: AnnotatedParameterTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	
	MethodVisitor mv;
	AnnotationVisitor av0;

	cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER,
			"soot/asm/backend/targets/AnnotatedParameter",
			null, "java/lang/Object", null);
	cw.visitSource("AnnotatedParameter.java", null);
	
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "doSth", "(Ljava/lang/String;)V", null, null);
	{
	av0 = mv.visitParameterAnnotation(0, "Lsoot/asm/backend/targets/MyTestAnnotation;", true);
	av0.visit("iVal", new Integer(1));
	av0.visit("fVal", new Float("1.0"));
	av0.visit("lVal", new Long(1L));
	av0.visit("dVal", new Double("1.0"));
	av0.visit("zVal", Boolean.TRUE);
	av0.visit("bVal", new Byte((byte)1));
	av0.visit("sVal", new Short((short)1));
	av0.visit("strVal", "1");
	av0.visit("rVal", Type.getType("Lsoot/asm/backend/targets/AnnotatedClass;"));
	av0.visit("iAVal", new int[] {1,2,3,4});
	{
	AnnotationVisitor av1 = av0.visitArray("sAVal");
	av1.visit(null, "A");
	av1.visit(null, "B");
	av1.visit(null, "C");
	av1.visitEnd();
	}
	av0.visitEnd();
	}
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();



}
 
Example 12
Source File: OuterClassTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;

	cw.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/InnerClass", null,
			"java/lang/Object", null);

	cw.visitSource("InnerClass.java", null);

	cw.visitInnerClass("soot/asm/backend/targets/InnerClass$1", null, null, 0);

	cw.visitInnerClass("soot/asm/backend/targets/InnerClass$Inner", "soot/asm/backend/targets/InnerClass", "Inner",
			ACC_PRIVATE);

	{
		mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>",
				"()V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	{
		mv = cw.visitMethod(ACC_PUBLIC, "doInner", "()V", null, null);
		mv.visitCode();
		mv.visitTypeInsn(NEW, "soot/asm/backend/targets/InnerClass$1");
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKESPECIAL, "soot/asm/backend/targets/InnerClass$1", "<init>",
				"(Lsoot/asm/backend/targets/InnerClass;)V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	{
		mv = cw.visitMethod(ACC_PUBLIC, "getA", "()I", null, null);
		mv.visitCode();
		mv.visitInsn(ICONST_3);
		mv.visitInsn(IRETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	cw.visitEnd();

}
 
Example 13
Source File: AnnotatedMethodTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {

	
	MethodVisitor mv;
	AnnotationVisitor av0;

	cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/AnnotatedMethod",
			null, "java/lang/Object", null);
	cw.visitSource("AnnotatedMethod.java", null);
	
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "doSth", "()V", null, null);
	{
	av0 = mv.visitAnnotation("Lsoot/asm/backend/targets/MyTestAnnotation;", true);
	av0.visit("iVal", new Integer(124));
	av0.visit("fVal", new Float("5132.0"));
	av0.visit("lVal", new Long(5123L));
	av0.visit("dVal", new Double("745.0"));
	av0.visit("zVal", Boolean.TRUE);
	av0.visit("bVal", new Byte((byte)1));
	av0.visit("sVal", new Short((short)123));
	av0.visit("strVal", "435243");
	av0.visit("rVal", Type.getType("Lsoot/asm/backend/targets/AnnotatedClass;"));
	av0.visit("iAVal", new int[] {123,234,345,456});
	{
	AnnotationVisitor av1 = av0.visitArray("sAVal");
	av1.visit(null, "A");
	av1.visit(null, "B");
	av1.visit(null, "C");
	av1.visitEnd();
	}
	av0.visitEnd();
	}
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();


}
 
Example 14
Source File: InnerClassTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor visitor) {
	MethodVisitor mv;
	FieldVisitor fv;

	visitor.visit(V1_1, ACC_SUPER, "soot/asm/backend/targets/InnerClass$Inner", null,
			"java/lang/Object", null);
	
	visitor.visitSource("InnerClass.java", null);

	visitor.visitInnerClass("soot/asm/backend/targets/InnerClass$Inner", "soot/asm/backend/targets/InnerClass",
			"Inner", ACC_PRIVATE);

	{
		fv = visitor.visitField(ACC_FINAL + ACC_STATIC, "a", "I", null,
				new Integer(3));
		fv.visitEnd();
	}
	{
		fv = visitor.visitField(ACC_FINAL + ACC_SYNTHETIC, "this$0",
				"Lsoot/asm/backend/targets/InnerClass;", null, null);
		fv.visitEnd();
	}
	{
		mv = visitor.visitMethod(ACC_PRIVATE, "<init>",
				"(Lsoot/asm/backend/targets/InnerClass;)V", null, null);
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 0);
		mv.visitVarInsn(ALOAD, 1);
		mv.visitFieldInsn(PUTFIELD, "soot/asm/backend/targets/InnerClass$Inner", "this$0",
				"Lsoot/asm/backend/targets/InnerClass;");
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>",
				"()V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	visitor.visitEnd();

}
 
Example 15
Source File: AnnotatedClassTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;
	AnnotationVisitor av0;

	cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/AnnotatedClass",
			null, "java/lang/Object", null);
	
	cw.visitSource("AnnotatedClass.java", null);

	{
	av0 = cw.visitAnnotation("Lsoot/asm/backend/targets/MyTestAnnotation;", true);
	av0.visit("iVal", new Integer(1));
	av0.visit("fVal", new Float("1.0"));
	av0.visit("lVal", new Long(1L));
	av0.visit("dVal", new Double("1.0"));
	av0.visit("zVal", Boolean.TRUE);
	av0.visit("bVal", new Byte((byte)1));
	av0.visit("sVal", new Short((short)1));
	av0.visit("strVal", "1");
	av0.visit("rVal", Type.getType("Lsoot/asm/backend/targets/AnnotatedClass;"));
	av0.visit("iAVal", new int[] {1,2,3,4});
	{
	AnnotationVisitor av1 = av0.visitArray("sAVal");
	av1.visit(null, "A");
	av1.visit(null, "B");
	av1.visit(null, "C");
	av1.visitEnd();
	}
	av0.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	cw.visitEnd();

}
 
Example 16
Source File: AnnotationTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;
	AnnotationVisitor av0;

	cw.visit(V1_5, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT
			+ ACC_INTERFACE, "soot/asm/backend/targets/MyTestAnnotation", null,
			"java/lang/Object",
			new String[] { "java/lang/annotation/Annotation" });
	
	cw.visitSource("MyTestAnnotation.java", null);

	{
	av0 = cw.visitAnnotation("Ljava/lang/annotation/Retention;", true);
	av0.visitEnum("value", "Ljava/lang/annotation/RetentionPolicy;", "RUNTIME");
	av0.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "bVal", "()B", null, null);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "dVal", "()D", null, null);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "fVal", "()F", null, null);
	mv.visitEnd();
	}
	{
		mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "iAVal", "()[I", null, null);
		mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "iVal", "()I", null, null);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "lVal", "()J", null, null);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "rVal", "()Ljava/lang/Class;",
			"()Ljava/lang/Class<Lsoot/asm/backend/targets/AnnotatedClass;>;", null);
	mv.visitEnd();
	}
	{
		mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "sAVal", "()[Ljava/lang/String;", null, null);
		mv.visitEnd();
	}
	{
		mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "sVal", "()S", null, null);
		mv.visitEnd();
	}
	{
		mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "strVal", "()Ljava/lang/String;", null, null);
		mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "zVal", "()Z", null, null);
	mv.visitEnd();
	}


	cw.visitEnd();

}
 
Example 17
Source File: MethodExampleTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor visitor) {
	FieldVisitor fv;
	MethodVisitor mv;

	visitor.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER,
			"soot/asm/backend/targets/Bean", null, "java/lang/Object", null);
	visitor.visitSource("Bean.java", null);
	{
	fv = visitor.visitField(Opcodes.ACC_PRIVATE, "f", "I", null, null);
	fv.visitEnd();
	}
	{
	mv = visitor.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(Opcodes.ALOAD, 0);
	mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(Opcodes.RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = visitor.visitMethod(Opcodes.ACC_PUBLIC, "checkAndSetF", "(I)V", null, null);
	mv.visitCode();
	mv.visitVarInsn(Opcodes.ILOAD, 1);
	Label l0 = new Label();
	mv.visitJumpInsn(Opcodes.IFLT, l0);
	mv.visitVarInsn(Opcodes.ALOAD, 0);
	mv.visitVarInsn(Opcodes.ILOAD, 1);
	mv.visitFieldInsn(Opcodes.PUTFIELD, "soot/asm/backend/targets/Bean", "f", "I");
	Label l1 = new Label();
	mv.visitJumpInsn(Opcodes.GOTO, l1);
	mv.visitLabel(l0);
	mv.visitTypeInsn(Opcodes.NEW, "java/lang/IllegalArgumentException");
	mv.visitInsn(Opcodes.DUP);
	mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/IllegalArgumentException", "<init>", "()V", false);
	mv.visitInsn(Opcodes.ATHROW);
	mv.visitLabel(l1);
	mv.visitInsn(Opcodes.RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = visitor.visitMethod(Opcodes.ACC_PUBLIC, "getF", "()I", null, null);
	mv.visitCode();
	mv.visitVarInsn(Opcodes.ALOAD, 0);
	mv.visitFieldInsn(Opcodes.GETFIELD, "soot/asm/backend/targets/Bean", "f", "I");
	mv.visitInsn(Opcodes.IRETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = visitor.visitMethod(Opcodes.ACC_PUBLIC, "setF", "(I)V", null, null);
	mv.visitCode();
	mv.visitVarInsn(Opcodes.ALOAD, 0);
	mv.visitVarInsn(Opcodes.ILOAD, 1);
	mv.visitFieldInsn(Opcodes.PUTFIELD, "soot/asm/backend/targets/Bean", "f", "I");
	mv.visitInsn(Opcodes.RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	visitor.visitEnd();

}
 
Example 18
Source File: ModifiersTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;
	FieldVisitor fv;
	

	cw.visit(V1_3, ACC_PUBLIC + ACC_SUPER + ACC_ABSTRACT, "soot/asm/backend/targets/Modifiers", null, "java/lang/Object", null);
	cw.visitSource("Modifiers.java", null);

	{
	fv = cw.visitField(ACC_PRIVATE + ACC_VOLATILE, "i", "I", null, null);
	fv.visitEnd();
	}
	{
	fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "j", "I", null, new Integer(213));
	fv.visitEnd();
	}
	{
	fv = cw.visitField(ACC_PRIVATE + ACC_TRANSIENT, "k", "I", null, null);
	fv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_STRICT, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitVarInsn(ALOAD, 0);
	mv.visitIntInsn(SIPUSH, 213);
	mv.visitFieldInsn(PUTFIELD, "soot/asm/backend/targets/Modifiers", "j", "I");
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_STRICT, "a", "()V", null, null);
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_SYNCHRONIZED + ACC_STRICT, "b", "()V", null, null);
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC + ACC_STRICT, "c", "()V", null, null);
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_STRICT, "d", "()V", null, null);
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PROTECTED + ACC_STRICT, "e", "()V", null, null);
	mv.visitCode();
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_ABSTRACT, "f", "()V", null, null);
	mv.visitEnd();
	}
	{
		if (targetCompiler == TargetCompiler.eclipse)
			mv = cw.visitMethod(ACC_PRIVATE + ACC_NATIVE, "g", "()V", null, null);
		else
			mv = cw.visitMethod(ACC_PRIVATE + ACC_NATIVE + ACC_STRICT, "g", "()V", null, null);
	mv.visitEnd();
	}
	cw.visitEnd();


}
 
Example 19
Source File: InstanceOfCastsTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	MethodVisitor mv;

	cw.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/InstanceOfCasts",
			null, "java/lang/Object", null);
	cw.visitSource("InstanceOfCasts.java", null);
	
	{
		mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
		}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "convertMeasurableArray", "([Ljava/lang/Object;)[Lsoot/asm/backend/targets/Measurable;", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 1);
	mv.visitTypeInsn(INSTANCEOF, "[Lsoot/asm/backend/targets/Measurable;");
	Label l0 = new Label();
	mv.visitJumpInsn(IFEQ, l0);
	mv.visitVarInsn(ALOAD, 1);
	mv.visitTypeInsn(CHECKCAST, "[Lsoot/asm/backend/targets/Measurable;");
	if (targetCompiler != TargetCompiler.eclipse)
		mv.visitTypeInsn(CHECKCAST, "[Lsoot/asm/backend/targets/Measurable;");
	mv.visitInsn(ARETURN);
	mv.visitLabel(l0);
	mv.visitInsn(ACONST_NULL);
	mv.visitInsn(ARETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
		{
		mv = cw.visitMethod(ACC_PUBLIC, "isMeasurable", "(Ljava/lang/Object;)Z", null, null);
		mv.visitCode();
		mv.visitVarInsn(ALOAD, 1);
		mv.visitTypeInsn(INSTANCEOF, "soot/asm/backend/targets/Measurable");
		mv.visitInsn(IRETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
		}
		cw.visitEnd();

	
}
 
Example 20
Source File: MonitorTest.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void generate(TraceClassVisitor cw) {
	FieldVisitor fv;
	MethodVisitor mv;

	cw.visit(V1_1, ACC_PUBLIC + ACC_SUPER, "soot/asm/backend/targets/Monitor", null, "java/lang/Object", null);
	cw.visitSource("Monitor.java", null);

	{
	fv = cw.visitField(0, "o", "Ljava/lang/Object;", null, null);
	fv.visitEnd();
	}
	{
	mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	if (targetCompiler == TargetCompiler.eclipse) {
	mv = cw.visitMethod(ACC_PUBLIC, "doSth", "()V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ALOAD, 0);
	mv.visitFieldInsn(GETFIELD, "soot/asm/backend/targets/Monitor", "o", "Ljava/lang/Object;");
	mv.visitInsn(DUP);
	mv.visitInsn(MONITORENTER);
	mv.visitInsn(MONITOREXIT);
	mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
	mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "()V", false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(0, 0);
	mv.visitEnd();
	}
	else {
		mv = cw.visitMethod(ACC_PUBLIC, "doSth", "()V", null, null);
		mv.visitCode();
		Label l0 = new Label();
		Label l1 = new Label();
		Label l2 = new Label();
		mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable");
		Label l3 = new Label();
		mv.visitTryCatchBlock(l2, l3, l2, "java/lang/Throwable");
		mv.visitVarInsn(ALOAD, 0);
		mv.visitFieldInsn(GETFIELD, "soot/asm/backend/targets/Monitor", "o", "Ljava/lang/Object;");
		mv.visitInsn(DUP);
		mv.visitVarInsn(ASTORE, 0);
		mv.visitInsn(MONITORENTER);
		mv.visitLabel(l0);
		mv.visitVarInsn(ALOAD, 0);
		mv.visitInsn(MONITOREXIT);
		mv.visitLabel(l1);
		Label l4 = new Label();
		mv.visitJumpInsn(GOTO, l4);
		mv.visitLabel(l2);
		mv.visitVarInsn(ASTORE, 1);
		mv.visitVarInsn(ALOAD, 0);
		mv.visitInsn(MONITOREXIT);
		mv.visitLabel(l3);
		mv.visitVarInsn(ALOAD, 1);
		mv.visitInsn(ATHROW);
		mv.visitLabel(l4);
		mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
		mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "()V", false);
		mv.visitInsn(RETURN);
		mv.visitMaxs(0, 0);
		mv.visitEnd();
	}
	cw.visitEnd();
	
}