Java generics and “Bound mismatch?

I think you've messed your question up... This compiles for me.

Up vote 1 down vote favorite share g+ share fb share tw.

I have a number some classes that user java generics and everything was working fine until I added some additional layers to the class hierarchy. I am wondering if the problem is related to "type erasure" but I am not sure how to express the inheritance to eliminate this. Class definitions: public interface IBaseDAO ; public interface IEntityDAO extends IBaseDAO; public interface IBaseFileDAO extends IEntityDAO; public interface IInvoiceDAO extends IBaseFileDAO; public class BaseDAO implements IBaseDAO; public abstract class EntityDAO extends BaseDAO implements IEntityDAO; public abstract class BaseFileDAO extends EntityDAO implements IBaseFileDAO; public class InvoiceDAO extends BaseFileDAO implements IInvoiceDAO; public abstract class BaseEntity implements Serializable; public class File extends BaseEntity; public abstract class Transaction extends File; public class Request extends Transaction; public class Invoice extends Request; The errors are: Bound mismatch: The type Invoice is not a valid substitute for the bounded parameter of the type BaseFileDAO Bound mismatch: The type Invoice is not a valid substitute for the bounded parameter of the type IBaseFileDAO I am a bit out of my depth here, can anyone give me some advice on how to express the Invoice class to eliminate the error?

EDIT: Not sure if this helps but I also have: public class FileDAO extends BaseFileDAO implements IFileDAO; public interface IFileDAO extends IBaseFileDAO; java generics link|improve this question edited Nov 11 '11 at 21:59 asked Nov 11 '11 at 21:27hairyone476 60% accept rate.

3 I can't believe it requires 13 classes/interfaces to exhibit this problem. Please can you construct a minimal example, so that it's easier to read. – Oli Charlesworth Nov 11 '11 at 21:30 Are you sure you don't have a conflict with java.io.

File? – Jim Garrison Nov 11 '11 at 21:36 should it be IEntityDAO and EntityDAO – gigadot Nov 11 '11 at 21:37 @OliCharlesworth I am sorry I would have liked to have presented a simpler case. But I don't really understand what is causing the problem, so it is difficult for me to write code that reproduces it.

I daresay that someone who knew what the cause was could. Produce a simpler case. – hairyone Nov 11 '11 at 21:47 1 When these are created as empty classes, the error does not occur (at least as inner classes, under Eclipse).

You didn't include the line number where the problem is occurring. I suspect it's dependent on code inside the classes that we can't guess at. – Ed Staub Nov 11 '11 at 22:00.

I think you've messed your question up... This compiles for me: import java.io. Serializable; interface IBaseDAO { } interface IEntityDAO extends IBaseDAO { } interface IBaseFileDAO extends IEntityDAO { } interface IInvoiceDAO extends IBaseFileDAO { } class BaseDAO implements IBaseDAO { } abstract class EntityDAO extends BaseDAO implements IEntityDAO { } abstract class BaseFileDAO extends EntityDAO implements IBaseFileDAO { } class InvoiceDAO extends BaseFileDAO implements IInvoiceDAO { } abstract class BaseEntity implements Serializable { } class File extends BaseEntity { } abstract class Transaction extends File { } class Request extends Transaction { } class Invoice extends Request { } There is nothing to do with type erasure here in code presented.

I just created a new project in Eclipse with the code you suggested and you are quite correct it compiles with just a few warnings about serialVersionUID!. – hairyone Nov 11 '11 at 22:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions