Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this mean in a stack trace?

I see this in a stack trace:

myorg.vignettemodules.customregistration.NewsCategoryVAPDAO.getEmailContentByID(I)Lmyorg/pushemail/model/EmailContent;

What does the "(I)L" mean?

like image 433
bpapa Avatar asked Dec 10 '08 19:12

bpapa


2 Answers

It's a form of name mangling used for disambiguating method overloads. The method name is appended by a series of characters describing the parameters and return type: the parameters appear sequentially inside parentheses, and the return type follows the closing parenthesis. The codes are as follows:

  • Z: boolean
  • B: byte
  • C: char
  • S: short
  • I: int
  • J: long
  • F: float
  • D: double
  • Lfully-qualified-class-name ; : fully qualified class
  • [ type : array of type
  • V: void

So, in your case, the (I)Lmyorg/pushemail/model/EmailContent; means the method takes one argument of type int and returns an object of type myorg.pushemail.model.EmailContent.

like image 81
Adam Rosenfield Avatar answered Oct 15 '22 09:10

Adam Rosenfield


It means the method takes an int, and returns myorg.pushemail.model.EmailContent

The string from "L" to ";" is one type descriptor, for the return type. The stuff inside parentheses are the method parameters (in this case, there's just one).

These type descriptors are defined as part of the Java Virtual Machine Specification, in section 4.3.2. Table 4.3-A shows all of the codes used. When a class is compiled, descriptors of this form are used to specify the signature of methods and the types of fields and variables.

In Java serialization, method descriptors are part of the information that is hashed to form the default serialVersionUID for a Serializable class.

In RMI, method descriptors are hashed, and the result is used to identify which method is being invoked in the remote interface.

like image 43
erickson Avatar answered Oct 15 '22 11:10

erickson