views:

395

answers:

3

I see this in a stack trace:

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

What does the "(I)L" mean?

+7  A: 

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.2 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.

erickson
+10  A: 

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
  • L fully-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.

Adam Rosenfield
A: 

It's a minor point but I don't think this is name mangling. Name mangling implies adding extra stuff to a name. ZBC etc is just how java encodes method signatures in class files. Instead of writing boolean, they put a Z. It saves space.

According to wikipedia (standard disclaimer applies), the only name mangling in java involves inner classes and JNI.

Brel