자바 클래스 의 모든 방법 및 매개 변 수 를 가 져 옵 니 다.

1430 단어 android
    private void getReflectAllMethod( Class > mLocalClass){
    
    Class> c;
    c = mLocalClass;
try {
do{



     Method m[] = c.getDeclaredMethods(); //        
     for (int i = 0; i < m.length; i++) {
      String mod = Modifier.toString(m[i].getModifiers()); //       
      String metName = m[i].getName(); //       
      Class> ret = m[i].getReturnType();//        
      Class> param[] = m[i].getParameterTypes(); //          
      Class> exc[] = m[i].getExceptionTypes(); //        
      System.out.print(mod + " ");//           
      System.out.print(ret + " ");//            
      System.out.print(metName + " (");//         
      for (int x = 0; x < param.length; x++) {//              
       System.out.print(param[x] + "arg-" + x);
       if (x < param.length - 1) {
        System.out.print(",");
       }
      }
      System.out.print(") ");
      if (exc.length > 0) {//      
       System.out.print("throws ");
       for (int x = 0; x < exc.length; x++) {//                
        System.out.print(exc[x].getName());
        if (x < param.length - 1) {
         System.out.print(",");
        }
       }
      }
      System.out.println();
     }
     c=c.getSuperclass();
}while(c!=null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    }

좋은 웹페이지 즐겨찾기