我想搭上java.io.FileInputStream中的一個子類的超()與此類AspectJ中,無法攔截超()構造函數調用
package de.scrum_master.app;
class ABC {
public ABC() {
System.out.println("Ctr ABC");
}
}
public class DEF extends ABC {
public DEF() throws Exception {
System.out.println("Ctr DEF");
}
static class MyFileInputStream extends java.io.FileInputStream {
MyFileInputStream() throws Exception {
super("de/scrum_master/app/ABC.java"); // HERE
}
};
public static void main(String[] args) throws Exception {
new MyFileInputStream();
new DEF();
}
}
我能趕上DEF和ABC之間的初始化這樣:
@Before("initialization(de.scrum_master.app.DEF.new(..))")
public void test(JoinPoint thisJoinPoint) throws AuditReactiveException {
System.err.println("Aspect DEF:"+thisJoinPoint);
}
但與java.io.FileInputStream中
@Before("initialization(java.io.FileInputStream.new(..))")
public void test2(JoinPoint thisJoinPoint) throws Exception {
System.err.println("Aspect FileInpputStream:"+thisJoinPoint);
}
爲什麼?謝謝。