RFR: 8293067: (fs) Implement WatchService using system library (macOS)
Michael Hall
mik3hall at gmail.com
Sat Feb 18 14:54:56 UTC 2023
> On Feb 16, 2023, at 11:54 AM, Michael Hall <mik3hall at gmail.com> wrote:
>
>
>
>> On Feb 15, 2023, at 5:36 PM, Michael Hall <mik3hall at gmail.com <mailto:mik3hall at gmail.com>> wrote:
>>
>> Exception in thread "FileSystemWatcher" Exception in thread "FileSystemWatcher" java.lang.InternalError: platform encoding not initialized
>
> I had to add a JNI_OnLoad to resolve jvm references which seemed to work. Initializing the encoding from there also seems to work.
> The code now in fact does seem to work. Not a lot of debugging required.
> I’ll try to get my GitHub project updated with maybe improved markdown.
> But for me, now with mine, this seems to work just fine.
Still a little thrown together but I have updated my GitHub project for this.
https://github.com/mik3hall/trz <https://github.com/mik3hall/trz>
My original code is a custom default FileSystemProvider. It is almost all pass through except I added some OS/X specific FileAttributeView’s for file related native api's. For your code this means you are basically a plugin WatchService replacing the default platform polling one for whatever jdk you choose to use it on. No other actual changes to the platform provider are involved.
This jdk needs to include the module jdk.incubator.foreign. I used MemoryAddress to replace the use of Unsafe getInt. A possible way around this, reverting my changes, is mentioned in the README. As are other details of what I remembered needed changing to go from a runtime based implementation to a jni one.
I also detail some of what the original code did.
I have test now with the nio Move, Basic, and a modified extra heavy duty LotsOfEvents. It seems to work fine. Surprisingly easily.
So, this should mean you or anyone else who wants to can try this out against any recent openjdk version.
If anyone does, I would of course be interested in hearing about it. Especially if there are any problems related to what I’ve done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nio-dev/attachments/20230218/85dc1e6b/attachment.htm>
More information about the nio-dev
mailing list