Compile error on MappingModelMetadataProvider on some JVMs only

Description

On some JVMs compiling Search results in a compile error:

Compilation failure:
[ERROR]
\hibernate-search\hibernate-search-engine\src\main\java\org\hibernate\search\impl\MappingModelMetadataProvider.java:[251,34]
type parameters of <T>T cannot be determined; no unique maximal instance
exists for type variable T with upper bounds
T,java.lang.annotation.Annotation
[ERROR]
\hibernate-search\hibernate-search-engine\src\main\java\org\hibernate\search\impl\MappingModelMetadataProvider.java:[257,84]
type parameters of <T>T cannot be determined; no unique maximal instance
exists for type variable T with upper bounds
T,java.lang.annotation.Annotation

See also thread on mailing list:
http://lists.jboss.org/pipermail/hibernate-dev/2012-April/008195.html

specifically Nicolas:

After a goo bisect it seems 31b485c1aaabd9b0ff178505067147e5628e3010 is the
first bad commit.

It is Annotation proxies created by Programmatic Mapping

I m still on windows 7 x64 with 1.6.0_24 jvm

and Emmanuel:

It seems that we are a bit optimistic with out generic Russian dolls

http://stackoverflow.com/questions/2431334/java-generics-what-is-the-compilers-issue-here-no-unique-maximal-instance

/**

  • Creates the proxy for an annotation using Hibernate Commons Annotations

  • @param annotation the AnnotationDescriptor

  • @return the proxy
    */
    private static <T extends Annotation> T createAnnotation(AnnotationDescriptor annotation) {
    //This is a filthy workaround for the Annotations proxy generation,
    //which is using the ContextClassLoader to define the proxy classes
    //(not working fine in modular environments when Search is used by
    //other services such as CapeDwarf).
    //See

//use annotation's own classloader
try {
return AnnotationFactory.create( annotation, annotation.type().getClassLoader() );
}
catch ( Exception e ) {
//first try, but we have another trick
}
//Use TCCL
return org.hibernate.annotations.common.annotationfactory.AnnotationFactory.create( annotation );
}

Basically the compiler cannot guarantee that T in the outer method is the same as T in the AnnotationFactory.create methods. Unfortunately it yells in some strange language.
It looks like the compiler is a bit more stupid on Windows for some obscure reason. Could you try 1.6.0_31 (the latest)?

Assigning to Gail as she was able to reproduce locally and seems to have a solution already.

Environment

None

Status

Assignee

Gail Badner

Reporter

Sanne Grinovero

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Priority

Critical