I am thinking of a framework which accepts weak references. Having weak reference to an anonymous class instance does not make sense, so I want to warn the user at runtime by an assertion failure.
So, is there a way to identify that the particular class instance is of some anonymous class?
这应该工作:
myObj.getClass().isAnonymousClass();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.