Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

When I wrap a collection to be read-only or synchronized, why can I call any of the collection methods via reflection without getting an IllegalAccessException?

0
10 Posted

When I wrap a collection to be read-only or synchronized, why can I call any of the collection methods via reflection without getting an IllegalAccessException?

0
10

Location: http://www.jguru.com/faq/view.jsp?EID=304724 Created: Jan 17, 2001 Modified: 2001-01-17 05:30:21.271 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Brandon Wiley (http://www.jguru.com/guru/viewbio.jsp?EID=304445 When you wrap a collection through the static methods of the Collections class, this creates an instance of a package-private (default access) class. Because you don’t have access to these classes, you can’t call their methods via reflection (though you can call their methods directly through the appropriate interface).

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123