[hibernate-dev] Typing Help with JPA 2.1 impl

Steve Ebersole steve at hibernate.org
Thu Jun 14 10:15:10 EDT 2012


So I tried with JDK 1.7 and it worked fine.  I am hoping we can get 
people to try this on different architecture/jdk combos so we can see 
where the issue boundaries are.

I am running on Linux and using the Oracle JDKs:
java version "1.6.0_30"
java version "1.7.0_03"

This does in fact seem to be an issue in the Oracle JDK code.  The bug 
is 6294779, but it does not seem to be available in the bug database 
anymore.  According to any reports I could find it was fixed in beta 31 
of Java 7 JDK.  But apparently no fix was ever ported to Java 6 JDK.

This obviously leads to some interesting question about handling Java 
versions in Hibernate builds and how to best handle this situation.  
I'd like to define these boundaries first and then have that 
discussion.  I have attached my working HEAD with the changes in 
question (I hope, first time using git archive command).  Can others 
using alternative JDKs and other OS architectures try compiling this 
with their Java 6 JDKs?

Thanks

On Thu 14 Jun 2012 07:20:09 AM CDT, Steve Ebersole wrote:
> Ah great point. No I have been compiling with JDK 1.6
>
> On Thu 14 Jun 2012 04:45:27 AM CDT, Hardy Ferentschik wrote:
>> Hi,
>>
>> OOI, have you tried with the Java 7 compiler? I think there used to
>> be a bug in the Java 6 compiler
>> when it came to covariant return types.
>>
>> --Hardy
>>
>>
>>
>> On Jun 13, 2012, at 10:04 PM, Steve Ebersole wrote:
>>
>>> I realize I could split Join and Fetch into different hierarchies.
>>> That is what I want to try to avoid though...
>>>
>>> On Wed 13 Jun 2012 02:55:03 PM CDT, Steve Ebersole wrote:
>>>> I need some help with generic types in the JPA 2.1 API, specifically
>>>> with regard to the new Join#on and Fetch#on methods. We ultimately
>>>> unify those 2 interface hierarchies into a single hierarchy in out
>>>> code using org.hibernate.ejb.criteria.JoinImplementor which extends
>>>> from both Join and Fetch.
>>>>
>>>> The problem I am facing is in the return types. So, Join defines:
>>>> public interface Join<Z,X> {
>>>> public Join<Z,X> on(...);
>>>> ...
>>>> }
>>>>
>>>> Fetch defines:
>>>> public interface Fetch<Z,X> {
>>>> public Fetch<Z,X> on(...);
>>>> ...
>>>> }
>>>>
>>>>
>>>> public interface JoinImplementor<Z,X>
>>>> extends Join<Z,X>, Fetch<Z,X>, FromImplementor<Z,X> {
>>>> ...
>>>> }
>>>>
>>>> The compiler does not at all like JoinImplementor as is, so I have to
>>>> override the method:
>>>>
>>>> public interface JoinImplementor<Z,X>
>>>> extends Join<Z,X>, Fetch<Z,X>, FromImplementor<Z,X> {
>>>> public JoinImplementor<Z,X> on(...);
>>>> ...
>>>> }
>>>>
>>>> which should be fine as it is simple return type clarification. And
>>>> actually that definition compiles fine.
>>>>
>>>> However, JPA also defines a whole hierarchy from Join such as.
>>>> CollectionJoin, ListJoin, etc. So Hibernate has for example:
>>>>
>>>> public interface CollectionJoinImplementor<Z,X> extends
>>>> JoinImplementor<Z,X>, CollectionJoin<Z,X> {
>>>> @Override
>>>> public CollectionJoinImplementor<Z, X> on(...);
>>>> ...
>>>> }
>>>>
>>>> The IDE is fine with this type signature, however trying to compile
>>>> this leads to the following error:
>>>>
>>>> types org.hibernate.ejb.criteria.JoinImplementor<Z,X> and
>>>> org.hibernate.ejb.criteria.JoinImplementor<Z,X> are incompatible; both
>>>> define on(javax.persistence.criteria.Predicate[]), but with unrelated
>>>> return types
>>>>
>>>> I have no idea what I need to do here. Can anyone see the solution?
>>>>
>>>>
>>>
>>> --
>>> steve at hibernate.org
>>> http://hibernate.org
>>> _______________________________________________
>>> hibernate-dev mailing list
>>> hibernate-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>
> --
> steve at hibernate.org
> http://hibernate.org

--
steve at hibernate.org
http://hibernate.org


More information about the hibernate-dev mailing list