java - invoking as instance method -


what functionality going follwing

class c = class.forname(handler); class partypes[] = new class[1]; partypes[0] = new string().getclass(); constructor ct = c.getconstructor(partypes); object arglist1[] = new object[1]; arglist1[0] = address; method meth[] = c.getmethods(); object arglist[] = new object[7];  arglist[0] = new integer(transid); arglist[1] = transobj;             arglist[2] = data_vec;             arglist[3] = company_name;         arglist[4] = new boolean(flag_final_level_approval);  flag_final_level_approval=true else false arglist[5] = con;                 arglist[6] = scon;               boolean found = false; for(int i=0;i<meth.length;i++) {     method m = meth[i];     if(m.getname().equals(functionname)) {         result_vec = (vector)m.invoke(ct.newinstance(arglist1),arglist);     } } 

someone using heinous reflection call methods on handler class.

i'd curious know why arguments being put laboriously array of arguments couldn't have been passed handler instance , called.

it looks decided go complex implementation satisfy (real or imagined) requirement ultimate flexibility.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -