If you like creating the seed array of the right type, you can use jsni along with some super-super-source knowledge to create arrays WITHOUT copying through an ArrayList (I avoid java.util overhead such as a plague):
public static native <T> T[] newArray(T[] seed, int length) ;
Where the seed is an array of zero length of the desired type, and the length is the desired length (although in production mode arrays do not have upper bounds, this makes the [] .length field correct).
The com.google.gwt.lang package is a collection of basic utilities used by the compiler for basic emulation, and can be found in gwt-dev! com / google / gwt / dev / jjs / intrinsic / com / google / GWT / languages.
You can use these classes only through jsni calls and only in production gwt code (use GWT.isProdMode ()). In general, if you only access the com.google.gwt.lang classes in super-source code, you are guaranteed to never leak references to classes that exist only in compiled javascript.
if (GWT.isProdMode()){ return newArray(seed, length); }else{ return Array.newInstance(seed.getComponentType(), length); }
Note that you will probably need a super-source for the java.lang.reflect.Array class to avoid the gwt compiler error, which assumes that you want to host your own helper method. However, I cannot help you more than this, since it will go beyond the scope of my employment contract.
source share