RFR: 8293067: (fs) Implement WatchService using system library (macOS)

Michael Hall mik3hall at gmail.com
Sat Feb 18 15:00:52 UTC 2023



> On Feb 18, 2023, at 8:54 AM, Michael Hall <mik3hall at gmail.com> wrote:
> 
> 
> 
>> On Feb 16, 2023, at 11:54 AM, Michael Hall <mik3hall at gmail.com <mailto: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.

And to possibly make it a little easier for anyone who does want to try it I added a release for the first time.
This just contains the jar (non-modular), dylib, and a sample invocation.
All it takes.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nio-dev/attachments/20230218/a78237e1/attachment-0001.htm>


More information about the nio-dev mailing list