Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我是 AspectJ 的新手,我想知道是否使用 Aspects 创建类的变体 - 我也会创建该类的另一个实例吗?
我猜问题是,如果我添加方面,是否会创建一个新类。
答案是否定的,因为编织,无论是在编译时还是在运行时,使用 AspectJ 都会将更改添加到受切面影响的类中,因此没有创建新类,只是字节码对于原始类和最终类是不同的。
你说的变种是什么意思?如果您询问 AspectJ 是否实例化您的类的副本,答案是否定的。AspectJ 使用一种称为proxy拦截对您的类的调用的设计模式。
proxy