From ooo_saturn7 at mail.ru Fri May 6 11:26:28 2022 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBPcmxvdg==?=) Date: Fri, 06 May 2022 14:26:28 +0300 Subject: =?UTF-8?B?SXMgaXQgc2FmZSB0byB1cGRhdGUgamFyIHRoYXQgYXJlIHVzZWQgZm9yIGR5?= =?UTF-8?B?bmFtaWMgbGF5ZXJzPw==?= Message-ID: <1651836388.691541796@f457.i.mail.ru> Hello. ? Please, consider the following situation. We have /home/user/temp/foo.jar that is used in dynamically created jpms layer bar. ? Could anyone say if it is safe to do the following: destroy layer bar, update /home/user/temp/foo.jar (modify some code in this jar)and create a new jpms layer (bar_2) that will use /home/user/temp/foo.jar. ? -- Best regards, Alex Orlov From Alan.Bateman at oracle.com Fri May 6 13:08:52 2022 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 6 May 2022 14:08:52 +0100 Subject: Is it safe to update jar that are used for dynamic layers? In-Reply-To: <1651836388.691541796@f457.i.mail.ru> References: <1651836388.691541796@f457.i.mail.ru> Message-ID: On 06/05/2022 12:26, Alex Orlov wrote: > Hello. > > Please, consider the following situation. We have /home/user/temp/foo.jar that is used in dynamically created jpms > layer bar. > > Could anyone say if it is safe to do the following: destroy layer bar, update /home/user/temp/foo.jar (modify some code in this jar)and create a new jpms layer (bar_2) that will use /home/user/temp/foo.jar. > This isn't really a module system issue, it's more about whether about you know if a JAR file is still open (and in use) and whether you can replace a JAR file that is open. In general it is not safe/reliable to do this. If you search JBS you will find dozens of bug reports on this topic, most going back many years. Many of the older bug reports are crashes because the central directory of a zip file was historically memory mapped and accessing a memory mapped region after the file has been replaced will typically SIGBUS. You'll also see bug reports on Windows with errors replacing zip or JAR files that are open. For the module system then you could use a weak reference and have it be queued when the module layer is GC'ed. However, I suspect this may not be timely enough for what you are doing and maybe you could look at using a unique name/location for each update instead. -Alan From ooo_saturn7 at mail.ru Fri May 6 13:13:45 2022 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBPcmxvdg==?=) Date: Fri, 06 May 2022 16:13:45 +0300 Subject: =?UTF-8?B?UmVbMl06IElzIGl0IHNhZmUgdG8gdXBkYXRlIGphciB0aGF0IGFyZSB1c2Vk?= =?UTF-8?B?IGZvciBkeW5hbWljIGxheWVycz8=?= In-Reply-To: References: <1651836388.691541796@f457.i.mail.ru> Message-ID: <1651842825.691618781@f541.i.mail.ru> Thank you very much for such detailed answer. ? ? -- Best regards, Alex Orlov ? ? >???????, 6 ??? 2022, 16:09 +03:00 ?? Alan Bateman : >? >On 06/05/2022 12:26, Alex Orlov wrote: >> Hello. >> >> Please, consider the following situation. We have /home/user/temp/foo.jar that is used in dynamically created jpms >> layer bar. >> >> Could anyone say if it is safe to do the following: destroy layer bar, update /home/user/temp/foo.jar (modify some code in this jar)and create a new jpms layer (bar_2) that will use /home/user/temp/foo.jar. >> This isn't really a module system issue, it's more about whether about >you know if a JAR file is still open (and in use) and whether you can >replace a JAR file that is open. In general it is not safe/reliable to >do this. If you search JBS you will find dozens of bug reports on this >topic, most going back many years. Many of the older bug reports are >crashes because the central directory of a zip file was historically >memory mapped and accessing a memory mapped region after the file has >been replaced will typically SIGBUS. You'll also see bug reports on >Windows with errors replacing zip or JAR files that are open. For the >module system then you could use a weak reference and have it be queued >when the module layer is GC'ed. However, I suspect this may not be >timely enough for what you are doing and maybe you could look at using a >unique name/location for each update instead. > >-Alan ?