Program to interfaces!
Map<Temp, ? extends Action> p = new HashMap<Temp, ? extends Action>();
Its better practice.
I noticed that perhaps this wasn't answered correctly. The problem is explained in detail here. What will work for you is perhaps
Map<Temp, ? super Action> p = new HashMap<Temp, Action>();
Hope that helps.
Third edit, I'm new to writing comments so note sure what the process is anyhow here is an example:
public void doSomething ()
{
Map<A, ? super A> p = new HashMap<A, A>();
A a1 = new A();
A a2 = new A();
// AS A CONSUMER
// Not a problem because at runtime we'll know we can accept A.
p.put(a1, new B());
p.put(a2, new C());
// AS A PRODUCER
// what do I cast to? No way of knowing if its B or C.
for (Object a : p.values())
{
}
// Same deal as above is it B or C?
p.get(a1);
}
class A{}
class B extends A {}
class C extends B {}