做访问修饰符影响也反映? [英] Do access modifiers affect reflection also?

查看:142
本文介绍了做访问修饰符影响也反映?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直相信他们做到了,但在这里看到了一些答案让我怀疑......

I always believe they did, but seeing some answers here make me doubt...

我可以通过反射访问从类外部私有字段/属性/方法?

Can I access private fields/properties/methods from outside a class through reflection?

推荐答案

是的,你可以通过反射来访问私有字段。这是一个很大的ORM的如何去填充一个对象,而无需通过你的属性(这将调用业务逻辑,你可能没有打算要在对象负荷运行)。

Yes you can access private fields via reflection. This is how a lot of ORMs go about populating an object without going through your properties (which will invoke business logic you might not have intended to be run on an object load).

访问修饰符是不是安全的一种形式!

Access modifiers are not a form of security!

这篇关于做访问修饰符影响也反映?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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