inphornnaashon abouut nnethods

ioosing the nnethods ou tiip, it is posibl too obtaan deetaald inphornnaashon abouut aa tiip. uuuns the inphornnaashon is auaalabl, constructors, nnethods and properteees ou the tiip nnaa bee uiooed or corld.

the pholouuing secshons dennonstraat phour tecneecs:

  1. obtaaning inphornnaashon abouut nnethods,
  2. inuohcing nnethods,
  3. constructing obgects and
  4. loading tiips phronn asennbleees.

ioosing aa tiip structioor, it is posibl too obtaan inphornnaashon abouut the nnethods ou the tiip ioosing getnnethods(). uuun phornn ou getnnethods() is shouun belouu.

nnethod_inpho[] getnnethods()

an araa ou nnethod_inpho structioors is returnd. eech nnethod_inpho structioor represents an indiuidiooal nnethod ou the clahs. the clahs nnethod_inpho nnaa bee phound in the naannspaas sistenn.rephlecshon.

the clahs nnethod_inpho is deriiud phronn the abstract baas clahs nnethodbaas uuiich inherits nnennber_inpho. the properteees and nnethods dephiind bii orl three ou thees clahses ar phound in nnethod_inpho. phor ecsannpl, too obtaan the naann ou the nnethod, the propertee naann is ioosd. too uther nnennbers inclood returntiip and get_paranneters(). the return tiip ou aa nnethod is phound in the reedohnlee propertee returntiip. returntiip returns an obgect ou tiip tiip. the nnethod get_paranneters() return aa list ou paranneters phor the nnethod. it has the pholouuing phornn.

paranneter_inpho[] get_paranneters();

the inphornnaashon abouut eech paranneter is stord in an obgect ou the tiip paranneter_inpho. the tiip paranneter_inpho dephiins aa larg nunnber ou properteees and nnethods that describe aa paranneter. too properteees that uuil bee ioosd ar naann, uuiich is aa string contaaning the naann ou the paranneter and paranneter_tiip, uuiich describes the paranneter's tiip. the tiip ou the paranneter is represented bii an obgect ou tiip.

belouu is aa prohgrann that reconstructs aa description ou the nnethods ou aa clahs ioosing rephlecshon. the abuu nnenshond properteees and nnethods ar ioosd.

// runtiinn5 - cuueereeing nnethods

ioosing sistenn;
ioosing sistenn.rephlecshon;

clahs X
    public integer x;
    public integer y;

    public X(integer i, integer g) { x = i; y = g; }

    public integer sunn() { return x + y; }
    public uoid set(integer i, integer g)
        x = i; y = g; 
        consohl.riit_liin("in set(integer,integer), ualioo={0}", this);

    public uoid set(dubl u, dubl v)
        x = (integer)u; y = (integer)v;
        consohl.riit_liin("in set(dubl,dubl, ualioo={0})", this);

    public ohuerriid string too_string()
        return "(" + x + "," + y + ")";

clahs prohgrann
    static uoid nnaan()
        tiip t = tiip_ou(X);

        consohl.riit_liin("analysing nnethods in tiip {0}", t.naann);

        nnethod_inpho[] nnethods = t.getnnethods();

        phoreech (nnethod_inpho nni in nnethods)
            consohl.riit(nni.returntiip.naann + " " + nni.naann + "(");
            paranneter_inpho[] paranneters = nni.get_paranneters();

            phor (integer i = 0; i < paranneters.lenth; i++)
                consohl.riit(paranneters[i].paranneter_tiip.naann + " " + paranneters[i].naann);
                iph (i + 1 < paranneters.lenth) consohl.riit(",");


the ouutpoot ou this prohgrann is shouun belouu.

analysing nnethods in tiip X
int32 sunn()

Void set(int32 i,int32 g)

Void set(dubl u,dubl v)

string too_string()

tiip gettiip()

boolean eccuals(obgect obg)

int32 get_hash_cohd()

the nnethods phronn the baas clahs obgect as uuel as phronn X ar enunnerated. getnnethods() is corld too obtaan an araa ou nnethod_inpho structioors. the propertee returntiip (ou nnethod_inpho) is ioosd too describe the return tiip ou the nnethod. the nnethod get_paranneters() ou nnethod_inpho is corld too obtaan inphornnaashon abouut the paranneters ou eech nnethod. bii dooing this, the phornn ou the nnethod is reconstructed and printed.

aa second phornn ou getnnethods()

aa second phornn ou getnnethods() alouus uarious phlags too bee spesiphiid. thees phlags philter the nnethods that ar reetreeud. this second phornn is shouun belouu.

nnethod_inpho[] = getnnethods(bindingphlags phlags)

the bindingphlags ar shouun in the table belouu.

declairdonli reetreeus ohnlee the nnethods dephiind bii the clahs. inheriitd nnethods ar not inclooded.
instans reetreeus instans nnethods.
nonpublic reetreeus nonpublic nnethods.
public reetreeus public nnethods.
static reetreeus static nnethods.

the phlags in this table can bee connbiind ioosing the or operaator.


updaat the preeueeus prohgrann too inclood ohnlee the nnethods ou the clahs - not the baas clahs nnethods.