Summary: | Covariant return type in ITD produces bad class file | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Ramnivas Laddad <ramnivas> |
Component: | Compiler | Assignee: | Andrew Clement <aclement> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | major | ||
Priority: | P3 | ||
Version: | DEVELOPMENT | ||
Target Milestone: | 1.5.0RC1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Ramnivas Laddad
2005-11-27 15:54:17 EST
I'll take a look tomorrow. Here is a pure java program: import java.io.Serializable; public interface Entity2 { public Long getId(); } class AnEntity implements Entity2,EntityWithId { public Long getId() { return null; } } interface EntityWithId { public Serializable getId(); } After compilation, if I 'javap AnEntity': class AnEntity extends java.lang.Object implements Entity2,EntityWithId{ AnEntity(); public java.lang.Long getId(); public java.io.Serializable getId(); } You can have two methods that differ purely in return type - one has to be a bridge method that forwards to the other, here is implementation of the 'Serializable getId()' method: public java.io.Serializable getId(); Code: Stack=1, Locals=1, Args_size=1 0: aload_0 1: invokevirtual #2; //Method getId:()Ljava/lang/Long; 4: areturn LineNumberTable: line 7: 0 It just calls the getId() returning a Long. AspectJ is doing the same thing. However ... there is *possibly* a bug that has concerned me for a while to do with how we tag methods as bridge methods. Either: we aren't tagging them correctly for hibernate or hibernate doesn't understand bridge methods. Ramnivas, can you try hibernate against a pure java case that results in bridge methods like the one above? Ramnivas, have you had a chance to try hibernate on the pure Java version of this that includes bridge methods? We're in danger of missing fixing this for RC1 if there is a real problem lurking... Good news! It is Hibernate's problem. I tried the same setup in plain Java and got identical failure. public interface SerializableEntity { public Serializable getId(); } And then public class Entity implements SerializableEntity, Serializable { private Long _id; public Long getId() { return _id; } @SuppressWarnings("unused") private void setId(Long id) { _id = id; } } Therefore, marking this bug as "INVALID". Thanks Andy for working on this. I will do more investigation and report to Hibernate. |