Java wildcard type security warning

Well, I have an interface that:

public interface abc { public<T extends JPanel> T initalize(); } 

And I am implementing it. Here's what when I define a function like:

 public class Startup_thePanel extends JPanel implements abc { public Startup_thePanel initalize() { return this; } } 

I get a warning about the initalize function, which is "Security type: type expression ... requires raw conversion to match ...".

I can get rid of this with suppresswarning, but I don't want to use it. What am I missing?

Thanks in advance...

+5
source share
2 answers
 public interface abc<T extends JPanel> { public T initalize(); } public class Startup_thePanel extends JPanel implements abc<Startup_thePanel> { public Startup_thePanel initalize() { return this; } } 

this will make the compiler know what type of interface you are implementing.

+6
source

try it

 public interface abc<T extends JPanel> { public T initalize(); } public class Startup_thePanel extends JPanel implements abc<Startup_thePanel> { private static final long serialVersionUID = 1L; @Override public Startup_thePanel initalize() { return this; } } 
+4
source

All Articles