uschindler commented on issue #12304:
URL: https://github.com/apache/lucene/issues/12304#issuecomment-1552722778

   Hi,
   I did some investigation. Actually it can't be done better with 
`MethodHandles.Lookup` (which inherits the actual visibility privileges by the 
caller; my idea was to require VirtualMethod v2.0 to take a 
`MethodHandles.Lookup` instance passed as ctor parameter, so it gets a "handle" 
to access the private methods of the class). Unfortunately this works the other 
way round, but VirtualMethod is about figuring out if a subclass override a 
method (and in addition how far the override is down the chain), to correctly 
delegate the calls of the backwards layer betwen the two implementations. 
Unfortunately in Java a superclass does not know of their subclasses and the 
superclass has no more rights to look into them. So a lookup does not help.
   
   So we need to use doPrivileged. But here the important limitation: It is NOT 
the responsibility of VirtualMethod to use AccessController, it must be done by 
the caller. In the current case here it is not an issue as both are in same 
module, but for example use of VirtualMethod in another module would break if 
VirtualMethod does the doPrivileged. So the caller (here oal.search.Query) has 
to do it.
   
   I will provide a PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to