xapi.reflect.service.ReflectionService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-dev Show documentation
Show all versions of xapi-dev Show documentation
Everything needed to run a comprehensive dev environment.
Just type X_ and pick a service from autocomplete;
new dev modules will be added as they are built.
The only dev service not included in the uber jar is xapi-dev-maven,
as it includes all runtime dependencies of maven, adding ~4 seconds to build time,
and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).
The newest version!
package xapi.reflect.service;
/**
* A service interface for providing reflection support to limited runtimes.
*
* Currently, this serves primarily to allow GWT to use reflection,
* but there's no reason it cannot be used for gwt-flash or java2objc tranpiling either.
*
* @author "James X. Nelson ([email protected])"
*
*/
public interface ReflectionService {
Class magicClass(Class classLit);
T[] newArray(Class classLit, int dimension);
T[] newArray(Class classLit, int ... dimensions);
/**
* This method is mostly for gwt; but is also useful for web apps and codegen
*
* Gwt dev mode has problems as its isolated classloader doesn't provide packages.
* We can get class metadata directly using the thread classloader,
* but the instances will throw class cast when trying to use constructors.
* Classes returned by magicClass in devmode will be fully functional in terms
* of reflection, but some data, like package, are stripped.
*
* It can also be used in gwt-prod to load class data that you do not want
* compiled into the javascript; it will request the binary class data,
* and parse out the metadata
*
* It can also be used in multi-classloader web app environments,
* to perform class metadata introspection on objects from foreign classloaders.
*
* the extra support needed for gwt-dev is extracted here.
*
* @param o
* @return
*/
Package getPackage(Object o);
Package getPackage(String parentName, ClassLoader cl);
}