mortonnex
V2EX  ›  Java

aop 和 反射的关系?

  •  
  •   mortonnex · Dec 17, 2018 · 3970 views
    This topic created in 2764 days ago, the information mentioned may be changed or developed.
    9 replies    2018-12-18 12:15:48 +08:00
    leriou
        1
    leriou  
       Dec 17, 2018
    没关系, 两个概念
    lxtx2018
        2
    lxtx2018  
       Dec 17, 2018 via Android
    aop 用到了反射
    lhx2008
        3
    lhx2008  
       Dec 17, 2018 via Android
    AOP 实现的时候可能会用到反射
    mortonnex
        4
    mortonnex  
    OP
       Dec 17, 2018
    @lxtx2018
    @lhx2008
    利用反射获取了代理对吧
    lhx2008
        5
    lhx2008  
       Dec 17, 2018 via Android
    @mortonnex 要看具体实现,Spring AOP 的部分实现用的 jdk 那个 Proxy,是反射调用的。但是还有些 AOP 实现是静态字节码织入的,应该不算用到反射
    mortonnex
        6
    mortonnex  
    OP
       Dec 17, 2018 via iPhone
    @lhx2008 明白了
    xpresslink
        7
    xpresslink  
       Dec 17, 2018
    AOP 是面向切面编程是框架级别的,反射是语言基础级别的。AOP 只是用到了 java.lang.reflect.Proxy 类和 java.lang.reflect.InvocationHandler 接口来实现动态代理。
    asAnotherJack
        8
    asAnotherJack  
       Dec 17, 2018
    没有关系,很多 AOP 的实现方式用到了 reflect
    javaWeber
        9
    javaWeber  
       Dec 18, 2018
    aop 基于动态代理,而动态代理用到了反射。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5388 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 01:18 · PVG 09:18 · LAX 18:18 · JFK 21:18
    ♥ Do have faith in what you're doing.