java·´ÉäµÄÀý×Ó
package cn.test;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* Java Reflection Cookbook
*
* @author Michael Lee
* @since 2006-8-23
* @version 0.1a
*/
public class TestReflection {
/**
* µÃµ½Ä³¸ö¶ÔÏóµÄ¹«¹²ÊôÐÔ
*
* @param owner, fieldName
* @return ¸ÃÊôÐÔ¶ÔÏó
* @throws Exception
*
*/
public Object getProperty(Object owner, String fieldName) throws Exception {
Class ownerClass = owner.getClass();
Field field = ownerClass.getField(fieldName);
Object property = field.get(owner);
return property;
}
/**
* µÃµ½Ä³ÀàµÄ¾²Ì¬¹«¹²ÊôÐÔ
*
* @param className ˈ̞
* @param fieldName ÊôÐÔÃû
* @return ¸ÃÊôÐÔ¶ÔÏó
* @throws Exception
*/
public Object getStaticProperty(String className, String fieldName)
throws Exception {
Class ownerClass = Class.forName(className);
Field field = ownerClass.getField(fieldName);
Object property = field.get(ownerClass);
return property;
}
/**
* Ö´ÐÐij¶ÔÏó·½·¨
*
* @param owner
* ¶ÔÏó
* @param methodName
* ·½·¨Ãû
* @param args
* ²ÎÊý
* @return ·½·¨·µ»ØÖµ
* @throws Exception
*/
public Object invokeMethod(Object owner, String methodName, Object[] args)
throws Exception {
Class ownerClass = owner.getClass();
Class[] argsClass = new Class[args.length];
for (int i = 0, j = args.length; i < j; i++) {
argsClass
Ïà¹ØÎĵµ£º
Ò»£º×¼±¸ www.savarese.org download
1. rocksaw-1.0.0-src.tar.gz
2. vserv-tcpip-0.9.2-src.tar.gz
¶þ£º±àÒëÔ´ÎļþµÃµ½jar°ü ʹÓÃAnt
1. build vserv-tcpip-0.9.2-src
ÔÚvserv-tcpip-0.9.2Ŀ¼ÏÂÃ潨һ¸ötestsĿ¼£¬È»ºóÔÚcmd´°¿ÚϽøÈë ......
ÉùÒô¿ÉÒÔ´´ÔìÒâ¾³£¬´¥·¢åÚÏ룬µ±ÓëÐéÄâͼÏñÏà½áºÏʱ£¬¸ü¼Ó¿ÉÒÔÈÃÕû¸öÊÀ½ç²¼Âú»Ã¾õ¡£ÉùÒôÊǶàýÌå¼¼ÊõµÄ»ù´¡¡£Õâ¾ÍÊÇSun¹«Ë¾µÄJavaýÌå¼¼Êõ¿ª·¢Ð¡×éæÓÚÔ¤±¸Java Sound 1.0 API²¢½«Æä°üº¬ÓÚÏÂÒ»°æ±¾µÄJAVA¿ª·¢¹¤¾ß¿âÖеÄÔÒò¡£
¡¡¡¡ÔÚJAVA2ƽ̨³öÏÖ֮ǰ£¬JAVAÓïÑÔÖ»ÄÜ´¦Àíµç»°ÒôÖʵÄÉùÒô£¬ÒÔµ¥ÉùµÀ8KHZµÄ²ÉÑùƵÂʴ洢Ϊ&mu ......
¶¨ÒåÒ»¸ö½Ó¿Ú
package com.beckham;
/*
* ¶¨ÒåÒ»¸ö½Ó¿Ú
*/
public interface Move {
public void move() ;
}
ºËÐĵÄʵÏÖÀà
package com.beckham;
/*
* ×î³õµÄ½Ó¿ÚʵÏÖ
*/
public class Tank implements Move {
public void move() {
System.out.println("̹¿Ë¿ª¶¯.......");
}
}
......
½øÐе¥Ôª²âÊÔÄ¿µÄ
µ¥Ôª²âÊÔ±£Ö¤¾Ö²¿´úÂëµÄÖÊÁ¿
µ¥Ôª²âÊÔ¸ÄÁ¼ÏîÄ¿´úÂëµÄÕûÌå½á¹¹
µ¥Ôª²âÊÔ½µµÍ²âÊÔ¡¢Î¬»¤Éý¼¶µÄ³É±¾
µ¥Ôª²âÊÔʹ¿ª·¢¹ý³ÌÊÊӦƵ·±±ä»¯µÄÐèÇó
µ¥Ôª²âÊÔÓÐÖúÓÚÌáÉý³ÌÐòÔ±µÄÄÜÁ¦
µ¥Ôª²âÊÔ×Å
Ó¦¸ÃÓÉ¿ª·¢²¿ÃŽøÐе¥Ôª²âÊÔ
ÓɲâÊÔ²¿ÃŽøÐе¥Ôª²âÊÔµÄÎÊÌ⣺´ú¼Û¸ß£¬ÈËÊÖ²»×㣬µ¢ÎóÁ˲âÊÔ²¿ÃŶÔÆäËû²âÊÔµÄ× ......