Java Dynamic Proxy
import java.lang.reflect.*;
public class A extends Thread {
public static void main(String[] args) throws Exception{
CC cc = new CC();
HH hh = new HH(cc);
II ii = (II) Proxy.newProxyInstance(HH.class.getClassLoader(),
new Class[]{II.class},
hh);
System.out.println ("" + ii.getClass().getName());
ii.test();
}
}
interface II {
void test();
}
class CC implements II {
public void test() {
System.out.println ("this is cc");
}
}
class HH implements InvocationHandler {
Object obj;
HH(Object obj) {
this.obj = obj;
}
public Object invoke(Object obj, Method m, Object[] args) throws Exception {
System.out.println ("start");
Object o = m.invoke(this.obj, args);
System.out.println ("end");
return o;
}
}
ÔËÐÐʱ¼ÓÈë -Dsun.misc.ProxyGenerator.saveGeneratedFiles=true£¬¿ÉÒԵõ½proxy class¡£
²Î¿¼£ºhttp://www.javablogging.com/what-is-java-dynamic-proxies-api/
Ïà¹ØÎĵµ£º
1.FileÀàΪ¹ÜÀíÎļþºÍĿ¼ÌṩÁË·½·¨£¬Æä¶ÔÏó±íʾһ¸öÎļþ»òÕßĿ¼¡£ËüÌṩÁËÈô¸É·½·¨¶ÔÎļþ»òÎļþ¼Ð½øÐвÙ×÷¡£ÆäÖеÄlist()·½·¨ºÍlistFiles()·½·¨¿ÉÒÔÆðµ½¶¨Î»Ìض¨ÎļþµÄ×÷Óá£
2.ObjectÀ࣬ÊÇËùÓÐJavaÀàµÄ׿ÏÈ£¬ÈôÒ»¸öÀàÉùÃ÷ʱûÓаüº¬extends¹Ø¼ü×Ö£¬ÔòÆäÖ±½Ó¼Ì³ÐÓÚObjetcÀà¡£ÆäÖÐÓÐÐí¶àÖØÒª·½·¨£º
equals(),not ......
import java.io.File;
/**
* @description <p>java ·¾¶</p>
* @author swandragon
* @date Nov 5, 2009
*/
public class FilePath{
/**
* ¿ª·¢Öв»ÒªÊ¹ÓÃSystem.getProperty("user.dir")»ñÈ¡µ±Ç°Óû§Ä¿Â¼µÄÏà¶Ô·¾¶
* Ò²¾¡¿ÉÄܲ»ÒªÊ¹Óþø¶Ô·¾¶£¬Ê¹Óþø¶Ô·¾¶Ê±¿ÉÒÔÔÚÅäÖÃÎļþÖÐ ......
If the requested address is not a valid virtual memory address (it doesn't belong to any of
the memory segments of the executing process), the page cannot be validated, and
a segmentation fault is generated. This vectors control to another part of the kernel and
usually results in the pro ......
ÎÒÏÖÔÚÊÇÈí¼þѧԺ´ó¶þµÄѧÉú£¬ÎÒÃÇѧµÄ½Ì²ÄÊÇ¡¶JavaÓïÑÔ³ÌÐòÉè¼Æ¡·£¬ÏÖÔÚѧµÄÊǽø½×ƪ£¬¿ÉÊÇÎҸоõºÃÏñ»¹ÊÇʲô¶¼²»»á°¡£¡Èç¹ûÕæ¸øÎÒÒ»¸öÌâÄ¿ÈÃÎÒ×Ô¼ºÈ¥×ö£¬ÎÒÏëÎÒ»á×ö²»³öÀ´¡£²»¹ýÈç¹û¿´×ÅÊéȥʵÏÖÒ»¸ö¹¦ÄÜÎÒ»¹ÒªÏëºÜ¾Ã²Å»á×ö³öÀ´£¬Ò²ÐíÊÇÎÒѧϰ»¹²»¹ýÈÏÕæ£¬×Ô¼º¶¯ÊÖµÄÄÜÁ¦»¹Ã»ÓÐÑø³É£¬Ò²ÐíÊÇÎÒ´ ......