[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-1106) Compile error on MappingModelMetadataProvider on some JVMs only

Gail Badner (JIRA) noreply at atlassian.com
Wed Apr 25 15:58:50 EDT 2012


    [ https://hibernate.onjira.com/browse/HSEARCH-1106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46427#comment-46427 ] 

Gail Badner commented on HSEARCH-1106:
--------------------------------------

I created a pull request (https://github.com/hibernate/hibernate-search/pull/280) that simply changes MappingModelMetadataProvider.createAnnotation() to return Annotation (instead of using generics). When this method is used, the return value is cast to the expected type.

This was failing using my Java environment:

Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

It compiles successfully using this pull request.


> Compile error on MappingModelMetadataProvider on some JVMs only
> ---------------------------------------------------------------
>
>                 Key: HSEARCH-1106
>                 URL: https://hibernate.onjira.com/browse/HSEARCH-1106
>             Project: Hibernate Search
>          Issue Type: Bug
>            Reporter: Sanne Grinovero
>            Assignee: Gail Badner
>            Priority: Critical
>
> On some JVMs compiling Search results in a compile error:
> {quote}
> 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
> {quote}
> See also thread on mailing list:
> http://lists.jboss.org/pipermail/hibernate-dev/2012-April/008195.html
> specifically Nicolas:
> {quote}
> After a goo bisect it seems 31b485c1aaabd9b0ff178505067147e5628e3010 is the
> first bad commit.
> It is HSEARCH-1084 Annotation proxies created by Programmatic Mapping
> I m still on windows 7 x64 with 1.6.0_24 jvm
> {quote}
> and Emmanuel:
> {quote}
> 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 HSEARCH-1084
>                //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)?
> {quote}
> Assigning to Gail as she was able to reproduce locally and seems to have a solution already.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list