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

asked 2012-08-07 08:59:37 +0800

cvarona gravatar image 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 flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2012-08-08 03:32:10 +0800

MontyPan gravatar image MontyPan
435 3

updated 2012-08-08 04:07:12 +0800

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... :'(

Monty Pan

link publish delete flag offensive edit

answered 2012-08-08 07:46:22 +0800

cvarona gravatar image cvarona
554 1 6

updated 2012-08-08 10:19:48 +0800


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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2012-08-07 08:59:37 +0800

Seen: 107 times

Last updated: Aug 08 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More