I am looking at https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2 and i am wondering how does one display the correct form of a method that takes in 2 different types.
E.g.
callthismethod(String a, ArrayMap<String aa, Task<String aaa> > )
where Task is imported from com.this.location
The field descriptor of an instance variable of type
int
is simplyI
.The field descriptor of an instance variable of type
Object
isLjava/lang/Object;
. Note that the internal form of the binary name for classObject
is used.The field descriptor of an instance variable that is a multidimensional
double
array,double d[][][]
, is[[[D
.
There seems to be some confusion as you’re looking at a field descriptor but asking a question about a method. So you have to look at the method descriptor documentation just beneath the “Field Descriptors” section.
A method descriptor has the form
(
ParameterDescriptor*)
ReturnDescriptor
where the parameter descriptors have the same form as field descriptors, concatenated without any separators and the return descriptor only differs from field descriptors in also allowing V
, to denote a void
method.
Since your question doesn’t include the return type, and also doesn’t show the qualified name of the second parameter¹ (we might assume the first one is java.lang.String
), no complete answer can be given for this example. If the method has been declared like
void callthismethod(java.lang.String a, some.location.ArrayMap<String, Task<String>> aa)
the method descriptor would look like
(Ljava/lang/String;Lsome/location/ArrayMap;)V
Note that neither, field descriptors nor method descriptors, encode type arguments. Generic signatures are an entirely different thing, only used for Reflection and debugging, not for the normal execution of code.
Getting the generic signature for your example is as problematic as getting the method descriptor, due to the missing information. Further, com.this.location
is not a valid package name. Assuming some.location
for Task
as well, the generic signature would look like
(Ljava/lang/String;Lsome/location/ArrayMap<Ljava/lang/String;Lsome/location/Task<Ljava/lang/String;>;>;)V
¹ in fact, your declaration is entirely invalid as it tries to assign names to type arguments but not to the actual parameter.