Assuming ThirdPartClass.someMajicMethod has a signature something like this:
public <T> T someMajicMethod(Class<T> class1, File file);
Then you can do something like this:
public void someMethod(Class<? extends Shape> type, File shapeFile) {
ThirdPartyClass foo = new ThirdPartyClass();
@SuppressWarnings("unchecked")
Class<? extends Shape[]> arrayType =
(Class<? extends Shape[]>) Array.newInstance(type, 0).getClass();
assert Shape[].class.isAssignableFrom(arrayType);
Shape[] shapes = foo.someMajicMethod(arrayType, shapeFile);
for (Shape shape: shapes)
shape.draw();
}
So, if you call someMethod(Triangle.class, file), it arrayTypewill be Triangle[].classin the call someMajicMethod.
, someMethod , , .