Functions of the Java Inverse Foundation

Source: Internet
Author: User

This article refer to http://www.vuln.cn/7115

The functions and methods mentioned in this article are the same meaning


Example 1, definition of method name

public class Halfrandom{public static double F () {return math.random ()/2;}}

Compile

Javac Halfrandom.java

Anti-compilation

Javap-c-verbose Halfrandom.class
... major version: 52 #2  = Methodref            #16 #17         // java/lang/math.random: () D#3 =  double             2.0d. #12  =  Utf8                () D ... #16  = Class               #20             // java/lang/Math#17 =  nameandtype         #21: #12          // random: () d#18 = utf8                HalfRandom#19 = Utf8                java/lang/object#20 = utf8                java/lang/Math#21 = Utf8                random...public static double f ();d escriptor:  () Dflags: acc_public, acc_staticcode:stack=4, locals=0, args_size=00: invokestatic    #2                    // method java/lang/math.random: () d3: ldc2_w          #3                    // double 2.0d6: ddiv7: dreturnlinenumbertable:line 5: 0

Invokestatic #2 Call the function defined by # #

The function name is defined in the methodref of the constant pool, which defines the class, method name, method return type

Constant # #, you can see it is by #16. #17拼接, #16定义了类名 Java/lang/math, #17是方法名和返回类型名random:() D

In constant #17, it is composed of #21: #12拼接, #21定义了方法名random, #12定义了返回类型名 () D

() d, there is nothing in parentheses to indicate that there are no parameters in parentheses, D is a double for the return type, or void if V

This way

1) The JVM can check the correctness of the data types:

2) The Java anti-compiler can modify the data type from the compiled class file.


Look Again "hello,world! "Example of

public class Helloworld{public static void Main (string[] args) {System.out.println ("Hello, World");}}

Anti-compilation

... major version: 52 #2  = Fieldref             #16. #17         // java/lang/system.out:ljava/io/ PrintStream, #3  = String               #18             // hello, world#4  = Methodref           #19. #20          // JAVA/IO/PRINTSTREAM.PRINTLN: (ljava/lang/string;) V ... #16  =  class               #23              // java/lang/system#17 = nameandtype          #24: #25         //  out:Ljava/io/PrintStream; #18   = utf8               hello,  World#19 = Class                #26             // java/io/printstream# 20 = nameandtype         #27: #28          // PRINTLN: (ljava/lang/string;) V ... #23  = Utf8                java/lang/System#24 = Utf8                out#25 = utf8                ljava/io/printstream ; #26  = Utf8                java/io/printstream#27 = utf8                println#28 = utf8                 (ljava/lang/string;) V...public static void main (java.lang.string[]);d escriptor:   ([ljava/lang/string;) vflags: acc_public, acc_staticcode:stack=2, locals=1, args_size =10: getstatic      #2                    // field java/lang/system.out:ljava/io/ printstream;3: ldc            #3                    // String  hello, world5: invokevirtual  #4                     // method java/io/printstream.println: (ljava/lang/string;) v8: returnlinenumbertable:line  5: 0line 6: 8

Getstatic #2 get System.out reference into the stack

LDC #3 The string hello, world into the stack

Invokevirtual #4 Call the println () method, here need to pass two parameters, parameters from the stack to get, 1 first will be Hello, the world out of the stack (ljava/lang/string;), 2 will system.out the reference out of the stack incoming java/ References to Io/printstream


Then look at the function call of beep (output computer alarm beep)

public class Bee{public static void Main (string[] args) {Java.awt.Toolkit.getDefaultToolkit (). Beep ();}}

Anti-compilation

... major version:52...public static void Main (java.lang.string[]);d escriptor: ([ljava/lang/string;) vflags:acc_ Public, Acc_staticcode:stack=1, Locals=1, args_size=10:invokestatic #2//Method java/awt/toolkit.getde Faulttoolkit: () ljava/awt/toolkit;3:invokevirtual #3//Method Java/awt/toolkit.beep: () v6:returnlinenumb Ertable:line 5:0line 6:6

Invokestatic #2 Call the Java.awt.Toolkit.getDefaultToolkit () method and press the reference of the returned result into the top of the stack

Invokevirtual #3 Call the Beep () function, where a reference is required to eject the objectref from the top of the stack to the incoming Java/awt/toolkit


Functions of the Java Inverse Foundation

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.