First what is CAP#1
I found this quote:
What on earth does "capture#337 of ?" mean? When the compiler encounters a variable with a wildcard in its type, such as the box parameter of rebox(), it knows that there must have been some T for which box is a Box. It does not know what type T represents, but it can create a placeholder for that type to refer to the type that T must be. That placeholder is called the capture of that particular wildcard. In this case, the compiler has assigned the name "capture#337 of ?" to the wildcard in the type of box. Each occurrence of a wildcard in each variable declaration gets a different capture, so in the generic declaration foo(Pair x, Pair y), the compiler would assign a different name to the capture of each of the four wildcards because there is no relationship between any of the unknown type parameters.
Now let's go back to the message CAP#1 extends Object from capture of ?
It considers the CAP#1
as an instance of Object
, more like an instance of a class extending the class Object
.
Now one need to imagine that the generic are transform into cast at compile time. Which means that:
HashMap<?, ?> map = new HashMap();
int test = (int) map.get("");
is more or less the equivalent of:
HashMap<?, ?> map = new HashMap();
int test = (int) (Object) map.get("");
Which is not possible (or allowed by the compiler) to cast an Object
into an 'int'.
Of course, this Object
is used to make it simple to represent.
But it is totally possible to cast an Object
into a 'String' or an 'Integer'.
So what you could do is:
HashMap<?, Integer> returncp = startAndWaitForJob("DSP_WF_" + operation, cp);
In that case you will not even need to cast anything (see).
But if that is not possible for any reason:
int respCode = ((Integer) returncp.get("statusInfoResponseCode")).intValue();