-
Notifications
You must be signed in to change notification settings - Fork 268
Description
Due to an ambiguity (spec bug) in the JLS, there's a difference between how Eclipse and Sun's JDK on one hand compiles the following, vs. how OpenJDK's javac compiles it. Eclipse and Sun can handle this, including the type inference at play from the generic about() method.
public static final SubjectFactory<FooSubject, Foo> FOO = new FooSubjectFactory();
...
// assuming ASSERT is some AbstractVerb subclass
ASSERT.about(FOO).that(someFoo).does(somethingFooIsh);
This is the standard delegation form of extension for Truth. Unfortunately, the statement
ASSERT.about(FOO);
... itself fails to compile on OpenJDK, because it drops a piece of type inference along the way and, as it is, ends up presuming the output is Object. It works, however, if one forces the inference in assignment.
DelegatedVerb<FooSubject, Foo> FOO_ASSERT = ASSERT.about(FOO);
FOO_ASSERT.that(someFoo).does(somethingFooIsh);
This is frustrating, because it means that OpenJDK compilers will fail on the literate, convenient syntax for delegation, which means organizations that use OpenJDK internally as the only "approved" JDK can't use this syntax, as currently implemented. They can create a test-local FOO_ASSERT, or they can use extension, but the bugs logged with Oracle are circa-2009 and it looks like this is a long way out from fixed - even in Java7, since it requires JLS changes.
We can look at an alternative way to get this same effect. I'll think about how to accomplish it in a similarly convenient syntax.