Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

Java reflection: How can I retrieve anonymous inner classes?

I have an anonymous inner class inside another class (SomeClass).

Both SomeClass.class.getClasses() and SomeClass.class.getDeclaredClasses() return empty arrays.

I couldn't find some hints on this in Class' Javadocs.

Can anonymous inner classes be retrieved using reflection in some way?

What else are notable differences between anonymous inner classes and normal inner classes?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could try a brute force search of Class$1 ... Class$n until you can't find any more.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...