Consider this:
public static abstract class JunkValue<X>{
public abstract X value();
public static <X> JunkValue<X> fix(final X x){
return new JunkValue<X>()
{
@Override
public X value() {
return x;
}};
}
}
now I can easily make these two methods:
void test(HappyObject object){test(JunkValue.fix(object));}
void test(JunkValue<HappyObject> object){...}
I want to tell my compiler that if I have a JunkValue<HappyObject> parameter I can just use a HappyObject object parameter instead to this effect.
I got the idea from the fact that you can do Number=1; instead of Number=new Number(1) which I’ve get a LOT of satisfaction from when I extended Number. I just want the same effect with objects instead of numbers.
Thanks.
Autoboxing is part of the language specification and cannot be extended (without changing the compiler)