是否可以确定是否在不加载类的情况下加载了该类?

时间:2019-04-25 15:28:38

标签: java reflection java-11

This question from 10 years ago(哇!)询问有关如何检查Java类是否已加载而又没有加载该类的情况。通过反射使用ClassLoader#findLoadedClass的公认答案对我来说效果很好。

但是,现在我已更新到Java 11,该系统抱怨非法访问,并指出该操作将在以后的版本中被拒绝。

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by foo.Bar(file:/F:/Foo/bin/) to method java.lang.ClassLoader.findLoadedClass(java.lang.String)
WARNING: Please consider reporting this to the maintainers of foo.Bar
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Java中是否有一种方法可以检查是否已在不加载类且没有违反访问限制的情况下加载了类?

0 个答案:

没有答案