There are obviously some differences between javac and Eclipse. However, the main point here is that javac is correct in emitting the error. Ultimately, your code converts a Maybe<BarExtendsFoo> to a Maybe<Foo> which is risky.
Here's a rewrite of the visit() method:
public static <TV, TG extends TV> Maybe<TV> something(final TG value) {
return new Maybe<TV>(value);
}
public static class Foo { }
public static class BarExtendsFoo extends Foo { }
public Maybe<Foo> visit() {
Maybe<BarExtendsFoo> maybeBar = something(new BarExtendsFoo());
Maybe<Foo> maybeFoo = maybeBar; // <-- Compiler error here
return maybeFoo;
}
This rewrite is practically identical to your code but it explicitly shows the assignment you're trying to make from Maybe<BarExtendsFoo> to Maybe<Foo>. This is risky. Indeed my Eclipse compiler issues an error on the assignment line. Here's a piece of code that exploits this risk to store an Integer inside a Maybe<String> object:
public static void bomb() {
Maybe<String> maybeString = new Maybe<String>("");
// Use casts to make the compiler OK the assignment
Maybe<Object> maybeObject = (Maybe<Object>) ((Object) maybeString);
maybeObject.set(new Integer(5));
String s = maybeString.get(); // Runtime error (classCastException):
// java.lang.Integer incompatible with
// java.lang.String
}