In my project I have a factory method that loads an object that implements an interface. You pass in the class you desire and receive an instantiation of it, like so.
public class Factory {
public static <E extends SomeInterface> E load( Class<E> clss ) throws Exception {
return clss.newInstance();
}
}
You could invoke it like this:
MyObject obj = Factory.load( MyObject.class );
This code works just fine in Eclipse 3.4 with Java 6u13, however today I received a new laptop and installed Eclipse 3.5 and java 6u15 and now I am getting type mismatches everywhere.
MyObject obj = Factory.load( MyObject.class );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Type mismatch: cannot convert from SomeInterface to MyObject
Putting a cast before Factory on that line makes it go away and all runs well, but it makes the line a bit less clean, and I didn't need it before, so what gives?