[ 
https://issues.apache.org/jira/browse/LUCENE-6989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15118171#comment-15118171
 ] 

Uwe Schindler commented on LUCENE-6989:
---------------------------------------

The changes in OpenJDK are about to be committed, see [review 
request|http://cr.openjdk.java.net/~chegar/8148117/]. The final solution 
including a "hack" for us is:
- The Cleaner instance returned by {{cleaner()}} is private to JDK, but 
implements {{Runnable}}
- We can (if possible cast to {{Runnable}} and invoke the method as usual. It 
does not matter which class it implements, we only see {{Runnable}}.
- The call to run() methods does some extra SecurityManager check, so you must 
grant an additional permission. This RuntimePermission is: 
{{secManager.checkPackageAccess("jdk.internal.ref");}}. We have to give this 
permission in tests, otherwise the unmapping fails at runtime (not in static 
startup check). We might improve the startup check to also catch this. The 
extra permission check was suggested by me, because otherwise its far "too 
easy" to call the cleaner, because it implements public interface. Before you 
needed runtime permission "accessClassInPackage.sun.misc", now you need 
"accessClassInPackage.jdk.internal.ref".

I will add this permission and fully test the patch once we have first Java 9 
EA builds with this change available. Before doing anything, I want to try it 
out first. Maybe we can do this at the weekend on FOSDEM together with OpenJDK 
people. I don't have time to build my own JDK now (and not enough knowledge to 
do that on windows). Maybe Robert can help me on Linux?

> Implement MMapDirectory unmapping for coming Java 9 changes
> -----------------------------------------------------------
>
>                 Key: LUCENE-6989
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6989
>             Project: Lucene - Core
>          Issue Type: Task
>          Components: core/store
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>            Priority: Critical
>         Attachments: LUCENE-6989.patch
>
>
> Originally, the sun.misc.Cleaner interface was declared as "critical API" in 
> [JEP 260|http://openjdk.java.net/jeps/260 ]
> Unfortunately the decission was changed in favor of a oficially supported 
> {{java.lang.ref.Cleaner}} API. A side effect of this change is to move all 
> existing {{sun.misc.Cleaner}} APIs into a non-exported package. This causes 
> our forceful unmapping to no longer work, because we can get the cleaner 
> instance via reflection, but trying to invoke it will throw one of the new 
> Jigsaw RuntimeException because it is completely inaccessible. This will make 
> our forceful unmapping fail. There are also no changes in Garbage collector, 
> the problem still exists.
> For more information see this [mailing list 
> thread|http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-January/thread.html#38243].
> This commit will likely be done, making our unmapping efforts no longer 
> working. Alan Bateman is aware of this issue and will open a new issue at 
> OpenJDK to allow forceful unmapping without using the now private 
> sun.misc.Cleaner. The idea is to let the internal class sun.misc.Cleaner 
> implement the Runable interface, so we can simply cast to runable and call 
> the run() method to unmap. The code would then work. This will lead to minor 
> changes in our unmapper in MMapDirectory: An instanceof check and casting if 
> possible.
> I opened this issue to keep track and implement the changes as soon as 
> possible, so people will have working unmapping when java 9 comes out. 
> Current Lucene versions will no longer work with Java 9.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to