Preskočiť na hlavný obsah

Java Reflection

Reflection is a powerful thing to get extended class info at runtime. If you are loaded classes into your application dynamically then Java Reflection is the right thing to get the structure of the classes. Reflection uses java class: Class. The object of the 'Class class' can hold all the information of the class and have getter methods to extract and manipulate this information.


// Creates an object of Class String
Class cl = Class.forName("java.lang.String");

// returns all the constructors of the class.
Constructor cnst [] = cl.getConstructors();

// returns all the declared fields of the class.
Field fld [] = cl.getDeclaredFields();

Obľúbené príspevky z tohto blogu

mysql 5.0 upgrade to 5.1

The 5.1 series of MySQLwas unmasked for the gentoo portage. When upgrading from an older major version (including 5.0), you will be required to rebuild everything linked to the libmysqlclient.so.15 and libmysqlclient_r.so.15. You can do this by installing app-portage/gentoolkit and running: # revdep-rebuild --library libmysqlclient.so.15 # revdep-rebuild --library libmysqlclient_r.so.15 If you use the Portage 2.2 series, you may also use: # emerge @preserved-rebuild The official upgrade documentation is available here: http://dev.mysql.com/doc/refman/5.1/en/upgrading.html Note that existing databases may need converting as well, again including those upgrading from 5.0 to 5.1.