[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3719) Javassist fails to instrument valid classes in certain cases

Fabio adriano Lisboa Gomes (JIRA) noreply at atlassian.com
Sun Sep 20 14:36:50 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33995#action_33995 ] 

Fabio adriano Lisboa Gomes commented on HHH-3719:
-------------------------------------------------

I have similar problem when I migrate to Hibernate-Core 3.3.2.  To solve this one, I change Javassist by CGLIB. 

In my POM.xml file, instead of:

<dependency>
	<groupId>javassist</groupId>
	<artifactId>javassist</artifactId>
	<version>3.11.0.GA</version>
</dependency>

I use:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-cglib-repack</artifactId>
    <version>2.1_3</version>
</dependency>

<dependency>
   <groupId>cglib</groupId>
   <artifactId>cglib-nodep</artifactId>
   <version>2.1_3</version>
</dependency>
----
For Hibernate developers: Why not wait a fix for this bug in Javassist, before making the CGLIB library deprecated? 

> Javassist fails to instrument valid classes in certain cases
> ------------------------------------------------------------
>
>                 Key: HHH-3719
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3719
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1
>         Environment: Javassist 3.4.GA (also tested with 3.9.GA)
>            Reporter: Paul Pogonyshev
>            Priority: Minor
>
> In certain cases Javassist fails with the following message: "duplicate method: getId in org.hibernate.proxy.HibernateProxy_$$_javassist_0".
> I was able to trace the problem down to the following simple case.
> public interface Identifiable <Type>
> {  Type getId ();  }
> public interface Entity extends Identifiable <Long>
> {  Long getId ();  }
> public class EntityImpl implements Entity
> {
>     private Long  id;
>     public Long getId ()
>     {  return id;  }
>     void setId (Long id)
>     {  this.id = id;  }
> }
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
>           "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
>           "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping>
>   <class name="EntityImpl"
>          proxy="Entity">
>     <id name="id"/>
>   </class>
> </hibernate-mapping>
> Note that at least generics in definition of Identifiable interface and specifying proxy interface in the mapping seems important.  Easy workaround seems to just not explicitly redefine getId() in Entity interface, i.e. just keep the one (same one) gotten from Identifiable.  However, _finding_ this workaround was by no means easy.
> As I know, Java compiler removes generics information from compiled code, so the two methods might indeed appear different (i.e. as Objecte getId() and Long getId() correspondingly).  Maybe Javassist could just disable duplicate method checks in generated classes for the cases when _both_ methods come from the wrapped class?
> I'm not sure this is the right tracker, but I couldn't find one for Javassist.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list