Bug 713910

Summary: Compiler error in Hibernate 4 code
Product: [Fedora] Fedora Reporter: Andrig Miller <andrig.t.miller>
Component: java-1.6.0-openjdkAssignee: Deepak Bhole <dbhole>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 15CC: ahughes, dbhole, jon.vanalten, jvanek, k.georgiou, lkundrak, mjw, mmatejov, omajid, stliu
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-21 05:51:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Andrig Miller 2011-06-16 18:33:46 UTC
Description of problem:

In the following code, the javac in OpenJDK 1.6.0 gets a compilation error, when the Oracle JDK update 25 does not error on it.

/home/andrig/Build/myforkedhibernate4/hibernate-core/hibernate-entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractPathImpl.java:197: invalid inferred types for M; inferred type does not conform to declared bound(s)
inferred: java.util.Map<K,V>
bound(s): java.util.Map<capture#981 of ?,capture#59 of ?>
				return (PluralAttributePath<Y>) get( (MapAttribute<X,?,?>) pluralAttribute );
				                                   ^

The above is the error from the build, and the code in question is line 197 in org.hibernate.ejb.criteria.path.AbstractPathImpl.java in the Entity Manager, and it looks like the following:

 return (PluralAttributePath<Y>) get( (MapAttribute<X,?,?>) pluralAttribute );

The larger methods looks as follows:

/**
         * {@inheritDoc}
         */
        @SuppressWarnings({ "unchecked" })
        public <Y> Path<Y> get(String attributeName) {
                if ( ! canBeDereferenced() ) {
                        throw illegalDereference();
                }

                final Attribute attribute = locateAttribute( attributeName );

                if ( attribute.isCollection() ) {
                        final PluralAttribute<X,Y,?> pluralAttribute = (PluralAttribute<X,Y,?>) attribute;
                        if ( PluralAttribute.CollectionType.MAP.equals( pluralAttribute.getCollectionType() ) ) {
                                return (PluralAttributePath<Y>) get( (MapAttribute<X,?,?>) pluralAttribute );
                        }
                        else {
                                return (PluralAttributePath<Y>) get( (PluralAttribute) pluralAttribute );
                        }
                }
                else {
                        return get( (SingularAttribute<X,Y>) attribute );
                }
        }

As you can see, the error has to do with compiling around the "generics" stuff.

Version-Release number of selected component (if applicable):

[andrig@worklaptop path]$ java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.2) (fedora-58.1.10.2.fc15-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

How reproducible:

Every time.

Steps to Reproduce:
1.clone the Hibernate 4 Git repository.
2.run ./gradlew -x text clean build
3.See the error...
  
Actual results:

Compilation error shown above in the description.

Expected results:

Should compile cleanly as it does with Oracle JDK 1.6.0_25

Additional info:

Comment 1 Deepak Bhole 2011-08-14 22:25:55 UTC
FYI, this is fixed in OpenJDK7 btw and packages for it are available in Fedora 16 and rawhide (java-1.7.0-openjdk).

I will try to find the specific issue and backport it once I am back from vacation the week after the next.

Comment 2 Strong Liu 2011-08-20 03:01:56 UTC
this issue has been workaround by the patch supplied in https://hibernate.onjira.com/browse/HHH-5789

Comment 3 Andrig Miller 2011-11-21 04:33:17 UTC
(In reply to comment #1)
> FYI, this is fixed in OpenJDK7 btw and packages for it are available in Fedora
> 16 and rawhide (java-1.7.0-openjdk).
> 
> I will try to find the specific issue and backport it once I am back from
> vacation the week after the next.


This has been fixed.

Comment 4 Andrig Miller 2011-11-21 05:51:09 UTC
I tested this with building Hibernate 4 again, and all is well.