AspectJ可以将方法添加到java.lang.String中吗 [英] Can aspectj add methods to java.lang.String

查看:80
本文介绍了AspectJ可以将方法添加到java.lang.String中吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读过AspectJ的一些文章,我知道它可以增强类,这很有吸引力.我有一个非常愚蠢的问题,我找不到明确的答案:

I've read some articles of aspectj, I know it can enhance classes, which is attractive. I've a very stupid question that I can't find a clear answer:

Aspectj可以将方法添加到java.lang.String吗?

或类似的问题:如果我无法获得某些类的源代码,是否可以通过Aspectj对其进行增强?

Or similar question: If I can't get the sources of some classes, can I enhance them by aspectj?

推荐答案

不,我的朋友不能这样做.

No, you can't do this my friend.

我认为这是您正在寻找的类型不公开给用户

I think this is what you are looking for Type not exposed to user

有关更多详细信息,请查看 AspectJ开发环境指南#特殊情况

For further details please take a look at The AspectJ Development Environment Guide #Special Cases

如其所说

无论使用哪种aop.xml文件,以下类都不会在LTW基础结构中公开

The following classes are not exposed to the LTW infrastructure regardless of the aop.xml file(s) used

  • 所有org.aspectj.*类(和子包)-基础结构本身需要的类
  • 所有java.*和javax.*类(和子包)
  • 所有sun.reflect.*类-那些是发生反射调用时使用的JDK特定类
  • 这篇关于AspectJ可以将方法添加到java.lang.String中吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆