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

John Zukowski

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).

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.