如何限制开发人员使用反射来访问Java中的私有方法和构造函数? [英] How to restrict developers to use reflection to access private methods and constructors in Java?

查看:315
本文介绍了如何限制开发人员使用反射来访问Java中的私有方法和构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制开发人员使用反射来访问Java中的私有方法和构造函数?

How to restrict developers to use reflection to access private methods and constructors in Java?

使用普通的Java代码,我们无法访问私有构造函数或私有方法。一类。但是通过使用反射,我们可以访问Java类中的任何私有方法和构造函数。

Using normal Java code we can't access private constructors or private methods outside of a class. But by using reflection we can access any private methods and constructors in a Java class.

那么我们如何为Java代码提供安全性呢?

So how can we give security to our Java code?

推荐答案

使用 href =http://download.oracle.com/javase/7)SecurityManager.html =noreferrer> SecurityManager 和足够严格的限制安全政策

有一个教程中的简短摘要安全文档

这篇关于如何限制开发人员使用反射来访问Java中的私有方法和构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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