9

When I observe my Java project byte code, I see the following byte code :

java.lang.Object.()V

java.lang.Boolean.(Z)V

What is the meaning of <init>()V and <init>(Z)V

2 Answers 2

15
java.lang.Object.()V

is a void method (V) on java.lang.Object that takes no arguments.

java.lang.Boolean.(Z)V

is a void method on java.lang.Boolean that takes a single boolean (Z since B is byte) argument.

In short,

 abc.def.WXYZ(IIIIIIIIIIIIII)J
 ^            ^              ^ 
 target_class argument-types return_type

See JNI Type Signatures for more detail.

The JNI uses the Java VM’s representation of type signatures. Table 3-2 shows these type signatures.

Table 3-2 Java VM Type Signatures

Type Signature             Java Type
Z                          boolean
B                          byte
...
L fully-qualified-class ;  fully-qualified-class
[ type                      type[]
( arg-types ) ret-type      method type

For example, the Java method:

long f (int n, String s, int[] arr); 

has the following type signature:

(ILjava/lang/String;[I)J
4

It's all method signatures in bytecode used by JVM.

<init>()V and <init>(Z)V are construtor signatures. For JVM constructors are just as any other methods, they have a name, which is always <init>), and a return value, which is always V (means void). In our case Z means boolean parameter (B is reserved for byte)

that is

<init>(Z)V

in class Test's bytecode means

class Test {

    Test(boolean arg0) {
    }
}

you can also meet

 static <clinit>()V

which means static initialization block

static {
...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.