Closed qingbozhang closed 1 month ago
Hello @qingbozhang ,
I've seen some interceptor implementations using MetaObject
as a reflection utility, but you should not use MetaObject
in your code.
It's an internal utility and is not designed/optimized for a generic use.
At the very least, the comments should clearly state that it is an internal tool and is not recommended for external use.
It is advised not to rely on conventions to reach a consensus, but to enforce its package visibility. This is a poor design.
As far as I know, many people are not aware of this, and I have found many tutorials that use it, even answers from chatbots like ChatGPT also suggest it.
Well, you should contact the authors of those tutorials.
The interceptors that I saw used the MetaObject
for overwriting field value.
It may not be obvious to the readers of those tutorials, but it can be done by basic reflection and I'm not interested in adding obvious comments to the classes in this repo only because someone wrote a bad tutorial.
Thank you for your personal subjective advice. This is a project that does not embody the spirit of open source.
Just to be clear, I am sincerely asking you to contact the authors of those tutorials to improve the contents. That is one way to contribute to the open source project.
Hi, While using
SystemMetaObject.forObject
inside the Interceptor, I discovered that each call creates a newDefaultReflectorFactory
instance, which prevents the reuse of the reflector cache.To address this, I defined a default
DEFAULT_REFLECTOR_FACTORY
to facilitate cache reuse. Additionally, I added support for custom parameters, allowing users to pass the DefaultReflectorFactory from Configuration to maximize cache efficiency.here is the detail from JFR