A simple class of Java Reverse Foundation

Source: Internet
Author: User

This article refers to:http://www.vuln.cn/7118

This article references: "Reverse Engineering for Beginners" Dennis Yurichev

Class

Simple class

Example

public class Test {public static int a;private static int b;public test () {a = 0;b = 0;} public static void set_a (int input) {a = input;} public static int get_a () {return A;} public static void Set_b (int input) {b = input;} public static int Get_b () {return b;}}

Compile

Javac Test.java


Anti-compilation

Javap-c-verbose Test.class

Constructs a method that sets all static member variables to 0

  public test ();    descriptor:  () V    flags:  ACC_PUBLIC    Code:      stack=1, locals=1,  args_size=1         0: aload_0          1: invokespecial  #1                    // method java/lang/object. " <init> ":() v         4: iconst_0          5: putstatic      #2                    // field a:i          8: iconst_0          9: putstatic      #3                    // field b:i        12: return

The setter method of a

public static void set_a (int);         Descriptor: (I) V flags:acc_public, Acc_static code:stack=1, Locals=1, args_size=1 0:iload_0         1:putstatic #2//Field A:I 4:return

Getter Method of a

public static int get_a ();                  Descriptor: () I flags:acc_public, Acc_static code:stack=1, locals=0, args_size=0 0:getstatic #2         Field A:I 3:ireturn

The setter method of B

public static void Set_b (int);         Descriptor: (I) V flags:acc_public, Acc_static code:stack=1, Locals=1, args_size=1 0:iload_0         1:putstatic #3//Field b:i 4:return

The Getter method of B

public static int Get_b ();                  Descriptor: () I flags:acc_public, Acc_static code:stack=1, locals=0, args_size=0 0:getstatic #3         Field b:i 3:ireturn

Regardless of whether the member variables of this class are public or private, the code executes without distinction, but the type information of the member variable is displayed in the class file, and no other file can directly access the private member variables of the classes.


Next we create an object to invoke the method

Ex1.java

public class Ex1 {public static void main (string[] args) {Test obj = new test (); obj.set_a (1234); System.out.println (OBJ.A);}}

Anti-compilation

  public static void main (java.lang.string[]);     descriptor:   ([ljava/lang/string;) v    flags: acc_public, acc_static     Code:      stack=2, locals=2, args_size=1          0: new             #2                    // class test         3: dup          4: invokespecial  #3                    // method test. " <init> ":() v         7: astore_1          8: aload_1         9: pop         10: sipush        1234         13: invokestatic   #4                    // method test.set_a: (I) V         16: getstatic      #5                    // field java/lang/ system.out:ljava/io/printstream;        19: aload_1         20: pop        21:  getstatic      #6                    // field test.a:i        24: invokevirtual  #7                     method java/io/printstream.println: (I) v        27:  Return

The new directive creates an object, but does not call the constructor method in it (the construction method is called in offset block 4)

Offset Block 14 calls the Set_a () method

Offset Block 21 accesses the member variable a in the test class


A simple class of Java Reverse Foundation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.