# extends GenericForwardComposer<[some specific component class]> prevents arg from being used

cvarona
554 1 6

Hi there,

I think there's something wrong in defining the arg map as <?,?>. Doing so would normally result in precluding its usage from java code. However, by some obscure reason, it's possible to actually put something in it as long as our GenericForwardComposer subclass remains raw. The very moment we change our 'extends GenericForwardComposer' into 'extends GenericForwardComposer<Window>', any line reading 'arg.put( "someKey", someValue );' will cause a compilation error.

Wouldn't just "private Map arg" (or even private Map<String, Object> arg) do nicely?

With kind regards

César Varona

delete retag edit

## 2 Replies

MontyPan
435 3
http://xitop.blogspot.com...

Hi César,

Sorry, I can't understand your question, because I can't find method about Map<?,?> in GenericForwardComposer.
Can you provide more detail information or complete code?

update : I found this code in GenericAutowireComposer :

protected transient Map<?, ?> arg;

but... still can't understand... :'(

Regards,
Monty Pan

cvarona
554 1 6

Monty,

if you write a class like this:


import java.util.Map;

public class A<T> {

protected Map<?, ?> _map;
protected T _t;

public void impossibleToCompile() {
_map.put( "a", "b" );
}
}

your ide will surely mark the put operation as wrong. Any attempt to compile this class will fail like this:

A.java:11: put(capture#145 of ?,capture#339 of ?) in java.util.Map<capture#145 of ?,capture#339 of ?> cannot be applied to (java.lang.String,java.lang.String)
_map.put( "a", "b" );
^
1 error

If you remove the impossibleToCompile method everything will be ok, so I guess there is no zk code directly setting values into the arg map in GenericAutowireComposer.

The second misterious point is that if despite what's been said above you write something like

public class B extends A {

public void compilesOk() {
_map.put( "a", "b" );
}
}

your ide will find nothing wrong about it and you will be able to compile it.

*But* if you attempt something like this:

public class B extends A<String> {

public void wontCompile() {
_map.put( "a", "b" );
}
}

then your ide say it's wrong (and it will indeed prove impossible to compile).

That's exactly what happens with my GenericForwardComposer subclass. I need to put values into the arg map, but it only works if leave my subclass raw. If I declare it like 'extends GenericForwardComposer<Window>' then I'm unable to compile it.

With kind regards

César Varona

[hide preview]