AccessbileObject setAccessible array version vs non-array version

Jochen Theodorou blackdrag at gmx.org
Sat Dec 10 09:13:53 UTC 2016


Hi all,

motivated by the recent "Java 9 build 148 causes trouble in Apache 
Lucene/Solr/Elasticsearch" thead, I thought I ask... there is 
AcccessibleObject#setAccessible(boolean), which will ask the 
SecurityManager for permissions and then make itself accessible 
according to the boolean flag. the array version takes an array of 
AccessibleObjects, asks the security manager *once* and then makes all 
of them accessible. So if you are in need to make a lot of objects 
accessible the array version is superior in performance.

Now with jigsaw it is no longer a all or nothing for the class, now 
single methods or fields may no longer be made accessible, even without 
security manager. That means that even without a security manager set 
using the array version on File for example will fail with an exception 
(unless the module is opened from the command line, but we should leave 
that out for now)

My question now basically is the following... why is this method not 
made deprecated? It is kind of useless now, even misleading I would say.

bye Jochen


More information about the core-libs-dev mailing list