From hboehm at google.com Fri Apr 1 00:06:19 2016 From: hboehm at google.com (Hans Boehm) Date: Thu, 31 Mar 2016 17:06:19 -0700 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <56FDB09A.7050108@cs.oswego.edu> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FDB09A.7050108@cs.oswego.edu> Message-ID: The expectation would be that such memory would still be mapped with the same caching behavior as normal memory, e.g. writeback-cacheable, so that it would follow normal Java memory model rules when accessed as normal memory? AFAICT, mapping any kind of memory with different caching behavior is likely to be highly problematic on most architectures. Hans On Thu, Mar 31, 2016 at 4:19 PM, Doug Lea
wrote: > On 03/31/2016 05:14 PM, Dohrmann, Steve wrote: > >> This is a JDK 9 proposal to support allocation of direct >> java.nio.ByteBuffer >> instances backed by memory other than off-heap RAM. >> > > I like it. Various kinds of heterogeneous memories are becoming more > common, and this seems like the simplest accommodation that at least > gets ByteBuffer functionality. > > With such a simple API, it is hard to imagine fundamental problems > fitting to other heterogeneous systems, but it would still be great > if anyone dealing with non-Intel systems (TI/KeyStone?) could > sanity-check this. > > I suspect some people would prefer a more elaborate SPI scheme, > but this seems fine to me: > > > package java.nio; >> >> interface Memory { public ByteBuffer allocateByteBuffer(int size); } >> >> Developers would obtain instances of these Memory objects by calling >> public >> constructors on specific memory classes. We propose having developers >> call >> constructors directly because it is a simple way to accommodate varying >> initialization requirements (e.g. partitioning) that specific memory >> instances may have. >> >> For uniformity, we propose mirroring the existing off-heap >> java.nio.ByteBuffer allocation through an off-heap RAM class that >> implements >> the Memory interface: >> >> package java.nio; >> >> public class OffHeapRAM implements Memory { @Override public ByteBuffer >> allocateByteBuffer(int size) { return ByteBuffer.allocateDirect(size); } } >> >> Uniform access could be extended to on-heap ByteBuffers with a class that >> wraps the non-direct allocation method in ByteBuffer: >> >> package java.nio; >> >> public class HeapRAM implements Memory { @Override public ByteBuffer >> allocateByteBuffer(int size) { return ByteBuffer.allocate(size); } } >> >> The 3 additions above are the only changes proposed. Links to a bug >> report >> and to a JDK 9 patch containing these additions are shown below. For >> sample >> code, we are also creating a class that implements the Memory interface >> for >> java.nio.ByteBuffers backed by Intel's 3D XPoint memory. >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8153111 >> >> patch: http://cr.openjdk.java.net/~vdeshpande/8153111/webrev.00/ >> >> While other useful capabilities in this space (e.g. persistent memory, >> process-shared memory) are being explored, they are specifically not >> addressed or proposed here. We believe that supporting >> java.nio.ByteBuffer >> allocation on other memory spaces is sufficiently useful to propose it now >> for JDK 9. >> >> Please let us know if there is interest in this proposal and if you would >> like to sponsor a patch. >> >> Best regards, Steve Dohrmann >> >> >> > From ecki at zusammenkunft.net Fri Apr 1 02:30:01 2016 From: ecki at zusammenkunft.net (Bernd Eckenfels) Date: Fri, 1 Apr 2016 04:30:01 +0200 Subject: AW: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> Message-ID: <56fddd2b.034cc20a.40b40.fffffef8@mx.google.com> Hello, I like the proposal. I wonder if minimal support for requesting ?keyed? memory locations should already be present. The absolute minimum here would be a long (representing any key scheme but of course most natural would be a slot counter or base address) Memory { ByteBuffer allocate(int size); ByteBuffer request(long slot, int size);} (by Definition each request will produce independent ByteBuffer instances but sharing the backing) This would work for shared memory segments and persistent ram. There might be a need to interrogate the buffers (to get base address or slot number when allocate was used). So it might be a good idea to introduce generic signatures: interface Memory { T allocate(int size); T request(long slot, int size); } ShmMemory implements Memory { ... } ShmByteBuffer b = new ShmMemory().allocate(1*MB); I have the feeling the concept is only a bit more complex but covers much more cases with less wild casting and non standard factories. I like the Memory name, an alternative would be BufferSupplier (with the idea it could also be used for logical buffer pools). Gruss Bernd -- http://bernd.eckenfels.net Von: Dohrmann, Steve Gesendet: Donnerstag, 31. M?rz 2016 23:25 An: core-libs-dev at openjdk.java.net Cc: Fan, Lei t; Deshpande, Vivek R; Kaczmarek, Eric Betreff: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory This is a JDK 9 proposal to support allocation of direct java.nio.ByteBuffer instances backed by memory other than off-heap RAM. The current allocateDirect() static method in java.nio.ByteBuffer is being used by some applications to meet special memory needs -- in particular, allocating large amounts of memory without contributing significantly to GC pause times. Other kinds of memory could offer advantages to such applications. For example, Intel's 3D XPoint memory offers large memory capacities that are more affordable than RAM and speeds that are much faster than NAND storage. Currently, there is no well-defined interface that can be used to offer a Java developer access to these other kinds of memory. Specifically, we propose adding a common memory interface that can be implemented by an open-ended set of memory classes. The interface would provide one method that allocates a java.nio.ByteBuffer on the memory associated with the specific memory instance. package java.nio; interface Memory { public ByteBuffer allocateByteBuffer(int size); } These ByteBuffers will have the same behavior as those allocated by the allocateDirect method in java.nio.ByteBuffer: 1) the ByteBuffer instance is managed on the Java heap, 2) the buffer's backing memory resides on whatever space the memory instance represents, and 3) the backing memory is automatically freed when the ByteBuffer object is garbage collected. Developers would obtain instances of these Memory objects by calling public constructors on specific memory classes. We propose having developers call constructors directly because it is a simple way to accommodate varying initialization requirements (e.g. partitioning) that specific memory instances may have. For uniformity, we propose mirroring the existing off-heap java.nio.ByteBuffer allocation through an off-heap RAM class that implements the Memory interface: package java.nio; public class OffHeapRAM implements Memory { @Override public ByteBuffer allocateByteBuffer(int size) { return ByteBuffer.allocateDirect(size); } } Uniform access could be extended to on-heap ByteBuffers with a class that wraps the non-direct allocation method in ByteBuffer: package java.nio; public class HeapRAM implements Memory { @Override public ByteBuffer allocateByteBuffer(int size) { return ByteBuffer.allocate(size); } } The 3 additions above are the only changes proposed. Links to a bug report and to a JDK 9 patch containing these additions are shown below. For sample code, we are also creating a class that implements the Memory interface for java.nio.ByteBuffers backed by Intel's 3D XPoint memory. bug: https://bugs.openjdk.java.net/browse/JDK-8153111 patch: http://cr.openjdk.java.net/~vdeshpande/8153111/webrev.00/ While other useful capabilities in this space (e.g. persistent memory, process-shared memory) are being explored, they are specifically not addressed or proposed here. We believe that supporting java.nio.ByteBuffer allocation on other memory spaces is sufficiently useful to propose it now for JDK 9. Please let us know if there is interest in this proposal and if you would like to sponsor a patch. Best regards, Steve Dohrmann From mandy.chung at oracle.com Fri Apr 1 04:07:33 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 31 Mar 2016 21:07:33 -0700 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56F96778.5020202@gmail.com> References: <56B72242.7050102@gmail.com> <56B874DA.80001@gmail.com> <56B9EB17.7020303@oracle.com> <56C1E765.7080603@oracle.com> <56C1FE37.9010507@oracle.com> <015201d16813$333650c0$99a2f240$@apache.org> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> Message-ID: Hi Peter, I found this thread has grown to discuss several relevant issues that can be separated. 1. Assist cleaner to deallocate direct byte buffer (JDK-6857566) 2. Replace direct byte buffer with java.lang.ref.Cleaner 3. java.lang.ref.Cleaner be an interface vs final class 4. Pending reference list lock (JDK-8055232) Roger has to speak for #3 which I don?t think he comments on that. For #4, working out the VM and library new interface to transfer the pending references definitely has to take more time and prototype. I?m interested in #4 but not sure if this can target in JDK 9 (given that FC in May). I?d like to address #1 to have the allocating thread to invoke cleaning actions to free native memory rather than any cleaning action. #2 is not as critical in my opinion while it?d be nice to get to. One possible option to move forward is to keep Cleaner as is and keep java.nio.Bits to invoke cleaning actions, i.e. webrev.08.part2 except that CleanerFactory will have two special cleaners - one for native memory cleaning and the other for anything else (there isn?t any client in JDK yet). We will see what Panama would provide for timely deallocation and we could replace the fix in Bits with that when?s available. My comments inlined below that are related #1 and #2. > On Mar 28, 2016, at 10:18 AM, Peter Levart wrote: > > > But first, let me reply to Mandy's comments... > > >> My uncomfort was the fix for JDK-6857566 - both enqueuing pending ref and invoking the cleaning code in an arbitrary thread. >> >> Looking at it again - enqueuing the pending reference is not so much of a concern (simply updating the link) but the common cleaner could be used by other code that may only expect to be invoked in system thread that?s still my concern (thinking of thread locals). >> > > As you'll see in the webrev below, enqueueing is performed solely be ReferenceHandler thread. Allocating thread(s) just wait for it to do its job. There's a little synchronization action performed at the end of enqueueing a chunk of pending references that notifies waiters (allocating threads) so that they can continue. This actually improves throughput (compared to helping enqueue Reference(s) one by one) because there's not much actual work to be done (just swapping pointers) so synchronization dominates. The goal here is to minimize synchronization among threads and by executing enqueuing of the whole bunch of pending references in private by a single thread achieves a reduction in synchronization when lots of Reference(s) are discovered at once - precisely the situation when it matters. > I understand this and have no issue with this. > OTOH helping the Cleaner thread is beneficial as cleanup actions take time to execute and this is the easiest way to retry allocation while there's still chance it will succeed. As the common Cleaner is using InnocuousThread, cleanup actions can't rely on any thread locals to be preserved from invocation to invocation anyway - they are cleared after each cleanup action so each action gets empty thread locals. We could simulate this in threads that help execute cleanup actions by saving thread-locals to local variables, clearing thread-locals, executing cleanup action and then restoring thread-locals from local variables. Mandy, if you think this is important I'll add such save/clear/restore code to appropriate place. I?m comfortable of running unsafe::freeMemory in allocating thread. That?s why I propose to have a specific cleaner for native memory allocation use that seems to be the simplest approach (but if it turns out changing to Cleaner as as interface - it?s a different question). I can?t speak for NIO if we want to put save/clear/restore logic in java.nio.Bits. Mandy From me at noctarius.com Fri Apr 1 04:57:31 2016 From: me at noctarius.com (Christoph Engelbert) Date: Fri, 1 Apr 2016 06:57:31 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <56fddd2b.034cc20a.40b40.fffffef8@mx.google.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56fddd2b.034cc20a.40b40.fffffef8@mx.google.com> Message-ID: Hey guys, I really like the proposal! I also have the strong feeling it should be proposed with an VarHandles in mind. So far VarHandles can only build views on top of ByteBuffers, which stuck with 32bit indexing. Wouldn?t it make sense to also support 64bit addressing when allocating memory? Apart from that I really love Bernd?s comment. Having an option to share memory potions without the need to put another layer on top sounds amazingly useful to me. Also the generic option makes perfect sense (for example if we ever get a 64BitByteBuffer ;-)). Chris > On 01 Apr 2016, at 04:30, Bernd Eckenfels wrote: > > Hello, > > I like the proposal. I wonder if minimal support for requesting ?keyed? memory locations should already be present. The absolute minimum here would be a long (representing any key scheme but of course most natural would be a slot counter or base address) > > Memory { ByteBuffer allocate(int size); ByteBuffer request(long slot, int size);} > > (by Definition each request will produce independent ByteBuffer instances but sharing the backing) > > This would work for shared memory segments and persistent ram. > > There might be a need to interrogate the buffers (to get base address or slot number when allocate was used). So it might be a good idea to introduce generic signatures: > > interface Memory { > T allocate(int size); > T request(long slot, int size); > } > > ShmMemory implements Memory { ... } > > ShmByteBuffer b = new ShmMemory().allocate(1*MB); > > I have the feeling the concept is only a bit more complex but covers much more cases with less wild casting and non standard factories. > > I like the Memory name, an alternative would be BufferSupplier (with the idea it could also be used for logical buffer pools). > > Gruss > Bernd > -- > http://bernd.eckenfels.net > > > Von: Dohrmann, Steve > Gesendet: Donnerstag, 31. M?rz 2016 23:25 > An: core-libs-dev at openjdk.java.net > Cc: Fan, Lei t; Deshpande, Vivek R; Kaczmarek, Eric > Betreff: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory > > This is a JDK 9 proposal to support allocation of direct java.nio.ByteBuffer instances backed by memory other than off-heap RAM. > > The current allocateDirect() static method in java.nio.ByteBuffer is being used by some applications to meet special memory needs -- in particular, allocating large amounts of memory without contributing significantly to GC pause times. Other kinds of memory could offer advantages to such applications. For example, Intel's 3D XPoint memory offers large memory capacities that are more affordable than RAM and speeds that are much faster than NAND storage. Currently, there is no well-defined interface that can be used to offer a Java developer access to these other kinds of memory. > > Specifically, we propose adding a common memory interface that can be implemented by an open-ended set of memory classes. The interface would provide one method that allocates a java.nio.ByteBuffer on the memory associated with the specific memory instance. > > package java.nio; > > interface Memory { > public ByteBuffer allocateByteBuffer(int size); > } > > These ByteBuffers will have the same behavior as those allocated by the allocateDirect method in java.nio.ByteBuffer: 1) the ByteBuffer instance is managed on the Java heap, 2) the buffer's backing memory resides on whatever space the memory instance represents, and 3) the backing memory is automatically freed when the ByteBuffer object is garbage collected. > > Developers would obtain instances of these Memory objects by calling public constructors on specific memory classes. We propose having developers call constructors directly because it is a simple way to accommodate varying initialization requirements (e.g. partitioning) that specific memory instances may have. > > For uniformity, we propose mirroring the existing off-heap java.nio.ByteBuffer allocation through an off-heap RAM class that implements the Memory interface: > > package java.nio; > > public class OffHeapRAM implements Memory { > @Override > public ByteBuffer allocateByteBuffer(int size) { > return ByteBuffer.allocateDirect(size); > } > } > > Uniform access could be extended to on-heap ByteBuffers with a class that wraps the non-direct allocation method in ByteBuffer: > > package java.nio; > > public class HeapRAM implements Memory { > @Override > public ByteBuffer allocateByteBuffer(int size) { > return ByteBuffer.allocate(size); > } > } > > The 3 additions above are the only changes proposed. Links to a bug report and to a JDK 9 patch containing these additions are shown below. For sample code, we are also creating a class that implements the Memory interface for java.nio.ByteBuffers backed by Intel's 3D XPoint memory. > > bug: https://bugs.openjdk.java.net/browse/JDK-8153111 > > patch: http://cr.openjdk.java.net/~vdeshpande/8153111/webrev.00/ > > While other useful capabilities in this space (e.g. persistent memory, process-shared memory) are being explored, they are specifically not addressed or proposed here. We believe that supporting java.nio.ByteBuffer allocation on other memory spaces is sufficiently useful to propose it now for JDK 9. > > Please let us know if there is interest in this proposal and if you would like to sponsor a patch. > > Best regards, > Steve Dohrmann > > From aph at redhat.com Fri Apr 1 07:49:52 2016 From: aph at redhat.com (Andrew Haley) Date: Fri, 1 Apr 2016 08:49:52 +0100 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> Message-ID: <56FE2820.5000906@redhat.com> On 31/03/16 22:14, Dohrmann, Steve wrote: > This is a JDK 9 proposal to support allocation of direct > java.nio.ByteBuffer instances backed by memory other than off-heap > RAM. I must be missing something. How is this different from exposing special memory via the filesystem and mapping a file? Andrew. From szegedia at gmail.com Fri Apr 1 08:54:02 2016 From: szegedia at gmail.com (Attila Szegedi) Date: Fri, 1 Apr 2016 10:54:02 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <56FE2820.5000906@redhat.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FE2820.5000906@redhat.com> Message-ID: <94F7C5F9-02F7-4D55-A107-12FC19DAFAC7@gmail.com> I can think of several differences. For one, you can?t presume the availability of a filesystem (Java doesn?t require that the host system give it access to a filesystem), nor the ability of the filesystem to expose all desired kinds of memory as files. Next, every such solution is OS specific and we love having OS independent APIs in Java. An aspect of OS-specific functionality would also be access controls to these files, while with a Java API such controls can (if needed) be managed by Java security policy (again, in OS independent fashion). Finally, even if all of this is present in the system, exposing memory as files can be a security issue if an external process can also gain access to them. So a simple in-process, OS-independent API is definitely better suited for the task. Just my opinion, Attila. On 01 Apr 2016, at 09:49, Andrew Haley wrote: > > On 31/03/16 22:14, Dohrmann, Steve wrote: > >> This is a JDK 9 proposal to support allocation of direct >> java.nio.ByteBuffer instances backed by memory other than off-heap >> RAM. > > I must be missing something. How is this different from exposing > special memory via the filesystem and mapping a file? > > Andrew. > From abhijit.r.roy at oracle.com Fri Apr 1 09:04:36 2016 From: abhijit.r.roy at oracle.com (Abhijit Roy) Date: Fri, 1 Apr 2016 02:04:36 -0700 (PDT) Subject: https://bugs.openjdk.java.net/browse/JI-9032379 Message-ID: <05380a93-5dee-4a06-a1bc-6904e8cbd3c1@default> Hi, Need some suggestion for this issue (2nd part). Thanks Abhijit From mr.chrisvest at gmail.com Fri Apr 1 09:27:28 2016 From: mr.chrisvest at gmail.com (Chris Vest) Date: Fri, 1 Apr 2016 11:27:28 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56fddd2b.034cc20a.40b40.fffffef8@mx.google.com> Message-ID: <98BC8212-52D3-4E34-AA5E-4EFDB7EBF05D@gmail.com> Could ?keyd? memory - the request method Bernd proposed - not be given as constructor parameters to the Memory implementation? For instance, an ShmMemory implementation that allocates out of /dev/shm, could take a filename through its constructor, and allocate by mapping that file in /dev/shm. Unfortunately this would make it implementation defined, if the allocate method returns the same memory every time, or new memory. To solve that, I would add a boolean isShared method to the Memory interface, so you can tell programatically if the buffers allocated from a given memory instance can be expected to be private (only accessible through the returned ByteBuffer) or shared (others might look at or modify this memory even if I keep my ByteBuffer secret). I would also like the allocate method to take a long size, instead of an int. Implementations are free to throw exceptions if clients ask to allocate more memory than is available, or can fit in the given buffer implementation. And with the current ByteBuffer interface, all implementations would have to throw for allocations greater than 2 GiBs, but if that limitation of the ByteBuffer interface were to be removed, then the Memory interface would be ready for it. Cheers, Chris > On 01 Apr 2016, at 06:57, Christoph Engelbert wrote: > > Hey guys, > > I really like the proposal! I also have the strong feeling it should be proposed with an VarHandles in mind. So far VarHandles can only build views on top of ByteBuffers, which stuck with 32bit indexing. Wouldn?t it make sense to also support 64bit addressing when allocating memory? > > Apart from that I really love Bernd?s comment. Having an option to share memory potions without the need to put another layer on top sounds amazingly useful to me. Also the generic option makes perfect sense (for example if we ever get a 64BitByteBuffer ;-)). > > Chris > >> On 01 Apr 2016, at 04:30, Bernd Eckenfels wrote: >> >> Hello, >> >> I like the proposal. I wonder if minimal support for requesting ?keyed? memory locations should already be present. The absolute minimum here would be a long (representing any key scheme but of course most natural would be a slot counter or base address) >> >> Memory { ByteBuffer allocate(int size); ByteBuffer request(long slot, int size);} >> >> (by Definition each request will produce independent ByteBuffer instances but sharing the backing) >> >> This would work for shared memory segments and persistent ram. >> >> There might be a need to interrogate the buffers (to get base address or slot number when allocate was used). So it might be a good idea to introduce generic signatures: >> >> interface Memory { >> T allocate(int size); >> T request(long slot, int size); >> } >> >> ShmMemory implements Memory { ... } >> >> ShmByteBuffer b = new ShmMemory().allocate(1*MB); >> >> I have the feeling the concept is only a bit more complex but covers much more cases with less wild casting and non standard factories. >> >> I like the Memory name, an alternative would be BufferSupplier (with the idea it could also be used for logical buffer pools). >> >> Gruss >> Bernd >> -- >> http://bernd.eckenfels.net >> >> >> Von: Dohrmann, Steve >> Gesendet: Donnerstag, 31. M?rz 2016 23:25 >> An: core-libs-dev at openjdk.java.net >> Cc: Fan, Lei t; Deshpande, Vivek R; Kaczmarek, Eric >> Betreff: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory >> >> This is a JDK 9 proposal to support allocation of direct java.nio.ByteBuffer instances backed by memory other than off-heap RAM. >> >> The current allocateDirect() static method in java.nio.ByteBuffer is being used by some applications to meet special memory needs -- in particular, allocating large amounts of memory without contributing significantly to GC pause times. Other kinds of memory could offer advantages to such applications. For example, Intel's 3D XPoint memory offers large memory capacities that are more affordable than RAM and speeds that are much faster than NAND storage. Currently, there is no well-defined interface that can be used to offer a Java developer access to these other kinds of memory. >> >> Specifically, we propose adding a common memory interface that can be implemented by an open-ended set of memory classes. The interface would provide one method that allocates a java.nio.ByteBuffer on the memory associated with the specific memory instance. >> >> package java.nio; >> >> interface Memory { >> public ByteBuffer allocateByteBuffer(int size); >> } >> >> These ByteBuffers will have the same behavior as those allocated by the allocateDirect method in java.nio.ByteBuffer: 1) the ByteBuffer instance is managed on the Java heap, 2) the buffer's backing memory resides on whatever space the memory instance represents, and 3) the backing memory is automatically freed when the ByteBuffer object is garbage collected. >> >> Developers would obtain instances of these Memory objects by calling public constructors on specific memory classes. We propose having developers call constructors directly because it is a simple way to accommodate varying initialization requirements (e.g. partitioning) that specific memory instances may have. >> >> For uniformity, we propose mirroring the existing off-heap java.nio.ByteBuffer allocation through an off-heap RAM class that implements the Memory interface: >> >> package java.nio; >> >> public class OffHeapRAM implements Memory { >> @Override >> public ByteBuffer allocateByteBuffer(int size) { >> return ByteBuffer.allocateDirect(size); >> } >> } >> >> Uniform access could be extended to on-heap ByteBuffers with a class that wraps the non-direct allocation method in ByteBuffer: >> >> package java.nio; >> >> public class HeapRAM implements Memory { >> @Override >> public ByteBuffer allocateByteBuffer(int size) { >> return ByteBuffer.allocate(size); >> } >> } >> >> The 3 additions above are the only changes proposed. Links to a bug report and to a JDK 9 patch containing these additions are shown below. For sample code, we are also creating a class that implements the Memory interface for java.nio.ByteBuffers backed by Intel's 3D XPoint memory. >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8153111 >> >> patch: http://cr.openjdk.java.net/~vdeshpande/8153111/webrev.00/ >> >> While other useful capabilities in this space (e.g. persistent memory, process-shared memory) are being explored, they are specifically not addressed or proposed here. We believe that supporting java.nio.ByteBuffer allocation on other memory spaces is sufficiently useful to propose it now for JDK 9. >> >> Please let us know if there is interest in this proposal and if you would like to sponsor a patch. >> >> Best regards, >> Steve Dohrmann >> >> > From Ulf.Zibis at CoSoCo.de Fri Apr 1 11:15:07 2016 From: Ulf.Zibis at CoSoCo.de (Ulf Zibis) Date: Fri, 1 Apr 2016 13:15:07 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <56FE2820.5000906@redhat.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FE2820.5000906@redhat.com> Message-ID: <56FE583B.9070109@CoSoCo.de> Hi, good point! As a convenience we could have something like: ByteBuffer#allocateDirect(Path path) ByteBuffer#allocateDirect(int size, Path path, Option options) What is the logical difference between a memory and a byte buffer, as both provide the facility to save bytes? Couldn't Intel just provide a com.intel.memory.XPoint3DByteBuffer extends Bytebuffer class with usual constructors? I do not see the point, why introducing a new named interface for a just existing solution. As a convenience we could have: ByteBuffer#allocateDirect(int size, Class bufferType) If one wants to hide the class itself as similar with HeapByteBuffer: ByteBuffer#allocateDirect(int size, BufferProvider provider) -Ulf Am 01.04.2016 um 09:49 schrieb Andrew Haley: > I must be missing something. How is this different from exposing special memory via the filesystem > and mapping a file? Andrew. From claes.redestad at oracle.com Fri Apr 1 12:32:08 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 1 Apr 2016 14:32:08 +0200 Subject: RFR: 8152641: Plugin to generate BMH$Species classes ahead-of-time In-Reply-To: References: <56F3EEAB.4090600@oracle.com> <1FE3F7A6-1C7B-4DC6-875C-E3FAEDED08F5@oracle.com> <56F50EC5.6020500@gmail.com> <56F5520D.3080205@oracle.com> <56F676CA.5000803@gmail.com> <56FB09D3.4090000@oracle.com> <56FB82FE.5010209@gmail.com> <56FB8607.8030000@gmail.com> <56FBB014.6050002@oracle.com> <56FBC4D8.8010603@gmail.com> <56FBDF98.4090102@oracle.com> <56FBEE08.7010600@gmail.com> <56FBFC23.5090104@oracle.com> Message-ID: <56FE6A48.4040007@oracle.com> Hi Mandy et al, On 2016-04-01 01:10, Mandy Chung wrote: > GenerateBMHClassesPlugin::configure > The plugin should validate of the input argument and throw an exception if it?s invalid. The plugin API is still being revised and JDK-8152800 is related to the exception case. The existing plugins throw PluginException. GenerateBMHClassesPlugin can do the same. > > Perhaps the expanded signatures should be stored after validation. > > GenerateBMHClassesPlugin::generateConcreteClass > It issues a warning if any exception thrown. If the user specifies the types in the command line, they should specify the valid values (I would expect). I prefer it to be an error and throw PluginException. > > It may be time to rename this plugin to ?-generate-jli-classes plugin, as John suggests. A jlink plugin can define its sub options e.g. ?-generate-jli-classes=bmh[:species=LL,LLL]. > > Can you add a test to sanity test if the classes are generated (both the default species types as well as specified in the input argument)? > > Mandy http://cr.openjdk.java.net/~redestad/8152641/webrev.06/ - Renamed GenerateBMHClassesPlugin to GenerateJLIClassesPlugin, --generate-bmh -> --generate-jli-classes - Implement control of BMH species with sub-parameters --generate-jli-classes=bmh:bmh-species=LL,L3,L5 etc. This will be easy to extend into something like --generate-jli-classes=all:bmh-species=LL,L3,...:invokers=??,...:lambda-forms=??,... as we add other things to this plugin - Expand and validate input in the plugin - Add a test which tests default, explicit, invalid and disabled cases - Add a defaultSpecies() method for testing convenience together with a comment alluding to how it was generated. - Bumped the counter in JLinkTest...[1] To try and answer John's other comments: Yes, I intend to file RFEs and work on adding support to generate other j.l.i classes in the near future as time allows, and also have some na?ve hope that we can add support to generate the default input arguments at build-time. Thanks for all the feedback and reviews! /Claes [1] Mandy filed https://bugs.openjdk.java.net/browse/JDK-8153238 to improve this test. From aph at redhat.com Fri Apr 1 12:59:30 2016 From: aph at redhat.com (Andrew Haley) Date: Fri, 1 Apr 2016 13:59:30 +0100 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <94F7C5F9-02F7-4D55-A107-12FC19DAFAC7@gmail.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FE2820.5000906@redhat.com> <94F7C5F9-02F7-4D55-A107-12FC19DAFAC7@gmail.com> Message-ID: <56FE70B2.4080608@redhat.com> On 04/01/2016 09:54 AM, Attila Szegedi wrote: > I can think of several differences. For one, you can?t presume the > availability of a filesystem (Java doesn?t require that the host > system give it access to a filesystem), nor the ability of the > filesystem to expose all desired kinds of memory as files. OK. I have no sympathy with operating systems that can't do this, but that's just MO. :-) > Next, every such solution is OS specific and we love having OS > independent APIs in Java. I would have thought that by definition memory with odd semantics is OS-dependent and non-portable. > An aspect of OS-specific functionality would also be access controls > to these files, while with a Java API such controls can (if needed) > be managed by Java security policy (again, in OS independent > fashion). Eh? Any OS has access controls on its files. > Finally, even if all of this is present in the system, exposing > memory as files can be a security issue if an external process can > also gain access to them. Exposing memory to an external process in any way can be a security issue. It doesn't matter if it's a file or not. This is irrelevant. Andrew. From aleksej.efimov at oracle.com Fri Apr 1 13:01:27 2016 From: aleksej.efimov at oracle.com (Aleksej Efimov) Date: Fri, 1 Apr 2016 16:01:27 +0300 Subject: RFR: 8153262: javax/xml/bind/marshal/8134111/UnmarshalTest.java fails Message-ID: <56FE7127.9040308@oracle.com> Hi, The push for JDK-8134111 missed one test file. Please, review and approve the addition of missing ObjectFactory.java file. Webrev with added file: http://cr.openjdk.java.net/~aefimov/8153262/00 Thanks, Aleksej From amy.lu at oracle.com Fri Apr 1 13:30:48 2016 From: amy.lu at oracle.com (Amy Lu) Date: Fri, 1 Apr 2016 21:30:48 +0800 Subject: RFR: 8153262: javax/xml/bind/marshal/8134111/UnmarshalTest.java fails In-Reply-To: <56FE7127.9040308@oracle.com> References: <56FE7127.9040308@oracle.com> Message-ID: <56FE7808.7040606@oracle.com> Looks fine. Thank you for the quick fix ! ( As I'm not openjdk reviewer, please wait for reviewer's feedback. ) Thanks, Amy On 4/1/16 9:01 PM, Aleksej Efimov wrote: > Hi, > The push for JDK-8134111 missed one test file. Please, review and > approve the addition of missing ObjectFactory.java file. > > Webrev with added file: http://cr.openjdk.java.net/~aefimov/8153262/00 > > Thanks, > Aleksej > From sean.coffey at oracle.com Fri Apr 1 13:32:20 2016 From: sean.coffey at oracle.com (=?UTF-8?Q?Se=c3=a1n_Coffey?=) Date: Fri, 1 Apr 2016 14:32:20 +0100 Subject: RFR: 8153262: javax/xml/bind/marshal/8134111/UnmarshalTest.java fails In-Reply-To: <56FE7127.9040308@oracle.com> References: <56FE7127.9040308@oracle.com> Message-ID: <56FE7864.1000408@oracle.com> Looks fine. Regards, Sean. On 01/04/16 14:01, Aleksej Efimov wrote: > Hi, > The push for JDK-8134111 missed one test file. Please, review and > approve the addition of missing ObjectFactory.java file. > > Webrev with added file: http://cr.openjdk.java.net/~aefimov/8153262/00 > > Thanks, > Aleksej > From mandy.chung at oracle.com Fri Apr 1 14:57:07 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 1 Apr 2016 07:57:07 -0700 Subject: RFR: 8152641: Plugin to generate BMH$Species classes ahead-of-time In-Reply-To: <56FE6A48.4040007@oracle.com> References: <56F3EEAB.4090600@oracle.com> <1FE3F7A6-1C7B-4DC6-875C-E3FAEDED08F5@oracle.com> <56F50EC5.6020500@gmail.com> <56F5520D.3080205@oracle.com> <56F676CA.5000803@gmail.com> <56FB09D3.4090000@oracle.com> <56FB82FE.5010209@gmail.com> <56FB8607.8030000@gmail.com> <56FBB014.6050002@oracle.com> <56FBC4D8.8010603@gmail.com> <56FBDF98.4090102@oracle.com> <56FBEE08.7010600@gmail.com> <56FBFC23.5090104@oracle.com> <56FE6A48.4040007@oracle.com> Message-ID: > On Apr 1, 2016, at 5:32 AM, Claes Redestad wrote: > > http://cr.openjdk.java.net/~redestad/8152641/webrev.06/ > Looks good except the new test with 2015 copyright start year. > > [1] Mandy filed https://bugs.openjdk.java.net/browse/JDK-8153238 to improve this test. Yes the test should be revised to validate a well-known list of plugins rather than hardcoding the number of plugins. Mandy From claes.redestad at oracle.com Fri Apr 1 15:04:58 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 1 Apr 2016 17:04:58 +0200 Subject: RFR: 8152641: Plugin to generate BMH$Species classes ahead-of-time In-Reply-To: References: <56F3EEAB.4090600@oracle.com> <1FE3F7A6-1C7B-4DC6-875C-E3FAEDED08F5@oracle.com> <56F50EC5.6020500@gmail.com> <56F5520D.3080205@oracle.com> <56F676CA.5000803@gmail.com> <56FB09D3.4090000@oracle.com> <56FB82FE.5010209@gmail.com> <56FB8607.8030000@gmail.com> <56FBB014.6050002@oracle.com> <56FBC4D8.8010603@gmail.com> <56FBDF98.4090102@oracle.com> <56FBEE08.7010600@gmail.com> <56FBFC23.5090104@oracle.com> <56FE6A48.4040007@oracle.com> Message-ID: <56FE8E1A.1010808@oracle.com> On 2016-04-01 16:57, Mandy Chung wrote: >> On Apr 1, 2016, at 5:32 AM, Claes Redestad wrote: >> >> http://cr.openjdk.java.net/~redestad/8152641/webrev.06/ >> > Looks good except the new test with 2015 copyright start year. Fixed. Thanks Mandy! /Claes From peter.levart at gmail.com Fri Apr 1 15:18:38 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 1 Apr 2016 17:18:38 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: References: <56B72242.7050102@gmail.com> <56C1E765.7080603@oracle.com> <56C1FE37.9010507@oracle.com> <015201d16813$333650c0$99a2f240$@apache.org> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> Message-ID: <56FE914E.2070804@gmail.com> Hi Mandy, Roger, On 04/01/2016 06:07 AM, Mandy Chung wrote: > Hi Peter, > > I found this thread has grown to discuss several relevant issues that can be separated. > 1. Assist cleaner to deallocate direct byte buffer (JDK-6857566) > 2. Replace direct byte buffer with java.lang.ref.Cleaner > 3. java.lang.ref.Cleaner be an interface vs final class > 4. Pending reference list lock (JDK-8055232) > > Roger has to speak for #3 which I don?t think he comments on that. For #4, working out the VM and library new interface to transfer the pending references definitely has to take more time and prototype. I?m interested in #4 but not sure if this can target in JDK 9 (given that FC in May). > > I?d like to address #1 to have the allocating thread to invoke cleaning actions to free native memory rather than any cleaning action. #2 is not as critical in my opinion while it?d be nice to get to. One possible option to move forward is to keep Cleaner as is and keep java.nio.Bits to invoke cleaning actions, i.e. webrev.08.part2 except that CleanerFactory will have two special cleaners - one for native memory cleaning and the other for anything else (there isn?t any client in JDK yet). We will see what Panama would provide for timely deallocation and we could replace the fix in Bits with that when?s available. > > My comments inlined below that are related #1 and #2. > >> On Mar 28, 2016, at 10:18 AM, Peter Levart wrote: >> >> >> But first, let me reply to Mandy's comments... >> >> >>> My uncomfort was the fix for JDK-6857566 - both enqueuing pending ref and invoking the cleaning code in an arbitrary thread. >>> >>> Looking at it again - enqueuing the pending reference is not so much of a concern (simply updating the link) but the common cleaner could be used by other code that may only expect to be invoked in system thread that?s still my concern (thinking of thread locals). >>> >> As you'll see in the webrev below, enqueueing is performed solely be ReferenceHandler thread. Allocating thread(s) just wait for it to do its job. There's a little synchronization action performed at the end of enqueueing a chunk of pending references that notifies waiters (allocating threads) so that they can continue. This actually improves throughput (compared to helping enqueue Reference(s) one by one) because there's not much actual work to be done (just swapping pointers) so synchronization dominates. The goal here is to minimize synchronization among threads and by executing enqueuing of the whole bunch of pending references in private by a single thread achieves a reduction in synchronization when lots of Reference(s) are discovered at once - precisely the situation when it matters. >> > I understand this and have no issue with this. > >> OTOH helping the Cleaner thread is beneficial as cleanup actions take time to execute and this is the easiest way to retry allocation while there's still chance it will succeed. As the common Cleaner is using InnocuousThread, cleanup actions can't rely on any thread locals to be preserved from invocation to invocation anyway - they are cleared after each cleanup action so each action gets empty thread locals. We could simulate this in threads that help execute cleanup actions by saving thread-locals to local variables, clearing thread-locals, executing cleanup action and then restoring thread-locals from local variables. Mandy, if you think this is important I'll add such save/clear/restore code to appropriate place. > I?m comfortable of running unsafe::freeMemory in allocating thread. That?s why I propose to have a specific cleaner for native memory allocation use that seems to be the simplest approach (but if it turns out changing to Cleaner as as interface - it?s a different question). I can?t speak for NIO if we want to put save/clear/restore logic in java.nio.Bits. > > Mandy Right, so let's focus on issue #1 for now. You would agree that to separate cleaning actions for DirectByteBuffers from other cleaning actions in the system, there has to be a special ReferenceQueue for them, therefore a special Cleaner instance. If we keep jdk.internal.ref.Cleaner (old sun.misc.Cleaner) just for DirectByteBuffer then we get similar guarantee - helping ReferenceHandler thread would just execute old Cleaners that deallocate or unmap DirectByteBuffer(s) and no other(s). But that would also keep helping threads enqueue other Reference(s) one by one and ReferenceHandler would keep executing old Cleaner(s) which is troublesome because of unresolved problems with OOME(s). It would also be harder to resolve a subtle dilemma described below... So I'm going to propose a solution for #1 while still keeping the rest of webrev unchanged for now and will try to address other issuer later. Here's new webrev: http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.12.part2/ ...the only change from webrev.11.part2 is in CleanerFactory and Direct-X-Buffer template. There are now two lazily initialized Cleaner instances. A dbbCleaner() which is used only for DirectByteBuffer(s) and has extended functionality and a common cleaner() which is used for all other purposes in JDK and doesn't have the extended functionality. The subtle dilemma here is whether to use the dbbCleaner() for all DirectByteBuffer(s) or just for DirectByteBuffer(s) that are created by allocating the native memory and not by mapping it. Only the former DBB(s) use Bits.[un]reserveMemory to limit usage of direct memory. In the webrev above I used dbbCleaner() for both types of DBB(s) so DBB allocating threads also help unmap DBB(s). It is easy to separate those two types and use dbbCleaner() for allocated DBB(s) and common cleaner() for mapped DBB(s) because DirectByteBuffer has two distinct constructors for the two usages and the two cleaners share a common Cleaner.Cleanable type. Such easy separation would not be possible if you wanted to use old jdk.internal.ref.Cleaner for allocated DBBs and the new java.lang.ref.Cleaner for mapped DBBs. I think that with above approach where helping threads are limited to DirectByteBuffer.Deallocator(s) and FileChannelImpl.Unmapper(s) (or only the former if desired) is quite safe. To guarantee (if supported by VM) that helping thread either executes the whole cleaning operation or no part of it, I added @ReservedStackAccess annotation on the critical CleanerImpl.Task.cleanNextEnqueued() method which is called by helping threads. So, what do you think about this webrev from the issue #1 perspective? @Roger: I thought about how to instead of helping the background Cleaner thread, make allocation threads just synchronize with cleaner thread but I haven't yet come up with an elegant way that would not include lots of additional synchronization which would represent overhead in normal operation too. So if helping is limited to DBBs like suggested above, do you still have any concerns? About entanglement between nio Bits and ExtendedCleaner.retryWhileHelpingClean(). It is the same level of entanglement as between the DirectByteBuffer constructor and Cleaner.register(). In both occasions an action is provided to the Cleaner. Cleaner.register() takes a cleanup action and ExtendedCleaner.retryWhileHelpingClean() takes a retriable "allocating" or "reservation" action. "allocation" or "reservation" is the opposite of cleanup. Both methods are encapsulated in the same object because those two functions must be coordinated. So I think that collocating them together makes sense. What do you think? Regards, Peter From peter.levart at gmail.com Fri Apr 1 16:08:52 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 1 Apr 2016 18:08:52 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FE914E.2070804@gmail.com> References: <56B72242.7050102@gmail.com> <56C1FE37.9010507@oracle.com> <015201d16813$333650c0$99a2f240$@apache.org> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> Message-ID: <56FE9D14.8010404@gmail.com> On 04/01/2016 05:18 PM, Peter Levart wrote: > @Roger: > > ... > > About entanglement between nio Bits and > ExtendedCleaner.retryWhileHelpingClean(). It is the same level of > entanglement as between the DirectByteBuffer constructor and > Cleaner.register(). In both occasions an action is provided to the > Cleaner. Cleaner.register() takes a cleanup action and > ExtendedCleaner.retryWhileHelpingClean() takes a retriable > "allocating" or "reservation" action. "allocation" or "reservation" is > the opposite of cleanup. Both methods are encapsulated in the same > object because those two functions must be coordinated. So I think > that collocating them together makes sense. What do you think? ...to illustrate what I mean, here's a variant that totally untangles Bits from Cleaner and moves the whole Cleaner interaction into the DirectByteBuffer itself: http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ Notice the symmetry between Cleaner.retryWhileHelpingClean : Cleaner.register and Allocator : Deallocator ? Regards, Peter From amaembo at gmail.com Fri Apr 1 16:25:05 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Fri, 1 Apr 2016 22:25:05 +0600 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations Message-ID: <755756441.20160401222505@gmail.com> Hello! Please review and sponsor the following patch: http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r1/ The patch preserves more characteristics on primitive stream operations: IntStream/LongStream/DoubleStream.boxed() preserves SORTED and DISTINCT IntStream.asLongStream() preserves SORTED and DISTINCT IntStream.asDoubleStream() and LongStream.asDoubleStream() preserves SORTED (different longs can be converted into the same double, so DISTINCT is not preserved here; not sure whether this is possible for ints) Fixing the boxed() case is especially important as distinct() for primitive streams is implemented like boxed().distinct().unbox, so the actual distinct() operation cannot take the advantage of DISTINCT flag (skip the operation at all) or SORTED flag (switch to more efficient implementation). Here's the small JMH benchmark which measures the performance boost of quite common operation: sort the input numbers and leave only distinct ones: http://cr.openjdk.java.net/~tvaleev/webrev/8153293/jmh/ new Random(1).ints(size).sorted().distinct().toArray() I've got the following results. 9ea+111: Benchmark (size) Mode Cnt Score Error Units SortDistinctTest.sortedDistinct 10 avgt 30 0,612 ? 0,004 us/op SortDistinctTest.sortedDistinct 1000 avgt 30 92,848 ? 1,039 us/op SortDistinctTest.sortedDistinct 100000 avgt 30 32147,205 ? 3487,422 us/op 9ea+111 patched: Benchmark (size) Mode Cnt Score Error Units SortDistinctTest.sortedDistinct 10 avgt 30 0,435 ? 0,001 us/op SortDistinctTest.sortedDistinct 1000 avgt 30 40,555 ? 0,772 us/op SortDistinctTest.sortedDistinct 100000 avgt 30 9031,651 ? 73,956 us/op With best regards, Tagir Valeev. From peter.levart at gmail.com Fri Apr 1 16:37:13 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 1 Apr 2016 18:37:13 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FE914E.2070804@gmail.com> References: <56B72242.7050102@gmail.com> <56C1FE37.9010507@oracle.com> <015201d16813$333650c0$99a2f240$@apache.org> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> Message-ID: <56FEA3B9.3020005@gmail.com> On 04/01/2016 05:18 PM, Peter Levart wrote: > So I'm going to propose a solution for #1 while still keeping the rest > of webrev unchanged for now and will try to address other issuer > later. Here's new webrev: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.12.part2/ > > ...the only change from webrev.11.part2 is in CleanerFactory and > Direct-X-Buffer template. There are now two lazily initialized Cleaner > instances. A dbbCleaner() which is used only for DirectByteBuffer(s) > and has extended functionality and a common cleaner() which is used > for all other purposes in JDK and doesn't have the extended functionality. Here's also a diff between webrev.11.part2 and webrev.12.part2 for easier reviewing: http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.11to12.part2/ Regards, Peter From peter.levart at gmail.com Fri Apr 1 16:46:55 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 1 Apr 2016 18:46:55 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FE9D14.8010404@gmail.com> References: <56B72242.7050102@gmail.com> <015201d16813$333650c0$99a2f240$@apache.org> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> Message-ID: <56FEA5FF.4060801@gmail.com> On 04/01/2016 06:08 PM, Peter Levart wrote: > > > On 04/01/2016 05:18 PM, Peter Levart wrote: >> @Roger: >> >> ... >> >> About entanglement between nio Bits and >> ExtendedCleaner.retryWhileHelpingClean(). It is the same level of >> entanglement as between the DirectByteBuffer constructor and >> Cleaner.register(). In both occasions an action is provided to the >> Cleaner. Cleaner.register() takes a cleanup action and >> ExtendedCleaner.retryWhileHelpingClean() takes a retriable >> "allocating" or "reservation" action. "allocation" or "reservation" >> is the opposite of cleanup. Both methods are encapsulated in the same >> object because those two functions must be coordinated. So I think >> that collocating them together makes sense. What do you think? > > ...to illustrate what I mean, here's a variant that totally untangles > Bits from Cleaner and moves the whole Cleaner interaction into the > DirectByteBuffer itself: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ > > > Notice the symmetry between Cleaner.retryWhileHelpingClean : > Cleaner.register and Allocator : Deallocator ? > > > Regards, Peter > And here's also a diff between webrev.12.part2 and webrev.13.part2: http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ Regards, Peter From david.lloyd at redhat.com Fri Apr 1 17:05:55 2016 From: david.lloyd at redhat.com (David M. Lloyd) Date: Fri, 1 Apr 2016 12:05:55 -0500 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FDB09A.7050108@cs.oswego.edu> Message-ID: <56FEAA73.8070308@redhat.com> Without a resolution to https://bugs.openjdk.java.net/browse/JDK-8008240 (atomics for buffers) or https://bugs.openjdk.java.net/browse/JDK-6476827 (memory consistency properties of buffers), how meaningful is this? On 03/31/2016 07:06 PM, Hans Boehm wrote: > The expectation would be that such memory would still be mapped with the > same caching behavior as normal memory, e.g. writeback-cacheable, so that > it would follow normal Java memory model rules when accessed as normal > memory? AFAICT, mapping any kind of memory with different caching behavior > is likely to be highly problematic on most architectures. > > Hans > > On Thu, Mar 31, 2016 at 4:19 PM, Doug Lea
wrote: > >> On 03/31/2016 05:14 PM, Dohrmann, Steve wrote: >> >>> This is a JDK 9 proposal to support allocation of direct >>> java.nio.ByteBuffer >>> instances backed by memory other than off-heap RAM. >>> >> >> I like it. Various kinds of heterogeneous memories are becoming more >> common, and this seems like the simplest accommodation that at least >> gets ByteBuffer functionality. >> >> With such a simple API, it is hard to imagine fundamental problems >> fitting to other heterogeneous systems, but it would still be great >> if anyone dealing with non-Intel systems (TI/KeyStone?) could >> sanity-check this. >> >> I suspect some people would prefer a more elaborate SPI scheme, >> but this seems fine to me: >> >> >> package java.nio; >>> >>> interface Memory { public ByteBuffer allocateByteBuffer(int size); } >>> >>> Developers would obtain instances of these Memory objects by calling >>> public >>> constructors on specific memory classes. We propose having developers >>> call >>> constructors directly because it is a simple way to accommodate varying >>> initialization requirements (e.g. partitioning) that specific memory >>> instances may have. >>> >>> For uniformity, we propose mirroring the existing off-heap >>> java.nio.ByteBuffer allocation through an off-heap RAM class that >>> implements >>> the Memory interface: >>> >>> package java.nio; >>> >>> public class OffHeapRAM implements Memory { @Override public ByteBuffer >>> allocateByteBuffer(int size) { return ByteBuffer.allocateDirect(size); } } >>> >>> Uniform access could be extended to on-heap ByteBuffers with a class that >>> wraps the non-direct allocation method in ByteBuffer: >>> >>> package java.nio; >>> >>> public class HeapRAM implements Memory { @Override public ByteBuffer >>> allocateByteBuffer(int size) { return ByteBuffer.allocate(size); } } >>> >>> The 3 additions above are the only changes proposed. Links to a bug >>> report >>> and to a JDK 9 patch containing these additions are shown below. For >>> sample >>> code, we are also creating a class that implements the Memory interface >>> for >>> java.nio.ByteBuffers backed by Intel's 3D XPoint memory. >>> >>> bug: https://bugs.openjdk.java.net/browse/JDK-8153111 >>> >>> patch: http://cr.openjdk.java.net/~vdeshpande/8153111/webrev.00/ >>> >>> While other useful capabilities in this space (e.g. persistent memory, >>> process-shared memory) are being explored, they are specifically not >>> addressed or proposed here. We believe that supporting >>> java.nio.ByteBuffer >>> allocation on other memory spaces is sufficiently useful to propose it now >>> for JDK 9. >>> >>> Please let us know if there is interest in this proposal and if you would >>> like to sponsor a patch. >>> >>> Best regards, Steve Dohrmann >>> >>> >>> >> -- - DML From aph at redhat.com Fri Apr 1 17:40:17 2016 From: aph at redhat.com (Andrew Haley) Date: Fri, 1 Apr 2016 18:40:17 +0100 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <56FEAA73.8070308@redhat.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FDB09A.7050108@cs.oswego.edu> <56FEAA73.8070308@redhat.com> Message-ID: <56FEB281.5070102@redhat.com> On 04/01/2016 06:05 PM, David M. Lloyd wrote: > Without a resolution to https://bugs.openjdk.java.net/browse/JDK-8008240 > (atomics for buffers) or > https://bugs.openjdk.java.net/browse/JDK-6476827 (memory consistency > properties of buffers), how meaningful is this? That's on the list of things to get fixed with VarHandles. It's worth discussing in this context. The probelm is that "memory" with odd semantics may not map well onto the JMM. Andrew. From hboehm at google.com Fri Apr 1 20:12:00 2016 From: hboehm at google.com (Hans Boehm) Date: Fri, 1 Apr 2016 13:12:00 -0700 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <56FEB281.5070102@redhat.com> References: <7BA565EA-DB87-4583-93AD-1AF5DA68AA6C@intel.com> <56FDB09A.7050108@cs.oswego.edu> <56FEAA73.8070308@redhat.com> <56FEB281.5070102@redhat.com> Message-ID: It seems like the second one is kind of this issue. Atomics in buffers are not needed to cause problems. If a buffer on x86 were mapped write-through or write-coalescing, for example, I'm not at all sure that signalling completion of a write to the buffer by setting a separate volatile flag (outside the buffer) would work. On x86, there is no fence before the volatile store, and I'm not at all sure what ordering properties there are for a write-through or write-coalescing store followed by a write-back-cacheable store. There has also been a tendency to replace x86 MFENCE instructions following a volatile store, with an atomic read-modify-write instruction. AFAICT, this is usually faster precisely because it only orders write-back-cacheable accesses. So far, the memory model effort has concentrated on the assumption that all relevant memory is mapped write-back-cacheable (or whatever the standard mode is for user-level memory). My impression is that anything else is generally significantly less well specified, at all levels of the stack. On Fri, Apr 1, 2016 at 10:40 AM, Andrew Haley wrote: > On 04/01/2016 06:05 PM, David M. Lloyd wrote: > > Without a resolution to https://bugs.openjdk.java.net/browse/JDK-8008240 > > (atomics for buffers) or > > https://bugs.openjdk.java.net/browse/JDK-6476827 (memory consistency > > properties of buffers), how meaningful is this? > > That's on the list of things to get fixed with VarHandles. It's worth > discussing in this context. The probelm is that "memory" with odd > semantics may not map well onto the JMM. > > Andrew. > > From claes.redestad at oracle.com Fri Apr 1 20:25:04 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 1 Apr 2016 22:25:04 +0200 Subject: RFR: 8153317: Two jimage tests have been failing since JDK-8152641 was fixed Message-ID: <56FED920.3010207@oracle.com> Hi, seems my recent push for JDK-8152641 broke a jimage test or two. While I think these test seem a bit odd, it's apparent that checking that we're not adding the same resource twice is enough to make the tests happy for now: Webrev: http://cr.openjdk.java.net/~redestad/8153317/webrev.01/ Bug: https://bugs.openjdk.java.net/browse/JDK-8153317 Thanks! /Claes From joe.darcy at oracle.com Fri Apr 1 20:32:58 2016 From: joe.darcy at oracle.com (joe darcy) Date: Fri, 1 Apr 2016 13:32:58 -0700 Subject: RFR: 8153317: Two jimage tests have been failing since JDK-8152641 was fixed In-Reply-To: <56FED920.3010207@oracle.com> References: <56FED920.3010207@oracle.com> Message-ID: <56FEDAFA.80806@oracle.com> Hello Claes, I'll approve the test change in the interests of getting the tests back to green, but it does sound like some more investigation is warranted into what is going on. In other words, running down the root cause to make sure the same bad effect won't show up elsewhere. Thanks, -Joe On 4/1/2016 1:25 PM, Claes Redestad wrote: > Hi, > > seems my recent push for JDK-8152641 broke a jimage test or two. > > While I think these test seem a bit odd, it's apparent that checking > that we're not adding the same resource twice is enough to make the > tests happy for now: > > Webrev: http://cr.openjdk.java.net/~redestad/8153317/webrev.01/ > Bug: https://bugs.openjdk.java.net/browse/JDK-8153317 > > Thanks! > > /Claes From steve.drach at oracle.com Fri Apr 1 20:37:37 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 1 Apr 2016 13:37:37 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value Message-ID: Hi, Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. issue: https://bugs.openjdk.java.net/browse/JDK-8153213 webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html Thanks Steve From claes.redestad at oracle.com Fri Apr 1 20:39:46 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 1 Apr 2016 22:39:46 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: References: Message-ID: <56FEDC92.1010002@oracle.com> Hi Steve, this looks good to me! Thanks! /Claes On 2016-04-01 22:37, Steve Drach wrote: > Hi, > > Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. > > issue: https://bugs.openjdk.java.net/browse/JDK-8153213 > webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html > > Thanks > Steve From claes.redestad at oracle.com Fri Apr 1 20:46:10 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 1 Apr 2016 22:46:10 +0200 Subject: RFR: 8153317: Two jimage tests have been failing since JDK-8152641 was fixed In-Reply-To: <56FEDAFA.80806@oracle.com> References: <56FED920.3010207@oracle.com> <56FEDAFA.80806@oracle.com> Message-ID: <56FEDE12.8090506@oracle.com> Hello Joe, and thanks! The change is in the plugin and not the test, though, so might be as good as it gets (I've verified all jlink plugin tests work with this). The surprising thing here to me is why these tests was running the plugin twice on the same (exploded) image since regurgitating an image didn't occur to me to be a valid/supported use-case. /Claes On 2016-04-01 22:32, joe darcy wrote: > Hello Claes, > > I'll approve the test change in the interests of getting the tests > back to green, but it does sound like some more investigation is > warranted into what is going on. In other words, running down the root > cause to make sure the same bad effect won't show up elsewhere. > > Thanks, > > -Joe > > On 4/1/2016 1:25 PM, Claes Redestad wrote: >> Hi, >> >> seems my recent push for JDK-8152641 broke a jimage test or two. >> >> While I think these test seem a bit odd, it's apparent that checking >> that we're not adding the same resource twice is enough to make the >> tests happy for now: >> >> Webrev: http://cr.openjdk.java.net/~redestad/8153317/webrev.01/ >> Bug: https://bugs.openjdk.java.net/browse/JDK-8153317 >> >> Thanks! >> >> /Claes > From Roger.Riggs at Oracle.com Fri Apr 1 21:51:21 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 1 Apr 2016 17:51:21 -0400 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FEA5FF.4060801@gmail.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> Message-ID: <56FEED59.7090906@Oracle.com> Hi Peter, Thanks for the diffs to look at. Two observations on the changes. - The Cleaner instance was intentionally and necessarily different than the CleanerImpl to enable the CleanerImpl and its thread to terminate if the Cleaner is not longer referenced. Folding them into a single object breaks that. Perhaps it is not too bad for ExtendedCleaner to subclass CleanerImpl with the cleanup helper/supplier behavior and expose itself to Bits. There will be fewer moving parts. There is no need for two factory methods for ExtendedCleaner unless you are going to use a separate ThreadFactory. - The Deallocator (and now Allocator) nested classes are identical, and there is a separate copy for each type derived from the Direct-X-template. But it may not be worth fixing until the rest of it is settled to avoid more moving parts. I don't have an opinion on the code changes in Reference, that's different kettle of fish. More next week. Have a good weekend, Roger On 4/1/2016 12:46 PM, Peter Levart wrote: > > > On 04/01/2016 06:08 PM, Peter Levart wrote: >> >> >> On 04/01/2016 05:18 PM, Peter Levart wrote: >>> @Roger: >>> >>> ... >>> >>> About entanglement between nio Bits and >>> ExtendedCleaner.retryWhileHelpingClean(). It is the same level of >>> entanglement as between the DirectByteBuffer constructor and >>> Cleaner.register(). In both occasions an action is provided to the >>> Cleaner. Cleaner.register() takes a cleanup action and >>> ExtendedCleaner.retryWhileHelpingClean() takes a retriable >>> "allocating" or "reservation" action. "allocation" or "reservation" >>> is the opposite of cleanup. Both methods are encapsulated in the >>> same object because those two functions must be coordinated. So I >>> think that collocating them together makes sense. What do you think? >> >> ...to illustrate what I mean, here's a variant that totally untangles >> Bits from Cleaner and moves the whole Cleaner interaction into the >> DirectByteBuffer itself: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ >> >> >> Notice the symmetry between Cleaner.retryWhileHelpingClean : >> Cleaner.register and Allocator : Deallocator ? >> >> >> Regards, Peter >> > > And here's also a diff between webrev.12.part2 and webrev.13.part2: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ > > > Regards, Peter > From roger.riggs at oracle.com Fri Apr 1 23:31:01 2016 From: roger.riggs at oracle.com (Roger Riggs) Date: Fri, 1 Apr 2016 19:31:01 -0400 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FEED59.7090906@Oracle.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> Message-ID: <56FF04B5.2030507@oracle.com> Hi Peter, I overlooked the introduction of another nested class (Task) to handle the cleanup. But there are too many changes to see which ones solve a single problem. Sorry to make more work, but I think we need to go back to the minimum necessary change to make progress on this. Omit all of the little cleanups until the end or do them first and separately. Thanks, Roger On 4/1/16 5:51 PM, Roger Riggs wrote: > Hi Peter, > > Thanks for the diffs to look at. > > Two observations on the changes. > > - The Cleaner instance was intentionally and necessarily different > than the CleanerImpl to enable > the CleanerImpl and its thread to terminate if the Cleaner is not > longer referenced. > Folding them into a single object breaks that. > > Perhaps it is not too bad for ExtendedCleaner to subclass CleanerImpl > with the cleanup helper/supplier behavior > and expose itself to Bits. There will be fewer moving parts. There is > no need for two factory methods for > ExtendedCleaner unless you are going to use a separate ThreadFactory. > > - The Deallocator (and now Allocator) nested classes are identical, > and there is a separate copy for each > type derived from the Direct-X-template. But it may not be worth > fixing until the rest of it is settled to avoid > more moving parts. > > I don't have an opinion on the code changes in Reference, that's > different kettle of fish. > > More next week. > > Have a good weekend, Roger > > > On 4/1/2016 12:46 PM, Peter Levart wrote: >> >> >> On 04/01/2016 06:08 PM, Peter Levart wrote: >>> >>> >>> On 04/01/2016 05:18 PM, Peter Levart wrote: >>>> @Roger: >>>> >>>> ... >>>> >>>> About entanglement between nio Bits and >>>> ExtendedCleaner.retryWhileHelpingClean(). It is the same level of >>>> entanglement as between the DirectByteBuffer constructor and >>>> Cleaner.register(). In both occasions an action is provided to the >>>> Cleaner. Cleaner.register() takes a cleanup action and >>>> ExtendedCleaner.retryWhileHelpingClean() takes a retriable >>>> "allocating" or "reservation" action. "allocation" or "reservation" >>>> is the opposite of cleanup. Both methods are encapsulated in the >>>> same object because those two functions must be coordinated. So I >>>> think that collocating them together makes sense. What do you think? >>> >>> ...to illustrate what I mean, here's a variant that totally >>> untangles Bits from Cleaner and moves the whole Cleaner interaction >>> into the DirectByteBuffer itself: >>> >>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ >>> >>> >>> Notice the symmetry between Cleaner.retryWhileHelpingClean : >>> Cleaner.register and Allocator : Deallocator ? >>> >>> >>> Regards, Peter >>> >> >> And here's also a diff between webrev.12.part2 and webrev.13.part2: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ >> >> >> Regards, Peter >> > From mandy.chung at oracle.com Fri Apr 1 23:32:37 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 1 Apr 2016 16:32:37 -0700 Subject: RFR [9] 8153181: Examine sun.misc.VMSupport In-Reply-To: References: Message-ID: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> Hi Chris, Would jdk.internal.vm be appropriate for this VMSupoprt class? VMSupport::getAgentProperties simply calls JVM_InitAgentProperties. java.management could call JVM_InitAgentProperties directly. src/jdk.jdwp.agent/share/native/libjdwp/util.c JDWP calls it and needs to be updated. VMSupport.getVMTemporaryDirectory() is for jdk.jvmstat to use and I suggest to move this method to jdk.internal.perf.Perf. Mandy > On Mar 31, 2016, at 9:02 AM, Chris Hegarty wrote: > > As part of JEP 260, all non-Critical APIs in sun.misc are being examined. > > sun.misc.VMSupport is a utility class supporting two functions: > 1) the initialization of management Agent properties, and > 2) the retrieval of the VM temporary directory used by the attach and perf data files. > > The initialization of Agent properties is used statically by the java.managment module, > or can be provoked by a serviceability tool on a VM that has had an agent loaded in it. > The location of VM temporary files is a low-level interface between the libraries and VM. > For these reasons, VMSupport should remain in the base module, but be moved to an > internal package. > > http://cr.openjdk.java.net/~chegar/8153181/00/ > https://bugs.openjdk.java.net/browse/JDK-8153181 > > -Chris. From mandy.chung at oracle.com Fri Apr 1 23:36:08 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 1 Apr 2016 16:36:08 -0700 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FF04B5.2030507@oracle.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> Message-ID: > On Apr 1, 2016, at 4:31 PM, Roger Riggs wrote: > > Hi Peter, > > I overlooked the introduction of another nested class (Task) to handle the cleanup. > But there are too many changes to see which ones solve a single problem. > > Sorry to make more work, but I think we need to go back to the minimum necessary > change to make progress on this. Omit all of the little cleanups until the end > or do them first and separately. > +1. That?d really help the reviewers. thanks Mandy > Thanks, Roger > > > > > On 4/1/16 5:51 PM, Roger Riggs wrote: >> Hi Peter, >> >> Thanks for the diffs to look at. >> >> Two observations on the changes. >> >> - The Cleaner instance was intentionally and necessarily different than the CleanerImpl to enable >> the CleanerImpl and its thread to terminate if the Cleaner is not longer referenced. >> Folding them into a single object breaks that. >> >> Perhaps it is not too bad for ExtendedCleaner to subclass CleanerImpl with the cleanup helper/supplier behavior >> and expose itself to Bits. There will be fewer moving parts. There is no need for two factory methods for >> ExtendedCleaner unless you are going to use a separate ThreadFactory. >> >> - The Deallocator (and now Allocator) nested classes are identical, and there is a separate copy for each >> type derived from the Direct-X-template. But it may not be worth fixing until the rest of it is settled to avoid >> more moving parts. >> >> I don't have an opinion on the code changes in Reference, that's different kettle of fish. >> >> More next week. >> >> Have a good weekend, Roger >> >> >> On 4/1/2016 12:46 PM, Peter Levart wrote: >>> >>> >>> On 04/01/2016 06:08 PM, Peter Levart wrote: >>>> >>>> >>>> On 04/01/2016 05:18 PM, Peter Levart wrote: >>>>> @Roger: >>>>> >>>>> ... >>>>> >>>>> About entanglement between nio Bits and ExtendedCleaner.retryWhileHelpingClean(). It is the same level of entanglement as between the DirectByteBuffer constructor and Cleaner.register(). In both occasions an action is provided to the Cleaner. Cleaner.register() takes a cleanup action and ExtendedCleaner.retryWhileHelpingClean() takes a retriable "allocating" or "reservation" action. "allocation" or "reservation" is the opposite of cleanup. Both methods are encapsulated in the same object because those two functions must be coordinated. So I think that collocating them together makes sense. What do you think? >>>> >>>> ...to illustrate what I mean, here's a variant that totally untangles Bits from Cleaner and moves the whole Cleaner interaction into the DirectByteBuffer itself: >>>> >>>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ >>>> >>>> Notice the symmetry between Cleaner.retryWhileHelpingClean : Cleaner.register and Allocator : Deallocator ? >>>> >>>> >>>> Regards, Peter >>>> >>> >>> And here's also a diff between webrev.12.part2 and webrev.13.part2: >>> >>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ >>> >>> Regards, Peter >>> >> > From steve.dohrmann at intel.com Fri Apr 1 23:57:22 2016 From: steve.dohrmann at intel.com (Dohrmann, Steve) Date: Fri, 1 Apr 2016 23:57:22 +0000 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory Message-ID: Hi everyone, The questions and suggestions regarding this proposal (JDK-8153111) are interesting and useful. We are still digesting the feedback; next week we'll do our best to respond to items raised and add to the discussion. I hope this list captures the main concerns and suggestions seen so far in the discussion: 1. Why not enhance ByteBuffer allocation methods rather that create a new Memory interface 2. Does this proposal buy us anything over exposing special memory as a file mappable via the OS? 3. Possibly more elaborate SPI scheme for memory space creation 4. Provide keyed (e.g. long "slot") allocation of ByteBuffers in a memory space 5. Generic interfaces on Memory (alternate name: BufferSupplier) interface methods 6. Clearer shared / private ByteBuffer semantics within a memory space 7. 64-bit allocation / addressing in Memory interface, at least as prep for a less-restricted ByteBuffer interface 8. Importance of atomics for ByteBuffers (JDK-8008240) and ByteBuffer consistency (JDK-6476827) in the context of this proposal 9. Connection between this proposal and VarHandles Best regards, Steve Dohrmann From Alan.Bateman at oracle.com Sat Apr 2 09:53:02 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sat, 2 Apr 2016 10:53:02 +0100 Subject: RFR [9] 8153181: Examine sun.misc.VMSupport In-Reply-To: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> References: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> Message-ID: <56FF967E.5090102@oracle.com> (cc'ing serviceability-dev as this is where this code is maintained). On 02/04/2016 00:32, Mandy Chung wrote: > Hi Chris, > > Would jdk.internal.vm be appropriate for this VMSupoprt class? I agree. > > VMSupport::getAgentProperties simply calls JVM_InitAgentProperties. java.management could call JVM_InitAgentProperties directly. > > src/jdk.jdwp.agent/share/native/libjdwp/util.c > JDWP calls it and needs to be updated. If I recall correctly then this is so that the debugger transport details can be advertised. There is a process AttachingConnector that depends on that so I agree this needs to be updated. > > VMSupport.getVMTemporaryDirectory() is for jdk.jvmstat to use and I suggest to move this method to jdk.internal.perf.Perf. It could although I assume this means that introducing a new shared library. -Alan > > Mandy > >> On Mar 31, 2016, at 9:02 AM, Chris Hegarty wrote: >> >> As part of JEP 260, all non-Critical APIs in sun.misc are being examined. >> >> sun.misc.VMSupport is a utility class supporting two functions: >> 1) the initialization of management Agent properties, and >> 2) the retrieval of the VM temporary directory used by the attach and perf data files. >> >> The initialization of Agent properties is used statically by the java.managment module, >> or can be provoked by a serviceability tool on a VM that has had an agent loaded in it. >> The location of VM temporary files is a low-level interface between the libraries and VM. >> For these reasons, VMSupport should remain in the base module, but be moved to an >> internal package. >> >> http://cr.openjdk.java.net/~chegar/8153181/00/ >> https://bugs.openjdk.java.net/browse/JDK-8153181 >> >> -Chris. From abhijit.r.roy at oracle.com Sat Apr 2 10:56:33 2016 From: abhijit.r.roy at oracle.com (Abhijit Roy) Date: Sat, 2 Apr 2016 03:56:33 -0700 (PDT) Subject: https://bugs.openjdk.java.net/browse/JI-9032379 In-Reply-To: <05380a93-5dee-4a06-a1bc-6904e8cbd3c1@default> References: <05380a93-5dee-4a06-a1bc-6904e8cbd3c1@default> Message-ID: Hi All, It was a mistake from my end. Please ignore it. Thanks, Abhijit From: Abhijit Roy Sent: Friday, April 01, 2016 02:35 PM To: core-libs-dev at openjdk.java.net Subject: https://bugs.openjdk.java.net/browse/JI-9032379 Hi, Need some suggestion for this issue (2nd part). Thanks Abhijit From peter.levart at gmail.com Sat Apr 2 11:24:29 2016 From: peter.levart at gmail.com (Peter Levart) Date: Sat, 2 Apr 2016 13:24:29 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FF04B5.2030507@oracle.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> <56FF04B5.2030507@oracle.com> Message-ID: <56FFABED.2060708@gmail.com> Hi Roger, Thanks for looking at the patch. On 04/02/2016 01:31 AM, Roger Riggs wrote: > Hi Peter, > > I overlooked the introduction of another nested class (Task) to handle > the cleanup. > But there are too many changes to see which ones solve a single problem. > > Sorry to make more work, but I think we need to go back to the minimum > necessary > change to make progress on this. Omit all of the little cleanups until > the end > or do them first and separately. > > Thanks, Roger No Problem. I understand. So let's proceed in stages. Since part1 is already pushed, I'll call part2 stages with names: part2.1, part2.2, ... and I'll start counting webrev revisions from 01 again, so webrev names will be in the form: webrev.part2.1.rev01. Each part will be an incremental change to the previous one. part2.1: This is preparation work to be able to have an extended java.lang.ref.Cleaner type for internal use. Since java.lang.ref.Cleaner is a final class, I propose to make it an interface instead: http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.part2.1.rev01/ This is a source-compatible change and it also simplifies implementation (no injection of Cleaner.impl access function into CleanerImpl needed any more). What used to be java.lang.ref.Cleaner is renamed to jdk.internal.ref.CleanerImpl. What used to be jdk.internal.ref.CleanerImpl is now a nested static class jdk.internal.ref.CleanerImpl.Task (because it implements Runnable). Otherwise nothing has changed in the overall architecture of the Cleaner except that public-facing API is now an interface instead of a final class. This allows specifying internal extension interface and internal extension implementation. CleanerTest passes with this change. So what do you think? Regards, Peter > > > > > On 4/1/16 5:51 PM, Roger Riggs wrote: >> Hi Peter, >> >> Thanks for the diffs to look at. >> >> Two observations on the changes. >> >> - The Cleaner instance was intentionally and necessarily different >> than the CleanerImpl to enable >> the CleanerImpl and its thread to terminate if the Cleaner is not >> longer referenced. >> Folding them into a single object breaks that. >> >> Perhaps it is not too bad for ExtendedCleaner to subclass CleanerImpl >> with the cleanup helper/supplier behavior >> and expose itself to Bits. There will be fewer moving parts. There is >> no need for two factory methods for >> ExtendedCleaner unless you are going to use a separate ThreadFactory. >> >> - The Deallocator (and now Allocator) nested classes are identical, >> and there is a separate copy for each >> type derived from the Direct-X-template. But it may not be worth >> fixing until the rest of it is settled to avoid >> more moving parts. >> >> I don't have an opinion on the code changes in Reference, that's >> different kettle of fish. >> >> More next week. >> >> Have a good weekend, Roger >> >> >> On 4/1/2016 12:46 PM, Peter Levart wrote: >>> >>> >>> On 04/01/2016 06:08 PM, Peter Levart wrote: >>>> >>>> >>>> On 04/01/2016 05:18 PM, Peter Levart wrote: >>>>> @Roger: >>>>> >>>>> ... >>>>> >>>>> About entanglement between nio Bits and >>>>> ExtendedCleaner.retryWhileHelpingClean(). It is the same level of >>>>> entanglement as between the DirectByteBuffer constructor and >>>>> Cleaner.register(). In both occasions an action is provided to the >>>>> Cleaner. Cleaner.register() takes a cleanup action and >>>>> ExtendedCleaner.retryWhileHelpingClean() takes a retriable >>>>> "allocating" or "reservation" action. "allocation" or >>>>> "reservation" is the opposite of cleanup. Both methods are >>>>> encapsulated in the same object because those two functions must >>>>> be coordinated. So I think that collocating them together makes >>>>> sense. What do you think? >>>> >>>> ...to illustrate what I mean, here's a variant that totally >>>> untangles Bits from Cleaner and moves the whole Cleaner interaction >>>> into the DirectByteBuffer itself: >>>> >>>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ >>>> >>>> >>>> Notice the symmetry between Cleaner.retryWhileHelpingClean : >>>> Cleaner.register and Allocator : Deallocator ? >>>> >>>> >>>> Regards, Peter >>>> >>> >>> And here's also a diff between webrev.12.part2 and webrev.13.part2: >>> >>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ >>> >>> >>> Regards, Peter >>> >> > From amaembo at gmail.com Sat Apr 2 13:52:47 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Sat, 2 Apr 2016 19:52:47 +0600 Subject: RFR: 8153332 - Stream API: Fuse sorted().limit(n) into single operation Message-ID: <963711193.20160402195247@gmail.com> Hello! Please review the following enhancement: https://bugs.openjdk.java.net/browse/JDK-8153332 http://cr.openjdk.java.net/~tvaleev/webrev/8153332/r1/ It was earlier discussed here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-March/039308.html The motivation and algorithm are briefly described in the JIRA issue description. Visible behavior should not change after this patch, so all the existing tests pass. I added some more tests to focus on sorted().limit() chain. Again here's some performance tests which were presented in earlier discussion: http://cr.openjdk.java.net/~tvaleev/patches/sortedLimit/jmh/ http://cr.openjdk.java.net/~tvaleev/patches/sortedLimit/jmh/summary.txt With best regards, Tagir Valeev. From mandy.chung at oracle.com Sat Apr 2 19:34:09 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Sat, 2 Apr 2016 12:34:09 -0700 Subject: RFR [9] 8153181: Examine sun.misc.VMSupport In-Reply-To: <56FF967E.5090102@oracle.com> References: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> <56FF967E.5090102@oracle.com> Message-ID: <7DFFF28C-9562-405C-8C3F-B238C5950473@oracle.com> > On Apr 2, 2016, at 2:53 AM, Alan Bateman wrote: > > > (cc'ing serviceability-dev as this is where this code is maintained). > > >> On 02/04/2016 00:32, Mandy Chung wrote: >> Hi Chris, >> >> Would jdk.internal.vm be appropriate for this VMSupoprt class? > I agree. > >> >> VMSupport::getAgentProperties simply calls JVM_InitAgentProperties. java.management could call JVM_InitAgentProperties directly. >> >> src/jdk.jdwp.agent/share/native/libjdwp/util.c >> JDWP calls it and needs to be updated. > If I recall correctly then this is so that the debugger transport details can be advertised. There is a process AttachingConnector that depends on that so I agree this needs to be updated. > >> >> VMSupport.getVMTemporaryDirectory() is for jdk.jvmstat to use and I suggest to move this method to jdk.internal.perf.Perf. > It could although I assume this means that introducing a new shared library. jdk.internal.perf is in java.base. Another option is to move it to jdk.jvmstat that i considered but may not worth it since perf counter is still in java.base. Mandy > >> >> Mandy >> >>> On Mar 31, 2016, at 9:02 AM, Chris Hegarty wrote: >>> >>> As part of JEP 260, all non-Critical APIs in sun.misc are being examined. >>> >>> sun.misc.VMSupport is a utility class supporting two functions: >>> 1) the initialization of management Agent properties, and >>> 2) the retrieval of the VM temporary directory used by the attach and perf data files. >>> >>> The initialization of Agent properties is used statically by the java.managment module, >>> or can be provoked by a serviceability tool on a VM that has had an agent loaded in it. >>> The location of VM temporary files is a low-level interface between the libraries and VM. >>> For these reasons, VMSupport should remain in the base module, but be moved to an >>> internal package. >>> >>> http://cr.openjdk.java.net/~chegar/8153181/00/ >>> https://bugs.openjdk.java.net/browse/JDK-8153181 >>> >>> -Chris. > From claes.redestad at oracle.com Sun Apr 3 00:51:35 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Sun, 3 Apr 2016 02:51:35 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe Message-ID: <57006917.4090200@oracle.com> Hi, BufferedInputStream is loaded early, and uses AtomicReferenceFieldUpdater to provide CAS functionality to allow for closing streams asynchronously. Using Unsafe directly instead does the exact same thing in the end, but avoids loading a few (4) classes and thus brings us a small startup improvement. Bug: https://bugs.openjdk.java.net/browse/JDK-8153334 Webrev: http://cr.openjdk.java.net/~redestad/8153334/webrev.01/ Thanks! /Claes From forax at univ-mlv.fr Sun Apr 3 11:57:00 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Sun, 3 Apr 2016 13:57:00 +0200 (CEST) Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57006917.4090200@oracle.com> References: <57006917.4090200@oracle.com> Message-ID: <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> Hi Claes, the patch is fine for me with the minor nitpick that the static final containing Unsafe should be called UNSAFE and not just U. do you know why BufferedInputStream is loaded in first place during the startup of the VM ? regards, R?mi ----- Mail original ----- > De: "Claes Redestad" > ?: "core-libs-dev Libs" > Envoy?: Dimanche 3 Avril 2016 02:51:35 > Objet: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe > > Hi, > > BufferedInputStream is loaded early, and uses > AtomicReferenceFieldUpdater to provide > CAS functionality to allow for closing streams asynchronously. Using > Unsafe directly instead > does the exact same thing in the end, but avoids loading a few (4) > classes and thus brings > us a small startup improvement. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8153334 > Webrev: http://cr.openjdk.java.net/~redestad/8153334/webrev.01/ > > Thanks! > > /Claes > From claes.redestad at oracle.com Sun Apr 3 12:19:52 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Sun, 3 Apr 2016 14:19:52 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> Message-ID: <57010A68.9050307@oracle.com> Hi Remi, On 2016-04-03 13:57, Remi Forax wrote: > Hi Claes, > the patch is fine for me with the minor nitpick that the static final containing Unsafe should be called UNSAFE and not just U. sure, I copied the setup/naming convention from ConcurrentHashMap, but UNSAFE does make it stand out better. > > do you know why BufferedInputStream is loaded in first place during the startup of the VM ? given the output of -Xlog:classload I think it's first used by java.lang.System for what becomes System.in. Thanks! /Claes > > regards, > R?mi > > ----- Mail original ----- >> De: "Claes Redestad" >> ?: "core-libs-dev Libs" >> Envoy?: Dimanche 3 Avril 2016 02:51:35 >> Objet: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe >> >> Hi, >> >> BufferedInputStream is loaded early, and uses >> AtomicReferenceFieldUpdater to provide >> CAS functionality to allow for closing streams asynchronously. Using >> Unsafe directly instead >> does the exact same thing in the end, but avoids loading a few (4) >> classes and thus brings >> us a small startup improvement. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8153334 >> Webrev: http://cr.openjdk.java.net/~redestad/8153334/webrev.01/ >> >> Thanks! >> >> /Claes >> From forax at univ-mlv.fr Sun Apr 3 13:41:43 2016 From: forax at univ-mlv.fr (forax at univ-mlv.fr) Date: Sun, 3 Apr 2016 15:41:43 +0200 (CEST) Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57010A68.9050307@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> Message-ID: <1378582928.1471463.1459690903288.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Claes Redestad" > ?: "Remi Forax" > Cc: "core-libs-dev Libs" > Envoy?: Dimanche 3 Avril 2016 14:19:52 > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe > > Hi Remi, > > On 2016-04-03 13:57, Remi Forax wrote: > > Hi Claes, > > the patch is fine for me with the minor nitpick that the static final > > containing Unsafe should be called UNSAFE and not just U. > > sure, I copied the setup/naming convention from ConcurrentHashMap, but > UNSAFE does make it stand out better. > > > > > do you know why BufferedInputStream is loaded in first place during the > > startup of the VM ? > > given the output of -Xlog:classload I think it's first used by > java.lang.System for what becomes System.in. oh, i see :) > > Thanks! > > /Claes cheers, R?mi > > > > > regards, > > R?mi > > > > ----- Mail original ----- > >> De: "Claes Redestad" > >> ?: "core-libs-dev Libs" > >> Envoy?: Dimanche 3 Avril 2016 02:51:35 > >> Objet: RFR: 8153334: Replace BufferedInputStreams use of > >> AtomicReferenceFieldUpdater with Unsafe > >> > >> Hi, > >> > >> BufferedInputStream is loaded early, and uses > >> AtomicReferenceFieldUpdater to provide > >> CAS functionality to allow for closing streams asynchronously. Using > >> Unsafe directly instead > >> does the exact same thing in the end, but avoids loading a few (4) > >> classes and thus brings > >> us a small startup improvement. > >> > >> Bug: https://bugs.openjdk.java.net/browse/JDK-8153334 > >> Webrev: http://cr.openjdk.java.net/~redestad/8153334/webrev.01/ > >> > >> Thanks! > >> > >> /Claes > >> > > From Alan.Bateman at oracle.com Sun Apr 3 14:55:54 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sun, 3 Apr 2016 15:55:54 +0100 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57010A68.9050307@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> Message-ID: <57012EFA.9010201@oracle.com> On 03/04/2016 13:19, Claes Redestad wrote: > Hi Remi, > > On 2016-04-03 13:57, Remi Forax wrote: >> Hi Claes, >> the patch is fine for me with the minor nitpick that the static final >> containing Unsafe should be called UNSAFE and not just U. > > sure, I copied the setup/naming convention from ConcurrentHashMap, but > UNSAFE does make it stand out better. > >> >> do you know why BufferedInputStream is loaded in first place during >> the startup of the VM ? > > given the output of -Xlog:classload I think it's first used by > java.lang.System for what becomes System.in. > Yes, initPhase1 (or what used to be initializeSystemClass) will be the first usage. I skimmed the webrev, looks okay to me. I think I would import jdk.internal.misc.Unsafe rather than using the fully qualified class name twice. That will also avoid the line break. -Alan From chris.hegarty at oracle.com Sun Apr 3 15:47:54 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Sun, 3 Apr 2016 16:47:54 +0100 Subject: RFR [9] 8153181: Examine sun.misc.VMSupport In-Reply-To: <7DFFF28C-9562-405C-8C3F-B238C5950473@oracle.com> References: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> <56FF967E.5090102@oracle.com> <7DFFF28C-9562-405C-8C3F-B238C5950473@oracle.com> Message-ID: <75CEB036-1CE1-4FED-B667-7B79004E8C69@oracle.com> Updated webrev, as per comments: http://cr.openjdk.java.net/~chegar/8153181/01/ getVMTemporaryDirectory could be moved into jdk.internal.perf.Perf, which would move its native implementation into the VM, perf.cpp, but it doesn?t seem worth it, unless future refactoring wanted to get rid of JVM_GetTemporaryDirectory. -Chris. On 2 Apr 2016, at 20:34, Mandy Chung wrote: >> >> On Apr 2, 2016, at 2:53 AM, Alan Bateman wrote: >> >> >> (cc'ing serviceability-dev as this is where this code is maintained). >> >> >>> On 02/04/2016 00:32, Mandy Chung wrote: >>> Hi Chris, >>> >>> Would jdk.internal.vm be appropriate for this VMSupoprt class? >> I agree. >> >>> >>> VMSupport::getAgentProperties simply calls JVM_InitAgentProperties. java.management could call JVM_InitAgentProperties directly. >>> >>> src/jdk.jdwp.agent/share/native/libjdwp/util.c >>> JDWP calls it and needs to be updated. >> If I recall correctly then this is so that the debugger transport details can be advertised. There is a process AttachingConnector that depends on that so I agree this needs to be updated. >> >>> >>> VMSupport.getVMTemporaryDirectory() is for jdk.jvmstat to use and I suggest to move this method to jdk.internal.perf.Perf. >> It could although I assume this means that introducing a new shared library. > > jdk.internal.perf is in java.base. Another option is to move it to jdk.jvmstat that i considered but may not worth it since perf counter is still in java.base. > > Mandy > >> >>> >>> Mandy >>> >>>> On Mar 31, 2016, at 9:02 AM, Chris Hegarty wrote: >>>> >>>> As part of JEP 260, all non-Critical APIs in sun.misc are being examined. >>>> >>>> sun.misc.VMSupport is a utility class supporting two functions: >>>> 1) the initialization of management Agent properties, and >>>> 2) the retrieval of the VM temporary directory used by the attach and perf data files. >>>> >>>> The initialization of Agent properties is used statically by the java.managment module, >>>> or can be provoked by a serviceability tool on a VM that has had an agent loaded in it. >>>> The location of VM temporary files is a low-level interface between the libraries and VM. >>>> For these reasons, VMSupport should remain in the base module, but be moved to an >>>> internal package. >>>> >>>> http://cr.openjdk.java.net/~chegar/8153181/00/ >>>> https://bugs.openjdk.java.net/browse/JDK-8153181 >>>> >>>> -Chris. From martinrb at google.com Sun Apr 3 18:29:57 2016 From: martinrb at google.com (Martin Buchholz) Date: Sun, 3 Apr 2016 11:29:57 -0700 Subject: RFR: jsr166 jdk9 integration wave 6 Message-ID: Easy changes to review, up to April Fools day, in part to make room for later unfinished more exciting changes. http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ From Alan.Bateman at oracle.com Sun Apr 3 18:44:27 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sun, 3 Apr 2016 19:44:27 +0100 Subject: RFR [9] 8153181: Examine sun.misc.VMSupport In-Reply-To: <75CEB036-1CE1-4FED-B667-7B79004E8C69@oracle.com> References: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> <56FF967E.5090102@oracle.com> <7DFFF28C-9562-405C-8C3F-B238C5950473@oracle.com> <75CEB036-1CE1-4FED-B667-7B79004E8C69@oracle.com> Message-ID: <5701648B.8060305@oracle.com> On 03/04/2016 16:47, Chris Hegarty wrote: > Updated webrev, as per comments: > http://cr.openjdk.java.net/~chegar/8153181/01/ > > getVMTemporaryDirectory could be moved into jdk.internal.perf.Perf, which > would move its native implementation into the VM, perf.cpp, but it doesn?t > seem worth it, unless future refactoring wanted to get rid of > JVM_GetTemporaryDirectory. > This looks okay. -Alan From forax at univ-mlv.fr Sun Apr 3 19:34:33 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Sun, 3 Apr 2016 21:34:33 +0200 (CEST) Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: References: Message-ID: <723943099.1620291.1459712073220.JavaMail.zimbra@u-pem.fr> Hi Martin, for http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/miscellaneous/ aka introducing a new constructor seems to be a regression to me, the less overloads we have the better i understand the code. R?mi ----- Mail original ----- > De: "Martin Buchholz" > ?: "core-libs-dev" , "Doug Lea"
, "Paul Sandoz" > , "Chris Hegarty" , "David Holmes" > Envoy?: Dimanche 3 Avril 2016 20:29:57 > Objet: RFR: jsr166 jdk9 integration wave 6 > > Easy changes to review, up to April Fools day, in part to make room > for later unfinished more exciting changes. > > http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ > From forax at univ-mlv.fr Sun Apr 3 19:41:04 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Sun, 3 Apr 2016 21:41:04 +0200 (CEST) Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: References: Message-ID: <115068667.1621397.1459712464123.JavaMail.zimbra@u-pem.fr> Hi Martin, Dequeue doc change is fine, ParkLoops test is fine too, i suppose it's related to the recent change in the code of TimeUnit to test with different units. For the CompletableFuture change, i don't understand the consequence of the patch so i declare myself incompetent on that subject :) regards, R?mi ----- Mail original ----- > De: "Martin Buchholz" > ?: "core-libs-dev" , "Doug Lea"
, "Paul Sandoz" > , "Chris Hegarty" , "David Holmes" > Envoy?: Dimanche 3 Avril 2016 20:29:57 > Objet: RFR: jsr166 jdk9 integration wave 6 > > Easy changes to review, up to April Fools day, in part to make room > for later unfinished more exciting changes. > > http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ > From claes.redestad at oracle.com Sun Apr 3 20:39:26 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Sun, 3 Apr 2016 22:39:26 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57012EFA.9010201@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <57012EFA.9010201@oracle.com> Message-ID: <57017F7E.5000805@oracle.com> On 04/03/2016 04:55 PM, Alan Bateman wrote: > > > On 03/04/2016 13:19, Claes Redestad wrote: >> Hi Remi, >> >> On 2016-04-03 13:57, Remi Forax wrote: >>> Hi Claes, >>> the patch is fine for me with the minor nitpick that the static >>> final containing Unsafe should be called UNSAFE and not just U. >> >> sure, I copied the setup/naming convention from ConcurrentHashMap, >> but UNSAFE does make it stand out better. >> >>> >>> do you know why BufferedInputStream is loaded in first place during >>> the startup of the VM ? >> >> given the output of -Xlog:classload I think it's first used by >> java.lang.System for what becomes System.in. >> > Yes, initPhase1 (or what used to be initializeSystemClass) will be the > first usage. > > I skimmed the webrev, looks okay to me. I think I would import > jdk.internal.misc.Unsafe rather than using the fully qualified class > name twice. That will also avoid the line break. > > -Alan > Thanks for looking at this, Alan! Cleaned things up here: http://cr.openjdk.java.net/~redestad/8153334/webrev.02/ /Claes From martinrb at google.com Sun Apr 3 21:08:50 2016 From: martinrb at google.com (Martin Buchholz) Date: Sun, 3 Apr 2016 14:08:50 -0700 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: <723943099.1620291.1459712073220.JavaMail.zimbra@u-pem.fr> References: <723943099.1620291.1459712073220.JavaMail.zimbra@u-pem.fr> Message-ID: Thanks for the review! On Sun, Apr 3, 2016 at 12:34 PM, Remi Forax wrote: > Hi Martin, > for http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/miscellaneous/ > > aka introducing a new constructor seems to be a regression to me, > the less overloads we have the better i understand the code. For "telescoping constructors" and a parameter that's almost always null, I disagree. There's also the fear that the VM won't optimize away useless volatile write to next. > ParkLoops test is fine too, i suppose it's related to the recent change in the code of TimeUnit to test with different units. No, it fixes a mistake made when introducing timeout factor scaling. The webrev has a link to the bug report https://bugs.openjdk.java.net/browse/JDK-8151501 From forax at univ-mlv.fr Sun Apr 3 22:17:03 2016 From: forax at univ-mlv.fr (forax at univ-mlv.fr) Date: Mon, 4 Apr 2016 00:17:03 +0200 (CEST) Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: References: <723943099.1620291.1459712073220.JavaMail.zimbra@u-pem.fr> Message-ID: <1421264514.48409.1459721823940.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Martin Buchholz" > ?: "Remi Forax" > Cc: "core-libs-dev" , "Doug Lea"
, "Paul Sandoz" > , "Chris Hegarty" , "David Holmes" > Envoy?: Dimanche 3 Avril 2016 23:08:50 > Objet: Re: RFR: jsr166 jdk9 integration wave 6 > > Thanks for the review! > > On Sun, Apr 3, 2016 at 12:34 PM, Remi Forax wrote: > > Hi Martin, > > for > > http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/miscellaneous/ > > > > aka introducing a new constructor seems to be a regression to me, > > the less overloads we have the better i understand the code. > > For "telescoping constructors" and a parameter that's almost always > null, I disagree. if the parameter is often null, maybe the constructor with 4 parameters is useless, and next should be set explicitly in the few cases it's needed. > There's also the fear that the VM won't optimize away useless volatile > write to next. I've seen the bug [1] reported by Aleksey about Hotspot not being able to remove volatile writes with null in constructor. Here the code is different because val is also a volatile field, and written just before next, so the VM should be able to coalesce two volatile writes, if the VM is not able to do that, it's another bug. Nevertheless, we should only optimize to for the usual cases, so we should only have one constructor that doesn't set next. [...] [1] https://bugs.openjdk.java.net/browse/JDK-8145948 R?mi From mandy.chung at oracle.com Mon Apr 4 01:06:24 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Sun, 3 Apr 2016 18:06:24 -0700 Subject: RFR [9] 8153181: Examine sun.misc.VMSupport In-Reply-To: <75CEB036-1CE1-4FED-B667-7B79004E8C69@oracle.com> References: <85A7A426-8B74-49F5-9C43-B428BEF8B4E8@oracle.com> <56FF967E.5090102@oracle.com> <7DFFF28C-9562-405C-8C3F-B238C5950473@oracle.com> <75CEB036-1CE1-4FED-B667-7B79004E8C69@oracle.com> Message-ID: <5C64C8CB-F67E-4D2F-ADD8-D67B7664A219@oracle.com> > On Apr 3, 2016, at 8:47 AM, Chris Hegarty wrote: > > Updated webrev, as per comments: > http://cr.openjdk.java.net/~chegar/8153181/01/ > > getVMTemporaryDirectory could be moved into jdk.internal.perf.Perf, which > would move its native implementation into the VM, perf.cpp, but it doesn?t > seem worth it, unless future refactoring wanted to get rid of > JVM_GetTemporaryDirectory. > It looks okay. We should look into this when we look into future clean up work in this area. Mandy From sundararajan.athijegannathan at oracle.com Mon Apr 4 03:29:53 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Mon, 4 Apr 2016 08:59:53 +0530 Subject: RFR: 8153317: Two jimage tests have been failing since JDK-8152641 was fixed In-Reply-To: <56FED920.3010207@oracle.com> References: <56FED920.3010207@oracle.com> Message-ID: <5701DFB1.9070209@oracle.com> +1 On 4/2/2016 1:55 AM, Claes Redestad wrote: > Hi, > > seems my recent push for JDK-8152641 broke a jimage test or two. > > While I think these test seem a bit odd, it's apparent that checking > that we're not adding the same resource twice is enough to make the > tests happy for now: > > Webrev: http://cr.openjdk.java.net/~redestad/8153317/webrev.01/ > Bug: https://bugs.openjdk.java.net/browse/JDK-8153317 > > Thanks! > > /Claes From chris.hegarty at oracle.com Mon Apr 4 09:39:31 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 4 Apr 2016 10:39:31 +0100 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57017F7E.5000805@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <57012EFA.9010201@oracle.com> <57017F7E.5000805@oracle.com> Message-ID: <57023653.9020108@oracle.com> On 03/04/16 21:39, Claes Redestad wrote: > .... >> > > Thanks for looking at this, Alan! > > Cleaned things up here: > http://cr.openjdk.java.net/~redestad/8153334/webrev.02/ Looks good Claes. -Chris. From ramanand.patil at oracle.com Mon Apr 4 09:50:22 2016 From: ramanand.patil at oracle.com (Ramanand Patil) Date: Mon, 4 Apr 2016 02:50:22 -0700 (PDT) Subject: RFR: 8151876: (tz) Support tzdata2016c Message-ID: Hi all, Please review the latest TZDATA (tzdata2016c) integration to JDK9. Bug: https://bugs.openjdk.java.net/browse/JDK-8151876 Webrev: http://cr.openjdk.java.net/~rpatil/8151876/webrev.00/ All the TimeZone related tests are passed after integration. Please note that this patch includes both tzdata2016b and tzdata2016c integration. The tzdata2016b review was abandoned because tzdata2016c was already released. As suggested by Masayoshi, changes are made such that, "GMT+hh:mm" is used for formatting of the newly added TimeZones in tzdata2016b. [This is done to accommodate the IANA's new trial system where the new zones use numeric time zone abbreviations like "+04" instead of invented abbreviations like "ASTT".] Regards, Ramanand. From aleksey.shipilev at oracle.com Mon Apr 4 10:03:34 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Mon, 4 Apr 2016 13:03:34 +0300 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57006917.4090200@oracle.com> References: <57006917.4090200@oracle.com> Message-ID: <57023BF6.4010304@oracle.com> On 04/03/2016 03:51 AM, Claes Redestad wrote: > BufferedInputStream is loaded early, and uses > AtomicReferenceFieldUpdater to provide CAS functionality to allow for > closing streams asynchronously. Using Unsafe directly instead does > the exact same thing in the end, but avoids loading a few (4) classes > and thus brings us a small startup improvement. > Bug: https://bugs.openjdk.java.net/browse/JDK-8153334 > Webrev: http://cr.openjdk.java.net/~redestad/8153334/webrev.01/ I think this one is going too far. A*FU/VarHandles should are supposed to act like a go-to replacement for Unsafe throughout the class library, and we want to shrink the Unsafe exposure. Also, I don't think removing A*FU in favor of Unsafe here wins us anything: there should be no throughput hit, and we *will* load A*FU down the road anyway, negating the startup wins. -Aleksey From chris.hegarty at oracle.com Mon Apr 4 10:24:22 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 4 Apr 2016 11:24:22 +0100 Subject: RFR [9] 8153286: Move sun.misc.GC to java.rmi ( sun.rmi.transport ) Message-ID: <570240D6.4000303@oracle.com> sun.misc.GC is not "Critical APIs", as defined by JEP 260, so should be moved out of sun.misc and placed into a more appropriate package, where it can be encapsulated. Since GC is only used by RMI, I proposed to move it to the java.rmi module. Since it has a native component, and no other code in java.rmi has, then a new small native library is required. http://cr.openjdk.java.net/~chegar/8153286/ https://bugs.openjdk.java.net/browse/JDK-8153286 -Chris. From chris.hegarty at oracle.com Mon Apr 4 10:26:55 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 4 Apr 2016 11:26:55 +0100 Subject: RFR [9] 8153286: Move sun.misc.GC to java.rmi ( sun.rmi.transport ) In-Reply-To: <570240D6.4000303@oracle.com> References: <570240D6.4000303@oracle.com> Message-ID: <5702416F.3000500@oracle.com> [ including build-dev ] > sun.misc.GC is not "Critical APIs", as defined by JEP 260, so should > be moved out of sun.misc and placed into a more appropriate package, > where it can be encapsulated. > > Since GC is only used by RMI, I proposed to move it to the java.rmi > module. Since it has a native component, and no other code in java.rmi > has, then a new small native library is required. > > http://cr.openjdk.java.net/~chegar/8153286/ > https://bugs.openjdk.java.net/browse/JDK-8153286 > > -Chris. From erik.joelsson at oracle.com Mon Apr 4 11:04:05 2016 From: erik.joelsson at oracle.com (Erik Joelsson) Date: Mon, 4 Apr 2016 13:04:05 +0200 Subject: RFR [9] 8153286: Move sun.misc.GC to java.rmi ( sun.rmi.transport ) In-Reply-To: <5702416F.3000500@oracle.com> References: <570240D6.4000303@oracle.com> <5702416F.3000500@oracle.com> Message-ID: <57024A25.4000202@oracle.com> Makefile looks good. If you move Java_sun_rmi_transport_GC_maxObjectInspectionAge out of libjava, should you also remove it from the mapfile for libjava? /Erik On 2016-04-04 12:26, Chris Hegarty wrote: > [ including build-dev ] > >> sun.misc.GC is not "Critical APIs", as defined by JEP 260, so should >> be moved out of sun.misc and placed into a more appropriate package, >> where it can be encapsulated. >> >> Since GC is only used by RMI, I proposed to move it to the java.rmi >> module. Since it has a native component, and no other code in java.rmi >> has, then a new small native library is required. >> >> http://cr.openjdk.java.net/~chegar/8153286/ >> https://bugs.openjdk.java.net/browse/JDK-8153286 >> >> -Chris. From dl at cs.oswego.edu Mon Apr 4 11:14:06 2016 From: dl at cs.oswego.edu (Doug Lea) Date: Mon, 4 Apr 2016 07:14:06 -0400 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: <1421264514.48409.1459721823940.JavaMail.zimbra@u-pem.fr> References: <723943099.1620291.1459712073220.JavaMail.zimbra@u-pem.fr> <1421264514.48409.1459721823940.JavaMail.zimbra@u-pem.fr> Message-ID: <57024C7E.7010408@cs.oswego.edu> On 04/03/2016 06:17 PM, forax at univ-mlv.fr wrote: ---- >> De: "Martin Buchholz" >>> http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/miscellaneous/ >>> >>> aka introducing a new constructor seems to be a regression to me, >>> the less overloads we have the better i understand the code. >> >> For "telescoping constructors" and a parameter that's almost always >> null, I disagree. > > if the parameter is often null, maybe the constructor with 4 parameters is useless, and next should be set explicitly in the few cases it's needed. > >> There's also the fear that the VM won't optimize away useless volatile >> write to next. Right. The issue is whether to be explicit about lack of need of a fence, or to hope that the compiler figures it out. Especially in a component as commonly used as CHM, being explicit seems like the right choice. -Doug From nadeesh.tv at oracle.com Mon Apr 4 11:25:55 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Mon, 04 Apr 2016 16:55:55 +0530 Subject: RFR:JDK-8148947:DateTimeFormatter pattern letter 'g' In-Reply-To: <56FC16B9.3000806@oracle.com> References: <56FC16B9.3000806@oracle.com> Message-ID: <57024F43.2010503@oracle.com> Gentle reminder On 3/30/2016 11:41 PM, nadeesh tv wrote: > Hi all, > > BUG ID : https://bugs.openjdk.java.net/browse/JDK-8148947 > > Webrev : http://cr.openjdk.java.net/~ntv/8148947/webrev.00/ > > Added new pattern letter 'g' for Modified Julian day. > > Apart from that made clarification to JulianFields and removed > semicolons from docs of DateTimeFormatterBuilder as suggested by Stephen > -- Thanks and Regards, Nadeesh TV From nadeesh.tv at oracle.com Mon Apr 4 11:28:10 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Mon, 04 Apr 2016 16:58:10 +0530 Subject: RFR:JDK-8148849:Truncating Duration In-Reply-To: References: <56FA727C.201@oracle.com> <56FBB7AF.3030409@oracle.com> Message-ID: <57024FCA.2080702@oracle.com> Hi, I need one more review for this change Regards, Nadeesh On 3/30/2016 7:03 PM, Stephen Colebourne wrote: > Yes, that looks OK now. > thanks > Stephen > > > On 30 March 2016 at 12:25, nadeesh tv wrote: >> Hi Stephen, >> >> Thanks for the comments. >> Please see the updated webrev >> http://cr.openjdk.java.net/~ntv/8148849/webrev.01/ >> >> Made a change in unit == ChronoUnit.SECONDS also >> >> >> Regards, >> Nadeesh TV >> >> >> On 3/29/2016 6:10 PM, Stephen Colebourne wrote: >>> We're almost there, but looking at the tests, it looks like the >>> behaviour is wrong: >>> >>> The intended behaviour is that >>> -20.5mins (minus 20 minutes 30 secs) should truncate to -20mins >>> -2.1secs truncate to -2secs >>> >>> Note that the truncation is different to Instant here. >>> An Instant truncates towards the far past - like RoundingMode.FLOOR >>> A Duration truncates towards the zero - like RoundingMode.DOWN >>> >>> Stephen >>> >>> >>> On 29 March 2016 at 13:18, nadeesh tv wrote: >>>> Hi all, >>>> >>>> Bug Id : https://bugs.openjdk.java.net/browse/JDK-8148849 >>>> >>>> Enhanced Duration by adding public Duration truncatedTo(TemporalUnit >>>> unit) >>>> >>>> Please http://cr.openjdk.java.net/~ntv/8148849/webrev.00/ >>>> >>>> -- >>>> Thanks and Regards, >>>> Nadeesh TV >>>> >> -- >> Thanks and Regards, >> Nadeesh TV >> -- Thanks and Regards, Nadeesh TV From Alan.Bateman at oracle.com Mon Apr 4 11:34:53 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 4 Apr 2016 12:34:53 +0100 Subject: RFR [9] 8153286: Move sun.misc.GC to java.rmi ( sun.rmi.transport ) In-Reply-To: <57024A25.4000202@oracle.com> References: <570240D6.4000303@oracle.com> <5702416F.3000500@oracle.com> <57024A25.4000202@oracle.com> Message-ID: <5702515D.3040502@oracle.com> On 04/04/2016 12:04, Erik Joelsson wrote: > Makefile looks good. > > If you move Java_sun_rmi_transport_GC_maxObjectInspectionAge out of > libjava, should you also remove it from the mapfile for libjava? > Yes, libjava/mapfile-vers will need to be updated too. It otherwise looks okay to me, just a pity that it requires introducing another native library. -Alan From martinrb at google.com Mon Apr 4 15:45:46 2016 From: martinrb at google.com (Martin Buchholz) Date: Mon, 4 Apr 2016 08:45:46 -0700 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57010A68.9050307@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> Message-ID: On Sun, Apr 3, 2016 at 5:19 AM, Claes Redestad wrote: >> the patch is fine for me with the minor nitpick that the static final >> containing Unsafe should be called UNSAFE and not just U. > > > sure, I copied the setup/naming convention from ConcurrentHashMap, but > UNSAFE does make it stand out better. We adopted the U convention in java.util.concurrent because it makes that performance-obsessed code read better. > I think this one is going too far. > > A*FU/VarHandles should are supposed to act like a go-to replacement for > Unsafe throughout the class library, and we want to shrink the Unsafe > exposure. Also, I don't think removing A*FU in favor of Unsafe here wins > us anything: there should be no throughput hit, and we *will* load A*FU > down the road anyway, negating the startup wins. > > -Aleksey It is surprising to see new uses of Unsafe when we have an ongoing initiative within openjdk (especially from Paul Sandoz) to remove most uses. Varhandles are coming and are expected to replace uses of Unsafe in the JDK. From volker.simonis at gmail.com Mon Apr 4 16:47:38 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Mon, 4 Apr 2016 18:47:38 +0200 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version Message-ID: Hi, can I please have a review for this small fix: http://cr.openjdk.java.net/~simonis/webrevs/2016/8149519 https://bugs.openjdk.java.net/browse/JDK-8149519 Currently the value of the java.specification.version property comes from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in. It is currently set to VERSION_NUMBER which is the same value which is also used for the java.version property. This is a bad idea, because VERSION_NUMBER is a dot separated sequence of numbers (e.g. 9.0.1) which is expected to change frequently (i.e. for every build and/or update version). If we are configuring with "--with-version-patch=1" for example, VERSION_NUMBER and java.version will be "9.0.0.1". But it makes no sense that VERSION_SPECIFICATION and java.specification.version have the same, dotted value. And it breaks a lot of legacy applications which parse java.specification.version as a float number. That code would still work if java.specification.version would be a concrete number (e.g. '9' or '10'). I suggest to set VERSION_SPECIFICATION to VERSION_MAJOR in common/autoconf/spec.gmk.in. This should be the "right value" until we get a specification change during a major release which hasn't happened for quite some time now. Regards, Volker From spliterator at gmail.com Mon Apr 4 19:28:25 2016 From: spliterator at gmail.com (Stefan Zobel) Date: Mon, 4 Apr 2016 21:28:25 +0200 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: <755756441.20160401222505@gmail.com> References: <755756441.20160401222505@gmail.com> Message-ID: Hi Tagir, good catch! I like the proposal. > > (different longs can be converted into the same double, so DISTINCT is > not preserved here; not sure whether this is possible for ints) > I think IntStream.asDoubleStream() can also preserve DISTINCT as different ints can't be mapped to the same double. Math.ulp((double) Integer.MIN_VALUE) ~ 4.7E-7 in contrast to Math.ulp((double) Long.MIN_VALUE) = 2048.0 So there are more than enough doubles in the vicinity of large int values. It's only when ulp get's >= 1.0 that distinct integral values need to be mapped to the same double (that happens between 1.0E15 and 1.0E16 for longs). Please anyone correct me if I'm wrong. Regards, Stefan 2016-04-01 18:25 GMT+02:00 Tagir F. Valeev : > Hello! > > Please review and sponsor the following patch: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r1/ > > The patch preserves more characteristics on primitive stream > operations: > IntStream/LongStream/DoubleStream.boxed() preserves SORTED and DISTINCT > IntStream.asLongStream() preserves SORTED and DISTINCT > IntStream.asDoubleStream() and LongStream.asDoubleStream() preserves SORTED > (different longs can be converted into the same double, so DISTINCT is > not preserved here; not sure whether this is possible for ints) > > Fixing the boxed() case is especially important as distinct() for > primitive streams is implemented like boxed().distinct().unbox, so the > actual distinct() operation cannot take the advantage of DISTINCT flag > (skip the operation at all) or SORTED flag (switch to more efficient > implementation). > > Here's the small JMH benchmark which measures the performance boost of > quite common operation: sort the input numbers and leave only distinct > ones: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/jmh/ > > new Random(1).ints(size).sorted().distinct().toArray() > > I've got the following results. > > 9ea+111: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,612 ? 0,004 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 92,848 ? 1,039 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 32147,205 ? 3487,422 us/op > > 9ea+111 patched: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,435 ? 0,001 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 40,555 ? 0,772 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 9031,651 ? 73,956 us/op > > With best regards, > Tagir Valeev. > From Roger.Riggs at Oracle.com Mon Apr 4 21:50:05 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 4 Apr 2016 17:50:05 -0400 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <56FFABED.2060708@gmail.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> <56FF04B5.2030507@oracle.com> <56FFABED.2060708@gmail.com> Message-ID: <5702E18D.7010807@Oracle.com> Hi Peter, Stepping back just a bit. The old Cleaner running on the Reference processing thread had a few (2) very well controlled functions, reference processing and deallocating DirectByteBuffers. Maybe we can't do too much better than that. The old worst case performance/latency wise was the reference processing thread did the work and the allocating thread did very little synchronizing and just did the retries. In the best case, all the real work was done by the allocating thread, if the interactions with GC work out perfectly. But it was still the case that the buffer alloc/dealloc throughput was met with the division of work separating the reference processing thread and the allocating thread. The function that can only be provided by CleanerImpl / Reference processing thread state is knowledge that the cleaning queue is empty. The helping functions were/are a bit troublesome because of mixing execution environments of the thread allocating direct buffers and the cleanables and it seemed that more than a little complexity was needed to compensate. If the bottleneck in processing is between the reference processing and cleanup then it should be ok (based on previous comments) for the CleanerImpl to help with reference processing (after it has an empty queue and before it blocks waiting or in every loop). Though if you already tried this combination, I don't recall the results. As you pointed out it would be more efficient if the allocating thread could be aware when it was known there was nothing ready to cleanup so it can retry and invoke GC or throw out of memory if appropriate. Adding a method that returned the count of completed cleaning cycles (or similar) to CleanerImpl could exist with a minimal of coupling and still provide the information needed without commingling the execution threads. I don't see the need to change Cleaner to an interface to be able to provide an additional method on CleanerImpl or a subclass and a factory method could provide for a clean and very targeted interface to Bits/Direct buffer. I'm sorry I haven't had time to try out concretely what I have in mind. Please correct or remind me of missing salient considerations. Thanks, Roger On 4/2/2016 7:24 AM, Peter Levart wrote: > Hi Roger, > > Thanks for looking at the patch. > > On 04/02/2016 01:31 AM, Roger Riggs wrote: >> Hi Peter, >> >> I overlooked the introduction of another nested class (Task) to >> handle the cleanup. >> But there are too many changes to see which ones solve a single problem. >> >> Sorry to make more work, but I think we need to go back to the >> minimum necessary >> change to make progress on this. Omit all of the little cleanups >> until the end >> or do them first and separately. >> >> Thanks, Roger > > No Problem. I understand. So let's proceed in stages. Since part1 is > already pushed, I'll call part2 stages with names: part2.1, part2.2, > ... and I'll start counting webrev revisions from 01 again, so webrev > names will be in the form: webrev.part2.1.rev01. Each part will be an > incremental change to the previous one. > > part2.1: This is preparation work to be able to have an extended > java.lang.ref.Cleaner type for internal use. Since > java.lang.ref.Cleaner is a final class, I propose to make it an > interface instead: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.part2.1.rev01/ > > This is a source-compatible change and it also simplifies > implementation (no injection of Cleaner.impl access function into > CleanerImpl needed any more). What used to be java.lang.ref.Cleaner is > renamed to jdk.internal.ref.CleanerImpl. What used to be > jdk.internal.ref.CleanerImpl is now a nested static class > jdk.internal.ref.CleanerImpl.Task (because it implements Runnable). > Otherwise nothing has changed in the overall architecture of the > Cleaner except that public-facing API is now an interface instead of a > final class. This allows specifying internal extension interface and > internal extension implementation. > > CleanerTest passes with this change. > > So what do you think? > > Regards, Peter > >> >> >> >> >> On 4/1/16 5:51 PM, Roger Riggs wrote: >>> Hi Peter, >>> >>> Thanks for the diffs to look at. >>> >>> Two observations on the changes. >>> >>> - The Cleaner instance was intentionally and necessarily different >>> than the CleanerImpl to enable >>> the CleanerImpl and its thread to terminate if the Cleaner is not >>> longer referenced. >>> Folding them into a single object breaks that. >>> >>> Perhaps it is not too bad for ExtendedCleaner to subclass >>> CleanerImpl with the cleanup helper/supplier behavior >>> and expose itself to Bits. There will be fewer moving parts. There >>> is no need for two factory methods for >>> ExtendedCleaner unless you are going to use a separate ThreadFactory. >>> >>> - The Deallocator (and now Allocator) nested classes are identical, >>> and there is a separate copy for each >>> type derived from the Direct-X-template. But it may not be worth >>> fixing until the rest of it is settled to avoid >>> more moving parts. >>> >>> I don't have an opinion on the code changes in Reference, that's >>> different kettle of fish. >>> >>> More next week. >>> >>> Have a good weekend, Roger >>> >>> >>> On 4/1/2016 12:46 PM, Peter Levart wrote: >>>> >>>> >>>> On 04/01/2016 06:08 PM, Peter Levart wrote: >>>>> >>>>> >>>>> On 04/01/2016 05:18 PM, Peter Levart wrote: >>>>>> @Roger: >>>>>> >>>>>> ... >>>>>> >>>>>> About entanglement between nio Bits and >>>>>> ExtendedCleaner.retryWhileHelpingClean(). It is the same level of >>>>>> entanglement as between the DirectByteBuffer constructor and >>>>>> Cleaner.register(). In both occasions an action is provided to >>>>>> the Cleaner. Cleaner.register() takes a cleanup action and >>>>>> ExtendedCleaner.retryWhileHelpingClean() takes a retriable >>>>>> "allocating" or "reservation" action. "allocation" or >>>>>> "reservation" is the opposite of cleanup. Both methods are >>>>>> encapsulated in the same object because those two functions must >>>>>> be coordinated. So I think that collocating them together makes >>>>>> sense. What do you think? >>>>> >>>>> ...to illustrate what I mean, here's a variant that totally >>>>> untangles Bits from Cleaner and moves the whole Cleaner >>>>> interaction into the DirectByteBuffer itself: >>>>> >>>>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ >>>>> >>>>> >>>>> Notice the symmetry between Cleaner.retryWhileHelpingClean : >>>>> Cleaner.register and Allocator : Deallocator ? >>>>> >>>>> >>>>> Regards, Peter >>>>> >>>> >>>> And here's also a diff between webrev.12.part2 and webrev.13.part2: >>>> >>>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ >>>> >>>> >>>> Regards, Peter >>>> >>> >> > From masayoshi.okutsu at oracle.com Mon Apr 4 23:39:04 2016 From: masayoshi.okutsu at oracle.com (Masayoshi Okutsu) Date: Tue, 5 Apr 2016 08:39:04 +0900 Subject: RFR: 8151876: (tz) Support tzdata2016c In-Reply-To: References: Message-ID: <5702FB18.1060300@oracle.com> Looks good to me. But I'd like someone from java.time to review the changes to see if it's OK for java.time. Masayoshi On 4/4/2016 6:50 PM, Ramanand Patil wrote: > Hi all, > > Please review the latest TZDATA (tzdata2016c) integration to JDK9. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8151876 > > Webrev: http://cr.openjdk.java.net/~rpatil/8151876/webrev.00/ > > All the TimeZone related tests are passed after integration. > > > > Please note that this patch includes both tzdata2016b and tzdata2016c integration. The tzdata2016b review was abandoned because tzdata2016c was already released. > > As suggested by Masayoshi, changes are made such that, "GMT+hh:mm" is used for formatting of the newly added TimeZones in tzdata2016b. > > [This is done to accommodate the IANA's new trial system where the new zones use numeric time zone abbreviations like "+04" instead of invented abbreviations like "ASTT".] > > > > Regards, > > Ramanand. From brent.christian at oracle.com Mon Apr 4 23:45:31 2016 From: brent.christian at oracle.com (Brent Christian) Date: Mon, 04 Apr 2016 16:45:31 -0700 Subject: RFR 8153123 : Streamline StackWalker code Message-ID: <5702FC9B.7020600@oracle.com> Hi, I'd like to check in some footprint and code reduction changes to the java.lang.StackWalker implementation. Webrev: http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ Bug: https://bugs.openjdk.java.net/browse/JDK-8153123 A summary of the changes: * remove the "stackwalk.newThrowable" system property and "MemberNameInStackFrame" VM flag, originally left in to aid benchmarking * Streamline StackFrameInfo fields * Refactor/streamline StackStreamFactory (no more separate classes[]/StackFrame[] arrays, remove unneeded (for now) StackStreamFactory.StackTrace class) Given the hotspot changes, I plan to push this through hs-rt. Thanks, -Brent From mandy.chung at oracle.com Tue Apr 5 01:29:53 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Mon, 4 Apr 2016 18:29:53 -0700 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5702FC9B.7020600@oracle.com> References: <5702FC9B.7020600@oracle.com> Message-ID: > On Apr 4, 2016, at 4:45 PM, Brent Christian wrote: > > Hi, > > I'd like to check in some footprint and code reduction changes to the java.lang.StackWalker implementation. > > Webrev: > http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ > Bug: > https://bugs.openjdk.java.net/browse/JDK-8153123 > This looks good to me. One thing to mention is that this patch is a follow-up work from the investigation on what it takes to enable Throwable to use StackWalker (JDK-8141239). The current built-in VM backtrace is very compact and performant. We have identified and prototypes the performance improvements if Throwable backtrace is generated using stack walker. There are some performance gaps that we agree to defer JDK-8141239 to a future release and improve the footprint performance and GC throughput concerns when MemberNames are stored in the throwable backtrace. Mandy From chris.hegarty at oracle.com Tue Apr 5 09:51:46 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 5 Apr 2016 10:51:46 +0100 Subject: RFR [9] 8153498: Update the PostVMInitHook mechanism to use an internal package in the base module Message-ID: sun.misc.PostVMInitHook::run is called by the VM once its initialization is complete, when jdk_version_info.post_vm_init_hook_enabled bit is true. Since sun.misc will be moved out of the base module, the VM should look for the PostVMInitHook in a more suitable place, say jdk.internal.vm. http://cr.openjdk.java.net/~chegar/8153498/ -Chris. From dawid.weiss at gmail.com Tue Apr 5 10:47:05 2016 From: dawid.weiss at gmail.com (Dawid Weiss) Date: Tue, 5 Apr 2016 12:47:05 +0200 Subject: toRealPath throws InternalError: Should not get here on Windows (paths with junctions) In-Reply-To: <56E80691.3030607@oracle.com> References: <56E7F1F6.90405@oracle.com> <56E80691.3030607@oracle.com> Message-ID: I did a bit more digging. I can reproduce this every time on my machine if: 1) I open cmd from total commander (64 bit or 32 bit, doesn't matter); 2) from that cmd run the simple example in Java that attempts to resolve real path; this ends in InternalError. On the other hand, if I run cmd from the start menu, everything works fine. total commander is clean (checked md5 to rule out viruses or whatever). I have no idea what this is -- I think the problem can be marked as "non-reproducible", maybe it's a glitch in my system somewhere. Sorry for the noise. Dawid On Tue, Mar 15, 2016 at 1:56 PM, Rory O'Donnell wrote: > Hi Dawid, > > I will update bug. > > Rgds,Rory > > > On 15/03/2016 12:53, Dawid Weiss wrote: >> >> This must be more complicated than I thought because the same code >> passes with flying colors on another (fairly fresh install) of Windows >> 10... I don't know what the difference is, to be honest (I have >> Windows 10 Pro N). I'll try to dig deeper, time permitting, but >> perhaps a comment on the eventual Jira issue would be sensible (can't >> do it myself, no Jira access). >> >> Dawid >> >> On Tue, Mar 15, 2016 at 1:01 PM, Dawid Weiss >> wrote: >>> >>> I filed an issue (Review ID: JI-9032181). In any case, I checked with >>> Java 7, 8 and the ea: >>> >>> Java(TM) SE Runtime Environment (build >>> 9-ea+109-2016-03-09-181019.javare.4620.nc) >>> >>> The issue only affects Windows 10 (tested on 64-bit only), Windows 7 >>> behaves fine. The following sequence is enough to get the stack trace: >>> >>> mkdir foo >>> mklink /J bar foo >>> java -cp . Test bar >>> >>> The Test.java code is: >>> import java.io.*; >>> import java.nio.file.*; >>> >>> public class Test { >>> public static void main(String[] args) throws Exception { >>> Path p = Paths.get(args[0]); >>> System.out.println("p.toRealPath(): " + p.toRealPath()); >>> } >>> } >>> >>> and the stack trace: >>> >>> Exception in thread "main" java.lang.InternalError: Should not get here >>> at >>> sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native >>> Method) >>> at >>> sun.nio.fs.WindowsLinkSupport.getFinalPath(WindowsLinkSupport.java:77) >>> at >>> sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:242) >>> at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:840) >>> at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44) >>> at Test.main(Test.java:10) >>> >>> Dawid >>> >>> On Tue, Mar 15, 2016 at 12:28 PM, Alan Bateman >>> wrote: >>>> >>>> On 15/03/2016 11:19, Dawid Weiss wrote: >>>>> >>>>> I couldn't find an appropriate bug in bugzilla, but this fails >>>>> reliably for me with Java 8 and 9 on Windows 10, 64-bit: >>>>> >>>>> mkdir foo >>>>> mklink /J bar foo >>>>> cd bar >>>>> java -cp Test . >>>>> >>>>> where Test.java is as simple as: >>>>> >>>>> import java.io.*; >>>>> import java.nio.file.*; >>>>> >>>>> public class Test { >>>>> public static void main(String[] args) throws Exception { >>>>> System.out.println("p.toRealPath(): " + >>>>> Paths.get(args[0]).toRealPath()); >>>>> } >>>>> } >>>>> >>>>> The thrown error shows: >>>>> >>>>> Exception in thread "main" java.lang.InternalError: Should not get here >>>>> at >>>>> sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native >>>>> Method) >>>> >>>> There are a number of win32 functions that this code uses GetProcAddress >>>> to >>>> get their address in kernel32. This dates back to when we had to support >>>> Windows XP. This should be cleaned up now. Doesn't explain why you are >>>> seeing though, can you submit a bug? >>>> >>>> -Alan > > > -- > Rgds,Rory O'Donnell > Quality Engineering Manager > Oracle EMEA , Dublin, Ireland > From lois.foltan at oracle.com Tue Apr 5 13:59:47 2016 From: lois.foltan at oracle.com (Lois Foltan) Date: Tue, 05 Apr 2016 09:59:47 -0400 Subject: RFR [9] 8153498: Update the PostVMInitHook mechanism to use an internal package in the base module In-Reply-To: References: Message-ID: <5703C4D3.1090108@oracle.com> Hotspot changes look good. Lois On 4/5/2016 5:51 AM, Chris Hegarty wrote: > sun.misc.PostVMInitHook::run is called by the VM once its initialization is > complete, when jdk_version_info.post_vm_init_hook_enabled bit is true. > Since sun.misc will be moved out of the base module, the VM should > look for the PostVMInitHook in a more suitable place, say jdk.internal.vm. > > http://cr.openjdk.java.net/~chegar/8153498/ > > -Chris. From peter.levart at gmail.com Tue Apr 5 14:41:26 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 5 Apr 2016 16:41:26 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <5702E18D.7010807@Oracle.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> <56FF04B5.2030507@oracle.com> <56FFABED.2060708@gmail.com> <5702E18D.7010807@Oracle.com> Message-ID: <5703CE96.4040001@gmail.com> Hi Roger, On 04/04/2016 11:50 PM, Roger Riggs wrote: > Hi Peter, > > Stepping back just a bit. Right, let's clear up. > > The old Cleaner running on the Reference processing thread had a few > (2) very well controlled > functions, reference processing and deallocating DirectByteBuffers. > Maybe we can't do too much > better than that. ...yes, at the beginning, until it was (re)used for other purposes too, in: java.lang.ProcessImpl, java.lang.invoke.MethodHandleNatives.CallSiteContext, jdk.internal.perf.Perf, sun.nio.ch.IOVecWrapper, sun.nio.fs.NativeBuffer and sun.java2d.marlin.OffHeapArray. But those other usages have been converted to use new java.lang.ref.Cleaner so old cleaner is now back to basics - DirectByteBuffers. And with that, DirectByteBuffers allocating threads only help ReferenceHandler thread enqueue References and execute DirectByteBuffer deallocators, which is an improvement. But should we keep that status quo? It's nothing wrong with it as it is, except I think we can do better. > > The old worst case performance/latency wise was the reference > processing thread > did the work and the allocating thread did very little synchronizing > and just did the retries. The number of retries was exactly the same as the number of References helped to be enqueued or in case of Cleaner(s), executed: // retry while helping enqueue pending Reference objects // which includes executing pending Cleaner(s) which includes // Cleaner(s) that free direct buffer memory while (jlra.tryHandlePendingReference()) { if (tryReserveMemory(size, cap)) { return; } } If the share of pending References that are also Cleaners was high, chances were higher that not much helping was needed as one cleaned DBB.Deallocator could unreserve enough memory for next reservation attempt to succeed. So allocating thread helped only until it succeeded in reserving the native memory leaving the rest of work to another allocating request/thread or to ReferenceHandler. > In the best case, all the real work was done by the allocating thread, > if the interactions with GC > work out perfectly. But it was still the case that the buffer > alloc/dealloc throughput was > met with the division of work separating the reference processing > thread and the allocating thread. Yes, whichever thread was quicker. If ReferenceHandler thread had been waking up from wait() for a long time, allocating thread could have already processed all the References before ReferenceHandler finally started to look around. If there were lots of new pending referenced discovered, ReferenceHandler thread could finally join the party and fight for the same lock... > > The function that can only be provided by CleanerImpl / Reference > processing thread state is > knowledge that the cleaning queue is empty. ...and that the discovered pending references have actually been enqueued before that... > The helping functions were/are a bit troublesome because of mixing > execution > environments of the thread allocating direct buffers and the > cleanables and it seemed that > more than a little complexity was needed to compensate. I totally agree. > > If the bottleneck in processing is between the reference processing > and cleanup > then it should be ok (based on previous comments) for the CleanerImpl > to help with > reference processing (after it has an empty queue and before it blocks > waiting or in every loop). > Though if you already tried this combination, I don't recall the results. I don't thing there is a problem because of any bottleneck. And if there was a bottleneck we would only have a problem with allocation/deallocation throughput and not with OOME(s). The problem is because reference discovery is not triggered as a result of native memory reservation approaching or reaching the limit. There is no heap memory pressure from DirectByteBuffer(s) because they are small objects. So a mechanism must be in place that triggers reference discovery and waits for discovered references to be processed before failing the native memory allocation. A mechanism that tries to simulate what happens with GC when there is heap memory pressure. GC guarantees that full-GC is executed and heap allocation retried after that before finally giving up with OOME. We need a mechanism that attempts to do the same for direct memory. Throughput is a nice property but we are not directly seeking its improvement. We just not want to make things much worse. Helping the Cleaner thread to process cleanup functions is the easiest way to wait for cleanup functions to be processed and for queue to drain. Simply because of ReferenceQueue API. If you poll() next Reference from the queue and get null, you know the queue is empty, but if you get something, you have to execute it and not just ignore it. Maybe we could patch into the ReferenceQueue implementation and extend its API with an internal method that would not return next Reference but just information that ReferenceHandler thread has done so or that the queue is empty. I'll think about it. > > As you pointed out it would be more efficient if the allocating thread > could be aware > when it was known there was nothing ready to cleanup so it can retry > and invoke GC or > throw out of memory if appropriate. > Adding a method that returned the count of completed cleaning cycles > (or similar) > to CleanerImpl could exist with a minimal of coupling and still provide > the information needed without commingling the execution threads. I'll think about how to surface this functionality in the CleanerImpl most elegantly. The functionality of providing only the counter of cleaning cycles as a getter might not be most appropriate. What we also need is some mechanism to wait and be woken up to retry reservation only at appropriate points in time otherwise allocating threads could just spin eating CPU time. So my latest attempt was to encapsulate the entire retry logic inside ExtendedCleaner with ByteBuffer/Bits only providing allocation function to this logic, which in my view of API is pretty decoupled and general. > > I don't see the need to change Cleaner to an interface to be able to > provide > an additional method on CleanerImpl or a subclass and a factory method > could > provide for a clean and very targeted interface to Bits/Direct buffer. I would like this to be an instance method so it would naturally pertain to a particular Cleaner instance. Or it could be a static method that takes a Cleaner instance. One of my previous webrevs did have such method on the CleanerImpl, but I was advised to move it to Cleaner as a package-private method and expose it via SharedSecrets to internal code. I feel such "camouflage" is very awkward now that we have modules and other mechanisms exist. So I thought it would be most elegant to make Cleaner an interface so it can be extended with an internal interface to communicate intent in a type-safe and auto-discoverable way. The change to make it interface: http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.part2.1.rev01/ ...actually simplifies implementation (33 lines removed in total) and could be seen as an improvement in itself. Are you afraid that if Cleaner was an interface, others would attempt to make implementations of it? Now that we have default methods on interfaces it is easy to compatibly extend the API even if it is an interface so that no 3rd party implementations are immediately broken. Are you thinking of security implications when some code is handed a Cleaner instance that it doesn't trust? I don't think there is a utility for Cleaner instances to be passed from untrusted to trusted code, do you? In the end it doesn't really matter. We can do it one way or the other. I just feel that using an interface is cleaner. > > I'm sorry I haven't had time to try out concretely what I have in mind. > Please correct or remind me of missing salient considerations. The bottom line is that we need a mechanism that: - triggers reference discovery when native memory limit is approached or reached - retires native memory reservation at appropriate time slots until succeeding or until all pending references have been processed and Cleanables executed at which time native memory reservation can fail with OOME. - if possible, doesn't execute cleanup functions by the allocating thread but just waits for system threads to do the job. - when triggered, does not make native memory allocation a bottleneck. I think that what I did in my latest webrevs with ReferenceHandler thread is an improvement in minimizing contended synchronization and interference of allocating thread(s) with Reference enqueue-ing. But interaction of allocating thread(s) with Cleaner background thread could be improved and I have a couple of ideas to explore. > > Thanks, Roger > Regards, Peter > > On 4/2/2016 7:24 AM, Peter Levart wrote: >> Hi Roger, >> >> Thanks for looking at the patch. >> >> On 04/02/2016 01:31 AM, Roger Riggs wrote: >>> Hi Peter, >>> >>> I overlooked the introduction of another nested class (Task) to >>> handle the cleanup. >>> But there are too many changes to see which ones solve a single >>> problem. >>> >>> Sorry to make more work, but I think we need to go back to the >>> minimum necessary >>> change to make progress on this. Omit all of the little cleanups >>> until the end >>> or do them first and separately. >>> >>> Thanks, Roger >> >> No Problem. I understand. So let's proceed in stages. Since part1 is >> already pushed, I'll call part2 stages with names: part2.1, part2.2, >> ... and I'll start counting webrev revisions from 01 again, so webrev >> names will be in the form: webrev.part2.1.rev01. Each part will be an >> incremental change to the previous one. >> >> part2.1: This is preparation work to be able to have an extended >> java.lang.ref.Cleaner type for internal use. Since >> java.lang.ref.Cleaner is a final class, I propose to make it an >> interface instead: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.part2.1.rev01/ >> >> This is a source-compatible change and it also simplifies >> implementation (no injection of Cleaner.impl access function into >> CleanerImpl needed any more). What used to be java.lang.ref.Cleaner >> is renamed to jdk.internal.ref.CleanerImpl. What used to be >> jdk.internal.ref.CleanerImpl is now a nested static class >> jdk.internal.ref.CleanerImpl.Task (because it implements Runnable). >> Otherwise nothing has changed in the overall architecture of the >> Cleaner except that public-facing API is now an interface instead of >> a final class. This allows specifying internal extension interface >> and internal extension implementation. >> >> CleanerTest passes with this change. >> >> So what do you think? >> >> Regards, Peter >> >>> >>> >>> >>> >>> On 4/1/16 5:51 PM, Roger Riggs wrote: >>>> Hi Peter, >>>> >>>> Thanks for the diffs to look at. >>>> >>>> Two observations on the changes. >>>> >>>> - The Cleaner instance was intentionally and necessarily different >>>> than the CleanerImpl to enable >>>> the CleanerImpl and its thread to terminate if the Cleaner is not >>>> longer referenced. >>>> Folding them into a single object breaks that. >>>> >>>> Perhaps it is not too bad for ExtendedCleaner to subclass >>>> CleanerImpl with the cleanup helper/supplier behavior >>>> and expose itself to Bits. There will be fewer moving parts. There >>>> is no need for two factory methods for >>>> ExtendedCleaner unless you are going to use a separate ThreadFactory. >>>> >>>> - The Deallocator (and now Allocator) nested classes are identical, >>>> and there is a separate copy for each >>>> type derived from the Direct-X-template. But it may not be worth >>>> fixing until the rest of it is settled to avoid >>>> more moving parts. >>>> >>>> I don't have an opinion on the code changes in Reference, that's >>>> different kettle of fish. >>>> >>>> More next week. >>>> >>>> Have a good weekend, Roger >>>> >>>> >>>> On 4/1/2016 12:46 PM, Peter Levart wrote: >>>>> >>>>> >>>>> On 04/01/2016 06:08 PM, Peter Levart wrote: >>>>>> >>>>>> >>>>>> On 04/01/2016 05:18 PM, Peter Levart wrote: >>>>>>> @Roger: >>>>>>> >>>>>>> ... >>>>>>> >>>>>>> About entanglement between nio Bits and >>>>>>> ExtendedCleaner.retryWhileHelpingClean(). It is the same level >>>>>>> of entanglement as between the DirectByteBuffer constructor and >>>>>>> Cleaner.register(). In both occasions an action is provided to >>>>>>> the Cleaner. Cleaner.register() takes a cleanup action and >>>>>>> ExtendedCleaner.retryWhileHelpingClean() takes a retriable >>>>>>> "allocating" or "reservation" action. "allocation" or >>>>>>> "reservation" is the opposite of cleanup. Both methods are >>>>>>> encapsulated in the same object because those two functions must >>>>>>> be coordinated. So I think that collocating them together makes >>>>>>> sense. What do you think? >>>>>> >>>>>> ...to illustrate what I mean, here's a variant that totally >>>>>> untangles Bits from Cleaner and moves the whole Cleaner >>>>>> interaction into the DirectByteBuffer itself: >>>>>> >>>>>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.13.part2/ >>>>>> >>>>>> >>>>>> Notice the symmetry between Cleaner.retryWhileHelpingClean : >>>>>> Cleaner.register and Allocator : Deallocator ? >>>>>> >>>>>> >>>>>> Regards, Peter >>>>>> >>>>> >>>>> And here's also a diff between webrev.12.part2 and webrev.13.part2: >>>>> >>>>> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.diff.12to13.part2/ >>>>> >>>>> >>>>> Regards, Peter >>>>> >>>> >>> >> > From rory.odonnell at oracle.com Tue Apr 5 14:46:45 2016 From: rory.odonnell at oracle.com (Rory O'Donnell) Date: Tue, 5 Apr 2016 15:46:45 +0100 Subject: toRealPath throws InternalError: Should not get here on Windows (paths with junctions) In-Reply-To: References: <56E7F1F6.90405@oracle.com> <56E80691.3030607@oracle.com> Message-ID: <5703CFD5.9040803@oracle.com> Hi Dawid, I updated the bug. Rgds,Rory On 05/04/2016 11:47, Dawid Weiss wrote: > I did a bit more digging. I can reproduce this every time on my machine if: > > 1) I open cmd from total commander (64 bit or 32 bit, doesn't matter); > 2) from that cmd run the simple example in Java that attempts to > resolve real path; this ends in InternalError. > > On the other hand, if I run cmd from the start menu, everything works > fine. total commander is clean > (checked md5 to rule out viruses or whatever). > > I have no idea what this is -- I think the problem can be marked as > "non-reproducible", maybe it's a glitch in my system somewhere. Sorry > for the noise. > > Dawid > > > On Tue, Mar 15, 2016 at 1:56 PM, Rory O'Donnell > wrote: >> Hi Dawid, >> >> I will update bug. >> >> Rgds,Rory >> >> >> On 15/03/2016 12:53, Dawid Weiss wrote: >>> This must be more complicated than I thought because the same code >>> passes with flying colors on another (fairly fresh install) of Windows >>> 10... I don't know what the difference is, to be honest (I have >>> Windows 10 Pro N). I'll try to dig deeper, time permitting, but >>> perhaps a comment on the eventual Jira issue would be sensible (can't >>> do it myself, no Jira access). >>> >>> Dawid >>> >>> On Tue, Mar 15, 2016 at 1:01 PM, Dawid Weiss >>> wrote: >>>> I filed an issue (Review ID: JI-9032181). In any case, I checked with >>>> Java 7, 8 and the ea: >>>> >>>> Java(TM) SE Runtime Environment (build >>>> 9-ea+109-2016-03-09-181019.javare.4620.nc) >>>> >>>> The issue only affects Windows 10 (tested on 64-bit only), Windows 7 >>>> behaves fine. The following sequence is enough to get the stack trace: >>>> >>>> mkdir foo >>>> mklink /J bar foo >>>> java -cp . Test bar >>>> >>>> The Test.java code is: >>>> import java.io.*; >>>> import java.nio.file.*; >>>> >>>> public class Test { >>>> public static void main(String[] args) throws Exception { >>>> Path p = Paths.get(args[0]); >>>> System.out.println("p.toRealPath(): " + p.toRealPath()); >>>> } >>>> } >>>> >>>> and the stack trace: >>>> >>>> Exception in thread "main" java.lang.InternalError: Should not get here >>>> at >>>> sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native >>>> Method) >>>> at >>>> sun.nio.fs.WindowsLinkSupport.getFinalPath(WindowsLinkSupport.java:77) >>>> at >>>> sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:242) >>>> at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:840) >>>> at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44) >>>> at Test.main(Test.java:10) >>>> >>>> Dawid >>>> >>>> On Tue, Mar 15, 2016 at 12:28 PM, Alan Bateman >>>> wrote: >>>>> On 15/03/2016 11:19, Dawid Weiss wrote: >>>>>> I couldn't find an appropriate bug in bugzilla, but this fails >>>>>> reliably for me with Java 8 and 9 on Windows 10, 64-bit: >>>>>> >>>>>> mkdir foo >>>>>> mklink /J bar foo >>>>>> cd bar >>>>>> java -cp Test . >>>>>> >>>>>> where Test.java is as simple as: >>>>>> >>>>>> import java.io.*; >>>>>> import java.nio.file.*; >>>>>> >>>>>> public class Test { >>>>>> public static void main(String[] args) throws Exception { >>>>>> System.out.println("p.toRealPath(): " + >>>>>> Paths.get(args[0]).toRealPath()); >>>>>> } >>>>>> } >>>>>> >>>>>> The thrown error shows: >>>>>> >>>>>> Exception in thread "main" java.lang.InternalError: Should not get here >>>>>> at >>>>>> sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native >>>>>> Method) >>>>> There are a number of win32 functions that this code uses GetProcAddress >>>>> to >>>>> get their address in kernel32. This dates back to when we had to support >>>>> Windows XP. This should be cleaned up now. Doesn't explain why you are >>>>> seeing though, can you submit a bug? >>>>> >>>>> -Alan >> >> -- >> Rgds,Rory O'Donnell >> Quality Engineering Manager >> Oracle EMEA , Dublin, Ireland >> -- Rgds,Rory O'Donnell Quality Engineering Manager Oracle EMEA , Dublin, Ireland From claes.redestad at oracle.com Tue Apr 5 15:15:14 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Tue, 5 Apr 2016 17:15:14 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> Message-ID: <5703D682.1080300@oracle.com> On 04/04/2016 05:45 PM, Martin Buchholz wrote: >> I think this one is going too far. >> >> A*FU/VarHandles should are supposed to act like a go-to replacement for >> Unsafe throughout the class library, and we want to shrink the Unsafe >> exposure. Also, I don't think removing A*FU in favor of Unsafe here wins >> us anything: there should be no throughput hit, and we*will* load A*FU >> down the road anyway, negating the startup wins. >> >> -Aleksey > It is surprising to see new uses of Unsafe when we have an ongoing > initiative within openjdk (especially from Paul Sandoz) to remove most > uses. Varhandles are coming and are expected to replace uses of > Unsafe in the JDK. This is just a very minor win on hello world/-version style tests, so I'm happy to withdraw this if other early usages, such as CHM, is moving to VarHandles anyhow. OTOH using dangerous, internal APIs like this rather than nice, public APIs early in the VM bootstrap has other merits, such as not unintentionally causing bootstrap issues. Say, I don't know if VarHandles have any dependencies on java.lang.invoke currently... /Claes From volker.simonis at gmail.com Tue Apr 5 17:25:33 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Tue, 5 Apr 2016 19:25:33 +0200 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: Message-ID: Hi, can somebody please review this trivial change? Regards, Volker On Mon, Apr 4, 2016 at 6:47 PM, Volker Simonis wrote: > Hi, > > can I please have a review for this small fix: > > http://cr.openjdk.java.net/~simonis/webrevs/2016/8149519 > https://bugs.openjdk.java.net/browse/JDK-8149519 > > Currently the value of the java.specification.version property comes > from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in. It is > currently set to VERSION_NUMBER which is the same value which is also > used for the java.version property. > > This is a bad idea, because VERSION_NUMBER is a dot separated sequence > of numbers (e.g. 9.0.1) which is expected to change frequently (i.e. > for every build and/or update version). If we are configuring with > "--with-version-patch=1" for example, VERSION_NUMBER and java.version > will be "9.0.0.1". But it makes no sense that VERSION_SPECIFICATION > and java.specification.version have the same, dotted value. And it > breaks a lot of legacy applications which parse > java.specification.version as a float number. That code would still > work if java.specification.version would be a concrete number (e.g. > '9' or '10'). > > I suggest to set VERSION_SPECIFICATION to VERSION_MAJOR in > common/autoconf/spec.gmk.in. This should be the "right value" until we > get a specification change during a major release which hasn't > happened for quite some time now. > > Regards, > Volker From coleen.phillimore at oracle.com Tue Apr 5 17:29:11 2016 From: coleen.phillimore at oracle.com (Coleen Phillimore) Date: Tue, 5 Apr 2016 13:29:11 -0400 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5703F579.8050702@oracle.com> References: <5702FC9B.7020600@oracle.com> <5703F579.8050702@oracle.com> Message-ID: <5703F5E7.4060404@oracle.com> Also meant to include core-libs-dev in the email. Thanks, Coleen On 4/5/16 1:27 PM, Coleen Phillimore wrote: > > Hi, I've reviewed the hotspot changes and some of the jdk changes. > This looks really good. > > One comment about the jvm function names: > > I think FillInStackTraceElement is too close of a name to > Throwable::fill_in_stack_trace(). > > -JVM_ENTRY(void, JVM_SetMethodInfo(JNIEnv *env, jobject frame)) > +JVM_ENTRY(void, JVM_FillInStackTraceElement(JNIEnv *env, jobject > frame, jobject stack)) > JVMWrapper("JVM_SetMethodInfo"); > - Handle stackFrame(THREAD, JNIHandles::resolve(frame)); > - java_lang_StackFrameInfo::fill_methodInfo(stackFrame, THREAD); > + Handle stack_frame_info(THREAD, JNIHandles::resolve(frame)); > + Handle stack_trace_element(THREAD, JNIHandles::resolve(stack)); > + java_lang_StackFrameInfo::fill_methodInfo(stack_frame_info, > stack_trace_element, THREAD); JVM_END > > > And the function is called fill_methodInfo in the javaClasses function. > > I think the JVM and the java_lang_StackFrameInfo function names should > be closer. > > I wonder if the name JVM_ToStackFrameElement() and > java_lang_StackFrameInfo::to_stack_frame_element() would be better and > then it'd match the Java name. > > Thanks! > Coleen > > On 4/4/16 9:29 PM, Mandy Chung wrote: >>> On Apr 4, 2016, at 4:45 PM, Brent Christian >>> wrote: >>> >>> Hi, >>> >>> I'd like to check in some footprint and code reduction changes to >>> the java.lang.StackWalker implementation. >>> >>> Webrev: >>> http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ >>> Bug: >>> https://bugs.openjdk.java.net/browse/JDK-8153123 >>> >> This looks good to me. >> >> One thing to mention is that this patch is a follow-up work from the >> investigation on what it takes to enable Throwable to use StackWalker >> (JDK-8141239). The current built-in VM backtrace is very compact and >> performant. We have identified and prototypes the performance >> improvements if Throwable backtrace is generated using stack walker. >> There are some performance gaps that we agree to defer JDK-8141239 to >> a future release and improve the footprint performance and GC >> throughput concerns when MemberNames are stored in the throwable >> backtrace. >> >> Mandy >> > From claes.redestad at oracle.com Tue Apr 5 18:10:56 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Tue, 5 Apr 2016 20:10:56 +0200 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5702FC9B.7020600@oracle.com> References: <5702FC9B.7020600@oracle.com> Message-ID: <5703FFB0.5090303@oracle.com> Hi, On 04/05/2016 01:45 AM, Brent Christian wrote: > Hi, > > I'd like to check in some footprint and code reduction changes to the > java.lang.StackWalker implementation. > > Webrev: > http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ this looks really good to me. It seems the new implementation of StackFrameInfo::toStackTraceElement reads the volatile field ste twice on the fast path, though, so perhaps consider something like this: + StackTraceElement s = ste; + if (s == null) { + synchronized(this) { + s = ste; + if (s == null) { + s = new StackTraceElement(); + toStackTraceElement0(s); + ste = s; + } + } + } + return s; Thanks! /Claes > Bug: > https://bugs.openjdk.java.net/browse/JDK-8153123 > > A summary of the changes: > > * remove the "stackwalk.newThrowable" system property and > "MemberNameInStackFrame" VM flag, originally left in to aid benchmarking > > * Streamline StackFrameInfo fields > > * Refactor/streamline StackStreamFactory (no more separate > classes[]/StackFrame[] arrays, remove unneeded (for now) > StackStreamFactory.StackTrace class) > > > Given the hotspot changes, I plan to push this through hs-rt. > > Thanks, > -Brent > From kumar.x.srinivasan at oracle.com Tue Apr 5 18:18:43 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Tue, 05 Apr 2016 11:18:43 -0700 Subject: RFR: Message-ID: <57040183.3010300@oracle.com> Hi, The issue here was jimage extract was taking too long, exploding the modules onto certain slow filesystems, thus causing test timeouts. Now using jrtfs to zipfs, it takes a small fraction of that time. Please review: http://cr.openjdk.java.net/~ksrini/8152622/webrev.00/ Fix for: https://bugs.openjdk.java.net/browse/JDK-8152622 Thanks Kumar From coleen.phillimore at oracle.com Tue Apr 5 18:25:19 2016 From: coleen.phillimore at oracle.com (Coleen Phillimore) Date: Tue, 5 Apr 2016 14:25:19 -0400 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5703F5E7.4060404@oracle.com> References: <5702FC9B.7020600@oracle.com> <5703F579.8050702@oracle.com> <5703F5E7.4060404@oracle.com> Message-ID: <5704030F.80906@oracle.com> A correction below. On 4/5/16 1:29 PM, Coleen Phillimore wrote: > > Also meant to include core-libs-dev in the email. > Thanks, > Coleen > > On 4/5/16 1:27 PM, Coleen Phillimore wrote: >> >> Hi, I've reviewed the hotspot changes and some of the jdk changes. >> This looks really good. >> >> One comment about the jvm function names: >> >> I think FillInStackTraceElement is too close of a name to >> Throwable::fill_in_stack_trace(). >> >> -JVM_ENTRY(void, JVM_SetMethodInfo(JNIEnv *env, jobject frame)) >> +JVM_ENTRY(void, JVM_FillInStackTraceElement(JNIEnv *env, jobject >> frame, jobject stack)) >> JVMWrapper("JVM_SetMethodInfo"); >> - Handle stackFrame(THREAD, JNIHandles::resolve(frame)); >> - java_lang_StackFrameInfo::fill_methodInfo(stackFrame, THREAD); >> + Handle stack_frame_info(THREAD, JNIHandles::resolve(frame)); >> + Handle stack_trace_element(THREAD, JNIHandles::resolve(stack)); >> + java_lang_StackFrameInfo::fill_methodInfo(stack_frame_info, >> stack_trace_element, THREAD); JVM_END >> >> >> And the function is called fill_methodInfo in the javaClasses function. >> >> I think the JVM and the java_lang_StackFrameInfo function names >> should be closer. >> >> I wonder if the name JVM_ToStackFrameElement() and >> java_lang_StackFrameInfo::to_stack_frame_element() would be better >> and then it'd match the Java name. >> I meant JVM_ToStackTraceElement() and java_lang_StackFrameInfo::to_stack_trace_element(), since it's producing a StackTraceElement. thanks, Coleen >> Thanks! >> Coleen >> >> On 4/4/16 9:29 PM, Mandy Chung wrote: >>>> On Apr 4, 2016, at 4:45 PM, Brent Christian >>>> wrote: >>>> >>>> Hi, >>>> >>>> I'd like to check in some footprint and code reduction changes to >>>> the java.lang.StackWalker implementation. >>>> >>>> Webrev: >>>> http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ >>>> Bug: >>>> https://bugs.openjdk.java.net/browse/JDK-8153123 >>>> >>> This looks good to me. >>> >>> One thing to mention is that this patch is a follow-up work from the >>> investigation on what it takes to enable Throwable to use >>> StackWalker (JDK-8141239). The current built-in VM backtrace is very >>> compact and performant. We have identified and prototypes the >>> performance improvements if Throwable backtrace is generated using >>> stack walker. There are some performance gaps that we agree to >>> defer JDK-8141239 to a future release and improve the footprint >>> performance and GC throughput concerns when MemberNames are stored >>> in the throwable backtrace. >>> >>> Mandy >>> >> > From kumar.x.srinivasan at oracle.com Tue Apr 5 18:25:58 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Tue, 05 Apr 2016 11:25:58 -0700 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <57040183.3010300@oracle.com> References: <57040183.3010300@oracle.com> Message-ID: <57040336.9020703@oracle.com> sorry missed the subject. Kumar > Hi, > > The issue here was jimage extract was taking too long, exploding > the modules onto certain slow filesystems, thus causing test > timeouts. Now using jrtfs to zipfs, it takes a small fraction of > that time. > > Please review: > http://cr.openjdk.java.net/~ksrini/8152622/webrev.00/ > > Fix for: > https://bugs.openjdk.java.net/browse/JDK-8152622 > > Thanks > Kumar > From mandy.chung at oracle.com Tue Apr 5 23:33:00 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 5 Apr 2016 16:33:00 -0700 Subject: RFR [9] 8153498: Update the PostVMInitHook mechanism to use an internal package in the base module In-Reply-To: References: Message-ID: <55EB013A-6F42-424F-BED7-490BF635BB70@oracle.com> > On Apr 5, 2016, at 2:51 AM, Chris Hegarty wrote: > > sun.misc.PostVMInitHook::run is called by the VM once its initialization is > complete, when jdk_version_info.post_vm_init_hook_enabled bit is true. > Since sun.misc will be moved out of the base module, the VM should > look for the PostVMInitHook in a more suitable place, say jdk.internal.vm. > > http://cr.openjdk.java.net/~chegar/8153498/ Looks okay. Minor nit: would it be better to rename the vmSymbol to match the package name: vmSymbols::jdk_internal_vm_PostVMInitHook() Mandy From aleksej.efimov at oracle.com Tue Apr 5 23:47:24 2016 From: aleksej.efimov at oracle.com (Aleksej Efimov) Date: Wed, 6 Apr 2016 02:47:24 +0300 Subject: Bug id : 8140747 - Data corruption when parsing XML using StAX/Xerces In-Reply-To: <1964669852.72080.1459405377521.JavaMail.yahoo@mail.yahoo.com> References: <1964669852.72080.1459405377521.JavaMail.yahoo.ref@mail.yahoo.com> <1964669852.72080.1459405377521.JavaMail.yahoo@mail.yahoo.com> Message-ID: <57044E8C.1000903@oracle.com> Hi Vlad, This bug was fixed in 7u80. Please, see JDK-8059327 [1] for more information. Also I have successfully executed the test from JDK-8140747 on 7u80 and on 7u75 with [1] applied: It gave me a lot of 'rugs' =). Best Regards, Aleksej [1] https://bugs.openjdk.java.net/browse/JDK-8059327 On 03/31/2016 09:22 AM, Vlad-Lucian G?nju wrote: > Hello, > Encountered this bug on our server and after some investigations I was able to find the bug reported here https://bugs.openjdk.java.net/browse/JDK-8140747. > It seems that you were not able to reproduce on the Java versions mentioned in the bug's description. > I am able to reproduce it on JDK 7u75 constantly. Installed this Java version on several linux machines and I am able to reproduce it on every one of them using the code provided in bug's description.I hope this info can help you find the problem mentioned in the bug's description. > > [vlg at sec vladtmp]$ for i in $(seq 1 10); do java TestXmlReader; done; > bugs > bugs > bugs > bugs > bugs > bugs > bugs > bugs > bugs > bugs > [vlg at sec vladtmp]$ java -version > java version "1.7.0_75" > Java(TM) SE Runtime Environment (build 1.7.0_75-b13) > Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode) > > > Regards,Vlad-Lucian G?nju From brent.christian at oracle.com Tue Apr 5 23:48:24 2016 From: brent.christian at oracle.com (Brent Christian) Date: Tue, 05 Apr 2016 16:48:24 -0700 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5704030F.80906@oracle.com> References: <5702FC9B.7020600@oracle.com> <5703F579.8050702@oracle.com> <5703F5E7.4060404@oracle.com> <5704030F.80906@oracle.com> Message-ID: <57044EC8.7050602@oracle.com> Thanks, Coleen. Coordinating method/function names on "to stack trace element" is a fine thing. I've done so in the updated webrev, and also implemented Claes's suggestion. http://cr.openjdk.java.net/~bchristi/8153123/webrev.01/index.html -Brent On 04/05/2016 11:25 AM, Coleen Phillimore wrote: > > A correction below. > > On 4/5/16 1:29 PM, Coleen Phillimore wrote: >> >> Also meant to include core-libs-dev in the email. >> Thanks, >> Coleen >> >> On 4/5/16 1:27 PM, Coleen Phillimore wrote: >>> >>> Hi, I've reviewed the hotspot changes and some of the jdk changes. >>> This looks really good. >>> >>> One comment about the jvm function names: >>> >>> I think FillInStackTraceElement is too close of a name to >>> Throwable::fill_in_stack_trace(). >>> >>> -JVM_ENTRY(void, JVM_SetMethodInfo(JNIEnv *env, jobject frame)) >>> +JVM_ENTRY(void, JVM_FillInStackTraceElement(JNIEnv *env, jobject >>> frame, jobject stack)) >>> JVMWrapper("JVM_SetMethodInfo"); >>> - Handle stackFrame(THREAD, JNIHandles::resolve(frame)); >>> - java_lang_StackFrameInfo::fill_methodInfo(stackFrame, THREAD); >>> + Handle stack_frame_info(THREAD, JNIHandles::resolve(frame)); >>> + Handle stack_trace_element(THREAD, JNIHandles::resolve(stack)); >>> + java_lang_StackFrameInfo::fill_methodInfo(stack_frame_info, >>> stack_trace_element, THREAD); JVM_END >>> >>> >>> And the function is called fill_methodInfo in the javaClasses function. >>> >>> I think the JVM and the java_lang_StackFrameInfo function names >>> should be closer. >>> >>> I wonder if the name JVM_ToStackFrameElement() and >>> java_lang_StackFrameInfo::to_stack_frame_element() would be better >>> and then it'd match the Java name. >>> > > I meant JVM_ToStackTraceElement() and > java_lang_StackFrameInfo::to_stack_trace_element(), since it's producing > a StackTraceElement. > > thanks, > Coleen >>> Thanks! >>> Coleen >>> >>> On 4/4/16 9:29 PM, Mandy Chung wrote: >>>>> On Apr 4, 2016, at 4:45 PM, Brent Christian >>>>> wrote: >>>>> >>>>> Hi, >>>>> >>>>> I'd like to check in some footprint and code reduction changes to >>>>> the java.lang.StackWalker implementation. >>>>> >>>>> Webrev: >>>>> http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ >>>>> Bug: >>>>> https://bugs.openjdk.java.net/browse/JDK-8153123 >>>>> >>>> This looks good to me. >>>> >>>> One thing to mention is that this patch is a follow-up work from the >>>> investigation on what it takes to enable Throwable to use >>>> StackWalker (JDK-8141239). The current built-in VM backtrace is very >>>> compact and performant. We have identified and prototypes the >>>> performance improvements if Throwable backtrace is generated using >>>> stack walker. There are some performance gaps that we agree to >>>> defer JDK-8141239 to a future release and improve the footprint >>>> performance and GC throughput concerns when MemberNames are stored >>>> in the throwable backtrace. >>>> >>>> Mandy >>>> >>> >> > From steve.dohrmann at intel.com Wed Apr 6 01:49:01 2016 From: steve.dohrmann at intel.com (Dohrmann, Steve) Date: Wed, 6 Apr 2016 01:49:01 +0000 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory Message-ID: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> Re: JDK-8153111 Hi, Below are responses to some of the points brought up in the discussion as well as is a little expansion of the reasoning that went into the proposed API. One motivation we saw for doing anything beyond a concrete ByteBuffer class was application code (e.g. Cassandra) that allocates many off-heap ByteBuffers using ByteBuffer#allocateDirect. We reasoned that if the allocation of ByteBuffers could be done using a common memory interface then only the code that provisioned instances of the the memory spaces would have to change in order to switch or mix memory types. We did think of overloading the ByteBuffer#allocateDirect method with memory space info and avoid an allocation interface. We ended up with a separate user called interface scheme because we imagined that extensions of the memory interface would enable new memory functionality that required new methods (e.g. memory transactions for persistence). Without a separate callable interface, the static method space in ByteBuffer might have to change again. For any API In general we saw the need for two things 1) something to represent a memory space from which objects are allocated (a Memory instance) and 2) a broadly usable familiar "anchor" type as the common data object (java.nio.ByteBuffer). The two points for extension with the current proposal are: 1) Constructors on Memory implementation classes -- allow implementors the ability to offer features on the memory space itself (e.g. partitioning, size limits) and 2) future extensions on the Memory interface -- for example PersistentMemory. Regarding a more elaborate scheme for memory space creation -- we did consider a factory scheme for memory object allocation but could not get comfortable with either a) standardized method signatures suitable for various kinds of memory or b) the complexity that something like a general-purpose "spec" format would add, even if we could come up with it. Direct construction does expose more to the user but it seems sufficient and might be the best given what we can say about the future of heterogeneous memory at this point. Regarding the suggested addition of keyed access to ByteBuffers, we are assuming this is only proposed to enable sharing? We thought it might take a while to properly explore the details (i.e. semantics / thread safety / predicable performance) of sharing such that it would work well and maybe even extend well to things like process-shared and cluster-shared ByteBuffers. We elected to propose nothing for JDK 9 beyond what developers can already do with schemes based on e.g. ByteBuffer#duplicate. We were thinking shared buffers could appear later, possibly as an extension of the Memory interface. The keyed access scheme is simple and appealing, however. One question: how is the request method's size parameter to be interpreted? The suggestion of parameterizing the Memory interface bounded by ByteBuffers seems useful as it gives a clean way to support extended ByteBuffers. Not sure if the change of the allocation method name from #allocateByteBuffer to #allocate was incidental or not? Alternates to the "Memory" interface name might be preferred, BufferSupplier is certainly reasonable. We imagined instances that name different memory spaces (e.g. OffHeapRAM) for allocation rather that the role played -- thinking the role is explicit in the allocation method name (allocateByteBuffer). Regarding changing the allocation size parameter to a long, this would be very nice to have. We avoided it in order to match the existing ByteBuffer API. If 64-bit ByteBuffers are planned, sticking with int sizes might have been the wrong call. We are still coming up to speed on VarHandles (JEP 193), atomics for ByteBuffers (JDK-8008240), and ByteBuffer consistency (JDK-6476827). We hope there is continued interest in this proposal and happy to provide a modified patch. Best regards, Steve Dohrmann From mandy.chung at oracle.com Wed Apr 6 01:56:47 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 5 Apr 2016 18:56:47 -0700 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <5703CE96.4040001@gmail.com> References: <56B72242.7050102@gmail.com> <56C34B1B.8050001@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> <56FF04B5.2030507@oracle.com> <56FFABED.2060708@gmail.com> <5702E18D.7010807@Oracle.com> <5703CE96.40! 40001@gmail.com> Message-ID: Hi Peter, > On Apr 5, 2016, at 7:41 AM, Peter Levart wrote: > > The bottom line is that we need a mechanism that: > > - triggers reference discovery when native memory limit is approached or reached > - retires native memory reservation at appropriate time slots until succeeding or until all pending references have been processed and Cleanables executed at which time native memory reservation can fail with OOME. > - if possible, doesn't execute cleanup functions by the allocating thread but just waits for system threads to do the job. > - when triggered, does not make native memory allocation a bottleneck. > > I think that what I did in my latest webrevs with ReferenceHandler thread is an improvement in minimizing contended synchronization and interference of allocating thread(s) with Reference enqueue-ing. But interaction of allocating thread(s) with Cleaner background thread could be improved and I have a couple of ideas to explore. This is about timely native memory deallocation. Since direct byte buffer is the only one using jdk.internal.ref.Cleaner, I am inclined to suggest keep jdk.internal.ref.Cleaner as is and replaced it with a better mechanism when it?s available, either panama or better pending reference enqueuing that you and Per discussed. Given the time we have, I think it?s likely post JDK 9 timeframe. Minimizing contention and interference of allocating threads and ReferenceHandler may worth exploring. Mandy From kumar.x.srinivasan at oracle.com Wed Apr 6 03:47:50 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Tue, 05 Apr 2016 20:47:50 -0700 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <57040336.9020703@oracle.com> References: <57040183.3010300@oracle.com> <57040336.9020703@oracle.com> Message-ID: <570486E6.2030405@oracle.com> Hi, I made some adjustments, based on private feedback. New Webrev: http://cr.openjdk.java.net/~ksrini/8152622/webrev.01/ Changes * Modified ModuleAttributes test to use the new utility method, this also requires a way to filter/select filename patterns. * Use preVisitDirectory to create directories once, and ignore /packages directories. Thanks Kumar > > sorry missed the subject. > > Kumar >> Hi, >> >> The issue here was jimage extract was taking too long, exploding >> the modules onto certain slow filesystems, thus causing test >> timeouts. Now using jrtfs to zipfs, it takes a small fraction of >> that time. >> >> Please review: >> http://cr.openjdk.java.net/~ksrini/8152622/webrev.00/ >> >> Fix for: >> https://bugs.openjdk.java.net/browse/JDK-8152622 >> >> Thanks >> Kumar >> > From sundararajan.athijegannathan at oracle.com Wed Apr 6 04:40:51 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Wed, 6 Apr 2016 10:10:51 +0530 Subject: RFR: In-Reply-To: <57040183.3010300@oracle.com> References: <57040183.3010300@oracle.com> Message-ID: <57049353.2000809@oracle.com> +1 On 4/5/2016 11:48 PM, Kumar Srinivasan wrote: > Hi, > > The issue here was jimage extract was taking too long, exploding > the modules onto certain slow filesystems, thus causing test > timeouts. Now using jrtfs to zipfs, it takes a small fraction of > that time. > > Please review: > http://cr.openjdk.java.net/~ksrini/8152622/webrev.00/ > > Fix for: > https://bugs.openjdk.java.net/browse/JDK-8152622 > > Thanks > Kumar > From alejandro.murillo at oracle.com Wed Apr 6 05:14:00 2016 From: alejandro.murillo at oracle.com (Alejandro Murillo) Date: Tue, 5 Apr 2016 23:14:00 -0600 Subject: [9] RFR JDK-8153564: Add java/nio/Buffer/BasicByte.java to exclude list until JDK-8153563 is fixed Message-ID: <57049B18.5050307@oracle.com> I'd like to push the changeset below to exclude java/nio/Buffer/BasicByte.java It started failing after the hotspot snapshot was pushed to jdk9/dev tonight. https://bugs.openjdk.java.net/browse/JDK-8153563 has been filed for that failure. $ hg -R jdk9.dev/jdk tip -pv changeset: 14082:5c98c9ad8ff2 tag: tip user: amurillo date: Tue Apr 05 22:06:15 2016 -0700 files: test/ProblemList.txt description: 8153564: Add java/nio/Buffer/BasicByte.java to exclude list until JDK-8153563 is fixed Reviewed-by: tbd diff -r 04f56d4ca167 -r 5c98c9ad8ff2 test/ProblemList.txt --- a/test/ProblemList.txt Tue Apr 05 20:02:21 2016 -0700 +++ b/test/ProblemList.txt Tue Apr 05 22:06:15 2016 -0700 @@ -185,6 +185,8 @@ java/nio/charset/coders/BashStreams.java 8149712 generic-all +java/nio/Buffer/BasicByte.java 8153563 generic-all + ############################################################################ # jdk_rmi -- Alejandro From mandy.chung at oracle.com Wed Apr 6 05:36:23 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 5 Apr 2016 22:36:23 -0700 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <57044EC8.7050602@oracle.com> References: <5702FC9B.7020600@oracle.com> <5703F579.8050702@oracle.com> <5703F5E7.4060404@oracle.com> <5704030F.80906@oracle.com> <57044EC8.7050602@oracle.com> Message-ID: > On Apr 5, 2016, at 4:48 PM, Brent Christian wrote: > > Thanks, Coleen. Coordinating method/function names on "to stack trace element" is a fine thing. I've done so in the updated webrev, and also implemented Claes's suggestion. > > http://cr.openjdk.java.net/~bchristi/8153123/webrev.01/index.html > Looks good. Nit: can you add a space after ?synchronized? in StackFrameInfo.java line 109: 109 synchronized(this) { Mandy From amy.lu at oracle.com Wed Apr 6 05:59:43 2016 From: amy.lu at oracle.com (Amy Lu) Date: Wed, 6 Apr 2016 13:59:43 +0800 Subject: [9] RFR JDK-8153564: Add java/nio/Buffer/BasicByte.java to exclude list until JDK-8153563 is fixed In-Reply-To: <57049B18.5050307@oracle.com> References: <57049B18.5050307@oracle.com> Message-ID: <5704A5CF.2090804@oracle.com> java/nio/Buffer/CopyDirectMemory.java run into the same issue, maybe it could be problem listed together in this patch? Thanks, Amy On 4/6/16 1:14 PM, Alejandro Murillo wrote: > > I'd like to push the changeset below to exclude > java/nio/Buffer/BasicByte.java > It started failing after the hotspot snapshot was pushed to jdk9/dev > tonight. > https://bugs.openjdk.java.net/browse/JDK-8153563 has been filed for > that failure. > > $ hg -R jdk9.dev/jdk tip -pv > > changeset: 14082:5c98c9ad8ff2 > tag: tip > user: amurillo > date: Tue Apr 05 22:06:15 2016 -0700 > files: test/ProblemList.txt > description: > 8153564: Add java/nio/Buffer/BasicByte.java to exclude list until > JDK-8153563 is fixed > Reviewed-by: tbd > > > diff -r 04f56d4ca167 -r 5c98c9ad8ff2 test/ProblemList.txt > --- a/test/ProblemList.txt Tue Apr 05 20:02:21 2016 -0700 > +++ b/test/ProblemList.txt Tue Apr 05 22:06:15 2016 -0700 > @@ -185,6 +185,8 @@ > > java/nio/charset/coders/BashStreams.java 8149712 generic-all > > +java/nio/Buffer/BasicByte.java 8153563 generic-all > + > ############################################################################ > > > # jdk_rmi > > From alejandro.murillo at oracle.com Wed Apr 6 06:22:29 2016 From: alejandro.murillo at oracle.com (Alejandro Murillo) Date: Wed, 6 Apr 2016 00:22:29 -0600 Subject: [9] RFR JDK-8153564: Add java/nio/Buffer/BasicByte.java to exclude list until JDK-8153563 is fixed In-Reply-To: <5704A5CF.2090804@oracle.com> References: <57049B18.5050307@oracle.com> <5704A5CF.2090804@oracle.com> Message-ID: <5704AB25.903@oracle.com> I didn't see that one failing on my jprt sanity job I went to check the code CopyDirectMemory.java, and it doesn't use jdk.internal.misc.Unsafe (at least directly), so doesn't look like it's the same issue. where did you see the failure ? Alejandro On 4/5/2016 11:59 PM, Amy Lu wrote: > java/nio/Buffer/CopyDirectMemory.java > run into the same issue, maybe it could be problem listed together in > this patch? > > Thanks, > Amy > > On 4/6/16 1:14 PM, Alejandro Murillo wrote: >> >> I'd like to push the changeset below to exclude >> java/nio/Buffer/BasicByte.java >> It started failing after the hotspot snapshot was pushed to jdk9/dev >> tonight. >> https://bugs.openjdk.java.net/browse/JDK-8153563 has been filed for >> that failure. >> >> $ hg -R jdk9.dev/jdk tip -pv >> >> changeset: 14082:5c98c9ad8ff2 >> tag: tip >> user: amurillo >> date: Tue Apr 05 22:06:15 2016 -0700 >> files: test/ProblemList.txt >> description: >> 8153564: Add java/nio/Buffer/BasicByte.java to exclude list until >> JDK-8153563 is fixed >> Reviewed-by: tbd >> >> >> diff -r 04f56d4ca167 -r 5c98c9ad8ff2 test/ProblemList.txt >> --- a/test/ProblemList.txt Tue Apr 05 20:02:21 2016 -0700 >> +++ b/test/ProblemList.txt Tue Apr 05 22:06:15 2016 -0700 >> @@ -185,6 +185,8 @@ >> >> java/nio/charset/coders/BashStreams.java 8149712 generic-all >> >> +java/nio/Buffer/BasicByte.java 8153563 generic-all >> + >> ############################################################################ >> >> >> # jdk_rmi >> >> > -- Alejandro From ecki at zusammenkunft.net Wed Apr 6 06:37:09 2016 From: ecki at zusammenkunft.net (Bernd Eckenfels) Date: Wed, 6 Apr 2016 08:37:09 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> References: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> Message-ID: <5704ae9a.d4b61c0a.b7e1a.5525@mx.google.com> Hello Steve, Thank you for addressing all concerns raised in the discussion. For my points: Using BufferSupplier or similar as the interface name can be mixed with class/constructor names which describe the actual type of memory. However yes I agree that ?Memory? has the additional benefit that it can be used directly as a postfix in the class name, so thinking more about it, I agree with the nice and concrete ?Memory? name. I shortened the method to ?allocate()?, but you are right it might be better to make it a bit more specific if extensions are to be expected. My main motivation behind a long key was, that in most scenarios which come to my mind (NVRAM, Flash, mmaped, shmem) the position of the allocated segment is relevant for cross VM (concurrent or sequential, as in the persisted case) sharing. As a ByteBuffer is not only a window into those memory segments but also a active datastructure (pos) it would be ugly to request only a single buffer to cover a large region. Especially with a 32bit size limit. But yes it might also be possible to setup the position/sharing details with the Memory constructor request a large ByteBuffer and then split the actual buffers mapped on top of it (and do the allocation management based on start positions by hand) The meaning of size in combination with the allocation key would be provider dependent. One option would be to refuse overlapping allocations but a more common implementation would simply allocate the segments (and if two VMs use overlapping regions they will exactly receive them). In all cases it should describe the capacity of the buffer. Greetings bernd -- http://bernd.eckenfels.net Von: Dohrmann, Steve Gesendet: Mittwoch, 6. April 2016 03:59 An: core-libs-dev at openjdk.java.net Betreff: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory Re: JDK-8153111 Hi, Below are responses to some of the points brought up in the discussion as well as is a little expansion of the reasoning that went into the proposed API. One motivation we saw for doing anything beyond a concrete ByteBuffer class was application code (e.g. Cassandra) that allocates many off-heap ByteBuffers using ByteBuffer#allocateDirect. We reasoned that if the allocation of ByteBuffers could be done using a common memory interface then only the code that provisioned instances of the the memory spaces would have to change in order to switch or mix memory types. We did think of overloading the ByteBuffer#allocateDirect method with memory space info and avoid an allocation interface. We ended up with a separate user called interface scheme because we imagined that extensions of the memory interface would enable new memory functionality that required new methods (e.g. memory transactions for persistence). Without a separate callable interface, the static method space in ByteBuffer might have to change again. For any API In general we saw the need for two things 1) something to represent a memory space from which objects are allocated (a Memory instance) and 2) a broadly usable familiar "anchor" type as the common data object (java.nio.ByteBuffer). The two points for extension with the current proposal are: 1) Constructors on Memory implementation classes -- allow implementors the ability to offer features on the memory space itself (e.g. partitioning, size limits) and 2) future extensions on the Memory interface -- for example PersistentMemory. Regarding a more elaborate scheme for memory space creation -- we did consider a factory scheme for memory object allocation but could not get comfortable with either a) standardized method signatures suitable for various kinds of memory or b) the complexity that something like a general-purpose "spec" format would add, even if we could come up with it. Direct construction does expose more to the user but it seems sufficient and might be the best given what we can say about the future of heterogeneous memory at this point. Regarding the suggested addition of keyed access to ByteBuffers, we are assuming this is only proposed to enable sharing? We thought it might take a while to properly explore the details (i.e. semantics / thread safety / predicable performance) of sharing such that it would work well and maybe even extend well to things like process-shared and cluster-shared ByteBuffers. We elected to propose nothing for JDK 9 beyond what developers can already do with schemes based on e.g. ByteBuffer#duplicate. We were thinking shared buffers could appear later, possibly as an extension of the Memory interface. The keyed access scheme is simple and appealing, however. One question: how is the request method's size parameter to be interpreted? The suggestion of parameterizing the Memory interface bounded by ByteBuffers seems useful as it gives a clean way to support extended ByteBuffers. Not sure if the change of the allocation method name from #allocateByteBuffer to #allocate was incidental or not? Alternates to the "Memory" interface name might be preferred, BufferSupplier is certainly reasonable. We imagined instances that name different memory spaces (e.g. OffHeapRAM) for allocation rather that the role played -- thinking the role is explicit in the allocation method name (allocateByteBuffer). Regarding changing the allocation size parameter to a long, this would be very nice to have. We avoided it in order to match the existing ByteBuffer API. If 64-bit ByteBuffers are planned, sticking with int sizes might have been the wrong call. We are still coming up to speed on VarHandles (JEP 193), atomics for ByteBuffers (JDK-8008240), and ByteBuffer consistency (JDK-6476827). We hope there is continued interest in this proposal and happy to provide a modified patch. Best regards, Steve Dohrmann From peter.levart at gmail.com Wed Apr 6 06:43:43 2016 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 6 Apr 2016 08:43:43 +0200 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <5703CE96.4040001@gmail.com> References: <56B72242.7050102@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> <56FF04B5.2030507@oracle.com> <56FFABED.2060708@gmail.com> <5702E18D.7010807@Oracle.com> <5703CE96.4040001@gmail.com> Message-ID: <5704B01F.4070406@gmail.com> Hi Roger, On 04/05/2016 04:41 PM, Peter Levart wrote: >> On 04/04/2016 11:50 PM, Roger Riggs wrote: >> I don't see the need to change Cleaner to an interface to be able to >> provide >> an additional method on CleanerImpl or a subclass and a factory >> method could >> provide for a clean and very targeted interface to Bits/Direct buffer. > > I would like this to be an instance method so it would naturally > pertain to a particular Cleaner instance. Or it could be a static > method that takes a Cleaner instance. One of my previous webrevs did > have such method on the CleanerImpl, but I was advised to move it to > Cleaner as a package-private method and expose it via SharedSecrets to > internal code. I feel such "camouflage" is very awkward now that we > have modules and other mechanisms exist. So I thought it would be most > elegant to make Cleaner an interface so it can be extended with an > internal interface to communicate intent in a type-safe and > auto-discoverable way. The change to make it interface: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.part2.1.rev01/ > > ...actually simplifies implementation (33 lines removed in total) and > could be seen as an improvement in itself. > > Are you afraid that if Cleaner was an interface, others would attempt > to make implementations of it? Now that we have default methods on > interfaces it is easy to compatibly extend the API even if it is an > interface so that no 3rd party implementations are immediately broken. > Are you thinking of security implications when some code is handed a > Cleaner instance that it doesn't trust? I don't think there is a > utility for Cleaner instances to be passed from untrusted to trusted > code, do you? ...even if we don't do anything for DirectByteBuffer(s) in java.lang.ref.Cleaner and leave things as they stand (using jdk.internal.ref.Cleaner), I would still make this transition to interface to enable possible future internal extensions to java.lang.ref.Cleaner. As I said, this is a source compatible change, but not binary compatible, so if we do it, it must be performed before JDK 9 ships. Regards, Peter From Alan.Bateman at oracle.com Wed Apr 6 07:36:54 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Apr 2016 08:36:54 +0100 Subject: [9] RFR JDK-8153564: Add java/nio/Buffer/BasicByte.java to exclude list until JDK-8153563 is fixed In-Reply-To: <57049B18.5050307@oracle.com> References: <57049B18.5050307@oracle.com> Message-ID: <5704BC96.1060303@oracle.com> On 06/04/2016 06:14, Alejandro Murillo wrote: > > I'd like to push the changeset below to exclude > java/nio/Buffer/BasicByte.java > It started failing after the hotspot snapshot was pushed to jdk9/dev > tonight. > https://bugs.openjdk.java.net/browse/JDK-8153563 has been filed for > that failure. Would it be possible to add @modules java.base/jdk.internal.misc, as below, and not exclude these tests? -Alan $ hg diff -g . diff --git a/test/java/nio/Buffer/Basic.java b/test/java/nio/Buffer/Basic.java --- a/test/java/nio/Buffer/Basic.java +++ b/test/java/nio/Buffer/Basic.java @@ -22,6 +22,7 @@ */ /* @test + * @modules java.base/jdk.internal.misc * @summary Unit test for buffers * @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725 * 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529 diff --git a/test/java/nio/Buffer/CopyDirectMemory.java b/test/java/nio/Buffer/CopyDirectMemory.java --- a/test/java/nio/Buffer/CopyDirectMemory.java +++ b/test/java/nio/Buffer/CopyDirectMemory.java @@ -25,6 +25,7 @@ * @summary Test view buffer bulk operations for large buffers. * @bug 4463011 * + * @modules java.base/jdk.internal.misc * @build Basic * @run main CopyDirectMemory */ From paul.sandoz at oracle.com Wed Apr 6 07:37:00 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 6 Apr 2016 09:37:00 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <5703D682.1080300@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <5703D682.1080300@oracle.com> Message-ID: <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> > On 5 Apr 2016, at 17:15, Claes Redestad wrote: > > On 04/04/2016 05:45 PM, Martin Buchholz wrote: >>> I think this one is going too far. >>> >>> A*FU/VarHandles should are supposed to act like a go-to replacement for >>> Unsafe throughout the class library, and we want to shrink the Unsafe >>> exposure. Also, I don't think removing A*FU in favor of Unsafe here wins >>> us anything: there should be no throughput hit, and we *will* load A*FU >>> down the road anyway, negating the startup wins. +1 i would leave this one as is. In general same goes for the @Stable/ForceInline annotations etc. We should use this stuff carefully within java.base and also sparingly to qualifying JDK modules. >>> >>> -Aleksey >> It is surprising to see new uses of Unsafe when we have an ongoing >> initiative within openjdk (especially from Paul Sandoz) to remove most >> uses. Varhandles are coming and are expected to replace uses of >> Unsafe in the JDK. > > This is just a very minor win on hello world/-version style tests, so I'm happy to withdraw this if other early usages, such as CHM, is moving to VarHandles anyhow. > > OTOH using dangerous, internal APIs like this rather than nice, public APIs early in the VM bootstrap has other merits, such as not unintentionally causing bootstrap issues. Say, I don't know if VarHandles have any dependencies on java.lang.invoke currently? It does, but was designed to be minimize bootstrap issues and class spinning so there are less dependencies than MHs. CHM is a tricky class because MethodType uses CHM and VHs uses MethodType. There is probably a way of switching from a less concurrent concurrent map to CHM at ?safe-point? when the VM transitions to booted. To be investigated... Paul. From amy.lu at oracle.com Wed Apr 6 07:47:58 2016 From: amy.lu at oracle.com (Amy Lu) Date: Wed, 6 Apr 2016 15:47:58 +0800 Subject: JDK 9 RFR of JDK-8153563: java/nio/Buffer/Basic.java and CopyDirectMemory.java are failing after JDK-8149469 Message-ID: <5704BF2E.7080500@oracle.com> With test/java/nio/Buffer/BasicByte.java change in JDK-8149469, test java/nio/Buffer/Basic.java java/nio/Buffer/CopyDirectMemory.java now requires @modules java.base/jdk.internal.misc Please review the patch. bug: https://bugs.openjdk.java.net/browse/JDK-8153563 webrev: http://cr.openjdk.java.net/~amlu/8153563/webrev.00/ Thanks, Amy --- old/test/java/nio/Buffer/Basic.java 2016-04-06 15:39:19.000000000 +0800 +++ new/test/java/nio/Buffer/Basic.java 2016-04-06 15:39:19.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529 * 6221101 6234263 6535542 6591971 6593946 6795561 7190219 7199551 8065556 * 8149469 + * @modules java.base/jdk.internal.misc * @author Mark Reinhold */ --- old/test/java/nio/Buffer/CopyDirectMemory.java 2016-04-06 15:39:20.000000000 +0800 +++ new/test/java/nio/Buffer/CopyDirectMemory.java 2016-04-06 15:39:20.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 4463011 * * @build Basic + * @modules java.base/jdk.internal.misc * @run main CopyDirectMemory */ From Alan.Bateman at oracle.com Wed Apr 6 07:52:03 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Apr 2016 08:52:03 +0100 Subject: JDK 9 RFR of JDK-8153563: java/nio/Buffer/Basic.java and CopyDirectMemory.java are failing after JDK-8149469 In-Reply-To: <5704BF2E.7080500@oracle.com> References: <5704BF2E.7080500@oracle.com> Message-ID: <5704C023.7050704@oracle.com> On 06/04/2016 08:47, Amy Lu wrote: > : > * > * @build Basic > + * @modules java.base/jdk.internal.misc > * @run main CopyDirectMemory > */ > It might be clearer to put it before the @build, otherwise looks okay. -Alan From amy.lu at oracle.com Wed Apr 6 07:59:59 2016 From: amy.lu at oracle.com (Amy Lu) Date: Wed, 6 Apr 2016 15:59:59 +0800 Subject: JDK 9 RFR of JDK-8153563: java/nio/Buffer/Basic.java and CopyDirectMemory.java are failing after JDK-8149469 In-Reply-To: <5704C023.7050704@oracle.com> References: <5704BF2E.7080500@oracle.com> <5704C023.7050704@oracle.com> Message-ID: <5704C1FF.4020404@oracle.com> On 4/6/16 3:52 PM, Alan Bateman wrote: > > On 06/04/2016 08:47, Amy Lu wrote: >> : >> * >> * @build Basic >> + * @modules java.base/jdk.internal.misc >> * @run main CopyDirectMemory >> */ >> > It might be clearer to put it before the @build, otherwise looks okay. Yes :-) Please review the updated patch: http://cr.openjdk.java.net/~amlu/8153563/webrev.01/ Thanks, Amy --- old/test/java/nio/Buffer/Basic.java 2016-04-06 15:57:56.000000000 +0800 +++ new/test/java/nio/Buffer/Basic.java 2016-04-06 15:57:56.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529 * 6221101 6234263 6535542 6591971 6593946 6795561 7190219 7199551 8065556 * 8149469 + * @modules java.base/jdk.internal.misc * @author Mark Reinhold */ --- old/test/java/nio/Buffer/CopyDirectMemory.java 2016-04-06 15:57:57.000000000 +0800 +++ new/test/java/nio/Buffer/CopyDirectMemory.java 2016-04-06 15:57:57.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @summary Test view buffer bulk operations for large buffers. * @bug 4463011 * + * @modules java.base/jdk.internal.misc * @build Basic * @run main CopyDirectMemory */ From Alan.Bateman at oracle.com Wed Apr 6 08:32:22 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Apr 2016 09:32:22 +0100 Subject: JDK 9 RFR of JDK-8153563: java/nio/Buffer/Basic.java and CopyDirectMemory.java are failing after JDK-8149469 In-Reply-To: <5704C1FF.4020404@oracle.com> References: <5704BF2E.7080500@oracle.com> <5704C023.7050704@oracle.com> <5704C1FF.4020404@oracle.com> Message-ID: <5704C996.70104@oracle.com> On 06/04/2016 08:59, Amy Lu wrote: > Yes :-) > > Please review the updated patch: > http://cr.openjdk.java.net/~amlu/8153563/webrev.01/ > > Thanks, > Amy Looks fine. From Alan.Bateman at oracle.com Wed Apr 6 08:39:22 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Apr 2016 09:39:22 +0100 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <570486E6.2030405@oracle.com> References: <57040183.3010300@oracle.com> <57040336.9020703@oracle.com> <570486E6.2030405@oracle.com> Message-ID: <5704CB3A.8080004@oracle.com> On 06/04/2016 04:47, Kumar Srinivasan wrote: > Hi, > > I made some adjustments, based on private feedback. > > New Webrev: > http://cr.openjdk.java.net/~ksrini/8152622/webrev.01/ > > Changes > * Modified ModuleAttributes test to use the new utility method, > this also requires a way to filter/select filename patterns. > > * Use preVisitDirectory to create directories once, and ignore > /packages directories. > Creating a zip file from the classes in the jrt file system make sense, and should be fast. A few comments on Utils.JrtToZip: - the URI creation in the run() method isn't reliable, could you use this instead: URI uri = URI.create("jar:" + outFile.toURI()); - In the toZipFs method then I assume you should use URI.create("jrt:/"), best to stay away from URL. - Is Files.createDirectories needed? The walk is specified to be depth first so you'll also visit parent directories first. - I'm also curious about the REPLACE_EXISTING as I assume that isn't needed. A minor comment is that "root" rather than "p" would be nicer for the root directory. Personally I would avoid the really long lines as it makes future side-by-side reviews harder. Also throws Exception seems too broad but it's test code so not a big deal. -Alan. From michael.haupt at oracle.com Wed Apr 6 09:37:51 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 6 Apr 2016 11:37:51 +0200 Subject: RFR 8150829: Enhanced drop-args, identity and default constant, varargs adjustment In-Reply-To: <56F12F4C.70201@oracle.com> References: <56F12F4C.70201@oracle.com> Message-ID: <77CBB328-8BBE-4884-9EF4-F91163F84215@oracle.com> Hi Shilpi, note this is not a *R*eview, but thumbs up, and I'll be happy to sponsor the push once a *R*eviewer agrees. Best, Michael > Am 22.03.2016 um 12:41 schrieb shilpi.rastogi at oracle.com: > > Hi All, > > Please review the following- > > https://bugs.openjdk.java.net/browse/JDK-8150829 > http://cr.openjdk.java.net/~srastogi/8150829/webrev.04 > > > Thanks, > Shilpi -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From forax at univ-mlv.fr Wed Apr 6 10:10:03 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Wed, 6 Apr 2016 12:10:03 +0200 (CEST) Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> Message-ID: <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Paul Sandoz" > Cc: "core-libs-dev Libs" > Envoy?: Mercredi 6 Avril 2016 09:37:00 > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe > > > > On 5 Apr 2016, at 17:15, Claes Redestad wrote: > > > > On 04/04/2016 05:45 PM, Martin Buchholz wrote: > >>> I think this one is going too far. > >>> > >>> A*FU/VarHandles should are supposed to act like a go-to replacement for > >>> Unsafe throughout the class library, and we want to shrink the Unsafe > >>> exposure. Also, I don't think removing A*FU in favor of Unsafe here wins > >>> us anything: there should be no throughput hit, and we *will* load A*FU > >>> down the road anyway, negating the startup wins. > > +1 i would leave this one as is. > > In general same goes for the @Stable/ForceInline annotations etc. We should > use this stuff carefully within java.base and also sparingly to qualifying > JDK modules. While i fully agree in the general case, in disagree for this specific case, there are few uses of ARFU inside the JDK (or outside) but currently because BufferedInputStream uses an ARFU, each time someone starts a Java application, the VM loads ARFU and its implementation with a high probability to no need it at all after ARFU are not a replacement of Unsafe, VarHandles are. So adding a new usage of Unsafe for a good reason goes in the right direction here, when VarHandle will replace usages of Unsafe, the code of BufferedInputStream will be refactored again. > > >>> > >>> -Aleksey > >> It is surprising to see new uses of Unsafe when we have an ongoing > >> initiative within openjdk (especially from Paul Sandoz) to remove most > >> uses. Varhandles are coming and are expected to replace uses of > >> Unsafe in the JDK. > > > > This is just a very minor win on hello world/-version style tests, so I'm > > happy to withdraw this if other early usages, such as CHM, is moving to > > VarHandles anyhow. > > > > OTOH using dangerous, internal APIs like this rather than nice, public APIs > > early in the VM bootstrap has other merits, such as not unintentionally > > causing bootstrap issues. Say, I don't know if VarHandles have any > > dependencies on java.lang.invoke currently? > > It does, but was designed to be minimize bootstrap issues and class spinning > so there are less dependencies than MHs. > > CHM is a tricky class because MethodType uses CHM and VHs uses MethodType. > There is probably a way of switching from a less concurrent concurrent map > to CHM at ?safe-point? when the VM transitions to booted. To be > investigated... another solution is perhaps to not use a concurrent hashmap in MethodType, method types need to be interned only the first time a method handle is invoked with an invokeExact/invoke (but not by invokedynamic) so instead of interning all method types which artificially put pressure on the interning map to be lock free, interning only the method type when need it may allow to not use a CHM in MethodType. > > Paul. > R?mi From paul.sandoz at oracle.com Wed Apr 6 10:37:50 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 6 Apr 2016 12:37:50 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> Message-ID: > On 6 Apr 2016, at 12:10, Remi Forax wrote: > > ----- Mail original ----- >> De: "Paul Sandoz" >> Cc: "core-libs-dev Libs" >> Envoy?: Mercredi 6 Avril 2016 09:37:00 >> Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe >> >> >>> On 5 Apr 2016, at 17:15, Claes Redestad wrote: >>> >>> On 04/04/2016 05:45 PM, Martin Buchholz wrote: >>>>> I think this one is going too far. >>>>> >>>>> A*FU/VarHandles should are supposed to act like a go-to replacement for >>>>> Unsafe throughout the class library, and we want to shrink the Unsafe >>>>> exposure. Also, I don't think removing A*FU in favor of Unsafe here wins >>>>> us anything: there should be no throughput hit, and we *will* load A*FU >>>>> down the road anyway, negating the startup wins. >> >> +1 i would leave this one as is. >> >> In general same goes for the @Stable/ForceInline annotations etc. We should >> use this stuff carefully within java.base and also sparingly to qualifying >> JDK modules. > > While i fully agree in the general case, in disagree for this specific case, > there are few uses of ARFU inside the JDK (or outside) but currently because BufferedInputStream uses an ARFU, each time someone starts a Java application, the VM loads ARFU and its implementation with a high probability to no need it at all after > Does that really contribute sufficiently to slow down in start time? It really seems like a micro-optimisation. > ARFU are not a replacement of Unsafe, VarHandles are. So adding a new usage of Unsafe for a good reason goes in the right direction here, > when VarHandle will replace usages of Unsafe, the code of BufferedInputStream will be refactored again. > My preference is not to change it if it?s gonna change later on. >> >>>>> >>>>> -Aleksey >>>> It is surprising to see new uses of Unsafe when we have an ongoing >>>> initiative within openjdk (especially from Paul Sandoz) to remove most >>>> uses. Varhandles are coming and are expected to replace uses of >>>> Unsafe in the JDK. >>> >>> This is just a very minor win on hello world/-version style tests, so I'm >>> happy to withdraw this if other early usages, such as CHM, is moving to >>> VarHandles anyhow. >>> >>> OTOH using dangerous, internal APIs like this rather than nice, public APIs >>> early in the VM bootstrap has other merits, such as not unintentionally >>> causing bootstrap issues. Say, I don't know if VarHandles have any >>> dependencies on java.lang.invoke currently? >> >> It does, but was designed to be minimize bootstrap issues and class spinning >> so there are less dependencies than MHs. >> >> CHM is a tricky class because MethodType uses CHM and VHs uses MethodType. >> There is probably a way of switching from a less concurrent concurrent map >> to CHM at ?safe-point? when the VM transitions to booted. To be >> investigated... > > another solution is perhaps to not use a concurrent hashmap in MethodType, method types need to be interned only the first time a method handle is invoked with an invokeExact/invoke (but not by invokedynamic) so instead of interning all method types which artificially put pressure on the interning map to be lock free, interning only the method type when need it may allow to not use a CHM in MethodType. > I need to re-familiarise myself with the code to see what is possible here. MethodType also comes with a shared erased form which also caches LambdaForms for various kinds. It?s not clear to me if this can be easily be teased apart. Paul. From paul.sandoz at oracle.com Wed Apr 6 11:10:38 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 6 Apr 2016 13:10:38 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> References: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> Message-ID: Hi Steve, My feeling is it?s too premature to introduce a general Memory (region) allocation interface at this moment. What is currently specified can be supported using: IntFunction But i don?t wanna discourage you! this thread has raised some interesting points. Project Panama is gonna take a swing at defining a more general notion of a memory region and the Arrays 2.0 work should support indexes greater than Integer.MAX_VALUE. In this respect I think we should hold off doing anything premature for Java 9 (feature freeze is getting closer), and i encourage you to participate on the Panama lists. ? Here is some context some of which you probably know and some which you might not: - ByteBuffer constructors are deliberately package scoped, as there are some intricate dependencies between the implementations and we want control over who can implement. Any new form of allocation will require changes here (package scoped or otherwise). - current ByteBuffer implementations are either backed by a byte[] (managed or non-direct) or an off-heap allocated (direct) region. At the moment access to both those regions go through separate code paths, but they could be unified using the Unsafe double addressing mode, which should greatly simplify the implementations. I have started making some small steps towards that (JDK-8149469 and JDK-8151163). Even these small steps require careful analysis to evaluate performance across multiple platforms. - VarHandles leverages the Unsafe double addressing mode to support enhanced atomic access to heap or direct ByteBuffers [1], thus the same code is used in both kinds of buffer. ? I am not sure what plans you have for buffer implementations themselves. How do you propose to allocate a ByteBuffer instance that covers a region of 3D XPoint memory? Would it be similar to that of direct buffers, e.g. a variation of DirectByteBuffer, but with different factory constructor code to allocate the memory region within the XPoint memory system and assign the buffer base address to the start of that allocated region? Thanks, Paul. [1] http://cr.openjdk.java.net/~psandoz/jdk9/varhandles/specdiff/java/lang/invoke/MethodHandles-report.html#method:byteBufferViewVarHandle(java.lang.Class, boolean) > On 6 Apr 2016, at 03:49, Dohrmann, Steve wrote: > > Re: JDK-8153111 > > > Hi, > > Below are responses to some of the points brought up in the discussion as well as is a little expansion of the reasoning that went into the proposed API. > > One motivation we saw for doing anything beyond a concrete ByteBuffer class was application code (e.g. Cassandra) that allocates many off-heap ByteBuffers using ByteBuffer#allocateDirect. We reasoned that if the allocation of ByteBuffers could be done using a common memory interface then only the code that provisioned instances of the the memory spaces would have to change in order to switch or mix memory types. > > We did think of overloading the ByteBuffer#allocateDirect method with memory space info and avoid an allocation interface. We ended up with a separate user called interface scheme because we imagined that extensions of the memory interface would enable new memory functionality that required new methods (e.g. memory transactions for persistence). Without a separate callable interface, the static method space in ByteBuffer might have to change again. > > For any API In general we saw the need for two things 1) something to represent a memory space from which objects are allocated (a Memory instance) and 2) a broadly usable familiar "anchor" type as the common data object (java.nio.ByteBuffer). > > The two points for extension with the current proposal are: 1) Constructors on Memory implementation classes -- allow implementors the ability to offer features on the memory space itself (e.g. partitioning, size limits) and 2) future extensions on the Memory interface -- for example PersistentMemory. > > Regarding a more elaborate scheme for memory space creation -- we did consider a factory scheme for memory object allocation but could not get comfortable with either a) standardized method signatures suitable for various kinds of memory or b) the complexity that something like a general-purpose "spec" format would add, even if we could come up with it. Direct construction does expose more to the user but it seems sufficient and might be the best given what we can say about the future of heterogeneous memory at this point. > > Regarding the suggested addition of keyed access to ByteBuffers, we are assuming this is only proposed to enable sharing? We thought it might take a while to properly explore the details (i.e. semantics / thread safety / predicable performance) of sharing such that it would work well and maybe even extend well to things like process-shared and cluster-shared ByteBuffers. We elected to propose nothing for JDK 9 beyond what developers can already do with schemes based on e.g. ByteBuffer#duplicate. We were thinking shared buffers could appear later, possibly as an extension of the Memory interface. The keyed access scheme is simple and appealing, however. One question: how is the request method's size parameter to be interpreted? > > The suggestion of parameterizing the Memory interface bounded by ByteBuffers seems useful as it gives a clean way to support extended ByteBuffers. Not sure if the change of the allocation method name from #allocateByteBuffer to #allocate was incidental or not? > > Alternates to the "Memory" interface name might be preferred, BufferSupplier is certainly reasonable. We imagined instances that name different memory spaces (e.g. OffHeapRAM) for allocation rather that the role played -- thinking the role is explicit in the allocation method name (allocateByteBuffer). > > Regarding changing the allocation size parameter to a long, this would be very nice to have. We avoided it in order to match the existing ByteBuffer API. If 64-bit ByteBuffers are planned, sticking with int sizes might have been the wrong call. > > We are still coming up to speed on VarHandles (JEP 193), atomics for ByteBuffers (JDK-8008240), and ByteBuffer consistency (JDK-6476827). > > We hope there is continued interest in this proposal and happy to provide a modified patch. > > Best regards, > Steve Dohrmann > From forax at univ-mlv.fr Wed Apr 6 11:40:58 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Wed, 6 Apr 2016 13:40:58 +0200 (CEST) Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> Message-ID: <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Paul Sandoz" > Cc: "core-libs-dev Libs" > Envoy?: Mercredi 6 Avril 2016 12:37:50 > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe > > > > On 6 Apr 2016, at 12:10, Remi Forax wrote: > > > > ----- Mail original ----- > >> De: "Paul Sandoz" > >> Cc: "core-libs-dev Libs" > >> Envoy?: Mercredi 6 Avril 2016 09:37:00 > >> Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of > >> AtomicReferenceFieldUpdater with Unsafe > >> > >> > >>> On 5 Apr 2016, at 17:15, Claes Redestad > >>> wrote: > >>> > >>> On 04/04/2016 05:45 PM, Martin Buchholz wrote: > >>>>> I think this one is going too far. > >>>>> > >>>>> A*FU/VarHandles should are supposed to act like a go-to replacement for > >>>>> Unsafe throughout the class library, and we want to shrink the Unsafe > >>>>> exposure. Also, I don't think removing A*FU in favor of Unsafe here > >>>>> wins > >>>>> us anything: there should be no throughput hit, and we *will* load A*FU > >>>>> down the road anyway, negating the startup wins. > >> > >> +1 i would leave this one as is. > >> > >> In general same goes for the @Stable/ForceInline annotations etc. We > >> should > >> use this stuff carefully within java.base and also sparingly to qualifying > >> JDK modules. > > > > While i fully agree in the general case, in disagree for this specific > > case, > > there are few uses of ARFU inside the JDK (or outside) but currently > > because BufferedInputStream uses an ARFU, each time someone starts a Java > > application, the VM loads ARFU and its implementation with a high > > probability to no need it at all after > > > > Does that really contribute sufficiently to slow down in start time? It > really seems like a micro-optimisation. small streams become big rivers (i don't know the idiomatic sentence in English, so it's a rough translation from a French idiom), currently the main problem is that the loading of modules adds so much overhead to the startup time that you see nothing :( Also, startup time is one aspect, size of the VM data structures at runtime, size of the CDS archive* are also impacted. > > > > ARFU are not a replacement of Unsafe, VarHandles are. So adding a new usage > > of Unsafe for a good reason goes in the right direction here, > > when VarHandle will replace usages of Unsafe, the code of > > BufferedInputStream will be refactored again. > > > > My preference is not to change it if it?s gonna change later on. but there is also a good chance to miss that change later because you will look for usages of Unsafe and not usages of ARFU. Replacing ARFU by Unsafe in BufferedInputStream makes the code more similar to the other usages of Unsafe in the JDK. [...] > > Paul. > R?mi * removing classes from a CDS archive is important for 32 bits windows VM R?mi From paul.sandoz at oracle.com Wed Apr 6 12:54:54 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 6 Apr 2016 14:54:54 +0200 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: References: Message-ID: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> Hi Martin, miscellaneous ? You reverted Aleksey?s change s/putOrderedObject/putObjectRelease. The *Ordered* methods are now removed from the ?real? jdk.internal.misc.Unsafe. Paul. > On 3 Apr 2016, at 20:29, Martin Buchholz wrote: > > Easy changes to review, up to April Fools day, in part to make room > for later unfinished more exciting changes. > > http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ From vitalyd at gmail.com Wed Apr 6 13:04:39 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Wed, 6 Apr 2016 09:04:39 -0400 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> References: <57006917.4090200@oracle.com> <614728155.1438453.1459684620433.JavaMail.zimbra@u-pem.fr> <57010A68.9050307@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> Message-ID: On Wednesday, April 6, 2016, Remi Forax wrote: > ----- Mail original ----- > > De: "Paul Sandoz" > > > Cc: "core-libs-dev Libs" > > > Envoy?: Mercredi 6 Avril 2016 12:37:50 > > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of > AtomicReferenceFieldUpdater with Unsafe > > > > > > > On 6 Apr 2016, at 12:10, Remi Forax > > wrote: > > > > > > ----- Mail original ----- > > >> De: "Paul Sandoz" > > > >> Cc: "core-libs-dev Libs" > > > >> Envoy?: Mercredi 6 Avril 2016 09:37:00 > > >> Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of > > >> AtomicReferenceFieldUpdater with Unsafe > > >> > > >> > > >>> On 5 Apr 2016, at 17:15, Claes Redestad > > > >>> wrote: > > >>> > > >>> On 04/04/2016 05:45 PM, Martin Buchholz wrote: > > >>>>> I think this one is going too far. > > >>>>> > > >>>>> A*FU/VarHandles should are supposed to act like a go-to > replacement for > > >>>>> Unsafe throughout the class library, and we want to shrink the > Unsafe > > >>>>> exposure. Also, I don't think removing A*FU in favor of Unsafe here > > >>>>> wins > > >>>>> us anything: there should be no throughput hit, and we *will* load > A*FU > > >>>>> down the road anyway, negating the startup wins. > > >> > > >> +1 i would leave this one as is. > > >> > > >> In general same goes for the @Stable/ForceInline annotations etc. We > > >> should > > >> use this stuff carefully within java.base and also sparingly to > qualifying > > >> JDK modules. > > > > > > While i fully agree in the general case, in disagree for this specific > > > case, > > > there are few uses of ARFU inside the JDK (or outside) but currently > > > because BufferedInputStream uses an ARFU, each time someone starts a > Java > > > application, the VM loads ARFU and its implementation with a high > > > probability to no need it at all after > > > > > > > Does that really contribute sufficiently to slow down in start time? It > > really seems like a micro-optimisation. > > small streams become big rivers (i don't know the idiomatic sentence in > English, so it's a rough translation from a French idiom), "Death by a thousand cuts" is one of my favorites :). A "flat profile" is another description of a similar thing. In general, I agree that easy/cheap/maintainable/etc wins should be done even if individually they don't matter much (if that were the requirement, there would be no progress whatsoever). In this case, using Unsafe for now seems trivial; when VH is ready, someone is going to sweep the code anyway and this will be just one more place to mechanically update. Is VH definitely going to be part of Java 9? If so, then perhaps no point in making this change unless it's going to be backported to Java 8. currently the main problem is that the loading of modules adds so much > overhead to the startup time that you see nothing :( > > Also, startup time is one aspect, size of the VM data structures at > runtime, size of the CDS archive* are also impacted. > > > > > > > > ARFU are not a replacement of Unsafe, VarHandles are. So adding a new > usage > > > of Unsafe for a good reason goes in the right direction here, > > > when VarHandle will replace usages of Unsafe, the code of > > > BufferedInputStream will be refactored again. > > > > > > > My preference is not to change it if it?s gonna change later on. > > but there is also a good chance to miss that change later because you will > look for usages of Unsafe and not usages of ARFU. > Replacing ARFU by Unsafe in BufferedInputStream makes the code more > similar to the other usages of Unsafe in the JDK. > > [...] > > > > > Paul. > > > > R?mi > > * removing classes from a CDS archive is important for 32 bits windows VM > > R?mi > -- Sent from my phone From kumar.x.srinivasan at oracle.com Wed Apr 6 13:09:41 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 06 Apr 2016 06:09:41 -0700 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <5704CB3A.8080004@oracle.com> References: <57040183.3010300@oracle.com> <57040336.9020703@oracle.com> <570486E6.2030405@oracle.com> <5704CB3A.8080004@oracle.com> Message-ID: <57050A95.4040801@oracle.com> Alan, Thanks for the review. Please see inline comments. >> > Creating a zip file from the classes in the jrt file system make > sense, and should be fast. > > A few comments on Utils.JrtToZip: > > - the URI creation in the run() method isn't reliable, could you use > this instead: > URI uri = URI.create("jar:" + outFile.toURI()); Ok > > - In the toZipFs method then I assume you should use > URI.create("jrt:/"), best to stay away from URL. Ok > > - Is Files.createDirectories needed? The walk is specified to be depth > first so you'll also visit parent directories first. Yes, zipfs does not allow me to create the file without creating the enclosing directory first, so if I were to do this in visitFile, then presumably I would have to add a check, to prevent duplicate creation going into the provider, only to find a directory already exists and return, not sure if this is what you want, because preVisitDirectory does this conveniently. > > - I'm also curious about the REPLACE_EXISTING as I assume that isn't > needed. Oh! while I was developing in NB as a discrete/stand alone project, I was reusing the same zip/jar output file, will leave it as-is, no harm, right ?. > > A minor comment is that "root" rather than "p" would be nicer for the > root directory. Personally I would avoid the really long lines as it > makes future side-by-side reviews harder. Also throws Exception seems > too broad but it's test code so not a big deal. Ok Thanks Kumar > > -Alan. From Alan.Bateman at oracle.com Wed Apr 6 13:21:18 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Apr 2016 14:21:18 +0100 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <57050A95.4040801@oracle.com> References: <57040183.3010300@oracle.com> <57040336.9020703@oracle.com> <570486E6.2030405@oracle.com> <5704CB3A.8080004@oracle.com> <57050A95.4040801@oracle.com> Message-ID: <57050D4E.30807@oracle.com> On 06/04/2016 14:09, Kumar Srinivasan wrote: > >> >> - Is Files.createDirectories needed? The walk is specified to be >> depth first so you'll also visit parent directories first. > > Yes, zipfs does not allow me to create the file without creating the > enclosing directory > first, so if I were to do this in visitFile, then presumably I would > have to add a > check, to prevent duplicate creation going into the provider, only to > find a > directory already exists and return, not sure if this is what you > want, because > preVisitDirectory does this conveniently. I should have been clearer, I was trying to say that createDirectory should be sufficient here because the walk is specified to be depth first. > >> >> - I'm also curious about the REPLACE_EXISTING as I assume that isn't >> needed. > > Oh! while I was developing in NB as a discrete/stand alone project, I > was reusing the > same zip/jar output file, will leave it as-is, no harm, right ?. No harm, it just caught my eye as not needed. -Alan From forax at univ-mlv.fr Wed Apr 6 13:28:47 2016 From: forax at univ-mlv.fr (forax at univ-mlv.fr) Date: Wed, 6 Apr 2016 15:28:47 +0200 (CEST) Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> Message-ID: <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Vitaly Davidovich" > ?: "Remi Forax" > Cc: "Paul Sandoz" , "core-libs-dev Libs" > > Envoy?: Mercredi 6 Avril 2016 15:04:39 > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of > AtomicReferenceFieldUpdater with Unsafe > On Wednesday, April 6, 2016, Remi Forax < forax at univ-mlv.fr > wrote: > > ----- Mail original ----- > > > > De: "Paul Sandoz" < paul.sandoz at oracle.com > > > > > Cc: "core-libs-dev Libs" < core-libs-dev at openjdk.java.net > > > > > Envoy?: Mercredi 6 Avril 2016 12:37:50 > > > > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of > > > AtomicReferenceFieldUpdater with Unsafe > > > > > > > > > > > > > On 6 Apr 2016, at 12:10, Remi Forax < forax at univ-mlv.fr > wrote: > [...] > > > > While i fully agree in the general case, in disagree for this specific > > > > > case, > > > > > there are few uses of ARFU inside the JDK (or outside) but currently > > > > > because BufferedInputStream uses an ARFU, each time someone starts a > > > > Java > > > > > application, the VM loads ARFU and its implementation with a high > > > > > probability to no need it at all after > > > > > > > > > > > > > Does that really contribute sufficiently to slow down in start time? It > > > > really seems like a micro-optimisation. > > > small streams become big rivers (i don't know the idiomatic sentence in > > English, so it's a rough translation from a French idiom), > > "Death by a thousand cuts" is one of my favorites :). A "flat profile" is > another description of a similar thing. > In general, I agree that easy/cheap/maintainable/etc wins should be done even > if individually they don't matter much (if that were the requirement, there > would be no progress whatsoever). > In this case, using Unsafe for now seems trivial; when VH is ready, someone > is going to sweep the code anyway and this will be just one more place to > mechanically update. Is VH definitely going to be part of Java 9? If so, > then perhaps no point in making this change unless it's going to be > backported to Java 8. Also don't forget that releasing VarHandle API as a public API for 9 is vastly different from replacing all usages of Unsafe by some VarHandle methods inside the JDK, see Paul's answser about the bootstrap issues. R?mi From Roger.Riggs at Oracle.com Wed Apr 6 13:53:05 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 6 Apr 2016 09:53:05 -0400 Subject: RFR: JDK-8149925 We don't need jdk.internal.ref.Cleaner any more In-Reply-To: <5704B01F.4070406@gmail.com> References: <56B72242.7050102@gmail.com> <56C43817.7060805@gmail.com> <7BA56B2F-C1C6-4EAF-B900-A825C6B602EF@oracle.com> <56CA080F.6010308@gmail.com> <56CB83FF.4010808@Oracle.com> <56CC8A4A.9080303@gmail.com> <56CEAC28.80802@gmail.com> <56CEB49A.4090000@oracle.com> <56CEC6A5.3070202@gmail.com> <56D0C5F5.7060509@Oracle.com> <56DC29DE.4040006@gmail.com> <059F3798-66D4-4300-B618-09868A04E3DC@oracle.com> <56E09299.2050900@gmail.com> <56ED5B! 7A.3090809@gmail.com> <8EDD817B-F124-4613-9EEE-7865EE67037D@oracle.com> <56F96778.5020202@gmail.com> <56FE914E.2070804@gmail.com> <56FE9D14.8010404@gmail.com> <56FEA5FF.4060801@gmail.com> <56FEED59.7090906@Oracle.com> <56FF04B5.2030507@oracle.com> <56FFABED.2060708@gmail.com> <5702E18D.7010807@Oracle.com> <5703CE96.4040001@gmail.com> <5704B01F.4070406@gmail.com> Message-ID: <570514C1.5000507@Oracle.com> Hi Peter, Since the current implementation of the old Cleaner and DirectByteBuffer works well and there is a lot of work piling up against the FC date, I'm in favor of keeping it as it is until the possibilities with Panama settle out. It would best if reclamation was not GC based, except as a last resort. As for the Cleaner API, it is intended to have a specific function and API. It may be that there is some advantage/optimization in the cleaner implementation at some future point but the API for general use should be concrete and specific. For more specific purposes, especially internal ones like the topic here, separate factory methods would be more appropriate than potential overloading and mix-in interfaces. Roger On 4/6/2016 2:43 AM, Peter Levart wrote: > Hi Roger, > > On 04/05/2016 04:41 PM, Peter Levart wrote: >>> On 04/04/2016 11:50 PM, Roger Riggs wrote: >>> I don't see the need to change Cleaner to an interface to be able to >>> provide >>> an additional method on CleanerImpl or a subclass and a factory >>> method could >>> provide for a clean and very targeted interface to Bits/Direct buffer. >> >> I would like this to be an instance method so it would naturally >> pertain to a particular Cleaner instance. Or it could be a static >> method that takes a Cleaner instance. One of my previous webrevs did >> have such method on the CleanerImpl, but I was advised to move it to >> Cleaner as a package-private method and expose it via SharedSecrets >> to internal code. I feel such "camouflage" is very awkward now that >> we have modules and other mechanisms exist. So I thought it would be >> most elegant to make Cleaner an interface so it can be extended with >> an internal interface to communicate intent in a type-safe and >> auto-discoverable way. The change to make it interface: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/removeInternalCleaner/webrev.part2.1.rev01/ >> >> >> ...actually simplifies implementation (33 lines removed in total) and >> could be seen as an improvement in itself. >> >> Are you afraid that if Cleaner was an interface, others would attempt >> to make implementations of it? Now that we have default methods on >> interfaces it is easy to compatibly extend the API even if it is an >> interface so that no 3rd party implementations are immediately >> broken. Are you thinking of security implications when some code is >> handed a Cleaner instance that it doesn't trust? I don't think there >> is a utility for Cleaner instances to be passed from untrusted to >> trusted code, do you? > > ...even if we don't do anything for DirectByteBuffer(s) in > java.lang.ref.Cleaner and leave things as they stand (using > jdk.internal.ref.Cleaner), I would still make this transition to > interface to enable possible future internal extensions to > java.lang.ref.Cleaner. As I said, this is a source compatible change, > but not binary compatible, so if we do it, it must be performed before > JDK 9 ships. > > Regards, Peter > From paul.sandoz at oracle.com Wed Apr 6 14:09:14 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 6 Apr 2016 16:09:14 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> Message-ID: > On 6 Apr 2016, at 15:28, forax at univ-mlv.fr wrote: > > > > While i fully agree in the general case, in disagree for this specific > > > case, > > > there are few uses of ARFU inside the JDK (or outside) but currently > > > because BufferedInputStream uses an ARFU, each time someone starts a Java > > > application, the VM loads ARFU and its implementation with a high > > > probability to no need it at all after > > > > > > > Does that really contribute sufficiently to slow down in start time? It > > really seems like a micro-optimisation. > > small streams become big rivers (i don't know the idiomatic sentence in English, so it's a rough translation from a French idiom), > "Death by a thousand cuts" is one of my favorites :). A "flat profile" is another description of a similar thing. > I still remain unconvinced in this case that such changes warrant an increase in unsafe usage (temporary or otherwise). > In general, I agree that easy/cheap/maintainable/etc wins should be done even if individually they don't matter much (if that were the requirement, there would be no progress whatsoever). > > In this case, using Unsafe for now seems trivial; when VH is ready, someone is going to sweep the code anyway and this will be just one more place to mechanically update. Is VH definitely going to be part of Java 9? If so, then perhaps no point in making this change unless it's going to be backported to Java 8. > > Also don't forget that releasing VarHandle API as a public API for 9 is vastly different from replacing all usages of Unsafe by some VarHandle methods inside the JDK, see Paul's answser about the bootstrap issues. > VHs are now in jdk9/dev. I dunno when it will rise up to the master and the next EA build. Paul. From kumar.x.srinivasan at oracle.com Wed Apr 6 14:20:25 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 06 Apr 2016 07:20:25 -0700 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <57050D4E.30807@oracle.com> References: <57040183.3010300@oracle.com> <57040336.9020703@oracle.com> <570486E6.2030405@oracle.com> <5704CB3A.8080004@oracle.com> <57050A95.4040801@oracle.com> <57050D4E.30807@oracle.com> Message-ID: <57051B29.2030408@oracle.com> Alan, http://cr.openjdk.java.net/~ksrini/8152622/webrev.02/ I made the changes as you suggested below, I have retained Files.createDirectories, here is why, changing it to createDirectory will throw FileAlreadyExistsException, which means, that if the output zip/jar file exists then an exception handler is required to ignore it. I don't think its worth the trouble. Thanks Kumar > > > On 06/04/2016 14:09, Kumar Srinivasan wrote: >> >>> >>> - Is Files.createDirectories needed? The walk is specified to be >>> depth first so you'll also visit parent directories first. >> >> Yes, zipfs does not allow me to create the file without creating the >> enclosing directory >> first, so if I were to do this in visitFile, then presumably I would >> have to add a >> check, to prevent duplicate creation going into the provider, only to >> find a >> directory already exists and return, not sure if this is what you >> want, because >> preVisitDirectory does this conveniently. > I should have been clearer, I was trying to say that createDirectory > should be sufficient here because the walk is specified to be depth > first. > >> >>> >>> - I'm also curious about the REPLACE_EXISTING as I assume that isn't >>> needed. >> >> Oh! while I was developing in NB as a discrete/stand alone project, I >> was reusing the >> same zip/jar output file, will leave it as-is, no harm, right ?. > No harm, it just caught my eye as not needed. > > -Alan From Alan.Bateman at oracle.com Wed Apr 6 14:38:11 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Apr 2016 15:38:11 +0100 Subject: RFR: JDK-8152622: tools/pack200/Pack200Props.java timed out In-Reply-To: <57051B29.2030408@oracle.com> References: <57040183.3010300@oracle.com> <57040336.9020703@oracle.com> <570486E6.2030405@oracle.com> <5704CB3A.8080004@oracle.com> <57050A95.4040801@oracle.com> <57050D4E.30807@oracle.com> <57051B29.2030408@oracle.com> Message-ID: <57051F53.70008@oracle.com> On 06/04/2016 15:20, Kumar Srinivasan wrote: > Alan, > > http://cr.openjdk.java.net/~ksrini/8152622/webrev.02/ > > I made the changes as you suggested below, I have retained > Files.createDirectories, > here is why, changing it to createDirectory will throw > FileAlreadyExistsException, > which means, that if the output zip/jar file exists then an exception > handler is > required to ignore it. I don't think its worth the trouble. Okay, although each directory is only visited once so I don't immediately see how the FileAlreadyExistsException arises, unless this related to sym links in the jrt file system. In any case, the updated changes looking fine. I think I would still reduce some of the really long lines to make it easier for reviewers in the future. -Alan From claes.redestad at oracle.com Wed Apr 6 14:45:52 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Wed, 6 Apr 2016 16:45:52 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> Message-ID: <57052120.5010609@oracle.com> On 04/06/2016 04:09 PM, Paul Sandoz wrote: >> small streams become big rivers (i don't know the idiomatic sentence in English, so it's a rough translation from a French idiom), >> "Death by a thousand cuts" is one of my favorites:). A "flat profile" is another description of a similar thing. >> > I still remain unconvinced in this case that such changes warrant an increase in unsafe usage (temporary or otherwise). > I did not intend for this patch to spark any controversy - in my mind it was just a rather straightforward and easy way to save a few Kbs (and some theoretic startup time) on small program startup and I'm happy to withdraw it based on the feedback. I do however think that reducing the dependency graph of things which are loaded in this early has merits on its own, regardless of how much it actually improves things. Using VHs here - or even in CHM - seems more controversial to me than using Unsafe to take shortcuts in low-level class libraries that need to boot fast and with as few dependencies as possible (since that allows them to be used in more places). Thanks! /Claes From forax at univ-mlv.fr Wed Apr 6 14:46:25 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Wed, 6 Apr 2016 16:46:25 +0200 (CEST) Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> Message-ID: <1225605745.1953390.1459953985317.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Paul Sandoz" > Cc: "core-libs-dev Libs" > Envoy?: Mercredi 6 Avril 2016 16:09:14 > Objet: Re: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe > > > > On 6 Apr 2016, at 15:28, forax at univ-mlv.fr wrote: > > > > > > While i fully agree in the general case, in disagree for this specific > > > > case, > > > > there are few uses of ARFU inside the JDK (or outside) but currently > > > > because BufferedInputStream uses an ARFU, each time someone starts a > > > > Java > > > > application, the VM loads ARFU and its implementation with a high > > > > probability to no need it at all after > > > > > > > > > > Does that really contribute sufficiently to slow down in start time? It > > > really seems like a micro-optimisation. > > > > small streams become big rivers (i don't know the idiomatic sentence in > > English, so it's a rough translation from a French idiom), > > "Death by a thousand cuts" is one of my favorites :). A "flat profile" is > > another description of a similar thing. > > > I still remain unconvinced in this case that such changes warrant an increase > in unsafe usage (temporary or otherwise). Ok, you win :) > > > In general, I agree that easy/cheap/maintainable/etc wins should be done > > even if individually they don't matter much (if that were the requirement, > > there would be no progress whatsoever). > > > > In this case, using Unsafe for now seems trivial; when VH is ready, someone > > is going to sweep the code anyway and this will be just one more place to > > mechanically update. Is VH definitely going to be part of Java 9? If so, > > then perhaps no point in making this change unless it's going to be > > backported to Java 8. > > > > Also don't forget that releasing VarHandle API as a public API for 9 is > > vastly different from replacing all usages of Unsafe by some VarHandle > > methods inside the JDK, see Paul's answser about the bootstrap issues. > > > > VHs are now in jdk9/dev. I dunno when it will rise up to the master and the > next EA build. Oh, i didn't notice. congrat ! > > Paul. > R?mi From vitalyd at gmail.com Wed Apr 6 14:52:31 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Wed, 6 Apr 2016 10:52:31 -0400 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> Message-ID: So are there any bootstrap issues with VH that would preclude using it in BufferedInputStream? Is that even known at this point? You mentioned that VH was designed to minimize bootstrapping issues, but where's the "minimized" line drawn? On Wed, Apr 6, 2016 at 10:09 AM, Paul Sandoz wrote: > > > On 6 Apr 2016, at 15:28, forax at univ-mlv.fr wrote: > > > > > > While i fully agree in the general case, in disagree for this > specific > > > > case, > > > > there are few uses of ARFU inside the JDK (or outside) but currently > > > > because BufferedInputStream uses an ARFU, each time someone starts a > Java > > > > application, the VM loads ARFU and its implementation with a high > > > > probability to no need it at all after > > > > > > > > > > Does that really contribute sufficiently to slow down in start time? It > > > really seems like a micro-optimisation. > > > > small streams become big rivers (i don't know the idiomatic sentence in > English, so it's a rough translation from a French idiom), > > "Death by a thousand cuts" is one of my favorites :). A "flat profile" > is another description of a similar thing. > > > I still remain unconvinced in this case that such changes warrant an > increase in unsafe usage (temporary or otherwise). > > > In general, I agree that easy/cheap/maintainable/etc wins should be done > even if individually they don't matter much (if that were the requirement, > there would be no progress whatsoever). > > > > In this case, using Unsafe for now seems trivial; when VH is ready, > someone is going to sweep the code anyway and this will be just one more > place to mechanically update. Is VH definitely going to be part of Java 9? > If so, then perhaps no point in making this change unless it's going to be > backported to Java 8. > > > > Also don't forget that releasing VarHandle API as a public API for 9 is > vastly different from replacing all usages of Unsafe by some VarHandle > methods inside the JDK, see Paul's answser about the bootstrap issues. > > > > VHs are now in jdk9/dev. I dunno when it will rise up to the master and > the next EA build. > > Paul. > From paul.sandoz at oracle.com Wed Apr 6 15:48:53 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 6 Apr 2016 17:48:53 +0200 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: References: <755756441.20160401222505@gmail.com> Message-ID: <9DA064B7-FB87-46D7-931E-D738C912AFD9@oracle.com> > On 4 Apr 2016, at 21:28, Stefan Zobel wrote: > > Hi Tagir, > > good catch! I like the proposal. > Me too. +1. Extra bonus points to test, in addition to the tested characteristics, that the boxed/converted elements remain sorted/distinct :-) >> >> (different longs can be converted into the same double, so DISTINCT is >> not preserved here; not sure whether this is possible for ints) >> > > I think IntStream.asDoubleStream() can also preserve DISTINCT as > different ints can't be mapped to the same double. > Yes, there are 53 bits to play with, which is more than enough to exactly represent the full range of int values. Paul. > > Math.ulp((double) Integer.MIN_VALUE) ~ 4.7E-7 > > in contrast to > > Math.ulp((double) Long.MIN_VALUE) = 2048.0 > > > So there are more than enough doubles in the vicinity of large int > values. It's only when ulp get's >= 1.0 that distinct integral values > need to be mapped to the same double (that happens between 1.0E15 and > 1.0E16 for longs). Please anyone correct me if I'm wrong. > > > Regards, > Stefan > From alejandro.murillo at oracle.com Wed Apr 6 16:48:32 2016 From: alejandro.murillo at oracle.com (Alejandro Murillo) Date: Wed, 6 Apr 2016 10:48:32 -0600 Subject: [9] RFR JDK-8153564: Add java/nio/Buffer/BasicByte.java to exclude list until JDK-8153563 is fixed In-Reply-To: <5704BC96.1060303@oracle.com> References: <57049B18.5050307@oracle.com> <5704BC96.1060303@oracle.com> Message-ID: <57053DE0.6080001@oracle.com> It was late for me, so Amy took over and fixed it Thanks Alejandro On 4/6/2016 1:36 AM, Alan Bateman wrote: > > > On 06/04/2016 06:14, Alejandro Murillo wrote: >> >> I'd like to push the changeset below to exclude >> java/nio/Buffer/BasicByte.java >> It started failing after the hotspot snapshot was pushed to jdk9/dev >> tonight. >> https://bugs.openjdk.java.net/browse/JDK-8153563 has been filed for >> that failure. > > Would it be possible to add @modules java.base/jdk.internal.misc, as > below, and not exclude these tests? > > -Alan > > > $ hg diff -g . > diff --git a/test/java/nio/Buffer/Basic.java > b/test/java/nio/Buffer/Basic.java > --- a/test/java/nio/Buffer/Basic.java > +++ b/test/java/nio/Buffer/Basic.java > @@ -22,6 +22,7 @@ > */ > > /* @test > + * @modules java.base/jdk.internal.misc > * @summary Unit test for buffers > * @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 > 4490253 4523725 > * 4526177 4463011 4660660 4661219 4663521 4782970 4804304 > 4938424 6231529 > diff --git a/test/java/nio/Buffer/CopyDirectMemory.java > b/test/java/nio/Buffer/CopyDirectMemory.java > --- a/test/java/nio/Buffer/CopyDirectMemory.java > +++ b/test/java/nio/Buffer/CopyDirectMemory.java > @@ -25,6 +25,7 @@ > * @summary Test view buffer bulk operations for large buffers. > * @bug 4463011 > * > + * @modules java.base/jdk.internal.misc > * @build Basic > * @run main CopyDirectMemory > */ -- Alejandro From coleen.phillimore at oracle.com Wed Apr 6 17:58:56 2016 From: coleen.phillimore at oracle.com (Coleen Phillimore) Date: Wed, 6 Apr 2016 13:58:56 -0400 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <57044EC8.7050602@oracle.com> References: <5702FC9B.7020600@oracle.com> <5703F579.8050702@oracle.com> <5703F5E7.4060404@oracle.com> <5704030F.80906@oracle.com> <57044EC8.7050602@oracle.com> Message-ID: <57054E60.6030504@oracle.com> On 4/5/16 7:48 PM, Brent Christian wrote: > Thanks, Coleen. Coordinating method/function names on "to stack trace > element" is a fine thing. I've done so in the updated webrev, and > also implemented Claes's suggestion. > > http://cr.openjdk.java.net/~bchristi/8153123/webrev.01/index.html Thank you for making this change. It looks good! I've reviewed this. Coleen > > -Brent > On 04/05/2016 11:25 AM, Coleen Phillimore wrote: >> >> A correction below. >> >> On 4/5/16 1:29 PM, Coleen Phillimore wrote: >>> >>> Also meant to include core-libs-dev in the email. >>> Thanks, >>> Coleen >>> >>> On 4/5/16 1:27 PM, Coleen Phillimore wrote: >>>> >>>> Hi, I've reviewed the hotspot changes and some of the jdk changes. >>>> This looks really good. >>>> >>>> One comment about the jvm function names: >>>> >>>> I think FillInStackTraceElement is too close of a name to >>>> Throwable::fill_in_stack_trace(). >>>> >>>> -JVM_ENTRY(void, JVM_SetMethodInfo(JNIEnv *env, jobject frame)) >>>> +JVM_ENTRY(void, JVM_FillInStackTraceElement(JNIEnv *env, jobject >>>> frame, jobject stack)) >>>> JVMWrapper("JVM_SetMethodInfo"); >>>> - Handle stackFrame(THREAD, JNIHandles::resolve(frame)); >>>> - java_lang_StackFrameInfo::fill_methodInfo(stackFrame, THREAD); >>>> + Handle stack_frame_info(THREAD, JNIHandles::resolve(frame)); >>>> + Handle stack_trace_element(THREAD, JNIHandles::resolve(stack)); >>>> + java_lang_StackFrameInfo::fill_methodInfo(stack_frame_info, >>>> stack_trace_element, THREAD); JVM_END >>>> >>>> >>>> And the function is called fill_methodInfo in the javaClasses >>>> function. >>>> >>>> I think the JVM and the java_lang_StackFrameInfo function names >>>> should be closer. >>>> >>>> I wonder if the name JVM_ToStackFrameElement() and >>>> java_lang_StackFrameInfo::to_stack_frame_element() would be better >>>> and then it'd match the Java name. >>>> >> >> I meant JVM_ToStackTraceElement() and >> java_lang_StackFrameInfo::to_stack_trace_element(), since it's producing >> a StackTraceElement. >> >> thanks, >> Coleen >>>> Thanks! >>>> Coleen >>>> >>>> On 4/4/16 9:29 PM, Mandy Chung wrote: >>>>>> On Apr 4, 2016, at 4:45 PM, Brent Christian >>>>>> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> I'd like to check in some footprint and code reduction changes to >>>>>> the java.lang.StackWalker implementation. >>>>>> >>>>>> Webrev: >>>>>> http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ >>>>>> Bug: >>>>>> https://bugs.openjdk.java.net/browse/JDK-8153123 >>>>>> >>>>> This looks good to me. >>>>> >>>>> One thing to mention is that this patch is a follow-up work from the >>>>> investigation on what it takes to enable Throwable to use >>>>> StackWalker (JDK-8141239). The current built-in VM backtrace is very >>>>> compact and performant. We have identified and prototypes the >>>>> performance improvements if Throwable backtrace is generated using >>>>> stack walker. There are some performance gaps that we agree to >>>>> defer JDK-8141239 to a future release and improve the footprint >>>>> performance and GC throughput concerns when MemberNames are stored >>>>> in the throwable backtrace. >>>>> >>>>> Mandy >>>>> >>>> >>> >> > From iris.clark at oracle.com Wed Apr 6 18:28:12 2016 From: iris.clark at oracle.com (Iris Clark) Date: Wed, 6 Apr 2016 11:28:12 -0700 (PDT) Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: Message-ID: Hi, Volker. Sorry for the delay. I agree that the old implementation isn't quite correct. I can't see us potentially having a JCP MR for a security or patch release (9.0.0.X and 9.0.X respectively). I could see a MR for an very unusual minor release (9.X). If we had an MR there's no guarantee that we'd need to change the java.specification.version system property. However, in the event that we did need to change the java.specification.version, it should match that release's $MAJOR.$MINOR, even if it meant that we had a sequence of specification version numbers with gaps. As an example, let's say that JDK 9 is released via umbrella JSR with java.specification.value of "9". The system property would remain at "9" for all releases regardless of type until we choose to have a MR. Should that MR occur while we're working on minor release 9.3.X and there is a need to change the value of java.specification.value, it would become "9.3" and would remain so in every release until the next MR. While we haven't changed the system property recently, I think that we need to future-proof ourselves a little bit for MRs as described above. Assuming that we change the syntax of java.specification.version to $MAJOR.$MINOR (zeros truncated, value dependent on JCP) then we need to make a similar change to the syntax of java.vm.specification.version. [ Note that in the current implementation, I believe that the values of java.specification.version and java.vm.specification.version are tied to each other. ] Changing the syntax of java{.vm}?specification.version requires a CCC which I will file once we have agreement on the necessary changes. Regards, Iris -----Original Message----- From: Volker Simonis [mailto:volker.simonis at gmail.com] Sent: Tuesday, April 05, 2016 10:26 AM To: Java Core Libs Cc: verona-dev at openjdk.java.net Subject: Re: RFR(XXS): 8149519: Investigate implementation of java.specification.version Hi, can somebody please review this trivial change? Regards, Volker On Mon, Apr 4, 2016 at 6:47 PM, Volker Simonis wrote: > Hi, > > can I please have a review for this small fix: > > http://cr.openjdk.java.net/~simonis/webrevs/2016/8149519 > https://bugs.openjdk.java.net/browse/JDK-8149519 > > Currently the value of the java.specification.version property comes > from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in. It is > currently set to VERSION_NUMBER which is the same value which is also > used for the java.version property. > > This is a bad idea, because VERSION_NUMBER is a dot separated sequence > of numbers (e.g. 9.0.1) which is expected to change frequently (i.e. > for every build and/or update version). If we are configuring with > "--with-version-patch=1" for example, VERSION_NUMBER and java.version > will be "9.0.0.1". But it makes no sense that VERSION_SPECIFICATION > and java.specification.version have the same, dotted value. And it > breaks a lot of legacy applications which parse > java.specification.version as a float number. That code would still > work if java.specification.version would be a concrete number (e.g. > '9' or '10'). > > I suggest to set VERSION_SPECIFICATION to VERSION_MAJOR in > common/autoconf/spec.gmk.in. This should be the "right value" until we > get a specification change during a major release which hasn't > happened for quite some time now. > > Regards, > Volker From brent.christian at oracle.com Wed Apr 6 18:50:35 2016 From: brent.christian at oracle.com (Brent Christian) Date: Wed, 06 Apr 2016 11:50:35 -0700 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: References: <5702FC9B.7020600@oracle.com> <5703F579.8050702@oracle.com> <5703F5E7.4060404@oracle.com> <5704030F.80906@oracle.com> <57044EC8.7050602@oracle.com> Message-ID: <57055A7B.30903@oracle.com> On 04/05/2016 10:36 PM, Mandy Chung wrote: > > Looks good. Nit: can you add a space after ?synchronized? in StackFrameInfo.java line 109: > 109 synchronized(this) { Yep - changed locally. Thanks, -Brent From huizhe.wang at oracle.com Wed Apr 6 19:33:49 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Wed, 06 Apr 2016 12:33:49 -0700 Subject: RFR JDK 9 (JAXP) 8150969 : DEFER from Features API is taking precedence over defer preference in catalog file. Message-ID: <5705649D.3080001@oracle.com> Hi, Fix a typo in the catalog reader where the intention was to set the defer attribute, but the prefer was set instead. The tests are from the JCK. JBS: https://bugs.openjdk.java.net/browse/JDK-8150969 webrevs: http://cr.openjdk.java.net/~joehw/jdk9/8150969/webrev/ Thanks, Joe From lance.andersen at oracle.com Wed Apr 6 20:09:58 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Wed, 6 Apr 2016 16:09:58 -0400 Subject: RFR JDK 9 (JAXP) 8150969 : DEFER from Features API is taking precedence over defer preference in catalog file. In-Reply-To: <5705649D.3080001@oracle.com> References: <5705649D.3080001@oracle.com> Message-ID: looks fine joe > On Apr 6, 2016, at 3:33 PM, huizhe wang wrote: > > Hi, > > Fix a typo in the catalog reader where the intention was to set the defer attribute, but the prefer was set instead. The tests are from the JCK. > > JBS: https://bugs.openjdk.java.net/browse/JDK-8150969 > webrevs: http://cr.openjdk.java.net/~joehw/jdk9/8150969/webrev/ > > Thanks, > Joe Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From martinrb at google.com Wed Apr 6 20:17:05 2016 From: martinrb at google.com (Martin Buchholz) Date: Wed, 6 Apr 2016 13:17:05 -0700 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> References: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> Message-ID: We missed Aleksey's changes, which broke our integration. Historically, hotspot was more independent from jdk, and there were no "flag days" that required both to be modified together. In jsr166 CVS we still consistently use sun.misc.Unsafe, because it's ... ummm ... more portable. Our openjdk integration script changes that to jdk.internal.misc, but needs modification. Most of these will sadly soon change again, due to varhandlification. Everything regenerated, now with: # Replaces sun.misc.Unsafe with jdk9's preferred jdk.internal.misc find src/main -name '*.java' \ | xargs perl -pi -0777 \ -e 's~\bsun\.misc\.Unsafe\b~jdk.internal.misc.Unsafe~g; s~\bputOrdered([A-Za-z]+)\b~put${1}Release~g' On Wed, Apr 6, 2016 at 5:54 AM, Paul Sandoz wrote: > Hi Martin, > > miscellaneous > ? > > You reverted Aleksey?s change s/putOrderedObject/putObjectRelease. > > The *Ordered* methods are now removed from the ?real? jdk.internal.misc.Unsafe. > > Paul. > > >> On 3 Apr 2016, at 20:29, Martin Buchholz wrote: >> >> Easy changes to review, up to April Fools day, in part to make room >> for later unfinished more exciting changes. >> >> http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ > From Roger.Riggs at Oracle.com Wed Apr 6 20:19:22 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 6 Apr 2016 16:19:22 -0400 Subject: RFR:JDK-8148849:Truncating Duration In-Reply-To: References: <56FA727C.201@oracle.com> <56FBB7AF.3030409@oracle.com> Message-ID: <57056F4A.4070905@Oracle.com> Hi Nadeesh, An internal reviewer pointed out that Duration does not have 'fields' (it is not a TemporalAccessor) so the description might be clarified by saying: + * Truncating the duration returns a copy of the original with *conceptual *fields + * smaller than the specified unit set to zero. The rest is fine. Reviewed Thanks, Roger On 3/30/2016 9:33 AM, Stephen Colebourne wrote: > Yes, that looks OK now. > thanks > Stephen > > > On 30 March 2016 at 12:25, nadeesh tv wrote: >> Hi Stephen, >> >> Thanks for the comments. >> Please see the updated webrev >> http://cr.openjdk.java.net/~ntv/8148849/webrev.01/ >> >> Made a change in unit == ChronoUnit.SECONDS also >> >> >> Regards, >> Nadeesh TV >> >> >> On 3/29/2016 6:10 PM, Stephen Colebourne wrote: >>> We're almost there, but looking at the tests, it looks like the >>> behaviour is wrong: >>> >>> The intended behaviour is that >>> -20.5mins (minus 20 minutes 30 secs) should truncate to -20mins >>> -2.1secs truncate to -2secs >>> >>> Note that the truncation is different to Instant here. >>> An Instant truncates towards the far past - like RoundingMode.FLOOR >>> A Duration truncates towards the zero - like RoundingMode.DOWN >>> >>> Stephen >>> >>> >>> On 29 March 2016 at 13:18, nadeesh tv wrote: >>>> Hi all, >>>> >>>> Bug Id : https://bugs.openjdk.java.net/browse/JDK-8148849 >>>> >>>> Enhanced Duration by adding public Duration truncatedTo(TemporalUnit >>>> unit) >>>> >>>> Please http://cr.openjdk.java.net/~ntv/8148849/webrev.00/ >>>> >>>> -- >>>> Thanks and Regards, >>>> Nadeesh TV >>>> >> -- >> Thanks and Regards, >> Nadeesh TV >> From john.r.rose at oracle.com Wed Apr 6 22:03:29 2016 From: john.r.rose at oracle.com (John Rose) Date: Wed, 6 Apr 2016 15:03:29 -0700 Subject: RFR: 8150469: unpack200 fails to compare crc correctly. In-Reply-To: <56D46C79.80807@oracle.com> References: <56D46C79.80807@oracle.com> Message-ID: <4BF8B530-17D0-435A-B417-75389637A16D@oracle.com> Looks good, a clean fix. The negative test should be called "testBadChecksum" or "testBrokenTrailer". ? John On Feb 29, 2016, at 8:06 AM, Kumar Srinivasan wrote: > > Hello John, Alex, > > Please review fix for https://bugs.openjdk.java.net/browse/JDK-8150469 > > The previous fix keeps the storage in the unpacker object which is > reset, for a multi-segmented pack archive, thus the computed crc32 is lost. > > Now the storage is moved into the gzip container, which persists, across > multiple segments, I also added the length check as specified by RFC 1952, > as implemented by JDK. > > http://hg.openjdk.java.net/jdk9/dev/jdk/file/e4af8119eba4/src/java.base/share/classes/java/util/zip/GZIPInputStream.java#l222 > > The review is at: > http://cr.openjdk.java.net/~ksrini/8150469/webrev.00/ > > > Thanks > Kumar > > From john.r.rose at oracle.com Wed Apr 6 23:14:07 2016 From: john.r.rose at oracle.com (John Rose) Date: Wed, 6 Apr 2016 16:14:07 -0700 Subject: RFR: 8151901: test/tools/pack200/Pack200Test fails on verifying native unpacked JAR In-Reply-To: <56F0504A.4030204@oracle.com> References: <56F0504A.4030204@oracle.com> Message-ID: <17BABD81-589E-42A0-B5F1-6B3BFE496392@oracle.com> Good. Please change the comment: s/null, no tuple change, force recomputation/null, drop ICs attribute, force CP recomputation/ Reordering BSMs and ICs should work. The BSMs may need extra ICs, but ICs cannot depend on BSMs. I wonder why we did the other order first? I guess because that is what the spec. says. Oh, there's a problem with the attribute insertion order logic; it's buggy that we unconditionally insert a BSMs attr. and then delete it later. (That goes wrong when change<0 and we recompute from scratch.) Suggested amended patch enclosed. ? John On Mar 21, 2016, at 12:49 PM, Kumar Srinivasan wrote: > > Hi John, > > This patch contains fixes for two bugs: > 8151901: test/tools/pack200/Pack200Test fails on verifying native unpacked JAR > 8062335: Pack200 Java implementation differs from C version, outputs unused UTF8 for BootstrapMethods Note: The test case exhibits both of the above. > > With this the classes produced by java and the native implementation are congruent, > though the JDK image's classes exhibit these issues, as a precaution I have extracted the > minimal set of classes to reproduce the issues, into the golden jar. > > The webrev is at: > http://cr.openjdk.java.net/~ksrini/8151901/webrev.00/ > > Thanks > Kumar > -------------- next part -------------- diff --git a/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java b/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java --- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java @@ -312,6 +312,12 @@ void setBootstrapMethods(Collection bsms) { assert(bootstrapMethods == null); // do not do this twice bootstrapMethods = new ArrayList<>(bsms); + // Edit the attribute list, if necessary. + Attribute a = getAttribute(attrBootstrapMethodsEmpty); + if (bootstrapMethods != null && a == null) + addAttribute(attrBootstrapMethodsEmpty.canonicalInstance()); + else if (bootstrapMethods == null && a != null) + removeAttribute(a); } boolean hasInnerClasses() { diff --git a/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java --- a/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -1193,16 +1193,25 @@ cls.visitRefs(VRM_CLASSIC, cpRefs); ArrayList bsms = new ArrayList<>(); - /* - * BootstrapMethod(BSMs) are added here before InnerClasses(ICs), - * so as to ensure the order. Noting that the BSMs may be - * removed if they are not found in the CP, after the ICs expansion. - */ - cls.addAttribute(Package.attrBootstrapMethodsEmpty.canonicalInstance()); // flesh out the local constant pool ConstantPool.completeReferencesIn(cpRefs, true, bsms); + // Add the BSMs and references as required. + if (!bsms.isEmpty()) { + // Add the attirbute name to the CP (visitRefs would have wanted this). + cpRefs.add(Package.getRefString("BootstrapMethods")); + // The pack-spec requires that BootstrapMethods precedes the InnerClasses attribute. + // So add BSMs now before running expandLocalICs. + // But first delete any local InnerClasses attr. (This is rare.) + List localICs = cls.getInnerClasses(); + cls.setInnerClasses(null); + Collections.sort(bsms); + cls.setBootstrapMethods(bsms); + // Re-add the ICs, so the attribute lists are in the required order. + cls.setInnerClasses(localICs); + } + // Now that we know all our local class references, // compute the InnerClasses attribute. int changed = cls.expandLocalICs(); @@ -1221,16 +1230,6 @@ ConstantPool.completeReferencesIn(cpRefs, true, bsms); } - // remove the attr previously set, otherwise add the bsm and - // references as required - if (bsms.isEmpty()) { - cls.attributes.remove(Package.attrBootstrapMethodsEmpty.canonicalInstance()); - } else { - cpRefs.add(Package.getRefString("BootstrapMethods")); - Collections.sort(bsms); - cls.setBootstrapMethods(bsms); - } - // construct a local constant pool int numDoubles = 0; for (Entry e : cpRefs) { From paul.sandoz at oracle.com Thu Apr 7 09:07:48 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 7 Apr 2016 11:07:48 +0200 Subject: RFR 8152645 VarHandle lookup access control tests Message-ID: <81AC210F-C0C7-4DAA-BAA9-FCCCF89699FB@oracle.com> Hi, Please review a test to verify access control of looking up fields using a VarHandle: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8152645-VH-access-control/webrev/ For completeness i also added tests for MH as i could not find any such existing tests. Further follow on work might be to test lookup to fields across module boundaries. Paul. From volker.simonis at gmail.com Thu Apr 7 10:11:09 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Thu, 7 Apr 2016 12:11:09 +0200 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: Message-ID: On Wed, Apr 6, 2016 at 8:28 PM, Iris Clark wrote: > Hi, Volker. > > Sorry for the delay. I agree that the old implementation isn't quite correct. I can't see us potentially having a JCP MR for a security or patch release (9.0.0.X and 9.0.X respectively). > > I could see a MR for an very unusual minor release (9.X). If we had an MR there's no guarantee that we'd need to change the java.specification.version system property. However, in the event that we did need to change the java.specification.version, it should match that release's $MAJOR.$MINOR, even if it meant that we had a sequence of specification version numbers with gaps. > > As an example, let's say that JDK 9 is released via umbrella JSR with java.specification.value of "9". The system property would remain at "9" for all releases regardless of type until we choose to have a MR. Should that MR occur while we're working on minor release 9.3.X and there is a need to change the value of java.specification.value, it would become "9.3" and would remain so in every release until the next MR. > > While we haven't changed the system property recently, I think that we need to future-proof ourselves a little bit for MRs as described above. > > Assuming that we change the syntax of java.specification.version to $MAJOR.$MINOR (zeros truncated, value dependent on JCP) then we need to make a similar change to the syntax of java.vm.specification.version. [ Note that in the current implementation, I believe that the values of java.specification.version and java.vm.specification.version are tied to each other. ] > > Changing the syntax of java{.vm}?specification.version requires a CCC which I will file once we have agreement on the necessary changes. > Hi Iris, thanks for your comments. I don't think that using $MAJOR.$MINOR for java.specification.version is a good solution. As far as I understand, JEP 223 (i.e. the new version scheme) is an Oracle/OpenJDK implementation detail. There is no JSR for this and it won't be enforced trough a JCK/TCK test (please correct me if I'm wrong). The new versioning schema references the JCP in that is says that the $MAJOR number corresponds to the "Java SE Platform Specification" number as specified by the JCP in the corresponding JSR. But not vice versa - i.e. there's no JSR referencing JEP 223. JEP 223 also says that the $MINOR number will be increased if this is mandated by a Maintenance Release of the relevant Platform Specification (by the JCP). But as you correctly noticed, in reality, $MINOR is expected to be increased frequently compared to the number of Java SE Maintenance Releases (if there will be any at all). So if the JCP should decide to publish a Maintenance Release, why should it name if after the then actual $MINOR update release number of the Oracle/OpenJDK. I think a natural choice for such a MR would be "9.1", no difference at which update release version Oracle/OpenJDK will be at that time. So I think it would be best to decouple java.specification.version from the Java versioning schema. We can start with java.specification.version == $MAJOR. If there should be a MR sometimes in the future, we can just set java.specification.version to the version number of that MR, whatever that will be. That's exactly what this change is about. Regarding the value of java.vm.specification.version I'm not sure what it actually means at all. Until Java 1.6, java.vm.specification.version has always been "1.0", while java.specification.version has changed from 1.4, to 1.5 and 1.6 (notice that java.specification.version has never been changed to 1.4.2, it was 1.4 for Java 1.4.0 as well as for 1.4.2). Starting with Java 7, java.vm.specification.version is the same like java.specification.version (i.e. 1.7 and 1.8) but I'm not sure if that is mandated by JCP and if it will be possible that these numbers will diverge for a Java release. I.e. will it be possible to have a new Java version (say Java 10) where the VM specification (and thus java.vm.specification.version) will remain unchanged (say "9")? From my understanding, that should be possible. Especially for a MR, it seems highly probable to me that the java.specification.version will be increased, but the VM specification (and thus java.vm.specification.version) will remain unchanged. So again, I think we shouldn't tie java.vm.specification.version to java.specification.version and simply start with java.vm.specification.version == $MAJOR. The current implementation already does this correctly. While the java.specification.version property comes from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in and it is being set in jdk/src/java.base/share/native/libjava/System.c the java.vm.specification.version property is set being in hotspot/src/share/vm/runtime/arguments.cpp directly to the major Java version number. Because of this difference, there are currently no problems with the java.vm.specification.version property caused by the new versioning schema. As a side note: while I wrote all this down, I realized that we have java.lang.Package.getSpecificationVersion() in the class library which returns the specification version of a specific package. But this API is not mentioned anywhere in JEP 223. Shouldn't the output of java.lang.Package.getSpecificationVersion() be aligned with JEP 223 and java.vm.specification.version as well? And a final question. Why did we put jdk.Version into the jdk package? As far as I know, jdk is not a standard Java package and thus not enforced by the Java standard (please correct me if I'm wrong). Shouldn't the Version class be in a standard Java package such that it's implementation will be mandatory for all Java implementations? Regards, Volker > Regards, > Iris > > -----Original Message----- > From: Volker Simonis [mailto:volker.simonis at gmail.com] > Sent: Tuesday, April 05, 2016 10:26 AM > To: Java Core Libs > Cc: verona-dev at openjdk.java.net > Subject: Re: RFR(XXS): 8149519: Investigate implementation of java.specification.version > > Hi, > > can somebody please review this trivial change? > > Regards, > Volker > > > On Mon, Apr 4, 2016 at 6:47 PM, Volker Simonis wrote: >> Hi, >> >> can I please have a review for this small fix: >> >> http://cr.openjdk.java.net/~simonis/webrevs/2016/8149519 >> https://bugs.openjdk.java.net/browse/JDK-8149519 >> >> Currently the value of the java.specification.version property comes >> from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in. It is >> currently set to VERSION_NUMBER which is the same value which is also >> used for the java.version property. >> >> This is a bad idea, because VERSION_NUMBER is a dot separated sequence >> of numbers (e.g. 9.0.1) which is expected to change frequently (i.e. >> for every build and/or update version). If we are configuring with >> "--with-version-patch=1" for example, VERSION_NUMBER and java.version >> will be "9.0.0.1". But it makes no sense that VERSION_SPECIFICATION >> and java.specification.version have the same, dotted value. And it >> breaks a lot of legacy applications which parse >> java.specification.version as a float number. That code would still >> work if java.specification.version would be a concrete number (e.g. >> '9' or '10'). >> >> I suggest to set VERSION_SPECIFICATION to VERSION_MAJOR in >> common/autoconf/spec.gmk.in. This should be the "right value" until we >> get a specification change during a major release which hasn't >> happened for quite some time now. >> >> Regards, >> Volker From magnus.ihse.bursie at oracle.com Thu Apr 7 10:52:56 2016 From: magnus.ihse.bursie at oracle.com (Magnus Ihse Bursie) Date: Thu, 7 Apr 2016 12:52:56 +0200 Subject: RFR [9] 8153286: Move sun.misc.GC to java.rmi ( sun.rmi.transport ) In-Reply-To: <5702515D.3040502@oracle.com> References: <570240D6.4000303@oracle.com> <5702416F.3000500@oracle.com> <57024A25.4000202@oracle.com> <5702515D.3040502@oracle.com> Message-ID: <57063C08.1060400@oracle.com> On 2016-04-04 13:34, Alan Bateman wrote: > > > On 04/04/2016 12:04, Erik Joelsson wrote: >> Makefile looks good. >> >> If you move Java_sun_rmi_transport_GC_maxObjectInspectionAge out of >> libjava, should you also remove it from the mapfile for libjava? >> > Yes, libjava/mapfile-vers will need to be updated too. It otherwise > looks okay to me, just a pity that it requires introducing another > native library. Long term, we could consider trying to consolidate all native libraries for every module into a single one, e.g. something like libjava.base.so etc. Or at least provide a lib$MODULE as a default case where there is no need for a more specific library. /Magnus > > -Alan From daniel.fuchs at oracle.com Thu Apr 7 11:24:02 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Thu, 7 Apr 2016 13:24:02 +0200 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5702FC9B.7020600@oracle.com> References: <5702FC9B.7020600@oracle.com> Message-ID: <57064352.5010800@oracle.com> Hi Brent, This looks good! Thanks for taking care of this one. In http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/hotspot/src/share/vm/prims/jvm.cpp.frames.html 548 objArrayOop fa = objArrayOop(JNIHandles::resolve_non_null(frames)); 549 objArrayHandle frames_array_h(THREAD, fa); 550 551 int limit = start_index + frame_count; 552 if (frames_array_h.is_null()) { 553 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "parameters and mode mismatch", NULL); 554 } Can frames_array_h.is_null() ever be true, given that we used JNIHandles::resolve_non_null(frames) at line 548? I wonder if lines 552-554 are a remnant of the previous implementation and could be removed now... 589 Handle stack_frame_info(THREAD, JNIHandles::resolve(frame)); 590 Handle stack_trace_element(THREAD, JNIHandles::resolve(stack)); Should these call JNIHandles::resolve_non_null instead? http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/jdk/src/java.base/share/classes/java/lang/StackFrameInfo.java.frames.html I'd be very tempted to make 'ste' private volatile. That's all for me :-) best regards, -- daniel On 05/04/16 01:45, Brent Christian wrote: > Hi, > > I'd like to check in some footprint and code reduction changes to the > java.lang.StackWalker implementation. > > Webrev: > http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ > Bug: > https://bugs.openjdk.java.net/browse/JDK-8153123 > > A summary of the changes: > > * remove the "stackwalk.newThrowable" system property and > "MemberNameInStackFrame" VM flag, originally left in to aid benchmarking > > * Streamline StackFrameInfo fields > > * Refactor/streamline StackStreamFactory (no more separate > classes[]/StackFrame[] arrays, remove unneeded (for now) > StackStreamFactory.StackTrace class) > > > Given the hotspot changes, I plan to push this through hs-rt. > > Thanks, > -Brent > From paul.sandoz at oracle.com Thu Apr 7 13:17:13 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 7 Apr 2016 15:17:13 +0200 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: References: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> Message-ID: <18424863-8530-47E3-9529-DA8EE8229557@oracle.com> > On 6 Apr 2016, at 22:17, Martin Buchholz wrote: > > We missed Aleksey's changes, which broke our integration. > Looks good. Regarding CompletableFutureTest.testManyDependents i presume that kind of test was not failing before the modifications to CompletableFuture? I am struggling to square the CF updates to the test. AFAICT the cleaning of a CF stack is now less aggressive. A dependent?s stack stack will now only be cleared if it has not completed (rather than if also the computation is nested). Thus in theory that test should run more efficiently? Paul. > Historically, hotspot was more independent from jdk, and there were no > "flag days" that required both to be modified together. > > In jsr166 CVS we still consistently use sun.misc.Unsafe, because it's > ... ummm ... more portable. > Our openjdk integration script changes that to jdk.internal.misc, but > needs modification. > Most of these will sadly soon change again, due to varhandlification. > > Everything regenerated, now with: > > # Replaces sun.misc.Unsafe with jdk9's preferred jdk.internal.misc > find src/main -name '*.java' \ > | xargs perl -pi -0777 \ > -e 's~\bsun\.misc\.Unsafe\b~jdk.internal.misc.Unsafe~g; > s~\bputOrdered([A-Za-z]+)\b~put${1}Release~g' > > On Wed, Apr 6, 2016 at 5:54 AM, Paul Sandoz wrote: >> Hi Martin, >> >> miscellaneous >> ? >> >> You reverted Aleksey?s change s/putOrderedObject/putObjectRelease. >> >> The *Ordered* methods are now removed from the ?real? jdk.internal.misc.Unsafe. >> >> Paul. >> >> >>> On 3 Apr 2016, at 20:29, Martin Buchholz wrote: >>> >>> Easy changes to review, up to April Fools day, in part to make room >>> for later unfinished more exciting changes. >>> >>> http://cr.openjdk.java.net/~martin/webrevs/openjdk9/jsr166-jdk9-integration/ >> From paul.sandoz at oracle.com Thu Apr 7 13:39:12 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 7 Apr 2016 15:39:12 +0200 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style Message-ID: Hi, Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ I was persuaded (in internal CCC review) to change the enum VarHandle.AccessMode constant names to conform to the expected Java style. Previously, for convenience, the names corresponded exactly with the VH sig-poly method names. Most of the patch is just refactoring. I have added two new methods to translate to/from the sig-poly method name domain: 1175 /** 1176 * Returns the {@code VarHandle} signature-polymorphic method name 1177 * associated with this {@code AccessMode} value 1178 * 1179 * @return the signature-polymorphic method name 1180 * @see #valueFromMethodName 1181 */ 1182 public String methodName() { 1183 return methodName; 1184 } 1185 1186 /** 1187 * Returns the {@code AccessMode} value associated with the specified 1188 * {@code VarHandle} signature-polymorphic method name. 1189 * 1190 * @param methodName the signature-polymorphic method name 1191 * @return the {@code AccessMode} value 1192 * @throws IllegalArgumentException if there is no {@code AccessMode} 1193 * value associated with method name (indicating the method 1194 * name does not correspond to a {@code VarHandle} 1195 * signature-polymorphic method name). 1196 * @see #methodName 1197 */ 1198 public static AccessMode valueFromMethodName(String methodName) { 1199 AccessMode am = methodNameToAccessMode.get(methodName); 1200 if (am != null) return am; 1201 throw new IllegalArgumentException("No AccessMode value for method name " + methodName); 1202 } Paul. From spliterator at gmail.com Thu Apr 7 14:33:14 2016 From: spliterator at gmail.com (Stefan Zobel) Date: Thu, 7 Apr 2016 16:33:14 +0200 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: <755756441.20160401222505@gmail.com> References: <755756441.20160401222505@gmail.com> Message-ID: Hi Tagir, a few comments below a) IntPipeline: public final mapToObj(IntFunction mapper, int opFlags) should be private, not public b) IntPipeline: asDoubleStream() - as already discussed, 0 should be passed as the opFlags value to the DoublePipeline.StatelessOp constructor c) I think, the new "private final mapToObj(...)" methods can be "private" (dropping the "final") Regards, Stefan 2016-04-01 18:25 GMT+02:00 Tagir F. Valeev : > Hello! > > Please review and sponsor the following patch: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r1/ > > The patch preserves more characteristics on primitive stream > operations: > IntStream/LongStream/DoubleStream.boxed() preserves SORTED and DISTINCT > IntStream.asLongStream() preserves SORTED and DISTINCT > IntStream.asDoubleStream() and LongStream.asDoubleStream() preserves SORTED > (different longs can be converted into the same double, so DISTINCT is > not preserved here; not sure whether this is possible for ints) > > Fixing the boxed() case is especially important as distinct() for > primitive streams is implemented like boxed().distinct().unbox, so the > actual distinct() operation cannot take the advantage of DISTINCT flag > (skip the operation at all) or SORTED flag (switch to more efficient > implementation). > > Here's the small JMH benchmark which measures the performance boost of > quite common operation: sort the input numbers and leave only distinct > ones: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/jmh/ > > new Random(1).ints(size).sorted().distinct().toArray() > > I've got the following results. > > 9ea+111: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,612 ? 0,004 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 92,848 ? 1,039 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 32147,205 ? 3487,422 us/op > > 9ea+111 patched: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,435 ? 0,001 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 40,555 ? 0,772 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 9031,651 ? 73,956 us/op > > With best regards, > Tagir Valeev. > From martinrb at google.com Thu Apr 7 14:55:04 2016 From: martinrb at google.com (Martin Buchholz) Date: Thu, 7 Apr 2016 07:55:04 -0700 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: <18424863-8530-47E3-9529-DA8EE8229557@oracle.com> References: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> <18424863-8530-47E3-9529-DA8EE8229557@oracle.com> Message-ID: On Thu, Apr 7, 2016 at 6:17 AM, Paul Sandoz wrote: > >> On 6 Apr 2016, at 22:17, Martin Buchholz wrote: > Looks good. > > Regarding CompletableFutureTest.testManyDependents i presume that kind of test was not failing before the modifications to CompletableFuture? Right - technically it was not failing before, but the O(N^2) performance in case of regression would be noticed quickly. And it seems like a generally useful test. > > I am struggling to square the CF updates to the test. AFAICT the cleaning of a CF stack is now less aggressive. A dependent?s stack stack will now only be cleared if it has not completed (rather than if also the computation is nested). Thus in theory that test should run more efficiently? It's not useful to clean the stack of a future that has completed because all of its dependents will be triggered anyways, so there's no risk of garbage accumulation. But jsr166 CVS already has followon changes in this area that are not part of this integration. From spliterator at gmail.com Thu Apr 7 15:28:54 2016 From: spliterator at gmail.com (Stefan Zobel) Date: Thu, 7 Apr 2016 17:28:54 +0200 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: <755756441.20160401222505@gmail.com> References: <755756441.20160401222505@gmail.com> Message-ID: Hi Tagir, another minor issue. The testFlags() methods in IntPrimitiveOpsTests / LongPrimitiveOpsTests each have a duplicated assert: IntPrimitiveOpsTests: assertFalse(IntStreams.of(1, 10).boxed().spliterator() .hasCharacteristics(Spliterator.SORTED)); LongPrimitiveOpsTests: assertFalse(LongStreams.of(1, 10).boxed().spliterator() .hasCharacteristics(Spliterator.SORTED)); The asserts for IntStreams.range(1, 10).asDoubleStream() would have to be changed to account for DISTINCTness, of course. Regards, Stefan 2016-04-01 18:25 GMT+02:00 Tagir F. Valeev : > Hello! > > Please review and sponsor the following patch: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r1/ > > The patch preserves more characteristics on primitive stream > operations: > IntStream/LongStream/DoubleStream.boxed() preserves SORTED and DISTINCT > IntStream.asLongStream() preserves SORTED and DISTINCT > IntStream.asDoubleStream() and LongStream.asDoubleStream() preserves SORTED > (different longs can be converted into the same double, so DISTINCT is > not preserved here; not sure whether this is possible for ints) > > Fixing the boxed() case is especially important as distinct() for > primitive streams is implemented like boxed().distinct().unbox, so the > actual distinct() operation cannot take the advantage of DISTINCT flag > (skip the operation at all) or SORTED flag (switch to more efficient > implementation). > > Here's the small JMH benchmark which measures the performance boost of > quite common operation: sort the input numbers and leave only distinct > ones: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/jmh/ > > new Random(1).ints(size).sorted().distinct().toArray() > > I've got the following results. > > 9ea+111: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,612 ? 0,004 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 92,848 ? 1,039 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 32147,205 ? 3487,422 us/op > > 9ea+111 patched: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,435 ? 0,001 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 40,555 ? 0,772 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 9031,651 ? 73,956 us/op > > With best regards, > Tagir Valeev. > From paul.sandoz at oracle.com Thu Apr 7 15:29:55 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 7 Apr 2016 17:29:55 +0200 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: References: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> <18424863-8530-47E3-9529-DA8EE8229557@oracle.com> Message-ID: <0B4F368A-5DFB-40FB-88F0-3B36803DECCE@oracle.com> > On 7 Apr 2016, at 16:55, Martin Buchholz wrote: > > On Thu, Apr 7, 2016 at 6:17 AM, Paul Sandoz wrote: >> >>> On 6 Apr 2016, at 22:17, Martin Buchholz wrote: > >> Looks good. >> >> Regarding CompletableFutureTest.testManyDependents i presume that kind of test was not failing before the modifications to CompletableFuture? > > Right - technically it was not failing before, but the O(N^2) > performance in case of regression would be noticed quickly. And it > seems like a generally useful test. > Yes, no disagreement. >> >> I am struggling to square the CF updates to the test. AFAICT the cleaning of a CF stack is now less aggressive. A dependent?s stack stack will now only be cleared if it has not completed (rather than if also the computation is nested). Thus in theory that test should run more efficiently? > > It's not useful to clean the stack of a future that has completed > because all of its dependents will be triggered anyways, so there's no > risk of garbage accumulation. But jsr166 CVS already has followon > changes in this area that are not part of this integration. I was looking at those trying to understand where things are going. Current webrev is fine. Thanks, Paul. From dl at cs.oswego.edu Thu Apr 7 15:39:05 2016 From: dl at cs.oswego.edu (Doug Lea) Date: Thu, 7 Apr 2016 11:39:05 -0400 Subject: RFR: jsr166 jdk9 integration wave 6 In-Reply-To: <0B4F368A-5DFB-40FB-88F0-3B36803DECCE@oracle.com> References: <8A4AA663-C714-4460-AE0B-C199C51104B5@oracle.com> <18424863-8530-47E3-9529-DA8EE8229557@oracle.com> <0B4F368A-5DFB-40FB-88F0-3B36803DECCE@oracle.com> Message-ID: <57067F19.3050605@cs.oswego.edu> On 04/07/2016 11:29 AM, Paul Sandoz wrote: >>> >>> I am struggling to square the CF updates to the test. AFAICT the cleaning of a CF stack is now less aggressive. A dependent?s stack stack will now only be cleared if it has not completed (rather than if also the computation is nested). Thus in theory that test should run more efficiently? >> >> It's not useful to clean the stack of a future that has completed >> because all of its dependents will be triggered anyways, so there's no >> risk of garbage accumulation. But jsr166 CVS already has followon >> changes in this area that are not part of this integration. > > I was looking at those trying to understand where things are going. > > Current webrev is fine. > Thanks for looking at these! We've been diagnosing and addressing various (potential) CompletableFuture performance issues, as they are used increasingly often. Some of the changes in jsr166 CVS aren't yet evaluated enough to commit to though. -Doug From chris.hegarty at oracle.com Thu Apr 7 17:14:56 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 7 Apr 2016 18:14:56 +0100 Subject: RFR [9] 8153737: Unsupported Module Message-ID: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> Enough technical debt has been paid down that we can now create the new JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. This module will initially contain, and export, the sun.misc package, and will eventually export the sun.reflect package too ( once it has been sanitized ). The jdk.unsupported module will be present in full JRE and JDK images. http://cr.openjdk.java.net/~chegar/8153737/ https://bugs.openjdk.java.net/browse/JDK-8153737 Summary of the changes: - Restructure, what remains of, the sources in sun/misc to reflect the new modular layout. There are still a few non-Critical APIs in sun.misc that will be addressed later. - Add dependencies from several JDK modules to jdk.unsupported. All dependencies have issues tracking them, and should be removed in 9. - The test library in the top-level repo provides a convenience to tests to retrieve Unsafe. This has been updated to the "real" internal Unsafe, so there are many many tests that require to be updated, mostly the @modules tags. ( The Unsafe dependency in the library should probably be revisited at some point, as it requires many tests, not wishing to use Unsafe, to require an explicit dependency on it ) Note: with recent work from Mikael [2], sun.misc.Unsafe is now just a delegate for the "real" internal Unsafe, so it is time to move the tests to use it directly. - Cleanup any tests unnecessarily/incorrectly declaring a dependency on sun.misc ( this could have been unnecessarily added, been refactored out at one point, or the library upon which the tests depends refactored, that the dependency is no longer required ). I'm sure further cleanup could be done, but this is sufficient for now. - A small number of test in hotspot/test/compiler/unsafe, which are generated, have been updated, along with the generation script, to depend on jdk.unsupported/sun.misc ( they explicitly test the sun.misc version ) All 'core', 'pit', and 'hotspot' testsets have been successfully run on Mac, Linux, Windows, and Solaris. -Chris. [1] https://bugs.openjdk.java.net/browse/JDK-8132928 [2] https://bugs.openjdk.java.net/browse/JDK-8149159 From Alan.Bateman at oracle.com Thu Apr 7 18:57:24 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 7 Apr 2016 19:57:24 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> Message-ID: <5706AD94.8030701@oracle.com> On 07/04/2016 18:14, Chris Hegarty wrote: > Enough technical debt has been paid down that we can now create the new > JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. > This module will initially contain, and export, the sun.misc package, > and will eventually export the sun.reflect package too ( once it has > been sanitized ). The jdk.unsupported module will be present in full JRE > and JDK images. > > http://cr.openjdk.java.net/~chegar/8153737/ It's great to get to this milestone. I looked over the webrev and I don't see any issues. I'm surprised by the number of tests that had @modules java.base/sun.misc even though they aren't using anything in sun.misc. I see Phil has pushed JDK-8147544 to jdk9/client rather than jdk9/dev so it means that the module-info.java for java.desktop will need to be fixed up when it gets to jdk9/dev. I think we should bump the priority of all the issues that cause you to add `requires jdk.unsupported`we should at least get all of them resolved by FC as we shouldn't have any standard modules with this dependence. -Alan. From christoph.langer at sap.com Thu Apr 7 20:45:15 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Thu, 7 Apr 2016 20:45:15 +0000 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place Message-ID: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> Hi, I've run into a peculiar issue with Xerces. The problem is happening when a DTD shall be skipped, the DTD is larger than the buffer of the current entity and a CRLF sequence occurs just one char before the buffer end. The reason is that method skipDTD of class XMLDTDScannerImpl (about line 389) calls XMLEntityScanner.scanData() to scan for the next occurrence of ']'. The scanData method might return true which indicates that the delimiter ']' was not found yet and more data is to scan. Other users of scanData would handle this and call this method in a loop until it returns false or some other condition happens. So I've fixed that place like at the other callers of scanData. Nevertheless, the scanData method would usually load more data when it is at the end of the buffer. But in the special case when CRLF is found at the end of buffer - 1, scanData would just return true. So I also removed that check at line 1374 in XMLEntityScanner. Do you see any problem with that? Is there any reason behind it which I'm overseeing? Furthermore I took the chance for further little cleanups. I've added the new copyright header to the files... is that the correct one? I also aligned the calls to invokeListeners(position) in XMLEntityScanner to always pass the actual position from which the load is started. Do you think this is correct? Here is the bug: https://bugs.openjdk.java.net/browse/JDK-8153781 Here is the webrev: http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ Please give me some comments before I finalize my change including a jtreg testcase. Thanks & Best regards Christoph From steve.dohrmann at intel.com Thu Apr 7 22:03:11 2016 From: steve.dohrmann at intel.com (Dohrmann, Steve) Date: Thu, 7 Apr 2016 22:03:11 +0000 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: References: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> Message-ID: <7809D2A6-9665-458F-B9DB-37A3FD1451EB@intel.com> Hi Paul, We would like to have an an API for Intel's 3D XPoint memory sooner than the JDK 10 timeframe and proposed this API because it seems simple enough to consider for JDK 9. As you suggest, we will participate in the Panama discussions in this area. Any additional guidance you have would be appreciated. Just to clarify, it is incidental that the proposed Memory interface has only one method. We see the value of the interface as nominative; a new type that can be passed around to abstract various sources of ByteBuffer memory. Regarding construction and allocation, our current Memory implementation allocates ByteBuffers by calling the NewDirectByteBuffer JNI function with a pointer to 3D XPoint memory allocated via a supporting native library. The Linux libraries we have worked with are NVML (https://github.com/pmem/nvml/) and memkind (https://github.com/memkind/memkind). We recently also became aware of the NVM-Direct library (https://github.com/oracle/NVM-Direct). We currently don't need our own subclass and return the ByteBuffer returned by the JNI call. Thanks, Steve On Apr 6, 2016, at 4:10 AM, Paul Sandoz > wrote: Hi Steve, My feeling is it?s too premature to introduce a general Memory (region) allocation interface at this moment. What is currently specified can be supported using: IntFunction But i don?t wanna discourage you! this thread has raised some interesting points. Project Panama is gonna take a swing at defining a more general notion of a memory region and the Arrays 2.0 work should support indexes greater than Integer.MAX_VALUE. In this respect I think we should hold off doing anything premature for Java 9 (feature freeze is getting closer), and i encourage you to participate on the Panama lists. ? Here is some context some of which you probably know and some which you might not: - ByteBuffer constructors are deliberately package scoped, as there are some intricate dependencies between the implementations and we want control over who can implement. Any new form of allocation will require changes here (package scoped or otherwise). - current ByteBuffer implementations are either backed by a byte[] (managed or non-direct) or an off-heap allocated (direct) region. At the moment access to both those regions go through separate code paths, but they could be unified using the Unsafe double addressing mode, which should greatly simplify the implementations. I have started making some small steps towards that (JDK-8149469 and JDK-8151163). Even these small steps require careful analysis to evaluate performance across multiple platforms. - VarHandles leverages the Unsafe double addressing mode to support enhanced atomic access to heap or direct ByteBuffers [1], thus the same code is used in both kinds of buffer. ? I am not sure what plans you have for buffer implementations themselves. How do you propose to allocate a ByteBuffer instance that covers a region of 3D XPoint memory? Would it be similar to that of direct buffers, e.g. a variation of DirectByteBuffer, but with different factory constructor code to allocate the memory region within the XPoint memory system and assign the buffer base address to the start of that allocated region? Thanks, Paul. [1] http://cr.openjdk.java.net/~psandoz/jdk9/varhandles/specdiff/java/lang/invoke/MethodHandles-report.html#method:byteBufferViewVarHandle(java.lang.Class, boolean) On 6 Apr 2016, at 03:49, Dohrmann, Steve > wrote: Re: JDK-8153111 Hi, Below are responses to some of the points brought up in the discussion as well as is a little expansion of the reasoning that went into the proposed API. One motivation we saw for doing anything beyond a concrete ByteBuffer class was application code (e.g. Cassandra) that allocates many off-heap ByteBuffers using ByteBuffer#allocateDirect. We reasoned that if the allocation of ByteBuffers could be done using a common memory interface then only the code that provisioned instances of the the memory spaces would have to change in order to switch or mix memory types. We did think of overloading the ByteBuffer#allocateDirect method with memory space info and avoid an allocation interface. We ended up with a separate user called interface scheme because we imagined that extensions of the memory interface would enable new memory functionality that required new methods (e.g. memory transactions for persistence). Without a separate callable interface, the static method space in ByteBuffer might have to change again. For any API In general we saw the need for two things 1) something to represent a memory space from which objects are allocated (a Memory instance) and 2) a broadly usable familiar "anchor" type as the common data object (java.nio.ByteBuffer). The two points for extension with the current proposal are: 1) Constructors on Memory implementation classes -- allow implementors the ability to offer features on the memory space itself (e.g. partitioning, size limits) and 2) future extensions on the Memory interface -- for example PersistentMemory. Regarding a more elaborate scheme for memory space creation -- we did consider a factory scheme for memory object allocation but could not get comfortable with either a) standardized method signatures suitable for various kinds of memory or b) the complexity that something like a general-purpose "spec" format would add, even if we could come up with it. Direct construction does expose more to the user but it seems sufficient and might be the best given what we can say about the future of heterogeneous memory at this point. Regarding the suggested addition of keyed access to ByteBuffers, we are assuming this is only proposed to enable sharing? We thought it might take a while to properly explore the details (i.e. semantics / thread safety / predicable performance) of sharing such that it would work well and maybe even extend well to things like process-shared and cluster-shared ByteBuffers. We elected to propose nothing for JDK 9 beyond what developers can already do with schemes based on e.g. ByteBuffer#duplicate. We were thinking shared buffers could appear later, possibly as an extension of the Memory interface. The keyed access scheme is simple and appealing, however. One question: how is the request method's size parameter to be interpreted? The suggestion of parameterizing the Memory interface bounded by ByteBuffers seems useful as it gives a clean way to support extended ByteBuffers. Not sure if the change of the allocation method name from #allocateByteBuffer to #allocate was incidental or not? Alternates to the "Memory" interface name might be preferred, BufferSupplier is certainly reasonable. We imagined instances that name different memory spaces (e.g. OffHeapRAM) for allocation rather that the role played -- thinking the role is explicit in the allocation method name (allocateByteBuffer). Regarding changing the allocation size parameter to a long, this would be very nice to have. We avoided it in order to match the existing ByteBuffer API. If 64-bit ByteBuffers are planned, sticking with int sizes might have been the wrong call. We are still coming up to speed on VarHandles (JEP 193), atomics for ByteBuffers (JDK-8008240), and ByteBuffer consistency (JDK-6476827). We hope there is continued interest in this proposal and happy to provide a modified patch. Best regards, Steve Dohrmann From brent.christian at oracle.com Thu Apr 7 23:33:52 2016 From: brent.christian at oracle.com (Brent Christian) Date: Thu, 07 Apr 2016 16:33:52 -0700 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <57064352.5010800@oracle.com> References: <5702FC9B.7020600@oracle.com> <57064352.5010800@oracle.com> Message-ID: <5706EE60.3010901@oracle.com> Hi, Daniel On 04/07/2016 04:24 AM, Daniel Fuchs wrote: > > In > http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/hotspot/src/share/vm/prims/jvm.cpp.frames.html > > 548 objArrayOop fa = objArrayOop(JNIHandles::resolve_non_null(frames)); > 549 objArrayHandle frames_array_h(THREAD, fa); > 550 > 551 int limit = start_index + frame_count; > 552 if (frames_array_h.is_null()) { > 553 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), > "parameters and mode mismatch", NULL); > 554 } > > Can frames_array_h.is_null() ever be true, given that we used > JNIHandles::resolve_non_null(frames) at line 548? No! As you point out, it will assert out at 548. > I wonder if lines 552-554 are a remnant of the previous > implementation and could be removed now... You're absolutely right. > 589 Handle stack_frame_info(THREAD, JNIHandles::resolve(frame)); > 590 Handle stack_trace_element(THREAD, JNIHandles::resolve(stack)); > > Should these call JNIHandles::resolve_non_null instead? Yes! > http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/jdk/src/java.base/share/classes/java/lang/StackFrameInfo.java.frames.html > > I'd be very tempted to make 'ste' private volatile. Sounds good to me. Thank you for having a look. I will send: http://cr.openjdk.java.net/~bchristi/8153123/webrev.02/ to hs-rt shortly. -Brent > On 05/04/16 01:45, Brent Christian wrote: >> Hi, >> >> I'd like to check in some footprint and code reduction changes to the >> java.lang.StackWalker implementation. >> >> Webrev: >> http://cr.openjdk.java.net/~bchristi/8153123/webrev.00/ >> Bug: >> https://bugs.openjdk.java.net/browse/JDK-8153123 >> >> A summary of the changes: >> >> * remove the "stackwalk.newThrowable" system property and >> "MemberNameInStackFrame" VM flag, originally left in to aid benchmarking >> >> * Streamline StackFrameInfo fields >> >> * Refactor/streamline StackStreamFactory (no more separate >> classes[]/StackFrame[] arrays, remove unneeded (for now) >> StackStreamFactory.StackTrace class) >> >> >> Given the hotspot changes, I plan to push this through hs-rt. >> >> Thanks, >> -Brent >> > From steve.drach at oracle.com Fri Apr 8 01:57:16 2016 From: steve.drach at oracle.com (Steve Drach) Date: Thu, 7 Apr 2016 18:57:16 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value Message-ID: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. > Hi, > Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. > issue: https://bugs.openjdk.java.net/browse/JDK-8153213 > webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html > Thanks > Steve From mandy.chung at oracle.com Fri Apr 8 02:52:03 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 7 Apr 2016 19:52:03 -0700 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> Message-ID: <13C89E01-3396-4EFE-BC35-C289E59DBEED@oracle.com> > On Apr 7, 2016, at 10:14 AM, Chris Hegarty wrote: > > Enough technical debt has been paid down that we can now create the new > JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. > This module will initially contain, and export, the sun.misc package, > and will eventually export the sun.reflect package too ( once it has > been sanitized ). The jdk.unsupported module will be present in full JRE > and JDK images. > > http://cr.openjdk.java.net/~chegar/8153737/ > https://bugs.openjdk.java.net/browse/JDK-8153737 I?m glad to see jdk.unsupported module be created. jdeps tests are intended to test references to sun.misc and flagged as internal API. The jdeps test changes should be reverted. It?s exported to allow existing applications to continue to run on JDK 9 while sun.misc and other critical internal APIs remains to be internal APIs. jdeps -jdkinternals should flag them and get developers? attention to prepare to migrate when the replacements are available. Other than that, looks good. There are so many tests that have @modules java.base sun/misc but unused. It?s good that you clean that up. I agree with Alan that JDK modules depending on jdk.unsupported should get the priority to get eliminated by FC. thanks Mandy From paul.sandoz at oracle.com Fri Apr 8 07:41:30 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 09:41:30 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> Message-ID: Hi Steve, > On 8 Apr 2016, at 03:57, Steve Drach wrote: > > I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. > Is some or all of that really necessary? since the we can specify domain of values. For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. Paul. >> Hi, >> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >> Thanks >> Steve From paul.sandoz at oracle.com Fri Apr 8 08:41:47 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 10:41:47 +0200 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <7809D2A6-9665-458F-B9DB-37A3FD1451EB@intel.com> References: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> <7809D2A6-9665-458F-B9DB-37A3FD1451EB@intel.com> Message-ID: <5B9F9ACA-BCA9-455A-9EA5-59ECEFBFAF7F@oracle.com> Hi Steve, > On 8 Apr 2016, at 00:03, Dohrmann, Steve wrote: > > Hi Paul, > > We would like to have an an API for Intel's 3D XPoint memory sooner than the JDK 10 timeframe and proposed this API because it seems simple enough to consider for JDK 9. As you suggest, we will participate in the Panama discussions in this area. Any additional guidance you have would be appreciated. > e.g. clone/build the panama forest, join the pamana-dev email list, and start asking questions :-) I can send you links etc. off-line if need be. > Just to clarify, it is incidental that the proposed Memory interface has only one method. We see the value of the interface as nominative; a new type that can be passed around to abstract various sources of ByteBuffer memory. > I suspected as much, but would prefer that we gain more experience on what this interface should be, and how it intersects with other efforts, rather than introducing a skeletal version now. I suppose it?s possible for such an interface to extend from IntFunction for compatibility if existing 8 or 9 dependent libraries use IntFunction for abstracting buffer allocation. FWIW at one point i did postulate and prototyped a MemoryRegion class but after some thought and feedback made a hasty retreat :-) > Regarding construction and allocation, our current Memory implementation allocates ByteBuffers by calling the NewDirectByteBuffer JNI function with a pointer to 3D XPoint memory allocated via a supporting native library. Ok, that?s what we thought when some of us had an off-line discussion about this. It slots in quite nicely, and can be easily abstracted by IntFunction i.e. i don?t think there is anything fundamentally stopping you providing something that would work on Java 8 or 9. Is there any documentation on the memory ordering properties of 3D XPoint memory? how would it differ from say normal memory? can one access the memory using AVX instructions? does it support unaligned loads/stores? (i am guessing the latter is yes). (Separately there is also the question of whether this kind of memory is something HotSpot itself could leverage.) > The Linux libraries we have worked with are NVML (https://github.com/pmem/nvml/) and memkind (https://github.com/memkind/memkind). We recently also became aware of the NVM-Direct library (https://github.com/oracle/NVM-Direct). So do you create JNI bindings to NVML? Opportunistically perhaps this is also somewhere Panama might be able to help with, since it will provide good improvements over the current JNI experience. Paul. > We currently don't need our own subclass and return the ByteBuffer returned by the JNI call. > > Thanks, > Steve > From paul.sandoz at oracle.com Fri Apr 8 09:56:05 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 11:56:05 +0200 Subject: RFR 8151706: Update VarHandle implementation to use @Stable arrays Message-ID: Hi, Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151706-VH-form-table-stable/webrev/ Now that @Stable arrays are supported by C1 (thanks Vladimir!) we can switch from the explicit use of MemberName fields in VarForm to a @Stable MemberName[] array. I also took the opportunity to simplify the linking from a VarHandle impl to MemberName[] array, now that the implementation has settled down. This will reduce initialization costs and memory churn. I held off making further improvements for now. For example, VarForm can probably go away (also removing the dependency on ClassValue). A VarHandle instance can directly hold a MemberName[] array whose source reference is statically held on the associated VarHandle implementation. It should also be possible to lazily create MemberName instances as required, rather than aggressively doing so, which may further reduce initialization costs and memory usage in common cases. Paul. From paul.sandoz at oracle.com Fri Apr 8 10:24:08 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 12:24:08 +0200 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> Message-ID: > On 7 Apr 2016, at 19:14, Chris Hegarty wrote: > > Enough technical debt has been paid down that we can now create the new > JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. > This module will initially contain, and export, the sun.misc package, > and will eventually export the sun.reflect package too ( once it has > been sanitized ). The jdk.unsupported module will be present in full JRE > and JDK images. > And in the modular world it?s necessary to explicitly declare a requirement on idk.unsupported. > http://cr.openjdk.java.net/~chegar/8153737/ > https://bugs.openjdk.java.net/browse/JDK-8153737 > +1 An important milestone. Paul. From amy.lu at oracle.com Fri Apr 8 10:40:25 2016 From: amy.lu at oracle.com (Amy Lu) Date: Fri, 8 Apr 2016 18:40:25 +0800 Subject: JDK 9 RFR of JDK-8153722: Mark java/nio/channels/Selector/SelectAndClose.java as intermittently failing Message-ID: <57078A99.2000904@oracle.com> java/nio/channels/Selector/SelectAndClose.java This test is known to fail intermittently (JDK-8152814). This patch is to mark the test accordingly with keyword 'intermittent'. bug: https://bugs.openjdk.java.net/browse/JDK-8153722 webrev: http://cr.openjdk.java.net/~amlu/8153722/webrev.00/ Thanks, Amy --- old/test/java/nio/channels/Selector/SelectAndClose.java 2016-04-08 18:36:17.000000000 +0800 +++ new/test/java/nio/channels/Selector/SelectAndClose.java 2016-04-08 18:36:17.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 5004077 + * @key intermittent * @summary Check blocking of select and close */ From peter.levart at gmail.com Fri Apr 8 10:41:01 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 8 Apr 2016 12:41:01 +0200 Subject: RFR: JDK-8152115 (proxy) Examine performance of dynamic proxy creation Message-ID: <57078ABD.2020906@gmail.com> Hi, With Mandy we have prepared the following patch to restore performance of java.lanf.reflect.Proxy class caching that has regressed with introduction of additional checks that have to be performed due to modules: http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/webrev.05/ Jigsaw changed caching of proxy classes from ClassLoader+interfaces to Module+interfaces to accommodate possible future extension of the API that might take given Module as a parameter. Additional validation of constraints and derivation of dynamic module to host proxy class was performed on the fast path, degrading performance. This change restores the caching back to ClassLoader+interfaces, but also introduces new caching mechanism that allows simple derivation of other coexisting caching schemes that can support possible additions to the Proxy API. The new mechanism also simplifies caching by avoiding the need to reference ClassLoader and interfaces through WeakReference objects. Instead it uses a single ConcurrentHashMap per ClassLoader instance referenced directly from ClassLoader object. The caching API - ClassLoaderValue - is general enough to be used for other purposes where caching per ClassLoader is desired. Currently it is encapsulated as a java.lang.reflect package-private API, but could simply be promoted to a public API in an internal concealed package if desired. Performance of Proxy class caching is back to pre-jigsaw state and even better: http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/ProxyBench.java @Mandy I haven't yet removed the superfluous checking and providing access from dynamic module to the modules/packages of transitive closure of interfaces implemented by proxy class. I think this should be done in a separate issue so that this change doesn't change the semantics of implementation. Regards, Peter From kubota.yuji at gmail.com Fri Apr 8 11:04:49 2016 From: kubota.yuji at gmail.com (KUBOTA Yuji) Date: Fri, 8 Apr 2016 20:04:49 +0900 Subject: PING: RFR: JDK-4347142: Need method to set Password protection to Zip entries In-Reply-To: <56F9A4F4.6040108@oracle.com> References: <56F9A4F4.6040108@oracle.com> Message-ID: Hi Sherman and all, Thank you for all comments about this proposal! Thank Tomoyuki and Stephen for sharing your needs. Thank Bernd for sharing your information. However, I am afraid that AE1 and AE2 may have a risk of patent issue, while "Traditional PKWare encryption" is explicitly free from the risk according to the PKWare documents. Therefore, I think this proposed implementation to support legacy zip specification is meaningful as Tomoyuki said. We got some positive opinions / needs. I am glad if you consider the proposal acceptable for JDK. If this proposed implementation is acceptable, I and Yasumasa will improve it by corresponding to comments which given by Sherman and Stephen. Thanks! Yuji 2016-03-29 6:41 GMT+09:00 Xueming Shen : > Yasumasa > > It's a tricky call. To be honest, as I said at the very beginning, I'm not > sure whether > or not it's a good idea and worth the efffort to push this into the j.u.zip > package to > support the "traditional PKWare encryption", which is known to be "seriously > flawed, > and in particular is vulnerable to known-plaintext attacks" (from wiki), > while I fully > understood it is not a concern in your "problem-free" use scenario. Just > wonder > if there is anyone else on the list that has/had the need for such > encryption feature > in the past. It would be preferred to have more input (agree, disagree) to > make the > final decision. > > Here are some comments regarding the proposed implementation, > > (1) The changes in native code are probably no longer needed. The native > path is > left there for vm directly access. > (2) I'm concerned about the footprint increase for the ZipEntry class (the > proposed > change is adding 3 more fields into the entry class). Given this is > something rarely > needed/used, and we might have hundreds and thousands of zip/jar > entries during > startup/runtime, it might be desired to avoid adding these fields into > ZipEntry class. > A possible alternative to have a dedicated entry class extended from > the ZipEntry > to hold those extra fields and methods, EncryptionZipEntry for example. > So the > proposed encryption support code will not have any impact to the > existing use of > ZipInput/OutputStream/File. > (3) I'm also not comfortable to add the "encryption engine" logic into the > in/deflater > stream classes, while it might be convenient to do so from > implementation point > of view. Given the encryption is something between the raw bites in the > zip file > and the in/deflating layer, it might need an extra layer there, though > I'm not sure > if it's easy to do so. > > The webrev below is what I think might be better for the ZipFile and > ZipOutputStream > to have an extra layer in between to handle the encryption. Not try to test > if it really > works, just throw in the idea for discussion. > > http://cr.openjdk.java.net/~sherman/zencrypt/webrev/ > > No, I did not try the ZIS, the "pushback" stream there might be a little > tricky:-) > > -Sherman > > > On 03/28/2016 02:34 AM, Yasumasa Suenaga wrote: >> >> PING: Could you review it? >> We want to move forward this enhancement. >> >> Thanks, >> >> Yasumasa >> 2016/03/19 22:01 "Yasumasa Suenaga": >> >>> Hi Alan, >>> >>>> I think the main issue here is to decide whether the API >>>> should be extended for encryption or not. >>> >>> We've discussed on the premise that we add the API for supporting ZIP >>> encryption. >>> In this context, Sherman tried to implement AES encryption extending >>> current API. [1] >>> >>> IMHO, ZIP encryption should be implemented as extention of current ZIP >>> API >>> because encryption/decryption will process for each ZIP entries. >>> >>> According to Developers' Guide, guideline for adding new API is TBD. [2] >>> What should I do next? >>> >>> >>> Thanks, >>> >>> Yasumsa >>> >>> >>> [1] >>> >>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-January/037903.html >>> [2] http://openjdk.java.net/guide/changePlanning.html#api >>> >>> >>> On 2016/03/19 0:25, Alan Bateman wrote: >>>> >>>> On 18/03/2016 15:02, Yasumasa Suenaga wrote: >>>>> >>>>> Hi all, >>>>> >>>>> We (including me and Yuji Kubota (ykubota: OpenJDK jdk9 Author)) >>> >>> discussed >>>>> >>>>> about this issue from Nov. 2015. [1] >>>>> We heard several comments and we applied them to our patch. >>>>> >>>>> I have not heard new comment for our latest patch. >>>>> So I send review request for it. Could you review it? >>>>> >>>>> webrev: >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-4347142/webrev.04/ >>>>> >>>>> Usage of new API: >>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-4347142/webrev.04/Test.java >>>> >>>> Yasumasa - I think the main issue here is to decide whether the API >>>> should be extended for encryption or not. If exposing it in the API make >>>> sense then I assume that alternative names to java.util.zip.ZipCryption >>>> needs to be explored. >>>> >>>> -Alan. >>>> > From paul.sandoz at oracle.com Fri Apr 8 12:51:14 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 14:51:14 +0200 Subject: RFR 8151198: VarHandle factory-specific exceptions Message-ID: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> Hi Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151198-VH-factory-exceptions/webrev/ The patch tweaks the specification: 1) noting that factory methods may document additional undeclared exceptions that may be thrown by access methods e.g. IllegalSateException for VarHandles to ByteBuffer for misaligned access. 2) add the throwing of ClassCastException to each method, which i neglected to add when switching from invokeExact to invoke semantics. Paul. From michael.haupt at oracle.com Fri Apr 8 13:37:10 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 8 Apr 2016 15:37:10 +0200 Subject: RFR 8152645 VarHandle lookup access control tests In-Reply-To: <81AC210F-C0C7-4DAA-BAA9-FCCCF89699FB@oracle.com> References: <81AC210F-C0C7-4DAA-BAA9-FCCCF89699FB@oracle.com> Message-ID: Hi Paul, note this is a lower-case review. Thumbs up. I like how the test lucidly documents the access rules, and would applaud an extended test that additionally covers module boundaries. Just as a suggestion, how about using the fact that enum values are technically instances of subclasses of the enum and getting rid of the switches in FieldLookup.lookup/isAccessibleField by replacing the two with overridden methods in each of the enum elements? Switching over "this" just calls for polymorphism, and the default cases are dead code. Admittedly, it's a matter of style. :-) Best, Michael > Am 07.04.2016 um 11:07 schrieb Paul Sandoz : > > Hi, > > Please review a test to verify access control of looking up fields using a VarHandle: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8152645-VH-access-control/webrev/ > > For completeness i also added tests for MH as i could not find any such existing tests. > > > Further follow on work might be to test lookup to fields across module boundaries. > > Paul. -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From michael.haupt at oracle.com Fri Apr 8 14:10:23 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 8 Apr 2016 16:10:23 +0200 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style In-Reply-To: References: Message-ID: <32003C66-4DCC-492B-8383-48CF35CA0073@oracle.com> Hi Paul, note this is a lower-case review. Thumbs up, with one remarks (no new webrev required IMO). * VarHandle.java: static initialiser of AccessMode, comment: // Initial capacity of # values will is sufficient to avoid resizes -> remove "will" Best, Michael > Am 07.04.2016 um 15:39 schrieb Paul Sandoz : > > Hi, > > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ > > I was persuaded (in internal CCC review) to change the enum VarHandle.AccessMode constant names to conform to the expected Java style. > > Previously, for convenience, the names corresponded exactly with the VH sig-poly method names. > > Most of the patch is just refactoring. > > I have added two new methods to translate to/from the sig-poly method name domain: > > 1175 /** > 1176 * Returns the {@code VarHandle} signature-polymorphic method name > 1177 * associated with this {@code AccessMode} value > 1178 * > 1179 * @return the signature-polymorphic method name > 1180 * @see #valueFromMethodName > 1181 */ > 1182 public String methodName() { > 1183 return methodName; > 1184 } > 1185 > 1186 /** > 1187 * Returns the {@code AccessMode} value associated with the specified > 1188 * {@code VarHandle} signature-polymorphic method name. > 1189 * > 1190 * @param methodName the signature-polymorphic method name > 1191 * @return the {@code AccessMode} value > 1192 * @throws IllegalArgumentException if there is no {@code AccessMode} > 1193 * value associated with method name (indicating the method > 1194 * name does not correspond to a {@code VarHandle} > 1195 * signature-polymorphic method name). > 1196 * @see #methodName > 1197 */ > 1198 public static AccessMode valueFromMethodName(String methodName) { > 1199 AccessMode am = methodNameToAccessMode.get(methodName); > 1200 if (am != null) return am; > 1201 throw new IllegalArgumentException("No AccessMode value for method name " + methodName); > 1202 } > > Paul. > -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From michael.haupt at oracle.com Fri Apr 8 14:11:51 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 8 Apr 2016 16:11:51 +0200 Subject: RFR 8151706: Update VarHandle implementation to use @Stable arrays In-Reply-To: References: Message-ID: Hi Paul, note this is a lower-case review. Having looked at 8151705, thumbs up for this one as well - they go hand in hand and looking at one of them only doesn't feel right. :-) Best, Michael > Am 08.04.2016 um 11:56 schrieb Paul Sandoz : > > Hi, > > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151706-VH-form-table-stable/webrev/ > > Now that @Stable arrays are supported by C1 (thanks Vladimir!) we can switch from the explicit use of MemberName fields in VarForm to a @Stable MemberName[] array. > > I also took the opportunity to simplify the linking from a VarHandle impl to MemberName[] array, now that the implementation has settled down. This will reduce initialization costs and memory churn. > > > I held off making further improvements for now. For example, VarForm can probably go away (also removing the dependency on ClassValue). A VarHandle instance can directly hold a MemberName[] array whose source reference is statically held on the associated VarHandle implementation. It should also be possible to lazily create MemberName instances as required, rather than aggressively doing so, which may further reduce initialization costs and memory usage in common cases. > > Paul. -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From aleksey.shipilev at oracle.com Fri Apr 8 14:23:42 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 8 Apr 2016 17:23:42 +0300 Subject: RFR 8151706: Update VarHandle implementation to use @Stable arrays In-Reply-To: References: Message-ID: <5707BEEE.5050207@oracle.com> On 04/08/2016 12:56 PM, Paul Sandoz wrote: > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151706-VH-form-table-stable/webrev/ > > > Now that @Stable arrays are supported by C1 (thanks Vladimir!) we > can switch from the explicit use of MemberName fields in VarForm to a > @Stable MemberName[] array. Yes, glad to see that abomination gone. I've checked C1 and C2 performance against our battery of VarHandle microbenchmarks, and there were no regressions. So, +1. Thanks, -Aleksey From peter.levart at gmail.com Fri Apr 8 14:31:32 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 8 Apr 2016 16:31:32 +0200 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> Message-ID: <5707C0C4.1070209@gmail.com> On 04/08/2016 12:24 PM, Paul Sandoz wrote: >> On 7 Apr 2016, at 19:14, Chris Hegarty wrote: >> >> Enough technical debt has been paid down that we can now create the new >> JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. >> This module will initially contain, and export, the sun.misc package, >> and will eventually export the sun.reflect package too ( once it has >> been sanitized ). The jdk.unsupported module will be present in full JRE >> and JDK images. >> > And in the modular world it?s necessary to explicitly declare a requirement on idk.unsupported. Will jdk.unsupported be "required public" by java.se? Will you have to explicitly -addmodule jdk.unsupported for class-path programs too? Regards, Peter > >> http://cr.openjdk.java.net/~chegar/8153737/ >> https://bugs.openjdk.java.net/browse/JDK-8153737 >> > +1 > > An important milestone. > > Paul. From aleksey.shipilev at oracle.com Fri Apr 8 14:35:12 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 8 Apr 2016 17:35:12 +0300 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style In-Reply-To: References: Message-ID: <5707C1A0.2090408@oracle.com> On 04/07/2016 04:39 PM, Paul Sandoz wrote: > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ Looks good. The performance is OK. -Aleksey From chris.hegarty at oracle.com Fri Apr 8 14:37:39 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 8 Apr 2016 15:37:39 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <5707C0C4.1070209@gmail.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <5707C0C4.1070209@gmail.com> Message-ID: <5707C233.6010509@oracle.com> On 08/04/16 15:31, Peter Levart wrote: > > > On 04/08/2016 12:24 PM, Paul Sandoz wrote: >>> On 7 Apr 2016, at 19:14, Chris Hegarty wrote: >>> >>> Enough technical debt has been paid down that we can now create the new >>> JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. >>> This module will initially contain, and export, the sun.misc package, >>> and will eventually export the sun.reflect package too ( once it has >>> been sanitized ). The jdk.unsupported module will be present in full JRE >>> and JDK images. >>> >> And in the modular world it?s necessary to explicitly declare a >> requirement on idk.unsupported. > > Will jdk.unsupported be "required public" by java.se? No. Since jdk.unsupported will be in the JDK and JRE images, and it exports sun.misc, then it will be available ( see below ). > Will you have to > explicitly -addmodule jdk.unsupported for class-path programs too? Applications running on the class path will be able to access sun.misc without any command line flags, since it is exported. Modular applications, if they wish to use sun.misc, will have to 'require jdk.unsupported'. -Chris. > Regards, Peter > >> >>> http://cr.openjdk.java.net/~chegar/8153737/ >>> https://bugs.openjdk.java.net/browse/JDK-8153737 >>> >> +1 >> >> An important milestone. >> >> Paul. > From aleksey.shipilev at oracle.com Fri Apr 8 14:40:23 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 8 Apr 2016 17:40:23 +0300 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> Message-ID: <5707C2D7.3020206@oracle.com> On 04/08/2016 03:51 PM, Paul Sandoz wrote: > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151198-VH-factory-exceptions/webrev/ > I agree with updates. But have more comments on C/C++ @apiNote-s. Would you like to address them in follow-ups? Notably, getVolatile may be also marked analogous to memory_order_seq_cst, and get/setOpaque may be marked analogous to C/C++ "volatile"-s. And CAS/CAE memory semantics can also be spelled out in terms of std::memory_order. Thanks, -Aleksey From steve.dohrmann at intel.com Fri Apr 8 14:41:40 2016 From: steve.dohrmann at intel.com (Dohrmann, Steve) Date: Fri, 8 Apr 2016 14:41:40 +0000 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <7809D2A6-9665-458F-B9DB-37A3FD1451EB@intel.com> References: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> <7809D2A6-9665-458F-B9DB-37A3FD1451EB@intel.com> Message-ID: Hi Paul, One point I meant to call out in the last message but did not... Consistent with current ByteBuffers, we don't foresee public constructors on any ByteBuffer implementation classes themselves. Public constructors are only proposed for the class that implements the Memory interface with its ByteBuffer factory method. Thanks, Steve On Apr 7, 2016, at 3:03 PM, Dohrmann, Steve > wrote: Hi Paul, We would like to have an an API for Intel's 3D XPoint memory sooner than the JDK 10 timeframe and proposed this API because it seems simple enough to consider for JDK 9. As you suggest, we will participate in the Panama discussions in this area. Any additional guidance you have would be appreciated. Just to clarify, it is incidental that the proposed Memory interface has only one method. We see the value of the interface as nominative; a new type that can be passed around to abstract various sources of ByteBuffer memory. Regarding construction and allocation, our current Memory implementation allocates ByteBuffers by calling the NewDirectByteBuffer JNI function with a pointer to 3D XPoint memory allocated via a supporting native library. The Linux libraries we have worked with are NVML (https://github.com/pmem/nvml/) and memkind (https://github.com/memkind/memkind). We recently also became aware of the NVM-Direct library (https://github.com/oracle/NVM-Direct). We currently don't need our own subclass and return the ByteBuffer returned by the JNI call. Thanks, Steve On Apr 6, 2016, at 4:10 AM, Paul Sandoz > wrote: Hi Steve, My feeling is it?s too premature to introduce a general Memory (region) allocation interface at this moment. What is currently specified can be supported using: IntFunction But i don?t wanna discourage you! this thread has raised some interesting points. Project Panama is gonna take a swing at defining a more general notion of a memory region and the Arrays 2.0 work should support indexes greater than Integer.MAX_VALUE. In this respect I think we should hold off doing anything premature for Java 9 (feature freeze is getting closer), and i encourage you to participate on the Panama lists. ? Here is some context some of which you probably know and some which you might not: - ByteBuffer constructors are deliberately package scoped, as there are some intricate dependencies between the implementations and we want control over who can implement. Any new form of allocation will require changes here (package scoped or otherwise). - current ByteBuffer implementations are either backed by a byte[] (managed or non-direct) or an off-heap allocated (direct) region. At the moment access to both those regions go through separate code paths, but they could be unified using the Unsafe double addressing mode, which should greatly simplify the implementations. I have started making some small steps towards that (JDK-8149469 and JDK-8151163). Even these small steps require careful analysis to evaluate performance across multiple platforms. - VarHandles leverages the Unsafe double addressing mode to support enhanced atomic access to heap or direct ByteBuffers [1], thus the same code is used in both kinds of buffer. ? I am not sure what plans you have for buffer implementations themselves. How do you propose to allocate a ByteBuffer instance that covers a region of 3D XPoint memory? Would it be similar to that of direct buffers, e.g. a variation of DirectByteBuffer, but with different factory constructor code to allocate the memory region within the XPoint memory system and assign the buffer base address to the start of that allocated region? Thanks, Paul. [1] http://cr.openjdk.java.net/~psandoz/jdk9/varhandles/specdiff/java/lang/invoke/MethodHandles-report.html#method:byteBufferViewVarHandle(java.lang.Class, boolean) On 6 Apr 2016, at 03:49, Dohrmann, Steve > wrote: Re: JDK-8153111 Hi, Below are responses to some of the points brought up in the discussion as well as is a little expansion of the reasoning that went into the proposed API. One motivation we saw for doing anything beyond a concrete ByteBuffer class was application code (e.g. Cassandra) that allocates many off-heap ByteBuffers using ByteBuffer#allocateDirect. We reasoned that if the allocation of ByteBuffers could be done using a common memory interface then only the code that provisioned instances of the the memory spaces would have to change in order to switch or mix memory types. We did think of overloading the ByteBuffer#allocateDirect method with memory space info and avoid an allocation interface. We ended up with a separate user called interface scheme because we imagined that extensions of the memory interface would enable new memory functionality that required new methods (e.g. memory transactions for persistence). Without a separate callable interface, the static method space in ByteBuffer might have to change again. For any API In general we saw the need for two things 1) something to represent a memory space from which objects are allocated (a Memory instance) and 2) a broadly usable familiar "anchor" type as the common data object (java.nio.ByteBuffer). The two points for extension with the current proposal are: 1) Constructors on Memory implementation classes -- allow implementors the ability to offer features on the memory space itself (e.g. partitioning, size limits) and 2) future extensions on the Memory interface -- for example PersistentMemory. Regarding a more elaborate scheme for memory space creation -- we did consider a factory scheme for memory object allocation but could not get comfortable with either a) standardized method signatures suitable for various kinds of memory or b) the complexity that something like a general-purpose "spec" format would add, even if we could come up with it. Direct construction does expose more to the user but it seems sufficient and might be the best given what we can say about the future of heterogeneous memory at this point. Regarding the suggested addition of keyed access to ByteBuffers, we are assuming this is only proposed to enable sharing? We thought it might take a while to properly explore the details (i.e. semantics / thread safety / predicable performance) of sharing such that it would work well and maybe even extend well to things like process-shared and cluster-shared ByteBuffers. We elected to propose nothing for JDK 9 beyond what developers can already do with schemes based on e.g. ByteBuffer#duplicate. We were thinking shared buffers could appear later, possibly as an extension of the Memory interface. The keyed access scheme is simple and appealing, however. One question: how is the request method's size parameter to be interpreted? The suggestion of parameterizing the Memory interface bounded by ByteBuffers seems useful as it gives a clean way to support extended ByteBuffers. Not sure if the change of the allocation method name from #allocateByteBuffer to #allocate was incidental or not? Alternates to the "Memory" interface name might be preferred, BufferSupplier is certainly reasonable. We imagined instances that name different memory spaces (e.g. OffHeapRAM) for allocation rather that the role played -- thinking the role is explicit in the allocation method name (allocateByteBuffer). Regarding changing the allocation size parameter to a long, this would be very nice to have. We avoided it in order to match the existing ByteBuffer API. If 64-bit ByteBuffers are planned, sticking with int sizes might have been the wrong call. We are still coming up to speed on VarHandles (JEP 193), atomics for ByteBuffers (JDK-8008240), and ByteBuffer consistency (JDK-6476827). We hope there is continued interest in this proposal and happy to provide a modified patch. Best regards, Steve Dohrmann From Alan.Bateman at oracle.com Fri Apr 8 14:42:27 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 8 Apr 2016 15:42:27 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <5707C0C4.1070209@gmail.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <5707C0C4.1070209@gmail.com> Message-ID: <5707C353.8030902@oracle.com> On 08/04/2016 15:31, Peter Levart wrote: > > Will jdk.unsupported be "required public" by java.se? No because jdk.* are JDK-specific and should never be required by standard modules. > Will you have to explicitly -addmodule jdk.unsupported for class-path > programs too? It exports an API and therefore will be treated as a root module, so no -addmods. If you develop your own module that uses sun.misc.Unsafe then it will of course need to declare its dependency on jdk.unsupported. -Alan. From daniel.fuchs at oracle.com Fri Apr 8 14:52:59 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Fri, 8 Apr 2016 16:52:59 +0200 Subject: RFR: 8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class. Message-ID: <5707C5CB.4090403@oracle.com> Hi, Please find below a patch that slightly modifies the JEP 264 initial implementation to take advantage of the module system. The change modifies the LoggerFinder abstract service to take the Module of the caller class as parameter instead of the caller class itself. The caller class was used in the initial 9/dev implementation because java.lang.reflect.Module was not yet available. http://cr.openjdk.java.net/~dfuchs/jigsaw/webrev_8148568/webrev.01/ best regards, -- daniel From kumar.x.srinivasan at oracle.com Fri Apr 8 15:04:38 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Fri, 08 Apr 2016 08:04:38 -0700 Subject: RFR: 8151901: test/tools/pack200/Pack200Test fails on verifying native unpacked JAR In-Reply-To: <17BABD81-589E-42A0-B5F1-6B3BFE496392@oracle.com> References: <56F0504A.4030204@oracle.com> <17BABD81-589E-42A0-B5F1-6B3BFE496392@oracle.com> Message-ID: <5707C886.6090402@oracle.com> Thanks for the review, but your patches appears to have caused regressions, I will need to look at it this further, when I get some more cycles. Thanks Kumar > Good. > > Please change the comment: > s/null, no tuple change, force recomputation/null, drop ICs attribute, force CP recomputation/ > > Reordering BSMs and ICs should work. > The BSMs may need extra ICs, but ICs cannot depend on BSMs. > I wonder why we did the other order first? I guess because that is what the spec. says. > > Oh, there's a problem with the attribute insertion order logic; it's buggy that we unconditionally > insert a BSMs attr. and then delete it later. (That goes wrong when change<0 and we recompute > from scratch.) > > Suggested amended patch enclosed. > > --- John > > On Mar 21, 2016, at 12:49 PM, Kumar Srinivasan wrote: >> Hi John, >> >> This patch contains fixes for two bugs: >> 8151901: test/tools/pack200/Pack200Test fails on verifying native unpacked JAR >> 8062335: Pack200 Java implementation differs from C version, outputs unused UTF8 for BootstrapMethods Note: The test case exhibits both of the above. >> >> With this the classes produced by java and the native implementation are congruent, >> though the JDK image's classes exhibit these issues, as a precaution I have extracted the >> minimal set of classes to reproduce the issues, into the golden jar. >> >> The webrev is at: >> http://cr.openjdk.java.net/~ksrini/8151901/webrev.00/ >> >> Thanks >> Kumar >> > > > diff --git a/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java b/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java > --- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java > +++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java > @@ -312,6 +312,12 @@ > void setBootstrapMethods(Collection bsms) { > assert(bootstrapMethods == null); // do not do this twice > bootstrapMethods = new ArrayList<>(bsms); > + // Edit the attribute list, if necessary. > + Attribute a = getAttribute(attrBootstrapMethodsEmpty); > + if (bootstrapMethods != null && a == null) > + addAttribute(attrBootstrapMethodsEmpty.canonicalInstance()); > + else if (bootstrapMethods == null && a != null) > + removeAttribute(a); > } > > boolean hasInnerClasses() { > diff --git a/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java > --- a/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java > +++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java > @@ -1193,16 +1193,25 @@ > cls.visitRefs(VRM_CLASSIC, cpRefs); > > ArrayList bsms = new ArrayList<>(); > - /* > - * BootstrapMethod(BSMs) are added here before InnerClasses(ICs), > - * so as to ensure the order. Noting that the BSMs may be > - * removed if they are not found in the CP, after the ICs expansion. > - */ > - cls.addAttribute(Package.attrBootstrapMethodsEmpty.canonicalInstance()); > > // flesh out the local constant pool > ConstantPool.completeReferencesIn(cpRefs, true, bsms); > > + // Add the BSMs and references as required. > + if (!bsms.isEmpty()) { > + // Add the attirbute name to the CP (visitRefs would have wanted this). > + cpRefs.add(Package.getRefString("BootstrapMethods")); > + // The pack-spec requires that BootstrapMethods precedes the InnerClasses attribute. > + // So add BSMs now before running expandLocalICs. > + // But first delete any local InnerClasses attr. (This is rare.) > + List localICs = cls.getInnerClasses(); > + cls.setInnerClasses(null); > + Collections.sort(bsms); > + cls.setBootstrapMethods(bsms); > + // Re-add the ICs, so the attribute lists are in the required order. > + cls.setInnerClasses(localICs); > + } > + > // Now that we know all our local class references, > // compute the InnerClasses attribute. > int changed = cls.expandLocalICs(); > @@ -1221,16 +1230,6 @@ > ConstantPool.completeReferencesIn(cpRefs, true, bsms); > } > > - // remove the attr previously set, otherwise add the bsm and > - // references as required > - if (bsms.isEmpty()) { > - cls.attributes.remove(Package.attrBootstrapMethodsEmpty.canonicalInstance()); > - } else { > - cpRefs.add(Package.getRefString("BootstrapMethods")); > - Collections.sort(bsms); > - cls.setBootstrapMethods(bsms); > - } > - > // construct a local constant pool > int numDoubles = 0; > for (Entry e : cpRefs) { > From chris.hegarty at oracle.com Fri Apr 8 15:22:56 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 8 Apr 2016 16:22:56 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <5706AD94.8030701@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <5706AD94.8030701@oracle.com> Message-ID: <5707CCD0.30005@oracle.com> On 07/04/16 19:57, Alan Bateman wrote: > On 07/04/2016 18:14, Chris Hegarty wrote: >> Enough technical debt has been paid down that we can now create the new >> JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. >> This module will initially contain, and export, the sun.misc package, >> and will eventually export the sun.reflect package too ( once it has >> been sanitized ). The jdk.unsupported module will be present in full JRE >> and JDK images. >> >> http://cr.openjdk.java.net/~chegar/8153737/ > It's great to get to this milestone. > > I looked over the webrev and I don't see any issues. Thanks for the Review. > I'm surprised by > the number of tests that had @modules java.base/sun.misc even though > they aren't using anything in sun.misc. It was surprising to me too. > I see Phil has pushed JDK-8147544 to jdk9/client rather than jdk9/dev so > it means that the module-info.java for java.desktop will need to be > fixed up when it gets to jdk9/dev. Right. I have my eye on that, and will fix it once in jdk9/dev. > I think we should bump the priority of all the issues that cause you to > add `requires jdk.unsupported`we should at least get all of them > resolved by FC as we shouldn't have any standard modules with this > dependence. I bumped the priority, and targeted the issues to 9. -Chris. From chris.hegarty at oracle.com Fri Apr 8 15:35:23 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 8 Apr 2016 16:35:23 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <13C89E01-3396-4EFE-BC35-C289E59DBEED@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <13C89E01-3396-4EFE-BC35-C289E59DBEED@oracle.com> Message-ID: <5707CFBB.8020809@oracle.com> On 08/04/16 03:52, Mandy Chung wrote: > >> On Apr 7, 2016, at 10:14 AM, Chris Hegarty wrote: >> >> Enough technical debt has been paid down that we can now create the new >> JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. >> This module will initially contain, and export, the sun.misc package, >> and will eventually export the sun.reflect package too ( once it has >> been sanitized ). The jdk.unsupported module will be present in full JRE >> and JDK images. >> >> http://cr.openjdk.java.net/~chegar/8153737/ >> https://bugs.openjdk.java.net/browse/JDK-8153737 > > I?m glad to see jdk.unsupported module be created. > > jdeps tests are intended to test references to sun.misc and flagged as internal API. The jdeps test changes should be reverted. > > It?s exported to allow existing applications to continue to run on JDK 9 while sun.misc and other critical internal APIs remains to be internal APIs. jdeps -jdkinternals should flag them and get developers? attention to prepare to migrate when the replacements are available. I moved the tests from a directory named 'jdk.unsupported' to unsupported', as other tests, in test/tools/jdeps/module, use test/tools/jdeps as a test library, and the directory/test lib name is conflicting with the module name. jtreg fails immediately. The updates I made check that jdeps identifies both jdk.internal.misc and sun.misc Unsafe as internal APIs. > Other than that, looks good. Thanks for the Review. > There are so many tests that have @modules java.base sun/misc but unused. It?s good that you clean that up. I agree with Alan that JDK modules depending on jdk.unsupported should get the priority to get eliminated by FC. I bumped the priority, and target the issues to 9. -Chris. From mandy.chung at oracle.com Fri Apr 8 15:48:30 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 8 Apr 2016 08:48:30 -0700 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <5707CFBB.8020809@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <13C89E01-3396-4EFE-BC35-C289E59DBEED@oracle.com> <5707CFBB.8020809@oracle.com> Message-ID: > On Apr 8, 2016, at 8:35 AM, Chris Hegarty wrote: > > > I moved the tests from a directory named 'jdk.unsupported' to > unsupported', as other tests, in test/tools/jdeps/module, use > test/tools/jdeps as a test library, and the directory/test lib > name is conflicting with the module name. jtreg fails immediately. > The updates I made check that jdeps identifies both jdk.internal.misc > and sun.misc Unsafe as internal APIs. Thanks for explaining why you did the rename. Your change now makes sense to me. I may reorganize the jdeps tests to avoid the module name you ran into in the future. All looks good. Mandy From martinrb at google.com Fri Apr 8 15:59:08 2016 From: martinrb at google.com (Martin Buchholz) Date: Fri, 8 Apr 2016 08:59:08 -0700 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: <5707C2D7.3020206@oracle.com> References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> Message-ID: On Fri, Apr 8, 2016 at 7:40 AM, Aleksey Shipilev wrote: > On 04/08/2016 03:51 PM, Paul Sandoz wrote: >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151198-VH-factory-exceptions/webrev/ >> > > I agree with updates. > > But have more comments on C/C++ @apiNote-s. Would you like to address > them in follow-ups? Notably, getVolatile may be also marked analogous to > memory_order_seq_cst, and get/setOpaque may be marked analogous to C/C++ > "volatile"-s. And CAS/CAE memory semantics can also be spelled out in > terms of std::memory_order. I agree with Aleksey. From anthony.vanelverdinghe at gmail.com Fri Apr 8 16:52:56 2016 From: anthony.vanelverdinghe at gmail.com (Anthony Vanelverdinghe) Date: Fri, 8 Apr 2016 18:52:56 +0200 Subject: PING: RFR: JDK-4347142: Need method to set Password protection to Zip entries In-Reply-To: References: <56F9A4F4.6040108@oracle.com> Message-ID: <5707E1E8.9060202@gmail.com> Hi Yuji, Sherman et al. PKWARE's "Strong Encryption Specification" [1] indeed warns about patents, but how/why does this affect Winzip's AE-1 and AE-2 [2]? I don't mind if decryption support is added for the "Traditional Encryption". However, I believe it would be wrong to introduce encryption support for a known-to-be-broken encryption method in the JDK. Using the argument of "it's good enough for our case", I could also argue that Base64 qualifies as an encryption method, or that SSLv2 is an appropriate choice to secure network connections. However, if this is to be added, it should be supported by the zipfs FileSystemProvider as well. The passphrase handler could be passed by a property in the environment, e.g. Function> which would provide the passphrase for a given path, or Optional.empty() if the Path is unencrypted. Kind regards, Anthony [1] https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT [2] http://www.winzip.com/win/en/aes_info.htm On 8/04/2016 13:04, KUBOTA Yuji wrote: > Hi Sherman and all, > > Thank you for all comments about this proposal! > > Thank Tomoyuki and Stephen for sharing your needs. > > Thank Bernd for sharing your information. However, I am > afraid that AE1 and AE2 may have a risk of patent issue, > while "Traditional PKWare encryption" is explicitly free > from the risk according to the PKWare documents. > Therefore, I think this proposed implementation to support > legacy zip specification is meaningful as Tomoyuki said. > > We got some positive opinions / needs. I am glad if you > consider the proposal acceptable for JDK. > If this proposed implementation is acceptable, I and > Yasumasa will improve it by corresponding to comments > which given by Sherman and Stephen. > > Thanks! > Yuji > > 2016-03-29 6:41 GMT+09:00 Xueming Shen : >> Yasumasa >> >> It's a tricky call. To be honest, as I said at the very beginning, I'm not >> sure whether >> or not it's a good idea and worth the efffort to push this into the j.u.zip >> package to >> support the "traditional PKWare encryption", which is known to be "seriously >> flawed, >> and in particular is vulnerable to known-plaintext attacks" (from wiki), >> while I fully >> understood it is not a concern in your "problem-free" use scenario. Just >> wonder >> if there is anyone else on the list that has/had the need for such >> encryption feature >> in the past. It would be preferred to have more input (agree, disagree) to >> make the >> final decision. >> >> Here are some comments regarding the proposed implementation, >> >> (1) The changes in native code are probably no longer needed. The native >> path is >> left there for vm directly access. >> (2) I'm concerned about the footprint increase for the ZipEntry class (the >> proposed >> change is adding 3 more fields into the entry class). Given this is >> something rarely >> needed/used, and we might have hundreds and thousands of zip/jar >> entries during >> startup/runtime, it might be desired to avoid adding these fields into >> ZipEntry class. >> A possible alternative to have a dedicated entry class extended from >> the ZipEntry >> to hold those extra fields and methods, EncryptionZipEntry for example. >> So the >> proposed encryption support code will not have any impact to the >> existing use of >> ZipInput/OutputStream/File. >> (3) I'm also not comfortable to add the "encryption engine" logic into the >> in/deflater >> stream classes, while it might be convenient to do so from >> implementation point >> of view. Given the encryption is something between the raw bites in the >> zip file >> and the in/deflating layer, it might need an extra layer there, though >> I'm not sure >> if it's easy to do so. >> >> The webrev below is what I think might be better for the ZipFile and >> ZipOutputStream >> to have an extra layer in between to handle the encryption. Not try to test >> if it really >> works, just throw in the idea for discussion. >> >> http://cr.openjdk.java.net/~sherman/zencrypt/webrev/ >> >> No, I did not try the ZIS, the "pushback" stream there might be a little >> tricky:-) >> >> -Sherman >> >> >> On 03/28/2016 02:34 AM, Yasumasa Suenaga wrote: >>> PING: Could you review it? >>> We want to move forward this enhancement. >>> >>> Thanks, >>> >>> Yasumasa >>> 2016/03/19 22:01 "Yasumasa Suenaga": >>> >>>> Hi Alan, >>>> >>>>> I think the main issue here is to decide whether the API >>>>> should be extended for encryption or not. >>>> We've discussed on the premise that we add the API for supporting ZIP >>>> encryption. >>>> In this context, Sherman tried to implement AES encryption extending >>>> current API. [1] >>>> >>>> IMHO, ZIP encryption should be implemented as extention of current ZIP >>>> API >>>> because encryption/decryption will process for each ZIP entries. >>>> >>>> According to Developers' Guide, guideline for adding new API is TBD. [2] >>>> What should I do next? >>>> >>>> >>>> Thanks, >>>> >>>> Yasumsa >>>> >>>> >>>> [1] >>>> >>>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-January/037903.html >>>> [2] http://openjdk.java.net/guide/changePlanning.html#api >>>> >>>> >>>> On 2016/03/19 0:25, Alan Bateman wrote: >>>>> On 18/03/2016 15:02, Yasumasa Suenaga wrote: >>>>>> Hi all, >>>>>> >>>>>> We (including me and Yuji Kubota (ykubota: OpenJDK jdk9 Author)) >>>> discussed >>>>>> about this issue from Nov. 2015. [1] >>>>>> We heard several comments and we applied them to our patch. >>>>>> >>>>>> I have not heard new comment for our latest patch. >>>>>> So I send review request for it. Could you review it? >>>>>> >>>>>> webrev: >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-4347142/webrev.04/ >>>>>> >>>>>> Usage of new API: >>>>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-4347142/webrev.04/Test.java >>>>> Yasumasa - I think the main issue here is to decide whether the API >>>>> should be extended for encryption or not. If exposing it in the API make >>>>> sense then I assume that alternative names to java.util.zip.ZipCryption >>>>> needs to be explored. >>>>> >>>>> -Alan. >>>>> From paul.sandoz at oracle.com Fri Apr 8 16:52:57 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 18:52:57 +0200 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> Message-ID: <5E033392-8CB7-4913-BDDD-8CABA772E407@oracle.com> > On 8 Apr 2016, at 17:59, Martin Buchholz wrote: > > On Fri, Apr 8, 2016 at 7:40 AM, Aleksey Shipilev > wrote: >> On 04/08/2016 03:51 PM, Paul Sandoz wrote: >>> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151198-VH-factory-exceptions/webrev/ >>> >> >> I agree with updates. >> >> But have more comments on C/C++ @apiNote-s. Would you like to address >> them in follow-ups? Notably, getVolatile may be also marked analogous to >> memory_order_seq_cst, and get/setOpaque may be marked analogous to C/C++ >> "volatile"-s. And CAS/CAE memory semantics can also be spelled out in >> terms of std::memory_order. > > I agree with Aleksey. No objections, i will follow up using https://bugs.openjdk.java.net/browse/JDK-8153875 Thanks, Paul. From steve.drach at oracle.com Fri Apr 8 16:54:38 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 8 Apr 2016 09:54:38 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> Message-ID: <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> >> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. >> > > Is some or all of that really necessary? since the we can specify domain of values. I think it is. The spec states that one can have an arbitrary amount of leading/trailing spaces in the value part of the attribute. Apparently attribute values could also have ?hidden? characters such as vertical tab or nak for example. I wish the spec was tighter here. I?m merely stating the the domain can be ? *TRUE *? for upper/lower case letters. > > For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. Well then ?Sealed: true? won?t work, but the spec says it should work. I am fine without doing this nonsense, but I think we need to change the spec to make it correct. We could change the definition of "otherchar? to something like this otherchar:=ALPHA EXTALPHANUM* ALPHA:=[A-Z | a-z | _] EXTALPHANUM:=[ALPHA | 0-9 | SPACE] Even this will still allow trailing spaces, so after matching TRUE we?d need to make sure the next char is SPACE, \r, or \n. Other ideas? > > Paul. > >>> Hi, >>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>> Thanks >>> Steve > From paul.sandoz at oracle.com Fri Apr 8 17:30:03 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 8 Apr 2016 19:30:03 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> Message-ID: <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> > On 8 Apr 2016, at 18:54, Steve Drach wrote: > >>> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. >>> >> >> Is some or all of that really necessary? since the we can specify domain of values. > > I think it is. The spec states that one can have an arbitrary amount of leading/trailing spaces in the value part of the attribute. Apparently attribute values could also have ?hidden? characters such as vertical tab or nak for example. I wish the spec was tighter here. I?m merely stating the the domain can be > ? *TRUE *? for upper/lower case letters. > AFAICT the so called ?spec" says nothing about trimming white space from values and although not explicitly called out the actual value has to be what constitutes the character sequence for the ?otherchar" definition (otherwise the continuation space and newline characters would also be part of the actual value and that makes no sense). So it seems you may have quite a bit of wiggle room here :-) and it?s up to each attribute definition to state what constitutes its domain of possible valid values based on ?otherchar?. >> >> For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. > > Well then ?Sealed: true? won?t work, but the spec says it should work. > Where does the ?spec? state that it should? The value is literally the string ? true?, at least in one interpretation of the ?spec? :-) I suspect it?s ok to go with finding ?Multi-Release: true? (lower/upper case) as in your first patch, then check if it is terminated with a newline (and ignore the continuation case) Paul. > I am fine without doing this nonsense, but I think we need to change the spec to make it correct. We could change the definition of "otherchar? to something like this > > otherchar:=ALPHA EXTALPHANUM* > ALPHA:=[A-Z | a-z | _] > EXTALPHANUM:=[ALPHA | 0-9 | SPACE] > > Even this will still allow trailing spaces, so after matching TRUE we?d need to make sure the next char is SPACE, \r, or \n. > > Other ideas? > >> >> Paul. >> >>>> Hi, >>>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >>>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>>> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>>> Thanks >>>> Steve >> > From steve.drach at oracle.com Fri Apr 8 17:54:09 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 8 Apr 2016 10:54:09 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> Message-ID: >>>> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. >>>> >>> >>> Is some or all of that really necessary? since the we can specify domain of values. >> >> I think it is. The spec states that one can have an arbitrary amount of leading/trailing spaces in the value part of the attribute. Apparently attribute values could also have ?hidden? characters such as vertical tab or nak for example. I wish the spec was tighter here. I?m merely stating the the domain can be >> ? *TRUE *? for upper/lower case letters. >> > > AFAICT the so called ?spec" says nothing about trimming white space from values and although not explicitly called out the actual value has to be what constitutes the character sequence for the ?otherchar" definition (otherwise the continuation space and newline characters would also be part of the actual value and that makes no sense). No it doesn?t say you can trim white space, but if one doesn?t, then do we accept ?true?, ? true?, ? true?, etc.? > > So it seems you may have quite a bit of wiggle room here :-) and it?s up to each attribute definition to state what constitutes its domain of possible valid values based on ?other char?. So, we can say *otherchar is upper/lower case ?true? only? > > >>> >>> For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. >> >> Well then ?Sealed: true? won?t work, but the spec says it should work. >> > > Where does the ?spec? state that it should? It really comes down to the interpretation of otherchar. If it can be interpreted on an attribute by attribute basis then it?s not a problem. > > The value is literally the string ? true?, at least in one interpretation of the ?spec? :-) I?m fine with that. And we really should do something about the spec, it?s too loose and ambiguous. > > I suspect it?s ok to go with finding ?Multi-Release: true? (lower/upper case) as in your first patch, then check if it is terminated with a newline (and ignore the continuation case) Okay. I?d like Claes to weigh in because he?s the one who brought it up. He?s traveling today, so I don?t expect to hear from him soon. > > Paul. > > >> I am fine without doing this nonsense, but I think we need to change the spec to make it correct. We could change the definition of "otherchar? to something like this >> >> otherchar:=ALPHA EXTALPHANUM* >> ALPHA:=[A-Z | a-z | _] >> EXTALPHANUM:=[ALPHA | 0-9 | SPACE] >> >> Even this will still allow trailing spaces, so after matching TRUE we?d need to make sure the next char is SPACE, \r, or \n. >> >> Other ideas? >> >>> >>> Paul. >>> >>>>> Hi, >>>>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >>>>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>>>> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>>>> Thanks >>>>> Steve >>> >> > From brian.burkhalter at oracle.com Fri Apr 8 18:12:46 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Fri, 8 Apr 2016 11:12:46 -0700 Subject: JDK 9 RFR of JDK-8153722: Mark java/nio/channels/Selector/SelectAndClose.java as intermittently failing In-Reply-To: <57078A99.2000904@oracle.com> References: <57078A99.2000904@oracle.com> Message-ID: <9CD257C5-C17E-4242-B0D8-8B8292AE5930@oracle.com> [Looping in nio-dev ?] +1 (but you still need Reviewer approval). Brian On Apr 8, 2016, at 3:40 AM, Amy Lu wrote: > java/nio/channels/Selector/SelectAndClose.java > > This test is known to fail intermittently (JDK-8152814). This patch is to mark the test accordingly with keyword 'intermittent'. > > bug: https://bugs.openjdk.java.net/browse/JDK-8153722 > webrev: http://cr.openjdk.java.net/~amlu/8153722/webrev.00/ From claes.redestad at oracle.com Fri Apr 8 18:25:26 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 8 Apr 2016 20:25:26 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> Message-ID: <5707F796.1020001@oracle.com> On 04/08/2016 07:54 PM, Steve Drach wrote: >>>>> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. >>>>> >>>> Is some or all of that really necessary? since the we can specify domain of values. >>> I think it is. The spec states that one can have an arbitrary amount of leading/trailing spaces in the value part of the attribute. Apparently attribute values could also have ?hidden? characters such as vertical tab or nak for example. I wish the spec was tighter here. I?m merely stating the the domain can be >>> ? *TRUE *? for upper/lower case letters. >>> >> AFAICT the so called ?spec" says nothing about trimming white space from values and although not explicitly called out the actual value has to be what constitutes the character sequence for the ?otherchar" definition (otherwise the continuation space and newline characters would also be part of the actual value and that makes no sense). > No it doesn?t say you can trim white space, but if one doesn?t, then do we accept ?true?, ? true?, ? true?, etc.? > >> So it seems you may have quite a bit of wiggle room here :-) and it?s up to each attribute definition to state what constitutes its domain of possible valid values based on ?other char?. > So, we can say *otherchar is upper/lower case ?true? only? > >> >>>> For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. >>> Well then ?Sealed: true? won?t work, but the spec says it should work. >>> >> Where does the ?spec? state that it should? > It really comes down to the interpretation of otherchar. If it can be interpreted on an attribute by attribute basis then it?s not a problem. > >> The value is literally the string ? true?, at least in one interpretation of the ?spec? :-) > I?m fine with that. And we really should do something about the spec, it?s too loose and ambiguous. > >> I suspect it?s ok to go with finding ?Multi-Release: true? (lower/upper case) as in your first patch, then check if it is terminated with a newline (and ignore the continuation case) > Okay. I?d like Claes to weigh in because he?s the one who brought it up. He?s traveling today, so I don?t expect to hear from him soon. Yeah, I'm guilty of raising the silly question of whether or not accepting untrimmed true is OK according to spec. With a generous interpretation and the presence of prior art (Sealed) I think it's OK to go back to the first version of the patch (with the addition to check that Multi-Release: true is followed by a LF, CR or the end of the manifest) and add a similar note to the spec/notes that Multi-Release has the same value restrictions as Sealed. Perhaps both cases should be clarified in the notes to say that leading/trailing whitespace is not accepted, since that isn't directly obvious to a casual reader. Thanks! /Claes > >> Paul. >> >> >>> I am fine without doing this nonsense, but I think we need to change the spec to make it correct. We could change the definition of "otherchar? to something like this >>> >>> otherchar:=ALPHA EXTALPHANUM* >>> ALPHA:=[A-Z | a-z | _] >>> EXTALPHANUM:=[ALPHA | 0-9 | SPACE] >>> >>> Even this will still allow trailing spaces, so after matching TRUE we?d need to make sure the next char is SPACE, \r, or \n. >>> >>> Other ideas? >>> >>>> Paul. >>>> >>>>>> Hi, >>>>>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >>>>>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>>>>> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>>>>> Thanks >>>>>> Steve From joe.darcy at oracle.com Fri Apr 8 18:34:43 2016 From: joe.darcy at oracle.com (joe darcy) Date: Fri, 8 Apr 2016 11:34:43 -0700 Subject: JDK 9 RFR of JDK-8153722: Mark java/nio/channels/Selector/SelectAndClose.java as intermittently failing In-Reply-To: <9CD257C5-C17E-4242-B0D8-8B8292AE5930@oracle.com> References: <57078A99.2000904@oracle.com> <9CD257C5-C17E-4242-B0D8-8B8292AE5930@oracle.com> Message-ID: <5707F9C3.20800@oracle.com> Looks fine Amy; thanks, -Joe On 4/8/2016 11:12 AM, Brian Burkhalter wrote: > [Looping in nio-dev ?] > > +1 (but you still need Reviewer approval). > > Brian > > On Apr 8, 2016, at 3:40 AM, Amy Lu wrote: > >> java/nio/channels/Selector/SelectAndClose.java >> >> This test is known to fail intermittently (JDK-8152814). This patch is to mark the test accordingly with keyword 'intermittent'. >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8153722 >> webrev: http://cr.openjdk.java.net/~amlu/8153722/webrev.00/ From steve.drach at oracle.com Fri Apr 8 18:34:59 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 8 Apr 2016 11:34:59 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <5707F796.1020001@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> <5707F796.1020001@oracle.com> Message-ID: <0C847855-E030-4658-B3CA-6D990D348D97@oracle.com> Okay, I?ll prepare a new webrev. I think all we need to check for after ?true? is \r or \n. If the manifest just ends without at least one of those, it?s not a legal manifest. > On Apr 8, 2016, at 11:25 AM, Claes Redestad wrote: > > On 04/08/2016 07:54 PM, Steve Drach wrote: >>>>>> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. >>>>>> >>>>> Is some or all of that really necessary? since the we can specify domain of values. >>>> I think it is. The spec states that one can have an arbitrary amount of leading/trailing spaces in the value part of the attribute. Apparently attribute values could also have ?hidden? characters such as vertical tab or nak for example. I wish the spec was tighter here. I?m merely stating the the domain can be >>>> ? *TRUE *? for upper/lower case letters. >>>> >>> AFAICT the so called ?spec" says nothing about trimming white space from values and although not explicitly called out the actual value has to be what constitutes the character sequence for the ?otherchar" definition (otherwise the continuation space and newline characters would also be part of the actual value and that makes no sense). >> No it doesn?t say you can trim white space, but if one doesn?t, then do we accept ?true?, ? true?, ? true?, etc.? >> >>> So it seems you may have quite a bit of wiggle room here :-) and it?s up to each attribute definition to state what constitutes its domain of possible valid values based on ?other char?. >> So, we can say *otherchar is upper/lower case ?true? only? >> >>> >>>>> For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. >>>> Well then ?Sealed: true? won?t work, but the spec says it should work. >>>> >>> Where does the ?spec? state that it should? >> It really comes down to the interpretation of otherchar. If it can be interpreted on an attribute by attribute basis then it?s not a problem. >> >>> The value is literally the string ? true?, at least in one interpretation of the ?spec? :-) >> I?m fine with that. And we really should do something about the spec, it?s too loose and ambiguous. >> >>> I suspect it?s ok to go with finding ?Multi-Release: true? (lower/upper case) as in your first patch, then check if it is terminated with a newline (and ignore the continuation case) >> Okay. I?d like Claes to weigh in because he?s the one who brought it up. He?s traveling today, so I don?t expect to hear from him soon. > > Yeah, I'm guilty of raising the silly question of whether or not accepting untrimmed true is OK according to spec. > > With a generous interpretation and the presence of prior art (Sealed) I think it's OK to go back to the first version of the patch (with the addition to check that Multi-Release: true is followed by a LF, CR or the end of the manifest) and add a similar note to the spec/notes that Multi-Release has the same value restrictions as Sealed. > > Perhaps both cases should be clarified in the notes to say that leading/trailing whitespace is not accepted, since that isn't directly obvious to a casual reader. > > Thanks! > > /Claes > >> >>> Paul. >>> >>> >>>> I am fine without doing this nonsense, but I think we need to change the spec to make it correct. We could change the definition of "otherchar? to something like this >>>> >>>> otherchar:=ALPHA EXTALPHANUM* >>>> ALPHA:=[A-Z | a-z | _] >>>> EXTALPHANUM:=[ALPHA | 0-9 | SPACE] >>>> >>>> Even this will still allow trailing spaces, so after matching TRUE we?d need to make sure the next char is SPACE, \r, or \n. >>>> >>>> Other ideas? >>>> >>>>> Paul. >>>>> >>>>>>> Hi, >>>>>>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >>>>>>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>>>>>> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>>>>>> Thanks >>>>>>> Steve From hboehm at google.com Fri Apr 8 18:39:40 2016 From: hboehm at google.com (Hans Boehm) Date: Fri, 8 Apr 2016 11:39:40 -0700 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> Message-ID: I didn't previously have the impression that get/setOpaque was analogous to just C/C++ volatile. C volatile officially has nothing to do with threads and does not prevent undefined behavior for data races. It does not in general guarantee single-copy atomicity. (It can't, since it can be applied to arbitrary structs.) Whether or not it guarantees any sort of ordering (e.g. with respect to IO devices) is unclear if you go by the spec. Most platforms have decided it does not. But this is not 100% consistent and, in my personal opinion, it's not the most natural reading of the standard. It arguably doesn't guarantee cache coherence, i.e. single variable ordering, since it's unrelated to threads. (This isn't the cleanest state of affairs, or one to be emullated. It's also probably not fixable, since each platform does generally have a well-defined notion of what "volatile" means; they're just not entirely consistent.) My prior impression was that Opaque was intended to be similar to a C++ memory_order_relaxed access to a variable that is declared as both atomic and volatile, with the unordered interpretation of C++ "volatile". I.e. accesses are guaranteed single-copy-atomic (even for long and double), must result in a sequence of load and store instructions that exactly reflect the naive semantics (a property NOT guaranteed for C++ memory_order_seq_cst accesses or Java volatiles, but guaranteed for C volatiles). Accesses are guaranteed to be "cache coherent", i.e. access to a single variable appear to occur in a single total order. I am not sure that my prior impression reflects the true intent. But I'm currently quite confused as to what the intended semantics of "opaque" really are. The spec eeds to be clearer about single-copy atomicity and cache-coherence properties. And probably about the fact that the guarantees here are incomparable to volatile accesses, i.e. stronger in some respects, and weaker in others. On Fri, Apr 8, 2016 at 8:59 AM, Martin Buchholz wrote: > On Fri, Apr 8, 2016 at 7:40 AM, Aleksey Shipilev > wrote: > > On 04/08/2016 03:51 PM, Paul Sandoz wrote: > >> > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151198-VH-factory-exceptions/webrev/ > >> < > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151198-VH-factory-exceptions/webrev/ > > > > > > I agree with updates. > > > > But have more comments on C/C++ @apiNote-s. Would you like to address > > them in follow-ups? Notably, getVolatile may be also marked analogous to > > memory_order_seq_cst, and get/setOpaque may be marked analogous to C/C++ > > "volatile"-s. And CAS/CAE memory semantics can also be spelled out in > > terms of std::memory_order. > > I agree with Aleksey. > From mandy.chung at oracle.com Fri Apr 8 18:48:02 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 8 Apr 2016 11:48:02 -0700 Subject: Review request 8153665: URLClassLoader.definePackage() not throwing expected IAE Message-ID: The spec of java.lang.Package and ClassLoader::definePackage have been changed in jdk-9+111 such that Package objects are defined per class loader and no longer inspect what packages are defined in the class loader hierarchy. The spec of URLClassLoader::definePackage(String name, Manifest man, URL url) should also be changed accordingly. Webrev at: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153665/webrev.00/ Mandy From aleksey.shipilev at oracle.com Fri Apr 8 18:57:23 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 8 Apr 2016 21:57:23 +0300 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> Message-ID: <5707FF13.9090306@oracle.com> On 04/08/2016 09:39 PM, Hans Boehm wrote: > I didn't previously have the impression that get/setOpaque was analogous > to just C/C++ volatile. C volatile officially has nothing to do with > threads and does not prevent undefined behavior for data races. It does > not in general guarantee single-copy atomicity. Yes, Opaque does not imply memory ordering either. > My prior impression was that Opaque was intended to be similar to a C++ > memory_order_relaxed access to a variable that is declared as both > atomic and volatile, with the unordered interpretation of C++ > "volatile". Yes, that seems to be the intended semantics; sorry for the confusion. Let's have this discussion when Paul submits the follow-up fix for https://bugs.openjdk.java.net/browse/JDK-8153875; I linked your reply there. Some cross-check against what is implemented in C1 and C2 would be required at that point. Thanks, -Aleksey From steve.drach at oracle.com Fri Apr 8 19:23:58 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 8 Apr 2016 12:23:58 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <0C847855-E030-4658-B3CA-6D990D348D97@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> <5707F796.1020001@oracle.com> <0C847855-E030-4658-B3CA-6D990D348D97@oracle.com> Message-ID: <59EB84D0-EF17-4849-9024-0C76A7442E81@oracle.com> The new webrev is http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html and the issue is https://bugs.openjdk.java.net/browse/JDK-8153213 Now the value ?true? followed by either ?\r? or ?\n? is the only acceptable value. > On Apr 8, 2016, at 11:34 AM, Steve Drach wrote: > > Okay, I?ll prepare a new webrev. I think all we need to check for after ?true? is \r or \n. If the manifest just ends without at least one of those, it?s not a legal manifest. > >> On Apr 8, 2016, at 11:25 AM, Claes Redestad wrote: >> >> On 04/08/2016 07:54 PM, Steve Drach wrote: >>>>>>> I?ve put up a new webrev that addresses the issue of having spaces before (and after) the value ?true? in the Multi-Release attribute. >>>>>>> >>>>>> Is some or all of that really necessary? since the we can specify domain of values. >>>>> I think it is. The spec states that one can have an arbitrary amount of leading/trailing spaces in the value part of the attribute. Apparently attribute values could also have ?hidden? characters such as vertical tab or nak for example. I wish the spec was tighter here. I?m merely stating the the domain can be >>>>> ? *TRUE *? for upper/lower case letters. >>>>> >>>> AFAICT the so called ?spec" says nothing about trimming white space from values and although not explicitly called out the actual value has to be what constitutes the character sequence for the ?otherchar" definition (otherwise the continuation space and newline characters would also be part of the actual value and that makes no sense). >>> No it doesn?t say you can trim white space, but if one doesn?t, then do we accept ?true?, ? true?, ? true?, etc.? >>> >>>> So it seems you may have quite a bit of wiggle room here :-) and it?s up to each attribute definition to state what constitutes its domain of possible valid values based on ?other char?. >>> So, we can say *otherchar is upper/lower case ?true? only? >>> >>>> >>>>>> For example, the Sealed attribute can take on a value of ?true? or ?false? (case ignored), but there is no white space trimming. >>>>> Well then ?Sealed: true? won?t work, but the spec says it should work. >>>>> >>>> Where does the ?spec? state that it should? >>> It really comes down to the interpretation of otherchar. If it can be interpreted on an attribute by attribute basis then it?s not a problem. >>> >>>> The value is literally the string ? true?, at least in one interpretation of the ?spec? :-) >>> I?m fine with that. And we really should do something about the spec, it?s too loose and ambiguous. >>> >>>> I suspect it?s ok to go with finding ?Multi-Release: true? (lower/upper case) as in your first patch, then check if it is terminated with a newline (and ignore the continuation case) >>> Okay. I?d like Claes to weigh in because he?s the one who brought it up. He?s traveling today, so I don?t expect to hear from him soon. >> >> Yeah, I'm guilty of raising the silly question of whether or not accepting untrimmed true is OK according to spec. >> >> With a generous interpretation and the presence of prior art (Sealed) I think it's OK to go back to the first version of the patch (with the addition to check that Multi-Release: true is followed by a LF, CR or the end of the manifest) and add a similar note to the spec/notes that Multi-Release has the same value restrictions as Sealed. >> >> Perhaps both cases should be clarified in the notes to say that leading/trailing whitespace is not accepted, since that isn't directly obvious to a casual reader. >> >> Thanks! >> >> /Claes >> >>> >>>> Paul. >>>> >>>> >>>>> I am fine without doing this nonsense, but I think we need to change the spec to make it correct. We could change the definition of "otherchar? to something like this >>>>> >>>>> otherchar:=ALPHA EXTALPHANUM* >>>>> ALPHA:=[A-Z | a-z | _] >>>>> EXTALPHANUM:=[ALPHA | 0-9 | SPACE] >>>>> >>>>> Even this will still allow trailing spaces, so after matching TRUE we?d need to make sure the next char is SPACE, \r, or \n. >>>>> >>>>> Other ideas? >>>>> >>>>>> Paul. >>>>>> >>>>>>>> Hi, >>>>>>>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >>>>>>>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>>>>>>> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>>>>>>> Thanks >>>>>>>> Steve > From mandy.chung at oracle.com Fri Apr 8 19:45:22 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 8 Apr 2016 12:45:22 -0700 Subject: RFR: JDK-8152115 (proxy) Examine performance of dynamic proxy creation In-Reply-To: <57078ABD.2020906@gmail.com> References: <57078ABD.2020906@gmail.com> Message-ID: <8C64613C-10A1-4CBD-94E5-1C44EFADCBBC@oracle.com> > On Apr 8, 2016, at 3:41 AM, Peter Levart wrote: > > Hi, > > With Mandy we have prepared the following patch to restore performance of java.lanf.reflect.Proxy class caching that has regressed with introduction of additional checks that have to be performed due to modules: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/webrev.05/ > Thanks for taking this on and further improving the performance. With this patch, existing code could move to newProxyInstance and remove any code to cache Proxy classes for performance reason. The change looks quite good. Minor comments below. I like ClassLoaderValue idea that per-class loader proxy classes and dynamic modules are cached there that allows them to be GC?ed together. ClassLoaderValue might be useful for some other area and when those are identified, we could consider moving it to jdk.internal. The javadoc of ClassLoaderValue has references to root-ClassLoaderValue and sub-ClassLoaderValue. Sub is an inner class in AbstractClassLoaderValue. Should it be be ClassLoaderValue.Sub? They are minor points as this is for proxy use only. Something we could look into when we want to move it out from package scope. AbstractClassLoaderValue.java 263 ? BootLoader.getClassLoaderValueMap() 264 : JLA.createOrGetClassLoaderValueMap(cl) Nit: I generally like ?-ternary indent to the right below the test. Proxy.java 376 private static Constructor getProxyConstructor(Class caller, // null if no SecurityManager 377 ClassLoader loader, 378 Class... interfaces) 379 throws IllegalArgumentException 380 { IAE is an unchecked exception that does not need to be declared. I realized it?s pre-existing code. While you are on it, it can be taken out. The informal javadoc for getProxyConstructor would be helpful. So the comment next to the caller parameter would be moved to the javadoc. 384 if (caller != null) { 385 checkProxyAccess(caller, loader, intf); 386 } The conditional check (caller != null) is not needed since checkProxyAccess and checkNewProxyPermission are nop if security manager is not present. Same also applies to line 986. 532 return Boolean.TRUE.equals( 533 reverseProxyCache.sub(c).get(c.getClassLoader())); Maybe Objects::equals that checks == first. Driver.java 28 * @bug 8152115 29 * @summary functional and concurrency test for ClassLoaderValue The convention we use to move @bug and @summary after @test. It?d be good to move them up. > > @Mandy > > I haven't yet removed the superfluous checking and providing access from dynamic module to the modules/packages of transitive closure of interfaces implemented by proxy class. I think this should be done in a separate issue so that this change doesn't change the semantics of implementation. > I agree better to separate this as a different issue. Perhaps I can take that one since I?d like to do more testing before pushing it. Mandy From Alan.Bateman at oracle.com Fri Apr 8 19:54:09 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 8 Apr 2016 20:54:09 +0100 Subject: Review request 8153665: URLClassLoader.definePackage() not throwing expected IAE In-Reply-To: References: Message-ID: <57080C61.7050202@oracle.com> On 08/04/2016 19:48, Mandy Chung wrote: > The spec of java.lang.Package and ClassLoader::definePackage have been changed in jdk-9+111 such that Package objects are defined per class loader and no longer inspect what packages are defined in the class loader hierarchy. > > The spec of URLClassLoader::definePackage(String name, Manifest man, URL url) should also be changed accordingly. > > Webrev at: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153665/webrev.00/ > This looks fine. For the SplitPackage test then you could use @library to use CompilerUtils and drop the compile method. -Alan From mandy.chung at oracle.com Fri Apr 8 20:26:04 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 8 Apr 2016 13:26:04 -0700 Subject: RFR: 8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class. In-Reply-To: <5707C5CB.4090403@oracle.com> References: <5707C5CB.4090403@oracle.com> Message-ID: <27D6B566-3E8D-4E9A-8807-71294ABB3685@oracle.com> > On Apr 8, 2016, at 7:52 AM, Daniel Fuchs wrote: > > Hi, > > Please find below a patch that slightly modifies > the JEP 264 initial implementation to take advantage > of the module system. > > The change modifies the LoggerFinder abstract service > to take the Module of the caller class as parameter > instead of the caller class itself. > The caller class was used in the initial 9/dev implementation > because java.lang.reflect.Module was not yet available. > > http://cr.openjdk.java.net/~dfuchs/jigsaw/webrev_8148568/webrev.01/ Using the Module as the caller granularity is reasonable here to find the resource bundle. DefaultLoggerFinder.java 135 static boolean isSystem(Module m) { 136 ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { This isSystem method should check if the class loader is platform class loader (ClassLoader::getPlatformClassLoader) or its ancestor. There are several copies of this method. Better to have one single copy of this method shared for other classes to use? Nit: you can use the diamond operation PrivilegedAction<>. LazyLoggers.java. line 294 return new LazyLoggerAccessor(name, factories, module); I spot several long lines in LogManager.java, Logger.java, System.java and tests, maybe other files. It?d be good if you can wrap the lines to help side-by-side review. Other that that, looks good. Mandy From huizhe.wang at oracle.com Fri Apr 8 20:49:23 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Fri, 08 Apr 2016 13:49:23 -0700 Subject: RFR JDK 9 (JAXP) 8151162: Public entries not searched when prefer='system' Message-ID: <57081953.6000807@oracle.com> Hi, Please review a fix for the issue that caused public entries not being searched when prefer='system'. When prefer='system', the Catalog standard only required that public entries were not searched if there is a system identifier. I added tests to reflect a combination of the settings of prefer, identifier(s), and entry types (public and/or system). The test "matchWithPrefer" covered the three test cases in the JCK mentioned in the bug report plus 9 other scenarios, while "resolveWithPrefer" covered 18 resolution scenarios by a CatalogResolver. JBS: https://bugs.openjdk.java.net/browse/JDK-8151162 Webrev: http://cr.openjdk.java.net/~joehw/jdk9/8151162/webrev/ Thanks, Joe From mandy.chung at oracle.com Fri Apr 8 21:14:57 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 8 Apr 2016 14:14:57 -0700 Subject: Review request 8153665: URLClassLoader.definePackage() not throwing expected IAE In-Reply-To: <57080C61.7050202@oracle.com> References: <57080C61.7050202@oracle.com> Message-ID: > On Apr 8, 2016, at 12:54 PM, Alan Bateman wrote: > > On 08/04/2016 19:48, Mandy Chung wrote: >> The spec of java.lang.Package and ClassLoader::definePackage have been changed in jdk-9+111 such that Package objects are defined per class loader and no longer inspect what packages are defined in the class loader hierarchy. >> >> The spec of URLClassLoader::definePackage(String name, Manifest man, URL url) should also be changed accordingly. >> >> Webrev at: >> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153665/webrev.00/ >> > This looks fine. For the SplitPackage test then you could use @library to use CompilerUtils and drop the compile method. I could. Then I would have to move the .class files around. It compiles a given source directory but I wanted to compile source files from the same directory in a different destination. I could update the test either way. Mandy From brent.christian at oracle.com Fri Apr 8 21:23:50 2016 From: brent.christian at oracle.com (Brent Christian) Date: Fri, 08 Apr 2016 14:23:50 -0700 Subject: RFR 8153123 : Streamline StackWalker code In-Reply-To: <5706EE60.3010901@oracle.com> References: <5702FC9B.7020600@oracle.com> <57064352.5010800@oracle.com> <5706EE60.3010901@oracle.com> Message-ID: <57082166.1030500@oracle.com> On 04/07/2016 04:33 PM, Brent Christian wrote: > I will send: > http://cr.openjdk.java.net/~bchristi/8153123/webrev.02/ > to hs-rt shortly. ...after adding the following :) diff -r f628b87a6067 makefiles/symbols/symbols-unix --- a/makefiles/symbols/symbols-unix Fri Apr 08 13:14:23 2016 +0200 +++ b/makefiles/symbols/symbols-unix Fri Apr 08 12:22:14 2016 -0700 @@ -58,7 +58,6 @@ JVM_DumpAllStacks JVM_DumpThreads JVM_FillInStackTrace -JVM_FillStackFrames JVM_FindClassFromCaller JVM_FindClassFromClass JVM_FindLibraryEntry @@ -169,7 +168,6 @@ JVM_ResumeThread JVM_SetArrayElement JVM_SetClassSigners -JVM_SetMethodInfo JVM_SetNativeThreadName JVM_SetPrimitiveArrayElement JVM_SetThreadPriority @@ -178,6 +176,7 @@ JVM_StopThread JVM_SupportsCX8 JVM_SuspendThread +JVM_ToStackTraceElement JVM_TotalMemory JVM_UnloadLibrary JVM_Yield From mandy.chung at oracle.com Fri Apr 8 22:29:30 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 8 Apr 2016 15:29:30 -0700 Subject: Review request 8153665: URLClassLoader.definePackage() not throwing expected IAE In-Reply-To: References: <57080C61.7050202@oracle.com> Message-ID: Updated the test to use CompileUtils that is simple and clean: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153665/webrev.01/ Mandy From kedar.mhaswade at gmail.com Fri Apr 8 22:36:52 2016 From: kedar.mhaswade at gmail.com (kedar mhaswade) Date: Fri, 8 Apr 2016 15:36:52 -0700 Subject: Expecting Integer.valueOf(String) to accept Literal format ... Message-ID: While discussing with colleagues, someone said: However, my main gripe is about not supporting in String representation of > an integer what is supported in its literal representation. > Thus, Integer x = 1_000_000; is valid, whereas > Integer.valueOf("1_000_000") is not. That sucks. It seems to me that this is a reasonable expectation and has practical benefits (e.g. accepting program arguments that are integers with _'s). Supporting underscores in number literals (beginning JDK 7) was meant for readability of the ? ? Java source ? ? code. ?Perhaps doing this correctly incurs unwarranted implementation complexity in the JDK.? As library writers however, how would you explain this mismatch? ? ? Was this side effect ?(arguably so) ? considered at all? Regards, Kedar From aph at redhat.com Sat Apr 9 09:06:11 2016 From: aph at redhat.com (Andrew Haley) Date: Sat, 9 Apr 2016 10:06:11 +0100 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: Message-ID: <5708C603.8060300@redhat.com> On 08/04/16 23:36, kedar mhaswade wrote: > As library writers however, how would you explain this mismatch? Changing valueOf(String) runs the risk of breaking existing Java code, and Java takes compatibility very seriously. Whether it's worth the risk is a matter of judgement. Andrew. From me at noctarius.com Sat Apr 9 11:33:49 2016 From: me at noctarius.com (Christoph Engelbert) Date: Sat, 9 Apr 2016 13:33:49 +0200 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: <5708C603.8060300@redhat.com> References: <5708C603.8060300@redhat.com> Message-ID: <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Hey Andrew, Not sure it would risk breaking compatibility. It?s fairly easy to support it by just replacing underscore before parsing. Do you think of code that is expected to not parse underscore arguments? I think it?s a fair request to support underscore based integer representations, even though I never needed it yet, anyhow it makes sense to me to give users the possibility to have the same integer representation in, let?s say, properties files. Chris > On 09 Apr 2016, at 11:06, Andrew Haley wrote: > > On 08/04/16 23:36, kedar mhaswade wrote: >> As library writers however, how would you explain this mismatch? > > Changing valueOf(String) runs the risk of breaking existing Java code, > and Java takes compatibility very seriously. Whether it's worth the > risk is a matter of judgement. > > Andrew. > From dl at cs.oswego.edu Sat Apr 9 12:24:48 2016 From: dl at cs.oswego.edu (Doug Lea) Date: Sat, 9 Apr 2016 08:24:48 -0400 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> Message-ID: <5708F490.60106@cs.oswego.edu> On 04/08/2016 02:39 PM, Hans Boehm wrote: > My prior impression was that Opaque was intended to be similar to a C++ > memory_order_relaxed access to a variable that is declared as both atomic > and volatile, with the unordered interpretation of C++ "volatile". Yes. This is awkward to spell out in detail, but surely there is some way to say it that is more illuminating than confusing. Especially since the implementation on all known processors is straightforward -- reading/writing (all bits atomically) in program order. -Doug From vitalyd at gmail.com Sat Apr 9 13:03:50 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Sat, 9 Apr 2016 09:03:50 -0400 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: <5708F490.60106@cs.oswego.edu> References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> <5708F490.60106@cs.oswego.edu> Message-ID: Just to confirm - opaque is also a compiler fence right? C++ relaxed doesn't require compiler fence, but it sounds like opaque does. Would be good to clarify this, unless "program order" is the way you want to do that. On Saturday, April 9, 2016, Doug Lea
wrote: > On 04/08/2016 02:39 PM, Hans Boehm wrote: > > My prior impression was that Opaque was intended to be similar to a C++ >> memory_order_relaxed access to a variable that is declared as both atomic >> and volatile, with the unordered interpretation of C++ "volatile". >> > > Yes. This is awkward to spell out in detail, but surely there is > some way to say it that is more illuminating than confusing. > Especially since the implementation on all known processors > is straightforward -- reading/writing (all bits atomically) in program > order. > > -Doug > > > -- Sent from my phone From aph at redhat.com Sat Apr 9 13:33:59 2016 From: aph at redhat.com (Andrew Haley) Date: Sat, 9 Apr 2016 14:33:59 +0100 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Message-ID: <570904C7.8070703@redhat.com> On 04/09/2016 12:33 PM, Christoph Engelbert wrote: > Not sure it would risk breaking compatibility. It?s fairly easy to > support it by just replacing underscore before parsing. Do you think > of code that is expected to not parse underscore arguments? Yes. > I think it?s a fair request to support underscore based integer > representations, even though I never needed it yet, anyhow it makes > sense to me to give users the possibility to have the same integer > representation in, let?s say, properties files. Code which rejects underscores in strings today would not reject underscores if this were changed. This is a change which is visible to applications. Andrew. From dl at cs.oswego.edu Sat Apr 9 14:05:34 2016 From: dl at cs.oswego.edu (Doug Lea) Date: Sat, 9 Apr 2016 10:05:34 -0400 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> <5708F490.60106@cs.oswego.edu> Message-ID: <57090C2E.1040301@cs.oswego.edu> On 04/09/2016 09:03 AM, Vitaly Davidovich wrote: > Just to confirm - opaque is also a compiler fence right? C++ relaxed doesn't > require compiler fence, but it sounds like opaque does. Would be good to > clarify this, unless "program order" is the way you want to do that. > "Program order" normally requires a compiler fence. Most people don't know what a compiler fence is though, and it is not especially easy to define. So I don't think this would help. -Doug > On Saturday, April 9, 2016, Doug Lea
> wrote: > > On 04/08/2016 02:39 PM, Hans Boehm wrote: > > My prior impression was that Opaque was intended to be similar to a C++ > memory_order_relaxed access to a variable that is declared as both atomic > and volatile, with the unordered interpretation of C++ "volatile". > > > Yes. This is awkward to spell out in detail, but surely there is > some way to say it that is more illuminating than confusing. > Especially since the implementation on all known processors > is straightforward -- reading/writing (all bits atomically) in program order. > > -Doug > > > > > -- > Sent from my phone From vitalyd at gmail.com Sat Apr 9 14:15:40 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Sat, 9 Apr 2016 10:15:40 -0400 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: <57090C2E.1040301@cs.oswego.edu> References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> <5708F490.60106@cs.oswego.edu> <57090C2E.1040301@cs.oswego.edu> Message-ID: The issue with "program order" is it may confuse people, particularly ones that don't know what a compiler fence is, into thinking it implies CPU fences as well (they may not know those either, perhaps). You'd need to define program order anyway for them. IMHO, I'd rather see compiler fence used in description rather some more general notion; most people using this API will understand compiler fence, no need to make it more abstract. On Saturday, April 9, 2016, Doug Lea
wrote: > On 04/09/2016 09:03 AM, Vitaly Davidovich wrote: > >> Just to confirm - opaque is also a compiler fence right? C++ relaxed >> doesn't >> require compiler fence, but it sounds like opaque does. Would be good to >> clarify this, unless "program order" is the way you want to do that. >> >> > "Program order" normally requires a compiler fence. > Most people don't know what a compiler fence is though, and > it is not especially easy to define. So I don't think this would > help. > > -Doug > > > On Saturday, April 9, 2016, Doug Lea
> > wrote: >> >> On 04/08/2016 02:39 PM, Hans Boehm wrote: >> >> My prior impression was that Opaque was intended to be similar to >> a C++ >> memory_order_relaxed access to a variable that is declared as >> both atomic >> and volatile, with the unordered interpretation of C++ "volatile". >> >> >> Yes. This is awkward to spell out in detail, but surely there is >> some way to say it that is more illuminating than confusing. >> Especially since the implementation on all known processors >> is straightforward -- reading/writing (all bits atomically) in >> program order. >> >> -Doug >> >> >> >> >> -- >> Sent from my phone >> > > -- Sent from my phone From headius at headius.com Sat Apr 9 14:44:08 2016 From: headius at headius.com (Charles Oliver Nutter) Date: Sat, 9 Apr 2016 09:44:08 -0500 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Message-ID: I feel like this is an obvious API gap that should be fixed. If it is a valid syntax in javac, it should be a valid syntax in JDK APIs. My first impression was that this was an obvious oversight. - Charlie (mobile) On Apr 9, 2016 21:04, "Christoph Engelbert" wrote: > Hey Andrew, > > Not sure it would risk breaking compatibility. It?s fairly easy to support > it by just replacing underscore before parsing. Do you think of code that > is expected to not parse underscore arguments? I think it?s a fair request > to support underscore based integer representations, even though I never > needed it yet, anyhow it makes sense to me to give users the possibility to > have the same integer representation in, let?s say, properties files. > > Chris > > > On 09 Apr 2016, at 11:06, Andrew Haley wrote: > > > > On 08/04/16 23:36, kedar mhaswade wrote: > >> As library writers however, how would you explain this mismatch? > > > > Changing valueOf(String) runs the risk of breaking existing Java code, > > and Java takes compatibility very seriously. Whether it's worth the > > risk is a matter of judgement. > > > > Andrew. > > > > From vitalyd at gmail.com Sat Apr 9 14:51:01 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Sat, 9 Apr 2016 10:51:01 -0400 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Message-ID: I don't think the risk of breaking existing code in such a common API is worth the slight convenience improvement. If someone is keen on supporting such things, they can front this API by replacing underscores themselves, or more generally have something else accept underscores and canonicalize to what Integer.valueOf expects. On Saturday, April 9, 2016, Charles Oliver Nutter wrote: > I feel like this is an obvious API gap that should be fixed. If it is a > valid syntax in javac, it should be a valid syntax in JDK APIs. My first > impression was that this was an obvious oversight. > > - Charlie (mobile) > On Apr 9, 2016 21:04, "Christoph Engelbert" > wrote: > > > Hey Andrew, > > > > Not sure it would risk breaking compatibility. It?s fairly easy to > support > > it by just replacing underscore before parsing. Do you think of code that > > is expected to not parse underscore arguments? I think it?s a fair > request > > to support underscore based integer representations, even though I never > > needed it yet, anyhow it makes sense to me to give users the possibility > to > > have the same integer representation in, let?s say, properties files. > > > > Chris > > > > > On 09 Apr 2016, at 11:06, Andrew Haley > > wrote: > > > > > > On 08/04/16 23:36, kedar mhaswade wrote: > > >> As library writers however, how would you explain this mismatch? > > > > > > Changing valueOf(String) runs the risk of breaking existing Java code, > > > and Java takes compatibility very seriously. Whether it's worth the > > > risk is a matter of judgement. > > > > > > Andrew. > > > > > > > > -- Sent from my phone From headius at headius.com Sat Apr 9 14:56:16 2016 From: headius at headius.com (Charles Oliver Nutter) Date: Sat, 9 Apr 2016 09:56:16 -0500 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Message-ID: What are you breaking though? Text that would not parse before will now parse as a valid integer in an extremely narrow set of cases. It is *exactly* the same as code that would not compile before compiling now, but at a different phase of development. And guess what...you're going to get this report over, and over, and over... - Charlie (mobile) On Apr 9, 2016 22:51, "Vitaly Davidovich" wrote: > I don't think the risk of breaking existing code in such a common API is > worth the slight convenience improvement. If someone is keen on supporting > such things, they can front this API by replacing underscores themselves, > or more generally have something else accept underscores and canonicalize > to what Integer.valueOf expects. > > On Saturday, April 9, 2016, Charles Oliver Nutter > wrote: > >> I feel like this is an obvious API gap that should be fixed. If it is a >> valid syntax in javac, it should be a valid syntax in JDK APIs. My first >> impression was that this was an obvious oversight. >> >> - Charlie (mobile) >> On Apr 9, 2016 21:04, "Christoph Engelbert" wrote: >> >> > Hey Andrew, >> > >> > Not sure it would risk breaking compatibility. It?s fairly easy to >> support >> > it by just replacing underscore before parsing. Do you think of code >> that >> > is expected to not parse underscore arguments? I think it?s a fair >> request >> > to support underscore based integer representations, even though I never >> > needed it yet, anyhow it makes sense to me to give users the >> possibility to >> > have the same integer representation in, let?s say, properties files. >> > >> > Chris >> > >> > > On 09 Apr 2016, at 11:06, Andrew Haley wrote: >> > > >> > > On 08/04/16 23:36, kedar mhaswade wrote: >> > >> As library writers however, how would you explain this mismatch? >> > > >> > > Changing valueOf(String) runs the risk of breaking existing Java code, >> > > and Java takes compatibility very seriously. Whether it's worth the >> > > risk is a matter of judgement. >> > > >> > > Andrew. >> > > >> > >> > >> > > > -- > Sent from my phone > From amaembo at gmail.com Sat Apr 9 15:22:01 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Sat, 9 Apr 2016 21:22:01 +0600 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Message-ID: <1436377801.20160409212201@gmail.com> Strictly speaking there are many more ways to specify integer constant in Java. Like int x = 045; int x = 0x34; int x = 0b11101; So why should we support "4_5_6" only, but not "0x456"? Note that "045" is already parsed by Integer.valueOf, but as decimal number, not as octal. Thus I don't think that being valid syntax in Java language should be considered as a reason here. Also note that there are more integer parsing methods like Scanner.nextInt() and so on. I feel that they should provide consistent behavior with Integer.valueOf(). However changes in Scanner might break even more existing code. With best regards, Tagir Valeev. CON> I feel like this is an obvious API gap that should be fixed. If it is a CON> valid syntax in javac, it should be a valid syntax in JDK APIs. My first CON> impression was that this was an obvious oversight. CON> - Charlie (mobile) CON> On Apr 9, 2016 21:04, "Christoph Engelbert" wrote: >> Hey Andrew, >> >> Not sure it would risk breaking compatibility. It?s fairly easy to support >> it by just replacing underscore before parsing. Do you think of code that >> is expected to not parse underscore arguments? I think it?s a fair request >> to support underscore based integer representations, even though I never >> needed it yet, anyhow it makes sense to me to give users the possibility to >> have the same integer representation in, let?s say, properties files. >> >> Chris >> >> > On 09 Apr 2016, at 11:06, Andrew Haley wrote: >> > >> > On 08/04/16 23:36, kedar mhaswade wrote: >> >> As library writers however, how would you explain this mismatch? >> > >> > Changing valueOf(String) runs the risk of breaking existing Java code, >> > and Java takes compatibility very seriously. Whether it's worth the >> > risk is a matter of judgement. >> > >> > Andrew. >> > >> >> From hboehm at google.com Sat Apr 9 16:17:24 2016 From: hboehm at google.com (Hans Boehm) Date: Sat, 9 Apr 2016 09:17:24 -0700 Subject: RFR 8151198: VarHandle factory-specific exceptions In-Reply-To: References: <42A7827C-7C5E-4EF1-993F-E0CEF2A99DC2@oracle.com> <5707C2D7.3020206@oracle.com> <5708F490.60106@cs.oswego.edu> <57090C2E.1040301@cs.oswego.edu> Message-ID: Compiler fence with respect to all other memory accesses? Opaque and volatile accesses? It sounds like, unlike volatile, this doesn't support the equivalent of synchronization elimination. An opaque access to a thread private location still has visible effects beyond an ordinary access? We've established that it implies single-copy atomicity. What about cache coherence? On Sat, Apr 9, 2016 at 7:15 AM, Vitaly Davidovich wrote: > The issue with "program order" is it may confuse people, particularly ones > that don't know what a compiler fence is, into thinking it implies CPU > fences as well (they may not know those either, perhaps). You'd need to > define program order anyway for them. IMHO, I'd rather see compiler fence > used in description rather some more general notion; most people using this > API will understand compiler fence, no need to make it more abstract. > > On Saturday, April 9, 2016, Doug Lea
wrote: > > > On 04/09/2016 09:03 AM, Vitaly Davidovich wrote: > > > >> Just to confirm - opaque is also a compiler fence right? C++ relaxed > >> doesn't > >> require compiler fence, but it sounds like opaque does. Would be good > to > >> clarify this, unless "program order" is the way you want to do that. > >> > >> > > "Program order" normally requires a compiler fence. > > Most people don't know what a compiler fence is though, and > > it is not especially easy to define. So I don't think this would > > help. > > > > -Doug > > > > > > On Saturday, April 9, 2016, Doug Lea
>> > wrote: > >> > >> On 04/08/2016 02:39 PM, Hans Boehm wrote: > >> > >> My prior impression was that Opaque was intended to be similar > to > >> a C++ > >> memory_order_relaxed access to a variable that is declared as > >> both atomic > >> and volatile, with the unordered interpretation of C++ > "volatile". > >> > >> > >> Yes. This is awkward to spell out in detail, but surely there is > >> some way to say it that is more illuminating than confusing. > >> Especially since the implementation on all known processors > >> is straightforward -- reading/writing (all bits atomically) in > >> program order. > >> > >> -Doug > >> > >> > >> > >> > >> -- > >> Sent from my phone > >> > > > > > > -- > Sent from my phone > From ecki at zusammenkunft.net Sat Apr 9 16:25:29 2016 From: ecki at zusammenkunft.net (Bernd Eckenfels) Date: Sat, 9 Apr 2016 18:25:29 +0200 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: <1436377801.20160409212201@gmail.com> References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> <1436377801.20160409212201@gmail.com> Message-ID: <20160409182529.00002006.ecki@zusammenkunft.net> Hello, actually Integer.decode is used to parse JLS Integers. And its JavaDoc explicitely state that it does not support underscores. I would have changed that method, not the valueOf. I think there are some legit cases where changing the behavior of valueOf can cause problems. It is (unfortunatelly) often used to verify the format of a number (instead of retrieving its value). And if this verificationsuddenly gets more lenient it might let numbers pass which makes problems in other (possibly non-java) places. Gruss Bernd Am Sat, 9 Apr 2016 21:22:01 +0600 schrieb "Tagir F. Valeev" : > Strictly speaking there are many more ways to specify integer constant > in Java. Like > > int x = 045; > int x = 0x34; > int x = 0b11101; > > So why should we support "4_5_6" only, but not "0x456"? Note that > "045" is already parsed by Integer.valueOf, but as decimal number, not > as octal. Thus I don't think that being valid syntax in Java language > should be considered as a reason here. > > Also note that there are more integer parsing methods like > Scanner.nextInt() and so on. I feel that they should provide > consistent behavior with Integer.valueOf(). However changes in Scanner > might break even more existing code. > > With best regards, > Tagir Valeev. > > CON> I feel like this is an obvious API gap that should be fixed. If > CON> it is a valid syntax in javac, it should be a valid syntax in > CON> JDK APIs. My first impression was that this was an obvious > CON> oversight. > > CON> - Charlie (mobile) > CON> On Apr 9, 2016 21:04, "Christoph Engelbert" > CON> wrote: > > >> Hey Andrew, > >> > >> Not sure it would risk breaking compatibility. It?s fairly easy to > >> support it by just replacing underscore before parsing. Do you > >> think of code that is expected to not parse underscore arguments? > >> I think it?s a fair request to support underscore based integer > >> representations, even though I never needed it yet, anyhow it > >> makes sense to me to give users the possibility to have the same > >> integer representation in, let?s say, properties files. > >> > >> Chris > >> > >> > On 09 Apr 2016, at 11:06, Andrew Haley wrote: > >> > > >> > On 08/04/16 23:36, kedar mhaswade wrote: > >> >> As library writers however, how would you explain this mismatch? > >> > > >> > Changing valueOf(String) runs the risk of breaking existing Java > >> > code, and Java takes compatibility very seriously. Whether it's > >> > worth the risk is a matter of judgement. > >> > > >> > Andrew. > >> > > >> > >> > From joe.darcy at oracle.com Sat Apr 9 16:44:50 2016 From: joe.darcy at oracle.com (joe darcy) Date: Sat, 9 Apr 2016 09:44:50 -0700 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> Message-ID: <57093182.1080108@oracle.com> The Project Coin team did file JDK-6863378: Project Coin: Consider library support for underscores in numbers and binary literals https://bugs.openjdk.java.net/browse/JDK-6863378 back before JDK 7 shipped. This change in question wouldn't be unreasonable, but it didn't seem critical either, hence the bug was filed and left open to gauge interest, which generally has been slight. Cheers, -Joe On 4/9/2016 7:44 AM, Charles Oliver Nutter wrote: > I feel like this is an obvious API gap that should be fixed. If it is a > valid syntax in javac, it should be a valid syntax in JDK APIs. My first > impression was that this was an obvious oversight. > > - Charlie (mobile) > On Apr 9, 2016 21:04, "Christoph Engelbert" wrote: > >> Hey Andrew, >> >> Not sure it would risk breaking compatibility. It?s fairly easy to support >> it by just replacing underscore before parsing. Do you think of code that >> is expected to not parse underscore arguments? I think it?s a fair request >> to support underscore based integer representations, even though I never >> needed it yet, anyhow it makes sense to me to give users the possibility to >> have the same integer representation in, let?s say, properties files. >> >> Chris >> >>> On 09 Apr 2016, at 11:06, Andrew Haley wrote: >>> >>> On 08/04/16 23:36, kedar mhaswade wrote: >>>> As library writers however, how would you explain this mismatch? >>> Changing valueOf(String) runs the risk of breaking existing Java code, >>> and Java takes compatibility very seriously. Whether it's worth the >>> risk is a matter of judgement. >>> >>> Andrew. >>> >> From chris.hegarty at oracle.com Sat Apr 9 22:19:37 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Sat, 9 Apr 2016 23:19:37 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> Message-ID: This change has been pushed to jdk9/dev. The hotspot gatekeeper will bring it down into the hotspot forests. -Chris. > On 7 Apr 2016, at 18:14, Chris Hegarty wrote: > > Enough technical debt has been paid down that we can now create the new > JDK-specific module as proposed by JEP 260 [1], named jdk.unsupported. > This module will initially contain, and export, the sun.misc package, > and will eventually export the sun.reflect package too ( once it has > been sanitized ). The jdk.unsupported module will be present in full JRE > and JDK images. > > http://cr.openjdk.java.net/~chegar/8153737/ > https://bugs.openjdk.java.net/browse/JDK-8153737 > > Summary of the changes: > > - Restructure, what remains of, the sources in sun/misc to reflect the > new modular layout. There are still a few non-Critical APIs in sun.misc > that will be addressed later. > > - Add dependencies from several JDK modules to jdk.unsupported. All > dependencies have issues tracking them, and should be removed in 9. > > - The test library in the top-level repo provides a convenience to > tests to retrieve Unsafe. This has been updated to the "real" internal > Unsafe, so there are many many tests that require to be updated, mostly > the @modules tags. ( The Unsafe dependency in the library should > probably be revisited at some point, as it requires many tests, not > wishing to use Unsafe, to require an explicit dependency on it ) > > Note: with recent work from Mikael [2], sun.misc.Unsafe is now just a > delegate for the "real" internal Unsafe, so it is time to move the > tests to use it directly. > > - Cleanup any tests unnecessarily/incorrectly declaring a dependency > on sun.misc ( this could have been unnecessarily added, been refactored > out at one point, or the library upon which the tests depends refactored, > that the dependency is no longer required ). I'm sure further cleanup > could be done, but this is sufficient for now. > > - A small number of test in hotspot/test/compiler/unsafe, which are > generated, have been updated, along with the generation script, to > depend on jdk.unsupported/sun.misc ( they explicitly test the sun.misc > version ) > > All 'core', 'pit', and 'hotspot' testsets have been successfully run on > Mac, Linux, Windows, and Solaris. > > -Chris. > > [1] https://bugs.openjdk.java.net/browse/JDK-8132928 > [2] https://bugs.openjdk.java.net/browse/JDK-8149159 From claes.redestad at oracle.com Sun Apr 10 04:36:03 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Sun, 10 Apr 2016 06:36:03 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <59EB84D0-EF17-4849-9024-0C76A7442E81@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> <5707F796.1020001@oracle.com> <0C847855-E030-4658-B3CA-6D990D348D97@oracle.com> <59EB84D0-EF17-4849-9024-0C76A7442E81@oracle.com> Message-ID: <5709D833.607@oracle.com> Hi Steve, checking that there's a newline after the true seems OK according to the grammar[1], so that seems like a good call. Not sure it really matters, but perhaps setting isMultiRelease to true once the test passes improves readability: if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) { int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC); if (i != -1) { i += MULTIRELEASE_CHARS.length; if (i < b.length) { byte c = b[i]; if (c == '\r' || c == '\n') { isMultiRelease = true; } } } } For completeness, maybe we should also check that the value is not part of a continuation: // Check that the value is followed by a // newline and does not have a continuation if ((c == '\r' || c == '\n') && (i + 1 == b.length || b[i + 1] != ' ')) { isMultiRelease = true; } Thanks! /Claes [1] http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Name-Value_pairs_and_Sections On 2016-04-08 21:23, Steve Drach wrote: > The new webrev is > http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html > > and the issue is https://bugs.openjdk.java.net/browse/JDK-8153213 > > Now the value ?true? followed by either ?\r? or ?\n? is the only > acceptable value. > >> On Apr 8, 2016, at 11:34 AM, Steve Drach > > wrote: >> >> Okay, I?ll prepare a new webrev. I think all we need to check for >> after ?true? is \r or \n. If the manifest just ends without at least >> one of those, it?s not a legal manifest. >> >>> On Apr 8, 2016, at 11:25 AM, Claes Redestad >>> > wrote: >>> >>> On 04/08/2016 07:54 PM, Steve Drach wrote: >>>>>>>> I?ve put up a new webrev that addresses the issue of having >>>>>>>> spaces before (and after) the value ?true? in the Multi-Release >>>>>>>> attribute. >>>>>>>> >>>>>>> Is some or all of that really necessary? since the we can >>>>>>> specify domain of values. >>>>>> I think it is. The spec states that one can have an arbitrary >>>>>> amount of leading/trailing spaces in the value part of the >>>>>> attribute. Apparently attribute values could also have ?hidden? >>>>>> characters such as vertical tab or nak for example. I wish the >>>>>> spec was tighter here. I?m merely stating the the domain can be >>>>>> ? *TRUE *? for upper/lower case letters. >>>>>> >>>>> AFAICT the so called ?spec" says nothing about trimming white >>>>> space from values and although not explicitly called out the >>>>> actual value has to be what constitutes the character sequence for >>>>> the ?otherchar" definition (otherwise the continuation space and >>>>> newline characters would also be part of the actual value and that >>>>> makes no sense). >>>> No it doesn?t say you can trim white space, but if one doesn?t, >>>> then do we accept ?true?, ? true?, ? true?, etc.? >>>> >>>>> So it seems you may have quite a bit of wiggle room here :-) and >>>>> it?s up to each attribute definition to state what constitutes its >>>>> domain of possible valid values based on ?other char?. >>>> So, we can say *otherchar is upper/lower case ?true? only? >>>> >>>>> >>>>>>> For example, the Sealed attribute can take on a value of ?true? >>>>>>> or ?false? (case ignored), but there is no white space trimming. >>>>>> Well then ?Sealed: true? won?t work, but the spec says it >>>>>> should work. >>>>>> >>>>> Where does the ?spec? state that it should? >>>> It really comes down to the interpretation of otherchar. If it can >>>> be interpreted on an attribute by attribute basis then it?s not a >>>> problem. >>>> >>>>> The value is literally the string ? true?, at least in one >>>>> interpretation of the ?spec? :-) >>>> I?m fine with that. And we really should do something about the >>>> spec, it?s too loose and ambiguous. >>>> >>>>> I suspect it?s ok to go with finding ?Multi-Release: true? >>>>> (lower/upper case) as in your first patch, then check if it is >>>>> terminated with a newline (and ignore the continuation case) >>>> Okay. I?d like Claes to weigh in because he?s the one who brought >>>> it up. He?s traveling today, so I don?t expect to hear from him soon. >>> >>> Yeah, I'm guilty of raising the silly question of whether or not >>> accepting untrimmed true is OK according to spec. >>> >>> With a generous interpretation and the presence of prior art >>> (Sealed) I think it's OK to go back to the first version of the >>> patch (with the addition to check that Multi-Release: true is >>> followed by a LF, CR or the end of the manifest) and add a similar >>> note to the spec/notes that Multi-Release has the same value >>> restrictions as Sealed. >>> >>> Perhaps both cases should be clarified in the notes to say that >>> leading/trailing whitespace is not accepted, since that isn't >>> directly obvious to a casual reader. >>> >>> Thanks! >>> >>> /Claes >>> >>>> >>>>> Paul. >>>>> >>>>> >>>>>> I am fine without doing this nonsense, but I think we need to >>>>>> change the spec to make it correct. We could change the >>>>>> definition of "otherchar? to something like this >>>>>> >>>>>> otherchar:=ALPHA EXTALPHANUM* >>>>>> ALPHA:=[A-Z | a-z | _] >>>>>> EXTALPHANUM:=[ALPHA | 0-9 | SPACE] >>>>>> >>>>>> Even this will still allow trailing spaces, so after matching >>>>>> TRUE we?d need to make sure the next char is SPACE, \r, or \n. >>>>>> >>>>>> Other ideas? >>>>>> >>>>>>> Paul. >>>>>>> >>>>>>>>> Hi, >>>>>>>>> Please review this simple fix to require that the jar manifest >>>>>>>>> Multi-Release attribute has a value of ?true" in order to be >>>>>>>>> effective, i.e. to assert the jar is a multi-release jar. >>>>>>>>> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >>>>>>>>> >>>>>>>>> webrev: >>>>>>>>> http://cr.openjdk.java.net/~sdrach/8153213/webrev/index.html >>>>>>>>> >>>>>>>>> >>>>>>>> > >>>>>>>>> Thanks >>>>>>>>> Steve >> > From claes.redestad at oracle.com Sun Apr 10 06:05:37 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Sun, 10 Apr 2016 08:05:37 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <5709D833.607@oracle.com> References: <9765B51F-66C8-4273-8166-2AFB56BE9786@oracle.com> <9958CBEB-2966-42EF-B849-08FCEB4DABD1@oracle.com> <9F33E050-1566-40B6-8B10-E23F2A33D1B4@oracle.com> <5707F796.1020001@oracle.com> <0C847855-E030-4658-B3CA-6D990D348D97@oracle.com> <59EB84D0-EF17-4849-9024-0C76A7442E81@oracle.com> <5709D833.607@oracle.com> Message-ID: <5709ED31.2000707@oracle.com> On 2016-04-10 06:36, Claes Redestad wrote: > For completeness, maybe we should also check that the value is not > part of a continuation: > > // Check that the value is followed by a > // newline and does not have a continuation > if ((c == '\r' || c == '\n') && > (i + 1 == b.length || b[i + 1] != > ' ')) { > isMultiRelease = true; > } Scratch that, this would fail to check for \r\n followed by space, thus incomplete. /Claes From sean.coffey at oracle.com Sun Apr 10 13:41:39 2016 From: sean.coffey at oracle.com (Sean Coffey) Date: Sun, 10 Apr 2016 14:41:39 +0100 Subject: RFR: 8149450: LdapCtx.processReturnCode() throwing Null Pointer Exception Message-ID: <570A5813.9080905@oracle.com> Looking to fix this issue. Better checks for the referrrals field. bugID : https://bugs.openjdk.java.net/browse/JDK-8149450 webrev : http://cr.openjdk.java.net/~coffeys/webrev.8149450.jdk9/webrev/ regards, Sean. From xuelei.fan at oracle.com Sun Apr 10 15:03:42 2016 From: xuelei.fan at oracle.com (Xuelei Fan) Date: Sun, 10 Apr 2016 23:03:42 +0800 Subject: RFR: 8149450: LdapCtx.processReturnCode() throwing Null Pointer Exception In-Reply-To: <570A5813.9080905@oracle.com> References: <570A5813.9080905@oracle.com> Message-ID: <570A6B4E.5060402@oracle.com> Looks fine to me. Thanks, Xuelei On 4/10/2016 9:41 PM, Sean Coffey wrote: > Looking to fix this issue. Better checks for the referrrals field. > > bugID : https://bugs.openjdk.java.net/browse/JDK-8149450 > webrev : http://cr.openjdk.java.net/~coffeys/webrev.8149450.jdk9/webrev/ > > regards, > Sean. From peter.levart at gmail.com Sun Apr 10 18:59:10 2016 From: peter.levart at gmail.com (Peter Levart) Date: Sun, 10 Apr 2016 20:59:10 +0200 Subject: RFR: JDK-8152115 (proxy) Examine performance of dynamic proxy creation In-Reply-To: <8C64613C-10A1-4CBD-94E5-1C44EFADCBBC@oracle.com> References: <57078ABD.2020906@gmail.com> <8C64613C-10A1-4CBD-94E5-1C44EFADCBBC@oracle.com> Message-ID: <570AA27E.3070009@gmail.com> Hi Mandy, On 04/08/2016 09:45 PM, Mandy Chung wrote: >> On Apr 8, 2016, at 3:41 AM, Peter Levart wrote: >> >> Hi, >> >> With Mandy we have prepared the following patch to restore performance of java.lanf.reflect.Proxy class caching that has regressed with introduction of additional checks that have to be performed due to modules: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/webrev.05/ >> > Thanks for taking this on and further improving the performance. With this patch, existing code could move to newProxyInstance and remove any code to cache Proxy classes for performance reason. > > The change looks quite good. Minor comments below. > > I like ClassLoaderValue idea that per-class loader proxy classes and dynamic modules are cached there that allows them to be GC?ed together. ClassLoaderValue might be useful for some other area and when those are identified, we could consider moving it to jdk.internal. > > The javadoc of ClassLoaderValue has references to root-ClassLoaderValue and sub-ClassLoaderValue. Sub is an inner class in AbstractClassLoaderValue. Should it be be ClassLoaderValue.Sub? They are minor points as this is for proxy use only. Something we could look into when we want to move it out from package scope. In one of previous iterations, the abstract class was ClassLoaderValue and the two concrete subclasses were ClassLoaderValue.Root and ClassLoadeValue.Sub. In such arrangement, the types were called: ClassLoaderValue.Root clv = ....; ClassLoaderValue.Root.Sub.Sub clv_k12 = clv.sub(k1).sub(k2); In webrev.05, I renamed abstract class to AbstractClassLoaderValue and the concrete subclasses to ClassLoaderValue (the root) and AbstractClassLoaderValue.Sub. Sub is special, because it must be a subclass of abstract class and an inner class of abstract class at the same time, so it must be nested inside AbstractClassLoaderValue. Type names in this arrangement are nicer looking: ClassLoaderValue clv = ....; ClassLoaderValue.Sub.Sub clv_k12 = clv.sub(k1).sub(k2); If Sub was nested inside concrete ClassLoaderValue, then we could compose an instance of ClassLoaderValue.Sub, but could not continue composition and compose an instance of ClassLoaderValue.Sub.Sub for example. > AbstractClassLoaderValue.java > 263 ? BootLoader.getClassLoaderValueMap() > 264 : JLA.createOrGetClassLoaderValueMap(cl) > > Nit: I generally like ?-ternary indent to the right below the test. Reformatted. > Proxy.java > > 376 private static Constructor getProxyConstructor(Class caller, // null if no SecurityManager > 377 ClassLoader loader, > 378 Class... interfaces) > 379 throws IllegalArgumentException > 380 { > > IAE is an unchecked exception that does not need to be declared. I realized it?s pre-existing code. While you are on it, it can be taken out. > > The informal javadoc for getProxyConstructor would be helpful. So the comment next to the caller parameter would be moved to the javadoc. Added javadoc for getProxyConstructor and removed declared IAE. > 384 if (caller != null) { > 385 checkProxyAccess(caller, loader, intf); > 386 } > > The conditional check (caller != null) is not needed since checkProxyAccess and checkNewProxyPermission are nop if security manager is not present. Same also applies to line 986. I would still rather keep it that way. For example if there is a race with a thread setting SecurityManager, then without this check, NPE could result. > 532 return Boolean.TRUE.equals( > 533 reverseProxyCache.sub(c).get(c.getClassLoader())); > > Maybe Objects::equals that checks == first. Ok. > Driver.java > 28 * @bug 8152115 > 29 * @summary functional and concurrency test for ClassLoaderValue > > The convention we use to move @bug and @summary after @test. It?d be good to move them up. Moved. >> @Mandy >> >> I haven't yet removed the superfluous checking and providing access from dynamic module to the modules/packages of transitive closure of interfaces implemented by proxy class. I think this should be done in a separate issue so that this change doesn't change the semantics of implementation. >> > I agree better to separate this as a different issue. Perhaps I can take that one since I?d like to do more testing before pushing it. Agreed. So here's updated webrev: http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/webrev.06/ > Mandy Regards, Peter From mandy.chung at oracle.com Sun Apr 10 23:54:43 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Sun, 10 Apr 2016 16:54:43 -0700 Subject: RFR: JDK-8152115 (proxy) Examine performance of dynamic proxy creation In-Reply-To: <570AA27E.3070009@gmail.com> References: <57078ABD.2020906@gmail.com> <8C64613C-10A1-4CBD-94E5-1C44EFADCBBC@oracle.com> <570AA27E.3070009@gmail.com> Message-ID: <1BB45307-D36A-4018-804B-B398E90BED17@oracle.com> > On Apr 10, 2016, at 11:59 AM, Peter Levart wrote: > > So here's updated webrev: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/webrev.06/ Looks good to me. thanks Mandy From felix.yang at oracle.com Mon Apr 11 03:47:21 2016 From: felix.yang at oracle.com (Felix Yang) Date: Mon, 11 Apr 2016 11:47:21 +0800 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc Message-ID: <570B1E49.6040001@oracle.com> Hi there, please review the following bug fix. Bug: https://bugs.openjdk.java.net/browse/JDK-8153928 Webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.00/ After changes in JDK-8153737 , it introduced new dependency of java.base/jdk.internal.misc in test/lib/share/classes/jdk/test/lib/Utils.java. This leads to two test compilation failures. See changeset: http://hg.openjdk.java.net/jdk9/dev/rev/1d992540870f Thanks, Felix From amy.lu at oracle.com Mon Apr 11 04:49:35 2016 From: amy.lu at oracle.com (Amy Lu) Date: Mon, 11 Apr 2016 12:49:35 +0800 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B1E49.6040001@oracle.com> References: <570B1E49.6040001@oracle.com> Message-ID: <570B2CDF.8000705@oracle.com> On 4/11/16 11:47 AM, Felix Yang wrote: > Hi there, > please review the following bug fix. > Bug: https://bugs.openjdk.java.net/browse/JDK-8153928 > Webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.00/ You might want to do some cleanup to avoid using two @modules tags? BTW. I'm not openjdk reviewer, please wait for reviewer's feedback. Thanks, Amy > > After changes in JDK-8153737 > , it introduced new > dependency of java.base/jdk.internal.misc in > test/lib/share/classes/jdk/test/lib/Utils.java. This leads to two test > compilation failures. > See changeset: http://hg.openjdk.java.net/jdk9/dev/rev/1d992540870f > > Thanks, > Felix From felix.yang at oracle.com Mon Apr 11 05:04:43 2016 From: felix.yang at oracle.com (Felix Yang) Date: Mon, 11 Apr 2016 13:04:43 +0800 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B2CDF.8000705@oracle.com> References: <570B1E49.6040001@oracle.com> <570B2CDF.8000705@oracle.com> Message-ID: <570B306B.3080208@oracle.com> Amy, thanks. I'm not sure which practices are suggested. By searching the existing tests, I found lots of test with 2+ @modules, so I chose to add another @modules. Personally, both ways look clear and transparent for me. Thanks, Felix On 2016/4/11 12:49, Amy Lu wrote: > On 4/11/16 11:47 AM, Felix Yang wrote: >> Hi there, >> please review the following bug fix. >> Bug: https://bugs.openjdk.java.net/browse/JDK-8153928 >> Webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.00/ > > You might want to do some cleanup to avoid using two @modules tags? > > BTW. I'm not openjdk reviewer, please wait for reviewer's feedback. > > Thanks, > Amy > >> >> After changes in JDK-8153737 >> , it introduced new >> dependency of java.base/jdk.internal.misc in >> test/lib/share/classes/jdk/test/lib/Utils.java. This leads to two >> test compilation failures. >> See changeset: http://hg.openjdk.java.net/jdk9/dev/rev/1d992540870f >> >> Thanks, >> Felix > From Alan.Bateman at oracle.com Mon Apr 11 06:46:04 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 11 Apr 2016 07:46:04 +0100 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B306B.3080208@oracle.com> References: <570B1E49.6040001@oracle.com> <570B2CDF.8000705@oracle.com> <570B306B.3080208@oracle.com> Message-ID: <570B482C.5020600@oracle.com> On 11/04/2016 06:04, Felix Yang wrote: > Amy, > thanks. I'm not sure which practices are suggested. By searching > the existing tests, I found lots of test with 2+ @modules, so I chose > to add another @modules. Personally, both ways look clear and > transparent for me. We've tried to use one @modules per test but there are inconsistencies. I think some of those inconsistencies arose when patches were brought into jdk9/dev early and then subsequently merged. At some point we should do a pass over the existing usages to get them consistent. -Alan From uschindler at apache.org Mon Apr 11 06:52:15 2016 From: uschindler at apache.org (Uwe Schindler) Date: Mon, 11 Apr 2016 08:52:15 +0200 Subject: JDK 9 Build 111 seems to miss some locale data, Lucene tests fail with Farsi and Thai language In-Reply-To: <56F7ACE5.6030303@oracle.com> References: <0a9401d18756$9cad37f0$d607a7d0$@apache.org> <56F6984A.3070602@oracle.com> <0ac201d18793$45098890$cf1c99b0$@apache.org> <56F7079B.1090004@oracle.com> <0ace01d187b5$83052d80$890f8880$@apache.org> <56F7ACE5.6030303@oracle.com> Message-ID: <019c01d193be$b1899c30$149cd490$@apache.org> Hi Alan, I can confirm, the problem is fixed in build 113. Thanks! Uwe ----- Uwe Schindler uschindler at apache.org ASF Member, Apache Lucene PMC / Committer Bremen, Germany http://lucene.apache.org/ From: Alan Bateman [mailto:Alan.Bateman at oracle.com] Sent: Sunday, March 27, 2016 11:50 AM To: Uwe Schindler Cc: 'Rory O'Donnell' ; 'Core-Libs-Dev' ; 'Robert Muir' ; dev at lucene.apache.org Subject: Re: JDK 9 Build 111 seems to miss some locale data, Lucene tests fail with Farsi and Thai language On 26/03/2016 23:16, Uwe Schindler wrote: : Now all analysis tests pass, also the small test program posted previously: $ java -Djava.security.manager Test class sun.util.locale.provider.DictionaryBasedBreakIterator FYI: Lucene runs all tests with a security manager to enforce some restrictions (so tests can't escape their working dir, no useless permissions are required that may conflict,...). Lucene is designed to work with lowest permissions (except the memory mapping unmapper). I will patch the Jenkins Server's JDK-9 b111 dirs the same way, so we can run tests. I have the following question: Why don?t we see an exception when loading the locale data? Shouln?t Java fail in some way and print a stack trace? It is just silent! Thanks for the confirming the workaround. I've created JDK-8152817 to track this issue and I hope we can get this fixed in jdk9/dev quickly. The reason you aren't seeing the exception is that an internal class sun.util.Resources.loadBundleFromProviders is catching (and recording) the security exception. The cause may surface as the cause on a MissingResourceException but not in this case. This area has a lot of history, I'm sure Naoto can say more about this. -Alan From felix.yang at oracle.com Mon Apr 11 06:57:37 2016 From: felix.yang at oracle.com (Felix Yang) Date: Mon, 11 Apr 2016 14:57:37 +0800 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B482C.5020600@oracle.com> References: <570B1E49.6040001@oracle.com> <570B2CDF.8000705@oracle.com> <570B306B.3080208@oracle.com> <570B482C.5020600@oracle.com> Message-ID: <570B4AE1.1060008@oracle.com> Hi Alan and Amy, thanks for figuring this out. Updated to suggested practice. New webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.01/ Felix On 2016/4/11 14:46, Alan Bateman wrote: > On 11/04/2016 06:04, Felix Yang wrote: >> Amy, >> thanks. I'm not sure which practices are suggested. By searching >> the existing tests, I found lots of test with 2+ @modules, so I chose >> to add another @modules. Personally, both ways look clear and >> transparent for me. > We've tried to use one @modules per test but there are > inconsistencies. I think some of those inconsistencies arose when > patches were brought into jdk9/dev early and then subsequently merged. > At some point we should do a pass over the existing usages to get them > consistent. > > -Alan From Alan.Bateman at oracle.com Mon Apr 11 07:01:11 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 11 Apr 2016 08:01:11 +0100 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B4AE1.1060008@oracle.com> References: <570B1E49.6040001@oracle.com> <570B2CDF.8000705@oracle.com> <570B306B.3080208@oracle.com> <570B482C.5020600@oracle.com> <570B4AE1.1060008@oracle.com> Message-ID: <570B4BB7.6090607@oracle.com> On 11/04/2016 07:57, Felix Yang wrote: > Hi Alan and Amy, > thanks for figuring this out. Updated to suggested practice. > > New webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.01/ This looks okay. -Alan From amy.lu at oracle.com Mon Apr 11 07:08:58 2016 From: amy.lu at oracle.com (Amy Lu) Date: Mon, 11 Apr 2016 15:08:58 +0800 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B4BB7.6090607@oracle.com> References: <570B1E49.6040001@oracle.com> <570B2CDF.8000705@oracle.com> <570B306B.3080208@oracle.com> <570B482C.5020600@oracle.com> <570B4AE1.1060008@oracle.com> <570B4BB7.6090607@oracle.com> Message-ID: <570B4D8A.8060202@oracle.com> On 4/11/16 3:01 PM, Alan Bateman wrote: > On 11/04/2016 07:57, Felix Yang wrote: >> Hi Alan and Amy, >> thanks for figuring this out. Updated to suggested practice. >> >> New webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.01/ > This looks okay. > > -Alan Felix, I'll sponsor this for you. Thanks, Amy From chris.hegarty at oracle.com Mon Apr 11 08:03:49 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 11 Apr 2016 09:03:49 +0100 Subject: RFR 8153928, test/lib/share/classes/jdk/test/lib/Utils.java introduced dependency to java.base/jdk.internal.misc In-Reply-To: <570B4AE1.1060008@oracle.com> References: <570B1E49.6040001@oracle.com> <570B2CDF.8000705@oracle.com> <570B306B.3080208@oracle.com> <570B482C.5020600@oracle.com> <570B4AE1.1060008@oracle.com> Message-ID: <124FF15E-49E7-4006-B22A-9481743CEFCA@oracle.com> > On 11 Apr 2016, at 07:57, Felix Yang wrote: > > Hi Alan and Amy, > thanks for figuring this out. Updated to suggested practice. > > New webrev: http://cr.openjdk.java.net/~xiaofeya/8153928/webrev.01/ Thanks for jumping on this, Felix. +1 -Chris. > Felix > >> On 2016/4/11 14:46, Alan Bateman wrote: >>> On 11/04/2016 06:04, Felix Yang wrote: >>> Amy, >>> thanks. I'm not sure which practices are suggested. By searching the existing tests, I found lots of test with 2+ @modules, so I chose to add another @modules. Personally, both ways look clear and transparent for me. >> We've tried to use one @modules per test but there are inconsistencies. I think some of those inconsistencies arose when patches were brought into jdk9/dev early and then subsequently merged. At some point we should do a pass over the existing usages to get them consistent. >> >> -Alan > From michael.haupt at oracle.com Mon Apr 11 08:36:34 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Mon, 11 Apr 2016 10:36:34 +0200 Subject: RFR(S): 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0 Message-ID: Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8153637 Webrev: http://cr.openjdk.java.net/~mhaupt/8153637/webrev.00/ The countedLoop implementation currently initialises the loop counter to the start value and, because this takes place in the very first loop clause, increments it immediately, leading to start+1 being passed to the first body invocation. The solution passes counter-1 to body. Alternatives that were considered include initialising the counter to start-1 (possible counting range is diminished), and to reorder loop clauses to move counter increment to the end of the loop (requires argument permutation). Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From peter.levart at gmail.com Mon Apr 11 09:02:54 2016 From: peter.levart at gmail.com (Peter Levart) Date: Mon, 11 Apr 2016 11:02:54 +0200 Subject: RFR: JDK-8152115 (proxy) Examine performance of dynamic proxy creation In-Reply-To: <1BB45307-D36A-4018-804B-B398E90BED17@oracle.com> References: <57078ABD.2020906@gmail.com> <8C64613C-10A1-4CBD-94E5-1C44EFADCBBC@oracle.com> <570AA27E.3070009@gmail.com> <1BB45307-D36A-4018-804B-B398E90BED17@oracle.com> Message-ID: <570B683E.2090006@gmail.com> On 04/11/2016 01:54 AM, Mandy Chung wrote: >> On Apr 10, 2016, at 11:59 AM, Peter Levart wrote: >> >> So here's updated webrev: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.caching/webrev.06/ > Looks good to me. > > thanks > Mandy Thanks, pushed. Regards, Peter From paul.sandoz at oracle.com Mon Apr 11 09:17:25 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 11 Apr 2016 11:17:25 +0200 Subject: RFR(S): 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0 In-Reply-To: References: Message-ID: > On 11 Apr 2016, at 10:36, Michael Haupt wrote: > > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8153637 > Webrev: http://cr.openjdk.java.net/~mhaupt/8153637/webrev.00/ > > The countedLoop implementation currently initialises the loop counter to the start value and, because this takes place in the very first loop clause, increments it immediately, leading to start+1 being passed to the first body invocation. The solution passes counter-1 to body. Alternatives that were considered include initialising the counter to start-1 (possible counting range is diminished), and to reorder loop clauses to move counter increment to the end of the loop (requires argument permutation). > This seems like a pragmatic compromise, and there is still wiggle room to change the implementation to something else. Paul. From paul.sandoz at oracle.com Mon Apr 11 10:03:36 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 11 Apr 2016 12:03:36 +0200 Subject: RFR 8152645 VarHandle lookup access control tests In-Reply-To: References: <81AC210F-C0C7-4DAA-BAA9-FCCCF89699FB@oracle.com> Message-ID: > On 8 Apr 2016, at 15:37, Michael Haupt wrote: > > Hi Paul, > > note this is a lower-case review. Thumbs up. > > I like how the test lucidly documents the access rules, and would applaud an extended test that additionally covers module boundaries. > > Just as a suggestion, how about using the fact that enum values are technically instances of subclasses of the enum and getting rid of the switches in FieldLookup.lookup/isAccessibleField by replacing the two with overridden methods in each of the enum elements? Switching over "this" just calls for polymorphism, and the default cases are dead code. Admittedly, it's a matter of style. :-) > Done, updated in place: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8152645-VH-access-control/webrev/ Thanks, Paul. From paul.sandoz at oracle.com Mon Apr 11 10:54:48 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 11 Apr 2016 12:54:48 +0200 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style In-Reply-To: <32003C66-4DCC-492B-8383-48CF35CA0073@oracle.com> References: <32003C66-4DCC-492B-8383-48CF35CA0073@oracle.com> Message-ID: <5A0CDCD7-3749-45AD-85D8-E45D31149EEC@oracle.com> > On 8 Apr 2016, at 16:10, Michael Haupt wrote: > > Hi Paul, > > note this is a lower-case review. Thumbs up, with one remarks (no new webrev required IMO). > > * VarHandle.java: static initialiser of AccessMode, comment: > // Initial capacity of # values will is sufficient to avoid resizes > -> remove ?will? > Thanks (updated in place). > On 8 Apr 2016, at 16:35, Aleksey Shipilev wrote: > > On 04/07/2016 04:39 PM, Paul Sandoz wrote: >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ > > Looks good. The performance is OK. Thanks, Paul. From paul.sandoz at oracle.com Mon Apr 11 10:55:40 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 11 Apr 2016 12:55:40 +0200 Subject: RFR 8151706: Update VarHandle implementation to use @Stable arrays In-Reply-To: References: Message-ID: <368CB6AC-BE1C-45A7-9802-B3D705E30B23@oracle.com> > On 8 Apr 2016, at 16:11, Michael Haupt wrote: > > Hi Paul, > > note this is a lower-case review. Having looked at 8151705, thumbs up for this one as well - they go hand in hand and looking at one of them only doesn't feel right. :-) > Thanks. I got ?em swapped the wrong way around. I am gonna re-base this one and push, otherwise it will be blocked waiting on the CCC of 8151705. > On 8 Apr 2016, at 16:23, Aleksey Shipilev wrote: > > On 04/08/2016 12:56 PM, Paul Sandoz wrote: >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151706-VH-form-table-stable/webrev/ >> >> >> Now that @Stable arrays are supported by C1 (thanks Vladimir!) we >> can switch from the explicit use of MemberName fields in VarForm to a >> @Stable MemberName[] array. > > Yes, glad to see that abomination gone. > Indeed! > I've checked C1 and C2 performance against our battery of VarHandle > microbenchmarks, and there were no regressions. So, +1. Thanks, Paul. From ramanand.patil at oracle.com Mon Apr 11 10:59:11 2016 From: ramanand.patil at oracle.com (Ramanand Patil) Date: Mon, 11 Apr 2016 03:59:11 -0700 (PDT) Subject: RFR: 8151876: (tz) Support tzdata2016c In-Reply-To: <5702FB18.1060300@oracle.com> References: <5702FB18.1060300@oracle.com> Message-ID: <52bbec78-cd40-4fbb-81f3-77d2eb959b9c@default> Hi all, I would like someone from java.time to do a second review for this. Regards, Ramanand. -----Original Message----- From: Masayoshi Okutsu Sent: Tuesday, April 05, 2016 5:09 AM To: Ramanand Patil; i18n-dev at openjdk.java.net Cc: core-libs-dev at openjdk.java.net Subject: Re: RFR: 8151876: (tz) Support tzdata2016c Looks good to me. But I'd like someone from java.time to review the changes to see if it's OK for java.time. Masayoshi On 4/4/2016 6:50 PM, Ramanand Patil wrote: > Hi all, > > Please review the latest TZDATA (tzdata2016c) integration to JDK9. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8151876 > > Webrev: http://cr.openjdk.java.net/~rpatil/8151876/webrev.00/ > > All the TimeZone related tests are passed after integration. > > > > Please note that this patch includes both tzdata2016b and tzdata2016c integration. The tzdata2016b review was abandoned because tzdata2016c was already released. > > As suggested by Masayoshi, changes are made such that, "GMT+hh:mm" is used for formatting of the newly added TimeZones in tzdata2016b. > > [This is done to accommodate the IANA's new trial system where the new > zones use numeric time zone abbreviations like "+04" instead of > invented abbreviations like "ASTT".] > > > > Regards, > > Ramanand. From claes.redestad at oracle.com Mon Apr 11 10:59:59 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Mon, 11 Apr 2016 12:59:59 +0200 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style In-Reply-To: <5A0CDCD7-3749-45AD-85D8-E45D31149EEC@oracle.com> References: <32003C66-4DCC-492B-8383-48CF35CA0073@oracle.com> <5A0CDCD7-3749-45AD-85D8-E45D31149EEC@oracle.com> Message-ID: <570B83AF.4030508@oracle.com> Looks good /Claes On 2016-04-11 12:54, Paul Sandoz wrote: >> On 8 Apr 2016, at 16:10, Michael Haupt wrote: >> >> Hi Paul, >> >> note this is a lower-case review. Thumbs up, with one remarks (no new webrev required IMO). >> >> * VarHandle.java: static initialiser of AccessMode, comment: >> // Initial capacity of # values will is sufficient to avoid resizes >> -> remove ?will? >> > Thanks (updated in place). > > >> On 8 Apr 2016, at 16:35, Aleksey Shipilev wrote: >> >> On 04/07/2016 04:39 PM, Paul Sandoz wrote: >>> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ >> Looks good. The performance is OK. > Thanks, > Paul. From claes.redestad at oracle.com Mon Apr 11 11:00:16 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Mon, 11 Apr 2016 13:00:16 +0200 Subject: RFR 8151706: Update VarHandle implementation to use @Stable arrays In-Reply-To: <368CB6AC-BE1C-45A7-9802-B3D705E30B23@oracle.com> References: <368CB6AC-BE1C-45A7-9802-B3D705E30B23@oracle.com> Message-ID: <570B83C0.50901@oracle.com> Looks good /Claes On 2016-04-11 12:55, Paul Sandoz wrote: >> On 8 Apr 2016, at 16:11, Michael Haupt wrote: >> >> Hi Paul, >> >> note this is a lower-case review. Having looked at 8151705, thumbs up for this one as well - they go hand in hand and looking at one of them only doesn't feel right. :-) >> > Thanks. I got ?em swapped the wrong way around. I am gonna re-base this one and push, otherwise it will be blocked waiting on the CCC of 8151705. > > >> On 8 Apr 2016, at 16:23, Aleksey Shipilev wrote: >> >> On 04/08/2016 12:56 PM, Paul Sandoz wrote: >>> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151706-VH-form-table-stable/webrev/ >>> >>> >>> Now that @Stable arrays are supported by C1 (thanks Vladimir!) we >>> can switch from the explicit use of MemberName fields in VarForm to a >>> @Stable MemberName[] array. >> Yes, glad to see that abomination gone. >> > Indeed! > > >> I've checked C1 and C2 performance against our battery of VarHandle >> microbenchmarks, and there were no regressions. So, +1. > Thanks, > Paul. > From claes.redestad at oracle.com Mon Apr 11 11:02:24 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Mon, 11 Apr 2016 13:02:24 +0200 Subject: RFR 8152645 VarHandle lookup access control tests In-Reply-To: References: <81AC210F-C0C7-4DAA-BAA9-FCCCF89699FB@oracle.com> Message-ID: <570B8440.7030100@oracle.com> On 2016-04-11 12:03, Paul Sandoz wrote: >> On 8 Apr 2016, at 15:37, Michael Haupt wrote: >> >> Hi Paul, >> >> note this is a lower-case review. Thumbs up. >> >> I like how the test lucidly documents the access rules, and would applaud an extended test that additionally covers module boundaries. +1 >> >> Just as a suggestion, how about using the fact that enum values are technically instances of subclasses of the enum and getting rid of the switches in FieldLookup.lookup/isAccessibleField by replacing the two with overridden methods in each of the enum elements? Switching over "this" just calls for polymorphism, and the default cases are dead code. Admittedly, it's a matter of style. :-) >> > Done, updated in place: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8152645-VH-access-control/webrev/ Looks good. /Claes > > Thanks, > > Paul. From paul.sandoz at oracle.com Mon Apr 11 11:27:52 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 11 Apr 2016 13:27:52 +0200 Subject: RFR 8152645 VarHandle lookup access control tests In-Reply-To: <570B8440.7030100@oracle.com> References: <81AC210F-C0C7-4DAA-BAA9-FCCCF89699FB@oracle.com> <570B8440.7030100@oracle.com> Message-ID: > On 11 Apr 2016, at 13:02, Claes Redestad wrote: > > On 2016-04-11 12:03, Paul Sandoz wrote: >>> On 8 Apr 2016, at 15:37, Michael Haupt wrote: >>> >>> Hi Paul, >>> >>> note this is a lower-case review. Thumbs up. >>> >>> I like how the test lucidly documents the access rules, and would applaud an extended test that additionally covers module boundaries. > > +1 > I?ll follow up later with that, https://bugs.openjdk.java.net/browse/JDK-8153963 >>> >>> Just as a suggestion, how about using the fact that enum values are technically instances of subclasses of the enum and getting rid of the switches in FieldLookup.lookup/isAccessibleField by replacing the two with overridden methods in each of the enum elements? Switching over "this" just calls for polymorphism, and the default cases are dead code. Admittedly, it's a matter of style. :-) >>> >> Done, updated in place: >> >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8152645-VH-access-control/webrev/ > > Looks good. > Thanks, Paul. From claes.redestad at oracle.com Mon Apr 11 11:28:23 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Mon, 11 Apr 2016 13:28:23 +0200 Subject: RFR(S): 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0 In-Reply-To: References: Message-ID: <570B8A57.5020409@oracle.com> On 2016-04-11 11:17, Paul Sandoz wrote: >> On 11 Apr 2016, at 10:36, Michael Haupt wrote: >> >> Dear all, >> >> please review this change. >> Bug: https://bugs.openjdk.java.net/browse/JDK-8153637 >> Webrev: http://cr.openjdk.java.net/~mhaupt/8153637/webrev.00/ >> >> The countedLoop implementation currently initialises the loop counter to the start value and, because this takes place in the very first loop clause, increments it immediately, leading to start+1 being passed to the first body invocation. The solution passes counter-1 to body. Alternatives that were considered include initialising the counter to start-1 (possible counting range is diminished), and to reorder loop clauses to move counter increment to the end of the loop (requires argument permutation). >> > This seems like a pragmatic compromise, and there is still wiggle room to change the implementation to something else. > > Paul. +1 Seeing no discernible impact on the performance of the current implementation, either. /Claes From christoph.langer at sap.com Mon Apr 11 14:47:45 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Mon, 11 Apr 2016 14:47:45 +0000 Subject: PING: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place Message-ID: <68aea61d52794538aea2f934a01fefad@DEWDFE13DE11.global.corp.sap> Hi, Ping: Any comments on my changes? Thanks Christoph From: Langer, Christoph Sent: Donnerstag, 7. April 2016 22:45 To: core-libs-dev at openjdk.java.net Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place Hi, I've run into a peculiar issue with Xerces. The problem is happening when a DTD shall be skipped, the DTD is larger than the buffer of the current entity and a CRLF sequence occurs just one char before the buffer end. The reason is that method skipDTD of class XMLDTDScannerImpl (about line 389) calls XMLEntityScanner.scanData() to scan for the next occurrence of ']'. The scanData method might return true which indicates that the delimiter ']' was not found yet and more data is to scan. Other users of scanData would handle this and call this method in a loop until it returns false or some other condition happens. So I've fixed that place like at the other callers of scanData. Nevertheless, the scanData method would usually load more data when it is at the end of the buffer. But in the special case when CRLF is found at the end of buffer - 1, scanData would just return true. So I also removed that check at line 1374 in XMLEntityScanner. Do you see any problem with that? Is there any reason behind it which I'm overseeing? Furthermore I took the chance for further little cleanups. I've added the new copyright header to the files... is that the correct one? I also aligned the calls to invokeListeners(position) in XMLEntityScanner to always pass the actual position from which the load is started. Do you think this is correct? Here is the bug: https://bugs.openjdk.java.net/browse/JDK-8153781 Here is the webrev: http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ Please give me some comments before I finalize my change including a jtreg testcase. Thanks & Best regards Christoph From Roger.Riggs at Oracle.com Mon Apr 11 14:55:39 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 11 Apr 2016 10:55:39 -0400 Subject: RFR: 8151876: (tz) Support tzdata2016c In-Reply-To: <52bbec78-cd40-4fbb-81f3-77d2eb959b9c@default> References: <5702FB18.1060300@oracle.com> <52bbec78-cd40-4fbb-81f3-77d2eb959b9c@default> Message-ID: <570BBAEA.6030004@Oracle.com> Hi Ramanand, The change to the test.java.time.format.TestZoneTextPrinterParser.test_ParseText just eliminates the test. Is there an alternate test that the formatter is returning the correct value for the GMT+/- cases? Roger On 4/11/2016 6:59 AM, Ramanand Patil wrote: > Hi all, > > I would like someone from java.time to do a second review for this. > > Regards, > Ramanand. > > -----Original Message----- > From: Masayoshi Okutsu > Sent: Tuesday, April 05, 2016 5:09 AM > To: Ramanand Patil; i18n-dev at openjdk.java.net > Cc: core-libs-dev at openjdk.java.net > Subject: Re: RFR: 8151876: (tz) Support tzdata2016c > > Looks good to me. But I'd like someone from java.time to review the changes to see if it's OK for java.time. > > Masayoshi > > On 4/4/2016 6:50 PM, Ramanand Patil wrote: >> Hi all, >> >> Please review the latest TZDATA (tzdata2016c) integration to JDK9. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8151876 >> >> Webrev: http://cr.openjdk.java.net/~rpatil/8151876/webrev.00/ >> >> All the TimeZone related tests are passed after integration. >> >> >> >> Please note that this patch includes both tzdata2016b and tzdata2016c integration. The tzdata2016b review was abandoned because tzdata2016c was already released. >> >> As suggested by Masayoshi, changes are made such that, "GMT+hh:mm" is used for formatting of the newly added TimeZones in tzdata2016b. >> >> [This is done to accommodate the IANA's new trial system where the new >> zones use numeric time zone abbreviations like "+04" instead of >> invented abbreviations like "ASTT".] >> >> >> >> Regards, >> >> Ramanand. From steve.drach at oracle.com Mon Apr 11 21:21:06 2016 From: steve.drach at oracle.com (Steve Drach) Date: Mon, 11 Apr 2016 14:21:06 -0700 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value Message-ID: <399B3561-BF12-44A4-917C-45925C161524@oracle.com> Hi, I?ve updated the following patch, incorporating code by Claes Redestad to handle some corner cases while processing the attribute value. Note that we?ve limited the location of the value part of the attribute to accommodate startup performance requirements. It?s not without precedent as at least one other attribute is also limited in amount of whitespace surrounding the value. > Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. issue: https://bugs.openjdk.java.net/browse/JDK-8153213 webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev.01/index.html Thanks Steve From mandy.chung at oracle.com Mon Apr 11 21:22:39 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Mon, 11 Apr 2016 14:22:39 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed Message-ID: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> Webrev at: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html StackFrame::getFileName and StackFrame::getLineNumber are originally proposed with the view of any stack walking code can migrate to the StackWalker API without the use of StackTraceElement. File name and line number are useful for debugging and troubleshooting purpose. It has additional overhead to map from a method and BCI to look up the file name and line number. StackFrame::toStackTraceElement method returns StackTraceElement that includes the file name and line number. There is no particular benefit to duplicate getFileName and getLineNumber methods in StackFrame. It is equivalently convenient to call StackFrame.toStackTraceElement().getFileName() (or getLineNumber). This patch proposes to remove StackFrame::getFileName and StackFrame::getLineNumber methods since such information can be obtained from StackFrame.toStackTraceElement(). Mandy From john.r.rose at oracle.com Mon Apr 11 21:23:50 2016 From: john.r.rose at oracle.com (John Rose) Date: Mon, 11 Apr 2016 14:23:50 -0700 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style In-Reply-To: References: Message-ID: <1625A54A-7322-4855-9533-46956C20420D@oracle.com> On Apr 7, 2016, at 6:39 AM, Paul Sandoz wrote: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ > > I was persuaded (in internal CCC review) to change the enum VarHandle.AccessMode constant names to conform to the expected Java style. I'm sorry you were persuaded, because in some of these cases it is the code style that needs to flex here, not the source code names. When working with reflective representations of API points, there is no benefit from representing (say) a method called toString by a variable which is called TO_STRING. It just makes it hard to see the correspondences between the ground names and the reflective names. (To start with, grep and other tools will fail to find both names.) This is why, in the original JSR 292 code base, I have chosen to use hybrid names for fields that reflect API points. The prefix of the hybrid names does, in fact, follow the code style, but the suffix is the exact spelling of the reflected API point. I would be sad if some officious soul "fixed" these divergent names, because it would obscure the code. In fact, I wish this particular use case for hybrid identifiers were more widely recognized. Examples: http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/8c293ee99d5a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java#l660 NF_internalMemberName = new NamedFunction(DirectMethodHandle.class .getDeclaredMethod("internalMemberName", Object.class)), http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/8c293ee99d5a/src/java.base/share/classes/java/lang/invoke/Invokers.java#l443 MH_asSpreader = IMPL_LOOKUP.findVirtual(MethodHandle.class, "asSpreader", MethodType.methodType(MethodHandle.class, Class.class, int.class)); As a precedent, the JVMS uses hybrid identifiers for quasi-reflective names like CONSTANT_String, etc. Arguably (and also arguably not), the access types in your enums are quasi-reflective references to specific methods, and so should have their names derived (as a hybrid name) from the literal method names. Good style includes knowing when to bend the rules. ? John From mandy.chung at oracle.com Mon Apr 11 23:45:55 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Mon, 11 Apr 2016 16:45:55 -0700 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces Message-ID: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> Peter spots the redundant read edges are added to dynamic module when creating a proxy class. Proxy class does not access super interfaces of proxy interfaces. I have verified this simple patch with all core tests and JCK api tests. diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java @@ -804,11 +804,6 @@ continue; } ensureAccess(target, c); - - // add all superinterfaces - for (Class intf : c.getInterfaces()) { - deque.add(intf); - } } // set up proxy class access to types referenced in the method signature From alejandro.murillo at oracle.com Tue Apr 12 00:14:56 2016 From: alejandro.murillo at oracle.com (Alejandro Murillo) Date: Mon, 11 Apr 2016 18:14:56 -0600 Subject: [9] RFR 4154028: Several hotspot tests need to be updated after 8153737 (Unsupported Module) Message-ID: <570C3E00.60203@oracle.com> Can I get a quick review for this fix that's blocking the synching of jdk9/hs with jdk9/dev: Basically, https://bugs.openjdk.java.net/browse/JDK-8153737 introduced some changes that need to be applied to several hotspot tests that were not in jdk9/dev by the time that fix was pushed. They can't be fixed on either repo, the need to be fixed in the merging repo before being pushed back to jdk9/hs (first) Bug https://bugs.openjdk.java.net/browse/JDK-8154028 Webrev: http://cr.openjdk.java.net/~amurillo/9/8154028/ I'm running a sanity test job now, but wanted to get the review going as I need to get the synch done ASAP to start PIT Thanks -- Alejandro From joe.darcy at oracle.com Tue Apr 12 00:44:33 2016 From: joe.darcy at oracle.com (joe darcy) Date: Mon, 11 Apr 2016 17:44:33 -0700 Subject: [9] RFR 4154028: Several hotspot tests need to be updated after 8153737 (Unsupported Module) In-Reply-To: <570C3E00.60203@oracle.com> References: <570C3E00.60203@oracle.com> Message-ID: <570C44F1.7000500@oracle.com> Looks fine Alejandro; thanks, -Joe On 4/11/2016 5:14 PM, Alejandro Murillo wrote: > > Can I get a quick review for this fix that's blocking the > synching of jdk9/hs with jdk9/dev: > > Basically, https://bugs.openjdk.java.net/browse/JDK-8153737 > introduced some changes that need to be applied to > several hotspot tests that were not in jdk9/dev > by the time that fix was pushed. > > They can't be fixed on either repo, the need to be fixed > in the merging repo before being pushed back to jdk9/hs (first) > > Bug https://bugs.openjdk.java.net/browse/JDK-8154028 > Webrev: http://cr.openjdk.java.net/~amurillo/9/8154028/ > > I'm running a sanity test job now, but wanted to get the review going > as I need to get the synch done ASAP to start PIT > > Thanks > From huizhe.wang at oracle.com Tue Apr 12 00:49:08 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Mon, 11 Apr 2016 17:49:08 -0700 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> Message-ID: <570C4604.7060700@oracle.com> On 4/7/2016 1:45 PM, Langer, Christoph wrote: > Hi, > > > > I've run into a peculiar issue with Xerces. > > > > The problem is happening when a DTD shall be skipped, the DTD is larger than the buffer of the current entity and a CRLF sequence occurs just one char before the buffer end. > > > > The reason is that method skipDTD of class XMLDTDScannerImpl (about line 389) calls XMLEntityScanner.scanData() to scan for the next occurrence of ']'. The scanData method might return true which indicates that the delimiter ']' was not found yet and more data is to scan. Other users of scanData would handle this and call this method in a loop until it returns false or some other condition happens. So I've fixed that place like at the other callers of scanData. This part of the change looks good. > > > > Nevertheless, the scanData method would usually load more data when it is at the end of the buffer. But in the special case when CRLF is found at the end of buffer - 1, scanData would just return true. So I also removed that check at line 1374 in XMLEntityScanner. Do you see any problem with that? Is there any reason behind it which I'm overseeing? No need to remove this after the above change. The parser needs to retain what's in the xml, e.g., not removing new lines. > > Furthermore I took the chance for further little cleanups. I've added the new copyright header to the files... is that the correct one? Yes, that's the right license header. However, > > > I also aligned the calls to invokeListeners(position) in XMLEntityScanner to always pass the actual position from which the load is started. Do you think this is correct? Yes. > > > > Here is the bug: > > https://bugs.openjdk.java.net/browse/JDK-8153781 > > > > Here is the webrev: > > http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ > > > > Please give me some comments before I finalize my change including a jtreg testcase. It would be better if you had included the testcase so that the review can be done together with the code change. Thanks, Joe > > > > Thanks & Best regards > > Christoph > > > From vladimir.kozlov at oracle.com Tue Apr 12 01:19:48 2016 From: vladimir.kozlov at oracle.com (Vladimir Kozlov) Date: Mon, 11 Apr 2016 18:19:48 -0700 Subject: [9] RFR 4154028: Several hotspot tests need to be updated after 8153737 (Unsupported Module) In-Reply-To: <570C3E00.60203@oracle.com> References: <570C3E00.60203@oracle.com> Message-ID: <570C4D34.8070107@oracle.com> Looks good. Thanks, Vladimir On 4/11/16 5:14 PM, Alejandro Murillo wrote: > > Can I get a quick review for this fix that's blocking the > synching of jdk9/hs with jdk9/dev: > > Basically, https://bugs.openjdk.java.net/browse/JDK-8153737 > introduced some changes that need to be applied to > several hotspot tests that were not in jdk9/dev > by the time that fix was pushed. > > They can't be fixed on either repo, the need to be fixed > in the merging repo before being pushed back to jdk9/hs (first) > > Bug https://bugs.openjdk.java.net/browse/JDK-8154028 > Webrev: http://cr.openjdk.java.net/~amurillo/9/8154028/ > > I'm running a sanity test job now, but wanted to get the review going > as I need to get the synch done ASAP to start PIT > > Thanks > From amy.lu at oracle.com Tue Apr 12 01:50:00 2016 From: amy.lu at oracle.com (Amy Lu) Date: Tue, 12 Apr 2016 09:50:00 +0800 Subject: JDK 9 RFR of JDK-8154031: Mark tools/pack200/BandIntegrity.java as intermittently failing Message-ID: <570C5448.4040605@oracle.com> tools/pack200/BandIntegrity.java This test is known to fail intermittently (JDK-8153815). This patch is to mark the test accordingly with keyword 'intermittent'. bug: https://bugs.openjdk.java.net/browse/JDK-8154031 webrev: http://cr.openjdk.java.net/~amlu/8154031/webrev.00/ Thanks, Amy --- old/test/tools/pack200/BandIntegrity.java 2016-04-12 09:45:31.000000000 +0800 +++ new/test/tools/pack200/BandIntegrity.java 2016-04-12 09:45:31.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @summary test ensures the proper sequencing of bands, dump bands as well. * @compile -XDignore.symbol.file Utils.java BandIntegrity.java * @run main BandIntegrity + * @key intermittent * @author ksrini */ import java.io.File; From joe.darcy at oracle.com Tue Apr 12 01:50:02 2016 From: joe.darcy at oracle.com (Joseph D. Darcy) Date: Mon, 11 Apr 2016 18:50:02 -0700 Subject: JDK 9 RFR of JDK-8154031: Mark tools/pack200/BandIntegrity.java as intermittently failing In-Reply-To: <570C5448.4040605@oracle.com> References: <570C5448.4040605@oracle.com> Message-ID: <570C544A.2080108@oracle.com> Looks fine Amy; thanks, -Joe On 4/11/2016 6:50 PM, Amy Lu wrote: > tools/pack200/BandIntegrity.java > > This test is known to fail intermittently (JDK-8153815). This patch is > to mark the test accordingly with keyword 'intermittent'. > > bug: https://bugs.openjdk.java.net/browse/JDK-8154031 > webrev: http://cr.openjdk.java.net/~amlu/8154031/webrev.00/ > > Thanks, > Amy > > > --- old/test/tools/pack200/BandIntegrity.java 2016-04-12 > 09:45:31.000000000 +0800 > +++ new/test/tools/pack200/BandIntegrity.java 2016-04-12 > 09:45:31.000000000 +0800 > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2013, Oracle and/or its affiliates. All rights > reserved. > + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights > reserved. > * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. > * > * This code is free software; you can redistribute it and/or modify it > @@ -26,6 +26,7 @@ > * @summary test ensures the proper sequencing of bands, dump bands > as well. > * @compile -XDignore.symbol.file Utils.java BandIntegrity.java > * @run main BandIntegrity > + * @key intermittent > * @author ksrini > */ > import java.io.File; > > From alejandro.murillo at oracle.com Tue Apr 12 03:06:03 2016 From: alejandro.murillo at oracle.com (Alejandro Murillo) Date: Mon, 11 Apr 2016 21:06:03 -0600 Subject: [9] RFR 4154028: Several hotspot tests need to be updated after 8153737 (Unsupported Module) In-Reply-To: <570C44F1.7000500@oracle.com> References: <570C3E00.60203@oracle.com> <570C44F1.7000500@oracle.com> Message-ID: <570C661B.5000507@oracle.com> Thanks Joe. Alejandro On 4/11/2016 6:44 PM, joe darcy wrote: > Looks fine Alejandro; thanks, > > -Joe > > On 4/11/2016 5:14 PM, Alejandro Murillo wrote: >> >> Can I get a quick review for this fix that's blocking the >> synching of jdk9/hs with jdk9/dev: >> >> Basically, https://bugs.openjdk.java.net/browse/JDK-8153737 >> introduced some changes that need to be applied to >> several hotspot tests that were not in jdk9/dev >> by the time that fix was pushed. >> >> They can't be fixed on either repo, the need to be fixed >> in the merging repo before being pushed back to jdk9/hs (first) >> >> Bug https://bugs.openjdk.java.net/browse/JDK-8154028 >> Webrev: http://cr.openjdk.java.net/~amurillo/9/8154028/ >> >> I'm running a sanity test job now, but wanted to get the review going >> as I need to get the synch done ASAP to start PIT >> >> Thanks >> > -- Alejandro From alejandro.murillo at oracle.com Tue Apr 12 03:08:38 2016 From: alejandro.murillo at oracle.com (Alejandro Murillo) Date: Mon, 11 Apr 2016 21:08:38 -0600 Subject: [9] RFR 4154028: Several hotspot tests need to be updated after 8153737 (Unsupported Module) In-Reply-To: <570C4D34.8070107@oracle.com> References: <570C3E00.60203@oracle.com> <570C4D34.8070107@oracle.com> Message-ID: <570C66B6.5070708@oracle.com> Thanks Vladimir Alejandro On 4/11/2016 7:19 PM, Vladimir Kozlov wrote: > Looks good. > > Thanks, > Vladimir > > On 4/11/16 5:14 PM, Alejandro Murillo wrote: >> >> Can I get a quick review for this fix that's blocking the >> synching of jdk9/hs with jdk9/dev: >> >> Basically, https://bugs.openjdk.java.net/browse/JDK-8153737 >> introduced some changes that need to be applied to >> several hotspot tests that were not in jdk9/dev >> by the time that fix was pushed. >> >> They can't be fixed on either repo, the need to be fixed >> in the merging repo before being pushed back to jdk9/hs (first) >> >> Bug https://bugs.openjdk.java.net/browse/JDK-8154028 >> Webrev: http://cr.openjdk.java.net/~amurillo/9/8154028/ >> >> I'm running a sanity test job now, but wanted to get the review going >> as I need to get the synch done ASAP to start PIT >> >> Thanks >> -- Alejandro From chris.hegarty at oracle.com Tue Apr 12 08:02:57 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 12 Apr 2016 09:02:57 +0100 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> Message-ID: <3883833E-B01C-40D8-9981-87E964B871BC@oracle.com> Looks ok Mandy. -Chris. On 12 Apr 2016, at 00:45, Mandy Chung wrote: > Peter spots the redundant read edges are added to dynamic module when creating a proxy class. Proxy class does not access super interfaces of proxy interfaces. I have verified this simple patch with all core tests and JCK api tests. > > diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java > --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java > +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java > @@ -804,11 +804,6 @@ > continue; > } > ensureAccess(target, c); > - > - // add all superinterfaces > - for (Class intf : c.getInterfaces()) { > - deque.add(intf); > - } > } > > // set up proxy class access to types referenced in the method signature From claes.redestad at oracle.com Tue Apr 12 08:18:03 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Tue, 12 Apr 2016 10:18:03 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <399B3561-BF12-44A4-917C-45925C161524@oracle.com> References: <399B3561-BF12-44A4-917C-45925C161524@oracle.com> Message-ID: <570CAF3B.7090208@oracle.com> Hi Steve, On 2016-04-11 23:21, Steve Drach wrote: > Hi, > > I?ve updated the following patch, incorporating code by Claes Redestad > to handle some corner cases while processing the attribute value. > Note that we?ve limited the location of the value part of the > attribute to accommodate startup performance requirements. It?s not > without precedent as at least one other attribute is also limited in > amount of whitespace surrounding the value. > >> Please review this simple fix to require that the jar manifest >> Multi-Release attribute has a value of ?true" in order to be >> effective, i.e. to assert the jar is a multi-release jar. > > issue: https://bugs.openjdk.java.net/browse/JDK-8153213 > webrev: > http://cr.openjdk.java.net/~sdrach/8153213/webrev.01/index.html > > this looks good to me. Good catch to delete the new jars added by the test. I'll sponsor this for you once tests look OK. Thanks! /Claes > > Thanks > Steve From forax at univ-mlv.fr Tue Apr 12 08:34:50 2016 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Tue, 12 Apr 2016 08:34:50 +0000 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> Message-ID: Hi Mandy, I really don't like this patch. Being forced to call toStackElement to get the line number is counter intuitive. I would prefer the two methods to not return Optional but an int and a String with the same convention as StackElement if the point of this patch is to remove the dependency to Optional. R?mi Le 11 avril 2016 23:22:39 CEST, Mandy Chung a ?crit : >Webrev at: >http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html > >StackFrame::getFileName and StackFrame::getLineNumber are originally >proposed with the view of any stack walking code can migrate to the >StackWalker API without the use of StackTraceElement. > >File name and line number are useful for debugging and troubleshooting >purpose. It has additional overhead to map from a method and BCI to >look up the file name and line number. > >StackFrame::toStackTraceElement method returns StackTraceElement that >includes the file name and line number. There is no particular benefit >to duplicate getFileName and getLineNumber methods in StackFrame. It is >equivalently convenient to call >StackFrame.toStackTraceElement().getFileName() (or getLineNumber). > >This patch proposes to remove StackFrame::getFileName and >StackFrame::getLineNumber methods since such information can be >obtained from StackFrame.toStackTraceElement(). > >Mandy From ramanand.patil at oracle.com Tue Apr 12 08:47:29 2016 From: ramanand.patil at oracle.com (Ramanand Patil) Date: Tue, 12 Apr 2016 01:47:29 -0700 (PDT) Subject: RFR: 8151876: (tz) Support tzdata2016c In-Reply-To: <570BBAEA.6030004@Oracle.com> References: <5702FB18.1060300@oracle.com> <52bbec78-cd40-4fbb-81f3-77d2eb959b9c@default> <570BBAEA.6030004@Oracle.com> Message-ID: <76050ad0-5203-4820-9de3-fc2aa8497839@default> Hi Roger, I don't think this is covered in any alternate tests, because this Displayname format is newly introduced with tzdata2016b for the newly added TimeZones. Anyway, I will double check on this to see if any test already covers this scenario otherwise I will update or add a new test case to cover this. Regards, Ramanand. -----Original Message----- From: Roger Riggs Sent: Monday, April 11, 2016 8:26 PM To: core-libs-dev at openjdk.java.net Subject: Re: RFR: 8151876: (tz) Support tzdata2016c Hi Ramanand, The change to the test.java.time.format.TestZoneTextPrinterParser.test_ParseText just eliminates the test. Is there an alternate test that the formatter is returning the correct value for the GMT+/- cases? Roger On 4/11/2016 6:59 AM, Ramanand Patil wrote: > Hi all, > > I would like someone from java.time to do a second review for this. > > Regards, > Ramanand. > > -----Original Message----- > From: Masayoshi Okutsu > Sent: Tuesday, April 05, 2016 5:09 AM > To: Ramanand Patil; i18n-dev at openjdk.java.net > Cc: core-libs-dev at openjdk.java.net > Subject: Re: RFR: 8151876: (tz) Support tzdata2016c > > Looks good to me. But I'd like someone from java.time to review the changes to see if it's OK for java.time. > > Masayoshi > > On 4/4/2016 6:50 PM, Ramanand Patil wrote: >> Hi all, >> >> Please review the latest TZDATA (tzdata2016c) integration to JDK9. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8151876 >> >> Webrev: http://cr.openjdk.java.net/~rpatil/8151876/webrev.00/ >> >> All the TimeZone related tests are passed after integration. >> >> >> >> Please note that this patch includes both tzdata2016b and tzdata2016c integration. The tzdata2016b review was abandoned because tzdata2016c was already released. >> >> As suggested by Masayoshi, changes are made such that, "GMT+hh:mm" is used for formatting of the newly added TimeZones in tzdata2016b. >> >> [This is done to accommodate the IANA's new trial system where the >> new zones use numeric time zone abbreviations like "+04" instead of >> invented abbreviations like "ASTT".] >> >> >> >> Regards, >> >> Ramanand. From paul.sandoz at oracle.com Tue Apr 12 09:50:56 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 12 Apr 2016 11:50:56 +0200 Subject: RFR: 8153213: Jar manifest attribute "Multi-Release" accepts any value In-Reply-To: <570CAF3B.7090208@oracle.com> References: <399B3561-BF12-44A4-917C-45925C161524@oracle.com> <570CAF3B.7090208@oracle.com> Message-ID: <7E7293E4-B2AA-41F0-8F86-6E8A5A33B65C@oracle.com> > On 12 Apr 2016, at 10:18, Claes Redestad wrote: > > Hi Steve, > > On 2016-04-11 23:21, Steve Drach wrote: >> Hi, >> >> I?ve updated the following patch, incorporating code by Claes Redestad to handle some corner cases while processing the attribute value. Note that we?ve limited the location of the value part of the attribute to accommodate startup performance requirements. It?s not without precedent as at least one other attribute is also limited in amount of whitespace surrounding the value. >> >>> Please review this simple fix to require that the jar manifest Multi-Release attribute has a value of ?true" in order to be effective, i.e. to assert the jar is a multi-release jar. >> >> issue: https://bugs.openjdk.java.net/browse/JDK-8153213 >> webrev: http://cr.openjdk.java.net/~sdrach/8153213/webrev.01/index.html >> > > this looks good to me. Same here, and i like the additional tests. I think we have beaten this into submission at this point :-) Paul. > Good catch to delete the new jars added by the test. > > I'll sponsor this for you once tests look OK. > > Thanks! > > /Claes > >> >> Thanks >> Steve > From peter.levart at gmail.com Tue Apr 12 12:34:55 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 12 Apr 2016 14:34:55 +0200 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> Message-ID: <570CEB6F.8060408@gmail.com> Hi Mandy, This is OK, but the whole loop could be simplified. No need for Dequeue any more: // set up proxy class access to proxy interfaces Set> visited = new HashSet<>(interfaces); for (Class c : visited) { ensureAccess(target, c); } Regards, Peter On 04/12/2016 01:45 AM, Mandy Chung wrote: > Peter spots the redundant read edges are added to dynamic module when creating a proxy class. Proxy class does not access super interfaces of proxy interfaces. I have verified this simple patch with all core tests and JCK api tests. > > diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java > --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java > +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java > @@ -804,11 +804,6 @@ > continue; > } > ensureAccess(target, c); > - > - // add all superinterfaces > - for (Class intf : c.getInterfaces()) { > - deque.add(intf); > - } > } > > // set up proxy class access to types referenced in the method signature From claes.redestad at oracle.com Tue Apr 12 12:38:07 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Tue, 12 Apr 2016 14:38:07 +0200 Subject: RFR: 8154067: Avoid early use of limited privilege escalation in InnerClassLambdaMetafactory Message-ID: <570CEC2F.7000306@oracle.com> Hi, the first usage of limited doPrivileged appears to have a small startup penalty (loads 8 permission-related classes and does some reflection), and is arguably excessive for this particular instance. Unrestricted doPrivileged allows for a small reduction of lambda init cost. Webrev: http://cr.openjdk.java.net/~redestad/8154067/webrev.01/ Bug: https://bugs.openjdk.java.net/browse/JDK-8154067 Thanks! /Claes From peter.levart at gmail.com Tue Apr 12 13:16:14 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 12 Apr 2016 15:16:14 +0200 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <570CEB6F.8060408@gmail.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> Message-ID: <570CF51E.3030908@gmail.com> Hi Mandy, There's another redundant validation and read edge addition I think. When deriving referenced types from methods of interfaces, static methods could be skipped as they are not implemented or overridden by Proxy class: http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.noStaticSignatures/webrev.01/ And there's also a question whether referenced types derived from method signatures should be checked for visibility from the specified class loader (in method validateProxyInterfaces). On one hand it is nice to ensure that later usage of the proxy class will not encounter problems of visibility of types in method signatures, but on the other, Java has been known to practice late binding and a normal class implementing an interface is loaded without problems although its method signatures reference types that are not visible from the class' class loader. Only when such method is called does the resolving happen and exception is thrown. So the question is whether such visibility checks are actually beneficial. For example, one could successfully use a proxy class by only invoking methods that reference visible types if this check was not performed. The problem is of course with the setup procedure of the dynamic module where you have to add exports from modules/packages of those referenced types and read edges to modules of those references types upfront. But this problem is resolvable. If a type is not visible from the proxy class' class loader, then we don't need an export from its module/package and we don't need a read edge to its module, do we? What do you think? Regards, Peter On 04/12/2016 02:34 PM, Peter Levart wrote: > Hi Mandy, > > This is OK, but the whole loop could be simplified. No need for > Dequeue any more: > > // set up proxy class access to proxy interfaces > Set> visited = new HashSet<>(interfaces); > for (Class c : visited) { > ensureAccess(target, c); > } > > Regards, Peter > > On 04/12/2016 01:45 AM, Mandy Chung wrote: >> Peter spots the redundant read edges are added to dynamic module when >> creating a proxy class. Proxy class does not access super >> interfaces of proxy interfaces. I have verified this simple patch >> with all core tests and JCK api tests. >> >> diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java >> b/src/java.base/share/classes/java/lang/reflect/Proxy.java >> --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java >> +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java >> @@ -804,11 +804,6 @@ >> continue; >> } >> ensureAccess(target, c); >> - >> - // add all superinterfaces >> - for (Class intf : c.getInterfaces()) { >> - deque.add(intf); >> - } >> } >> // set up proxy class access to types referenced in >> the method signature > From Alan.Bateman at oracle.com Tue Apr 12 13:42:33 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 12 Apr 2016 14:42:33 +0100 Subject: RFR: 8154067: Avoid early use of limited privilege escalation in InnerClassLambdaMetafactory In-Reply-To: <570CEC2F.7000306@oracle.com> References: <570CEC2F.7000306@oracle.com> Message-ID: <570CFB49.8060006@oracle.com> On 12/04/2016 13:38, Claes Redestad wrote: > Hi, > > the first usage of limited doPrivileged appears to have a small > startup penalty (loads 8 permission-related classes and does some > reflection), and is arguably excessive for this particular instance. > Unrestricted doPrivileged allows for a small reduction of lambda init > cost. > > Webrev: http://cr.openjdk.java.net/~redestad/8154067/webrev.01/ > Bug: https://bugs.openjdk.java.net/browse/JDK-8154067 In general then we've been encouraging the use of limited doPrivileged where it make sense although for cases like this then it doesn't have much advantage. An alternative would be to just use System.getProperty then System.getSecurityManager() == null. -Alan From paul.sandoz at oracle.com Tue Apr 12 14:02:46 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 12 Apr 2016 16:02:46 +0200 Subject: RFR [9] 8150829: Enhanced drop-args, identity and default constant, varargs adjustment In-Reply-To: <570B3A7A.9030000@oracle.com> References: <56F37FC8.60305@oracle.com> <570B3A7A.9030000@oracle.com> Message-ID: <3E2FDDB3-9A8D-4681-864C-53BFD14B7628@oracle.com> Hi, Just minor comments, below. Paul. MethodHandle ? 972 /** 973 * Adapts this method handle to be {@linkplain #asVarargsCollector variable arity} 974 * if the boolean flag is true, else {@linkplain #asFixedArity fixed arity}. 975 * If the method handle is already of the proper arity mode, it is returned 976 * unchanged. 977 *

This method is sometimes useful when adapting a method handle that 978 * may be variable arity, to ensure that the resulting adapter is also 979 * variable arity if and only if the original handle was. For example, 980 * this code changes the first argument of a handle , {@code mh}, to {@code int} without 981 * disturbing its variable arity property: 982 * {@code mh.asType(mh.type().changeParameterType(0,int.class)).withVarargs(mh.isVarargsCollector())} The above paragraph can be an @apiNote. Also can you format the code block over two lines to emphasise the last call., otherwise i think it is harder to read. 983 * @param makeVarargs true if the return method handle should have variable arity behavior 984 * @return a method handle of the same type, with possibly adjusted variable arity behavior 985 * @throws IllegalArgumentException if {@code makeVarargs} is true and 986 * this method handle does not have a trailing array parameter 987 * @since 9 Add @see #asVarargsCollector @see #asFixedArity ? 988 */ 989 public MethodHandle withVarargs(boolean makeVarargs) { MethodHandles ? 2387 /** Produces a constant method handle of the requested return type which new line after ?/**' 2388 * returns the default value for that type every time it is invoked. 2389 * The resulting constant method handle will have no side effects. 2390 *

The returned method handle is equivalent to {@code empty(methodType(type))}. 2391 * It is also equivalent to {@code explicitCastArguments(constant(Object.class, null), methodType(type))}, 2392 * since {@code explicitCastArguments} converts {@code null} to default values. Is this method more efficient than the other two? 2393 * @param type the expected return type of the desired method handle 2394 * @return a constant method handle that takes no arguments and returns the default value of the given type (or void, if the type is void) Can you format to be a little more consistent and not so long on the line length, as it becomes really tricky read. 2395 * @throws NullPointerException if the argument is null 2396 * @see MethodHandles#constant 2397 * @see MethodHandles#empty 2398 * @since 9 2399 */ 2400 public static MethodHandle zero(Class type) { 2401 Objects.requireNonNull(type); 2402 return type.isPrimitive() ? zero(Wrapper.forPrimitiveType(type), type) : zero(Wrapper.OBJECT, type); 2403 } 2404 2409 /** 2410 * Produces a method handle of the requested type which ignores any arguments, does nothing, 2411 * and returns a suitable default depending on the return type. 2412 * That is, it returns a zero primitive value, a {@code null}, or {@code void}. 2413 *

The returned method handle is equivalent to 2414 * {@code dropArguments(zero(type.returnType()), 0, type.parameterList())}. 2415 *

2416 * Example: Given a predicate and target, a useful "if-then" construct can be constructed as s/Example:/@apiNote (same applies to the method dropArgumentsToMatch) s/constructed/produced 2417 * {@code guardWithTest(pred, target, empty(target.type())}. 2418 * @param type the type of the desired method handle 2419 * @return a constant method handle of the given type, which returns a default value of the given return type 2420 * @throws NullPointerException if the argument is null 2421 * @see MethodHandles#zero 2422 * @see MethodHandles#constant 2423 * @since 9 2424 */ 2425 public static MethodHandle empty(MethodType type) { 2726 MethodHandle h0= constant(boolean.class, true); Space before '=' ConstantIdentityMHTest ? You should test the signatures and values for all primitives, ref and void. > On 11 Apr 2016, at 07:47, shilpi.rastogi at oracle.com wrote: > > Gentle Reminder! > > -------- Forwarded Message -------- > Subject: RFR [9] 8150829: Enhanced drop-args, identity and default constant, varargs adjustment > Date: Thu, 24 Mar 2016 11:18:56 +0530 > From: shilpi.rastogi at oracle.com > Reply-To: core-libs-dev at openjdk.java.net > To: mlvm-dev at openjdk.java.net > > Hi All, > > Please review the following- > > > https://bugs.openjdk.java.net/browse/JDK-8150829 > http://cr.openjdk.java.net/~srastogi/8150829/webrev.04 > > > > Thanks, > Shilpi > > > > _______________________________________________ > mlvm-dev mailing list > mlvm-dev at openjdk.java.net > http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev From peter.levart at gmail.com Tue Apr 12 14:18:53 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 12 Apr 2016 16:18:53 +0200 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <570CF51E.3030908@gmail.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> Message-ID: <570D03CD.1000708@gmail.com> Mandy, On 04/12/2016 03:16 PM, Peter Levart wrote: > The problem is of course with the setup procedure of the dynamic > module where you have to add exports from modules/packages of those > referenced types and read edges to modules of those references types > upfront. But this problem is resolvable. If a type is not visible from > the proxy class' class loader, then we don't need an export from its > module/package and we don't need a read edge to its module, do we? > > What do you think? If you think my claims make sense, then the following change could establish such policy: http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.noStaticSignatures/webrev.02/ Regards, Peter From paul.sandoz at oracle.com Tue Apr 12 14:50:52 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 12 Apr 2016 16:50:52 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> Message-ID: <796EA2FB-95D5-4406-AF1C-2603B1915E62@oracle.com> > On 6 Apr 2016, at 16:52, Vitaly Davidovich wrote: > > So are there any bootstrap issues with VH that would preclude using it in BufferedInputStream? FWIW I did a quick perf experiment a while ago modifying A*FU to use VHs underneath and the VM booted just fine. > Is that even known at this point? Not precisely. > You mentioned that VH was designed to minimize bootstrapping issues, but where's the "minimized" line drawn? > I want to draw the line where it?s possible to modify CHM to use VHs. Paul. From paul.sandoz at oracle.com Tue Apr 12 14:52:49 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 12 Apr 2016 16:52:49 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <57052120.5010609@oracle.com> References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> <57052120.5010609@oracle.com> Message-ID: > On 6 Apr 2016, at 16:45, Claes Redestad wrote: > > On 04/06/2016 04:09 PM, Paul Sandoz wrote: >>> small streams become big rivers (i don't know the idiomatic sentence in English, so it's a rough translation from a French idiom), >>> "Death by a thousand cuts" is one of my favorites:). A "flat profile" is another description of a similar thing. >>> >> I still remain unconvinced in this case that such changes warrant an increase in unsafe usage (temporary or otherwise). >> > > I did not intend for this patch to spark any controversy - in my mind it was just a rather straightforward and easy way to save a few Kbs (and some theoretic startup time) on small program startup and I'm happy to withdraw it based on the feedback. > I don?t think there is any controversy. I just think we should place this one aside for the moment. We can revisit later on. Paul. > I do however think that reducing the dependency graph of things which are loaded in this early has merits on its own, regardless of how much it actually improves things. Using VHs here - or even in CHM - seems more controversial to me than using Unsafe to take shortcuts in low-level class libraries that need to boot fast and with as few dependencies as possible (since that allows them to be used in more places). > > Thanks! > > /Claes From steve.drach at oracle.com Tue Apr 12 16:24:59 2016 From: steve.drach at oracle.com (Steve Drach) Date: Tue, 12 Apr 2016 09:24:59 -0700 Subject: Request for comments -- resource reification vs. mrjar scheme for runtime versioning of multi-release jar files In-Reply-To: <0E10874E-48EE-4C92-985E-0C9231102F21@oracle.com> References: <49D7F484-5858-4961-A977-8437776BBA13@oracle.com> <0E10874E-48EE-4C92-985E-0C9231102F21@oracle.com> Message-ID: <683255CA-732B-4FE3-9DFA-54E680C78F6B@oracle.com> We?ve identified two possible ways to address issue JDK-8151542. One way is to append a #runtime fragment to the input URL in URLClassPath to convey to URLJarFile that we want to have the JarFile opened with the parameter Release.RUNTIME, so any loaded classes are runtime versioned. This is currently implemented and was integrated as part of issue JDK-8132734 For this case, a resource URL returned from ClassLoader.getResource(s) is reified, that is the returned URL does not have the #runtime fragment appended to it, instead the URL points directly to the desired entry. The other way is to create a new URL scheme ?mrjar? so that when URLJarFile sees the URL it knows to open the Jarfile with the Release.RUNTIME parameter. No fragment is required. A returned resource URL will be of the form ?mrjar:!/{entry} We?ve put together the following list of pros/cons for each approach. We?re soliciting feedback from the mailing list. We currently have a working patch for the reification approach, but not one for the new scheme approach. reification pros ? . produces a standard/normal URL pointing directly to the jar entry . the String equivalent is parsable so it shouldn?t affect legacy code reification cons ? . exposes the internals of a jar (i.e explicitly shows the META-INF/versions directory) . the input URL is modified by attaching a #runtime fragment to it . URL is not ?portable? across jars as platform release version changes mrjar scheme pros ? . one URL that always points to runtime versioned entries . the same URL (with entry appended) is returned by the getResource method . portable across different platform releases . jigsaw has also introduced a new URL scheme mrjar scheme cons ? . may break String based parsing of URLS . non-standard URL scheme . what does it mean with non MR files? . we haven?t put together a prototype yet As I said, we?re soliciting feedback from the list. My personal opinion is that we should go with what we have, the reification approach, since it?s least likely to break existing code. From amaembo at gmail.com Tue Apr 12 16:37:35 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Tue, 12 Apr 2016 22:37:35 +0600 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: References: <755756441.20160401222505@gmail.com> Message-ID: <1627999138.20160412223735@gmail.com> Hello! Thank you, Stefan and Paul for review. Here's updated webrev: http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r2/ Changes: - all new mapToObj are private and not final - IntStream.asDoubleStream preserves distinct now - Tests fixed according to Stefan's suggestions - Additional tests added which test how sorted and distinct actually work, as Paul suggests. Values close to Integer.MAX_VALUE and Long.MAX_VALUE are tested. TreeSet and TreeSet is used to produce expected result. With best regards, Tagir Valeev. SZ> Hi Tagir, SZ> another minor issue. The testFlags() methods in IntPrimitiveOpsTests SZ> / LongPrimitiveOpsTests each have a duplicated assert: SZ> IntPrimitiveOpsTests: SZ> assertFalse(IntStreams.of(1, 10).boxed().spliterator() SZ> .hasCharacteristics(Spliterator.SORTED)); SZ> LongPrimitiveOpsTests: SZ> assertFalse(LongStreams.of(1, 10).boxed().spliterator() SZ> .hasCharacteristics(Spliterator.SORTED)); SZ> The asserts for IntStreams.range(1, 10).asDoubleStream() would have SZ> to be changed to account for DISTINCTness, of course. SZ> Regards, SZ> Stefan SZ> 2016-04-01 18:25 GMT+02:00 Tagir F. Valeev : >> Hello! >> >> Please review and sponsor the following patch: >> http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r1/ >> >> The patch preserves more characteristics on primitive stream >> operations: >> IntStream/LongStream/DoubleStream.boxed() preserves SORTED and DISTINCT >> IntStream.asLongStream() preserves SORTED and DISTINCT >> IntStream.asDoubleStream() and LongStream.asDoubleStream() preserves SORTED >> (different longs can be converted into the same double, so DISTINCT is >> not preserved here; not sure whether this is possible for ints) >> >> Fixing the boxed() case is especially important as distinct() for >> primitive streams is implemented like boxed().distinct().unbox, so the >> actual distinct() operation cannot take the advantage of DISTINCT flag >> (skip the operation at all) or SORTED flag (switch to more efficient >> implementation). >> >> Here's the small JMH benchmark which measures the performance boost of >> quite common operation: sort the input numbers and leave only distinct >> ones: >> http://cr.openjdk.java.net/~tvaleev/webrev/8153293/jmh/ >> >> new Random(1).ints(size).sorted().distinct().toArray() >> >> I've got the following results. >> >> 9ea+111: >> >> Benchmark (size) Mode Cnt Score Error Units >> SortDistinctTest.sortedDistinct 10 avgt 30 0,612 ? 0,004 us/op >> SortDistinctTest.sortedDistinct 1000 avgt 30 92,848 ? 1,039 us/op >> SortDistinctTest.sortedDistinct 100000 avgt 30 32147,205 ? 3487,422 us/op >> >> 9ea+111 patched: >> >> Benchmark (size) Mode Cnt Score Error Units >> SortDistinctTest.sortedDistinct 10 avgt 30 0,435 ? 0,001 us/op >> SortDistinctTest.sortedDistinct 1000 avgt 30 40,555 ? 0,772 us/op >> SortDistinctTest.sortedDistinct 100000 avgt 30 9031,651 ? 73,956 us/op >> >> With best regards, >> Tagir Valeev. >> From mandy.chung at oracle.com Tue Apr 12 16:58:00 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 12 Apr 2016 09:58:00 -0700 Subject: RFR: 8154067: Avoid early use of limited privilege escalation in InnerClassLambdaMetafactory In-Reply-To: <570CEC2F.7000306@oracle.com> References: <570CEC2F.7000306@oracle.com> Message-ID: <2394587E-A7F3-490C-97B7-A2CC303191FF@oracle.com> > On Apr 12, 2016, at 5:38 AM, Claes Redestad wrote: > > Hi, > > the first usage of limited doPrivileged appears to have a small startup penalty (loads 8 permission-related classes and does some reflection), and is arguably excessive for this particular instance. Unrestricted doPrivileged allows for a small reduction of lambda init cost. > > Webrev: http://cr.openjdk.java.net/~redestad/8154067/webrev.01/ > Bug: https://bugs.openjdk.java.net/browse/JDK-8154067 > +1 I agree that getting system properties isn?t a good usage example of limited doPrivileged since the permission is very clear and explicit. Mandy From huizhe.wang at oracle.com Tue Apr 12 17:53:32 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Tue, 12 Apr 2016 10:53:32 -0700 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <570C4604.7060700@oracle.com> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> Message-ID: <570D361C.9060602@oracle.com> Also, EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET was a wrong msg id. It would be good to change that to DoctypedeclNotClosed and add a message to XMLMessages.properties right before DoctypedeclUnterminated, sth. like the following: DoctypedeclNotClosed = The document type declaration for root element type \"{0}\" must be closed with '']''. Thanks, Joe On 4/11/2016 5:49 PM, huizhe wang wrote: > > On 4/7/2016 1:45 PM, Langer, Christoph wrote: >> Hi, >> >> >> >> I've run into a peculiar issue with Xerces. >> >> >> >> The problem is happening when a DTD shall be skipped, the DTD is >> larger than the buffer of the current entity and a CRLF sequence >> occurs just one char before the buffer end. >> >> >> >> The reason is that method skipDTD of class XMLDTDScannerImpl (about >> line 389) calls XMLEntityScanner.scanData() to scan for the next >> occurrence of ']'. The scanData method might return true which >> indicates that the delimiter ']' was not found yet and more data is >> to scan. Other users of scanData would handle this and call this >> method in a loop until it returns false or some other condition >> happens. So I've fixed that place like at the other callers of scanData. > > This part of the change looks good. >> >> >> >> Nevertheless, the scanData method would usually load more data when >> it is at the end of the buffer. But in the special case when CRLF is >> found at the end of buffer - 1, scanData would just return true. So I >> also removed that check at line 1374 in XMLEntityScanner. Do you see >> any problem with that? Is there any reason behind it which I'm >> overseeing? > > No need to remove this after the above change. The parser needs to > retain what's in the xml, e.g., not removing new lines. >> >> Furthermore I took the chance for further little cleanups. I've added >> the new copyright header to the files... is that the correct one? > > Yes, that's the right license header. However, >> >> >> I also aligned the calls to invokeListeners(position) in >> XMLEntityScanner to always pass the actual position from which the >> load is started. Do you think this is correct? > > Yes. >> >> >> >> Here is the bug: >> >> https://bugs.openjdk.java.net/browse/JDK-8153781 >> >> >> >> Here is the webrev: >> >> http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ >> >> >> >> Please give me some comments before I finalize my change including a >> jtreg testcase. > > It would be better if you had included the testcase so that the review > can be done together with the code change. > > Thanks, > Joe > >> >> >> >> Thanks & Best regards >> >> Christoph >> >> >> > From sean.mullan at oracle.com Tue Apr 12 18:26:17 2016 From: sean.mullan at oracle.com (Sean Mullan) Date: Tue, 12 Apr 2016 14:26:17 -0400 Subject: RFR: 8154067: Avoid early use of limited privilege escalation in InnerClassLambdaMetafactory In-Reply-To: <2394587E-A7F3-490C-97B7-A2CC303191FF@oracle.com> References: <570CEC2F.7000306@oracle.com> <2394587E-A7F3-490C-97B7-A2CC303191FF@oracle.com> Message-ID: <570D3DC9.6070801@oracle.com> On 04/12/2016 12:58 PM, Mandy Chung wrote: > >> On Apr 12, 2016, at 5:38 AM, Claes Redestad wrote: >> >> Hi, >> >> the first usage of limited doPrivileged appears to have a small startup penalty (loads 8 permission-related classes and does some reflection), and is arguably excessive for this particular instance. Unrestricted doPrivileged allows for a small reduction of lambda init cost. >> >> Webrev: http://cr.openjdk.java.net/~redestad/8154067/webrev.01/ >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154067 >> > > +1 > > I agree that getting system properties isn?t a good usage example of limited doPrivileged since the permission is very clear and explicit. I also agree. In this case, the privileged action (System.getProperty) is very concise, so the risk is very low that the additional permissions could be abused. --Sean From brian.goetz at oracle.com Tue Apr 12 18:29:29 2016 From: brian.goetz at oracle.com (Brian Goetz) Date: Tue, 12 Apr 2016 14:29:29 -0400 Subject: RFR: 8154067: Avoid early use of limited privilege escalation in InnerClassLambdaMetafactory In-Reply-To: <570CEC2F.7000306@oracle.com> References: <570CEC2F.7000306@oracle.com> Message-ID: <7F54AE6D-8DAA-485D-9A29-1BD435AC4AB9@oracle.com> No problem with this change. +1. > On Apr 12, 2016, at 8:38 AM, Claes Redestad wrote: > > Hi, > > the first usage of limited doPrivileged appears to have a small startup penalty (loads 8 permission-related classes and does some reflection), and is arguably excessive for this particular instance. Unrestricted doPrivileged allows for a small reduction of lambda init cost. > > Webrev: http://cr.openjdk.java.net/~redestad/8154067/webrev.01/ > Bug: https://bugs.openjdk.java.net/browse/JDK-8154067 > > Thanks! > > /Claes From christoph.langer at sap.com Tue Apr 12 18:50:40 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Tue, 12 Apr 2016 18:50:40 +0000 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <570D361C.9060602@oracle.com> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> Message-ID: <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> Hi Joe, thanks as always for your suggestions and I'll try to work it in. It will probably take me a little while as I'm currently busy with another thing. I'll update my webrev eventually and add a testcase, too. But one question: I understand that the fix in skipDTD will be sufficient to fix the issue. Nevetheless, can you explain me why the change in scanData is not beneficial or could even cause issues? There are several places in scanData when further loads are done. But only at this point where there's exactly one character after CRLF at the end of the buffer the method just returns without further load. If it wouldn't leave here it seems to me as if it would continue correctly and load more data. That would probably also be better in the sense of performance I guess?? Thanks Christoph > -----Original Message----- > From: huizhe wang [mailto:huizhe.wang at oracle.com] > Sent: Dienstag, 12. April 2016 19:54 > To: Langer, Christoph > Cc: core-libs-dev at openjdk.java.net > Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: > EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping > large DOCTYPE section with CRLF at wrong place > > Also, EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET was a > wrong msg > id. It would be good to change that to DoctypedeclNotClosed and add a > message to XMLMessages.properties right before DoctypedeclUnterminated, > sth. like the following: > > DoctypedeclNotClosed = The document type declaration for root element > type \"{0}\" must be closed with '']''. > > Thanks, > Joe > > On 4/11/2016 5:49 PM, huizhe wang wrote: > > > > On 4/7/2016 1:45 PM, Langer, Christoph wrote: > >> Hi, > >> > >> > >> > >> I've run into a peculiar issue with Xerces. > >> > >> > >> > >> The problem is happening when a DTD shall be skipped, the DTD is > >> larger than the buffer of the current entity and a CRLF sequence > >> occurs just one char before the buffer end. > >> > >> > >> > >> The reason is that method skipDTD of class XMLDTDScannerImpl (about > >> line 389) calls XMLEntityScanner.scanData() to scan for the next > >> occurrence of ']'. The scanData method might return true which > >> indicates that the delimiter ']' was not found yet and more data is > >> to scan. Other users of scanData would handle this and call this > >> method in a loop until it returns false or some other condition > >> happens. So I've fixed that place like at the other callers of scanData. > > > > This part of the change looks good. > >> > >> > >> > >> Nevertheless, the scanData method would usually load more data when > >> it is at the end of the buffer. But in the special case when CRLF is > >> found at the end of buffer - 1, scanData would just return true. So I > >> also removed that check at line 1374 in XMLEntityScanner. Do you see > >> any problem with that? Is there any reason behind it which I'm > >> overseeing? > > > > No need to remove this after the above change. The parser needs to > > retain what's in the xml, e.g., not removing new lines. > >> > >> Furthermore I took the chance for further little cleanups. I've added > >> the new copyright header to the files... is that the correct one? > > > > Yes, that's the right license header. However, > >> > >> > >> I also aligned the calls to invokeListeners(position) in > >> XMLEntityScanner to always pass the actual position from which the > >> load is started. Do you think this is correct? > > > > Yes. > >> > >> > >> > >> Here is the bug: > >> > >> https://bugs.openjdk.java.net/browse/JDK-8153781 > >> > >> > >> > >> Here is the webrev: > >> > >> http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ > >> > >> > >> > >> Please give me some comments before I finalize my change including a > >> jtreg testcase. > > > > It would be better if you had included the testcase so that the review > > can be done together with the code change. > > > > Thanks, > > Joe > > > >> > >> > >> > >> Thanks & Best regards > >> > >> Christoph > >> > >> > >> > > From claes.redestad at oracle.com Tue Apr 12 18:56:43 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Tue, 12 Apr 2016 20:56:43 +0200 Subject: RFR: 8154067: Avoid early use of limited privilege escalation in InnerClassLambdaMetafactory In-Reply-To: <7F54AE6D-8DAA-485D-9A29-1BD435AC4AB9@oracle.com> References: <570CEC2F.7000306@oracle.com> <7F54AE6D-8DAA-485D-9A29-1BD435AC4AB9@oracle.com> Message-ID: <570D44EB.3000308@oracle.com> Mandy, Sean, Alan, Brian, thanks for reviewing this! /Claes On 2016-04-12 20:29, Brian Goetz wrote: > No problem with this change. +1. > > >> On Apr 12, 2016, at 8:38 AM, Claes Redestad wrote: >> >> Hi, >> >> the first usage of limited doPrivileged appears to have a small startup penalty (loads 8 permission-related classes and does some reflection), and is arguably excessive for this particular instance. Unrestricted doPrivileged allows for a small reduction of lambda init cost. >> >> Webrev: http://cr.openjdk.java.net/~redestad/8154067/webrev.01/ >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154067 >> >> Thanks! >> >> /Claes From lance.andersen at oracle.com Tue Apr 12 19:28:48 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Tue, 12 Apr 2016 15:28:48 -0400 Subject: RFR JDK 9 (JAXP) 8151162: Public entries not searched when prefer='system' In-Reply-To: <57081953.6000807@oracle.com> References: <57081953.6000807@oracle.com> Message-ID: <97896AB1-F75D-4679-BA0D-637FB270380C@oracle.com> Looks OK Joe. Best Lance > On Apr 8, 2016, at 4:49 PM, huizhe wang wrote: > > Hi, > > Please review a fix for the issue that caused public entries not being searched when prefer='system'. When prefer='system', the Catalog standard only required that public entries were not searched if there is a system identifier. > > I added tests to reflect a combination of the settings of prefer, identifier(s), and entry types (public and/or system). The test "matchWithPrefer" covered the three test cases in the JCK mentioned in the bug report plus 9 other scenarios, while "resolveWithPrefer" covered 18 resolution scenarios by a CatalogResolver. > > JBS: https://bugs.openjdk.java.net/browse/JDK-8151162 > Webrev: http://cr.openjdk.java.net/~joehw/jdk9/8151162/webrev/ > > Thanks, > Joe Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From spliterator at gmail.com Tue Apr 12 20:30:16 2016 From: spliterator at gmail.com (Stefan Zobel) Date: Tue, 12 Apr 2016 22:30:16 +0200 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: <1627999138.20160412223735@gmail.com> References: <755756441.20160401222505@gmail.com> <1627999138.20160412223735@gmail.com> Message-ID: Hi Tagir, thanks! Looks fine to me now - especially the new testSortDistinct() methods. But note: I'm only a participant, not a reviewer of any sort. Thanks, Stefan 2016-04-12 18:37 GMT+02:00 Tagir F. Valeev : > Hello! > > Thank you, Stefan and Paul for review. Here's updated webrev: > > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r2/ > > Changes: > - all new mapToObj are private and not final > - IntStream.asDoubleStream preserves distinct now > - Tests fixed according to Stefan's suggestions > - Additional tests added which test how sorted and distinct actually > work, as Paul suggests. Values close to Integer.MAX_VALUE and Long.MAX_VALUE > are tested. TreeSet and TreeSet is used to produce > expected result. > > With best regards, > Tagir Valeev. > From huizhe.wang at oracle.com Tue Apr 12 21:28:17 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Tue, 12 Apr 2016 14:28:17 -0700 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> Message-ID: <570D6871.5000405@oracle.com> On 4/12/2016 11:50 AM, Langer, Christoph wrote: > Hi Joe, > > thanks as always for your suggestions and I'll try to work it in. It will probably take me a little while as I'm currently busy with another thing. I'll update my webrev eventually and add a testcase, too. Ok. > > But one question: I understand that the fix in skipDTD will be sufficient to fix the issue. Nevetheless, can you explain me why the change in scanData is not beneficial or could even cause issues? There are several places in scanData when further loads are done. But only at this point where there's exactly one character after CRLF at the end of the buffer the method just returns without further load. If it wouldn't leave here it seems to me as if it would continue correctly and load more data. That would probably also be better in the sense of performance I guess?? It's there to handle the situation where a surrogate pair got split in between buffers. -Joe > > Thanks > Christoph > >> -----Original Message----- >> From: huizhe wang [mailto:huizhe.wang at oracle.com] >> Sent: Dienstag, 12. April 2016 19:54 >> To: Langer, Christoph >> Cc: core-libs-dev at openjdk.java.net >> Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: >> EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping >> large DOCTYPE section with CRLF at wrong place >> >> Also, EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET was a >> wrong msg >> id. It would be good to change that to DoctypedeclNotClosed and add a >> message to XMLMessages.properties right before DoctypedeclUnterminated, >> sth. like the following: >> >> DoctypedeclNotClosed = The document type declaration for root element >> type \"{0}\" must be closed with '']''. >> >> Thanks, >> Joe >> >> On 4/11/2016 5:49 PM, huizhe wang wrote: >>> On 4/7/2016 1:45 PM, Langer, Christoph wrote: >>>> Hi, >>>> >>>> >>>> >>>> I've run into a peculiar issue with Xerces. >>>> >>>> >>>> >>>> The problem is happening when a DTD shall be skipped, the DTD is >>>> larger than the buffer of the current entity and a CRLF sequence >>>> occurs just one char before the buffer end. >>>> >>>> >>>> >>>> The reason is that method skipDTD of class XMLDTDScannerImpl (about >>>> line 389) calls XMLEntityScanner.scanData() to scan for the next >>>> occurrence of ']'. The scanData method might return true which >>>> indicates that the delimiter ']' was not found yet and more data is >>>> to scan. Other users of scanData would handle this and call this >>>> method in a loop until it returns false or some other condition >>>> happens. So I've fixed that place like at the other callers of scanData. >>> This part of the change looks good. >>>> >>>> >>>> Nevertheless, the scanData method would usually load more data when >>>> it is at the end of the buffer. But in the special case when CRLF is >>>> found at the end of buffer - 1, scanData would just return true. So I >>>> also removed that check at line 1374 in XMLEntityScanner. Do you see >>>> any problem with that? Is there any reason behind it which I'm >>>> overseeing? >>> No need to remove this after the above change. The parser needs to >>> retain what's in the xml, e.g., not removing new lines. >>>> Furthermore I took the chance for further little cleanups. I've added >>>> the new copyright header to the files... is that the correct one? >>> Yes, that's the right license header. However, >>>> >>>> I also aligned the calls to invokeListeners(position) in >>>> XMLEntityScanner to always pass the actual position from which the >>>> load is started. Do you think this is correct? >>> Yes. >>>> >>>> >>>> Here is the bug: >>>> >>>> https://bugs.openjdk.java.net/browse/JDK-8153781 >>>> >>>> >>>> >>>> Here is the webrev: >>>> >>>> http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ >>>> >>>> >>>> >>>> Please give me some comments before I finalize my change including a >>>> jtreg testcase. >>> It would be better if you had included the testcase so that the review >>> can be done together with the code change. >>> >>> Thanks, >>> Joe >>> >>>> >>>> >>>> Thanks & Best regards >>>> >>>> Christoph >>>> >>>> >>>> From huizhe.wang at oracle.com Tue Apr 12 21:28:54 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Tue, 12 Apr 2016 14:28:54 -0700 Subject: RFR JDK 9 (JAXP) 8151162: Public entries not searched when prefer='system' In-Reply-To: <97896AB1-F75D-4679-BA0D-637FB270380C@oracle.com> References: <57081953.6000807@oracle.com> <97896AB1-F75D-4679-BA0D-637FB270380C@oracle.com> Message-ID: <570D6896.3040406@oracle.com> Thanks Lance! On 4/12/2016 12:28 PM, Lance Andersen wrote: > Looks OK Joe. > > Best > Lance >> On Apr 8, 2016, at 4:49 PM, huizhe wang > > wrote: >> >> Hi, >> >> Please review a fix for the issue that caused public entries not >> being searched when prefer='system'. When prefer='system', the >> Catalog standard only required that public entries were not searched >> if there is a system identifier. >> >> I added tests to reflect a combination of the settings of prefer, >> identifier(s), and entry types (public and/or system). The test >> "matchWithPrefer" covered the three test cases in the JCK mentioned >> in the bug report plus 9 other scenarios, while "resolveWithPrefer" >> covered 18 resolution scenarios by a CatalogResolver. >> >> JBS: https://bugs.openjdk.java.net/browse/JDK-8151162 >> Webrev: http://cr.openjdk.java.net/~joehw/jdk9/8151162/webrev/ >> >> >> Thanks, >> Joe > > > > Lance > Andersen| Principal Member of Technical Staff | +1.781.442.2037 > Oracle Java Engineering > 1 Network Drive > Burlington, MA 01803 > Lance.Andersen at oracle.com > > > From mandy.chung at oracle.com Tue Apr 12 23:55:02 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 12 Apr 2016 16:55:02 -0700 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <570CF51E.3030908@gmail.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> Message-ID: <2EA3B953-759F-433D-9DD1-C68DA5C270BD@oracle.com> > On Apr 12, 2016, at 6:16 AM, Peter Levart wrote: > > Hi Mandy, > > There's another redundant validation and read edge addition I think. When deriving referenced types from methods of interfaces, static methods could be skipped as they are not implemented or overridden by Proxy class: I think static methods could be skipped. > > http://cr.openjdk.java.net/~plevart/jdk9-dev/Proxy.noStaticSignatures/webrev.01/ > > And there's also a question whether referenced types derived from method signatures should be checked for visibility from the specified class loader (in method validateProxyInterfaces). On one hand it is nice to ensure that later usage of the proxy class will not encounter problems of visibility of types in method signatures, but on the other, Java has been known to practice late binding and a normal class implementing an interface is loaded without problems although its method signatures reference types that are not visible from the class' class loader. Only when such method is called does the resolving happen and exception is thrown. So the question is whether such visibility checks are actually beneficial. For example, one could successfully use a proxy class by only invoking methods that reference visible types if this check was not performed. > I noticed this missing visibility check when updating proxies to work with modules. I don?t know the history why it only checks of proxy interfaces when the API was defined. In typical cases, when a proxy interface is visible to the specified class loader, the referenced types are likely visible. On the other hand, I?m cautious of the compatibility risk if the visibility check applies to referenced types as well. I don?t think this check has vast benefits while past proxy changes broke existing libraries that show up the incompatibility risk is somewhat hard to assess. > The problem is of course with the setup procedure of the dynamic module where you have to add exports from modules/packages of those referenced types and read edges to modules of those references types upfront. But this problem is resolvable. If a type is not visible from the proxy class' class loader, then we don't need an export from its module/package and we don't need a read edge to its module, do we? True. If the type is not visible, NCFE will be thrown and this read edge and qualified exports would be redundant. Are you worrying the unused qualified exports causing security concerns? The proxy classes in a dynamic module are encapsulate and I?m not too concerned of the redundant ones. I?ll see what I would do for the static methods and send an updated webrev. Mandy > > What do you think? > > Regards, Peter > > On 04/12/2016 02:34 PM, Peter Levart wrote: >> Hi Mandy, >> >> This is OK, but the whole loop could be simplified. No need for Dequeue any more: >> >> // set up proxy class access to proxy interfaces >> Set> visited = new HashSet<>(interfaces); >> for (Class c : visited) { >> ensureAccess(target, c); >> } >> >> Regards, Peter >> >> On 04/12/2016 01:45 AM, Mandy Chung wrote: >>> Peter spots the redundant read edges are added to dynamic module when creating a proxy class. Proxy class does not access super interfaces of proxy interfaces. I have verified this simple patch with all core tests and JCK api tests. >>> >>> diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java >>> --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java >>> +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java >>> @@ -804,11 +804,6 @@ >>> continue; >>> } >>> ensureAccess(target, c); >>> - >>> - // add all superinterfaces >>> - for (Class intf : c.getInterfaces()) { >>> - deque.add(intf); >>> - } >>> } >>> // set up proxy class access to types referenced in the method signature >> > From mandy.chung at oracle.com Wed Apr 13 00:15:48 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 12 Apr 2016 17:15:48 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> Message-ID: <360DDB44-FDFC-41DE-8DF9-9BBA3AF28581@oracle.com> > On Apr 12, 2016, at 1:34 AM, R?mi Forax wrote: > > Hi Mandy, > I really don't like this patch. > > Being forced to call toStackElement to get the line number is counter intuitive. > I would prefer the two methods to not return Optional but an int and a String with the same convention as StackElement if the point of this patch is to remove the dependency to Optional. > I was expecting the common usage of StackWalker API does not need file name and line number. I think it'd be useful to include StackFrame::getBci (in the future it might include live information like locals etc) and keep the optional stuff and uncommon usage to StackTraceElement. Mandy > R?mi > > > Le 11 avril 2016 23:22:39 CEST, Mandy Chung a ?crit : >> Webrev at: >> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >> >> StackFrame::getFileName and StackFrame::getLineNumber are originally >> proposed with the view of any stack walking code can migrate to the >> StackWalker API without the use of StackTraceElement. >> >> File name and line number are useful for debugging and troubleshooting >> purpose. It has additional overhead to map from a method and BCI to >> look up the file name and line number. >> >> StackFrame::toStackTraceElement method returns StackTraceElement that >> includes the file name and line number. There is no particular benefit >> to duplicate getFileName and getLineNumber methods in StackFrame. It is >> equivalently convenient to call >> StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >> >> This patch proposes to remove StackFrame::getFileName and >> StackFrame::getLineNumber methods since such information can be >> obtained from StackFrame.toStackTraceElement(). >> >> Mandy > From joe.darcy at oracle.com Wed Apr 13 00:21:05 2016 From: joe.darcy at oracle.com (joe darcy) Date: Tue, 12 Apr 2016 17:21:05 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library Message-ID: <570D90F1.7050608@oracle.com> Hello, Please review the changes for JDK-4851642: Add fused mac to Java math library http://cr.openjdk.java.net/~darcy/4851642.0/ Fused mac (multiply-accumulate) is a ternary floating-point operation which accepts three inputs, a, b, c, and computes a * b + c with a single rounding error rather than the usual two rounding errors (a first for the multiply, a second one for the add). The fused mac operation was added in the 2008 update to the IEEE 754 floating-point standard and hardware support for the operation is becoming more and more common in different processor families. When present as a hardware instruction, a fused mac can speed up loops such as those for polynomial evaluation. A fused mac can also be used to support a correctly rounding floating-point divide and support various higher-precision operations such as "doubled-double" arithmetic. With the increasing availability of fused mac as a hardware primitive, the time has come to add fused mac to the Java math library. Fused mac is an ideal candidate to be intrinsified where hardware support is available. However, this initial implementation does not attempt to add any such intrinsics support in HotSpot; a follow-up RFE has been filed for that work (JDK-8154122). The current library implementation favors code simplicity over speed; a more performant implementation could be written by directly decomposing the floating-point inputs rather than turning to BigDecimal and may be written in the future. More extensive tests could be added in the future as well. Thanks, -Joe From mandy.chung at oracle.com Wed Apr 13 03:54:45 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 12 Apr 2016 20:54:45 -0700 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <570CF51E.3030908@gmail.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> Message-ID: <6C86E6CC-D964-45AB-A2A8-FD360F8F6041@oracle.com> Updated webrev to skip the static methods: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153895/webrev.01/ Mandy From sundararajan.athijegannathan at oracle.com Wed Apr 13 03:56:27 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Wed, 13 Apr 2016 09:26:27 +0530 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <6C86E6CC-D964-45AB-A2A8-FD360F8F6041@oracle.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> <6C86E6CC-D964-45AB-A2A8-FD360F8F6041@oracle.com> Message-ID: <570DC36B.3050502@oracle.com> +1 -Sundar On 4/13/2016 9:24 AM, Mandy Chung wrote: > Updated webrev to skip the static methods: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153895/webrev.01/ > > Mandy From peter.levart at gmail.com Wed Apr 13 06:03:09 2016 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 13 Apr 2016 08:03:09 +0200 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <6C86E6CC-D964-45AB-A2A8-FD360F8F6041@oracle.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> <6C86E6CC-D964-45AB-A2A8-FD360F8F6041@oracle.com> Message-ID: <570DE11D.6070100@gmail.com> On 04/13/2016 05:54 AM, Mandy Chung wrote: > Updated webrev to skip the static methods: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153895/webrev.01/ > > Mandy Looks good. Regards, Peter From peter.levart at gmail.com Wed Apr 13 06:22:58 2016 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 13 Apr 2016 08:22:58 +0200 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <2EA3B953-759F-433D-9DD1-C68DA5C270BD@oracle.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> <2EA3B953-759F-433D-9DD1-C68DA5C270BD@oracle.com> Message-ID: <570DE5C2.3040105@gmail.com> Hi Mandy, On 04/13/2016 01:55 AM, Mandy Chung wrote: >> On Apr 12, 2016, at 6:16 AM, Peter Levart wrote: >> >> ... >> >> And there's also a question whether referenced types derived from method signatures should be checked for visibility from the specified class loader (in method validateProxyInterfaces). On one hand it is nice to ensure that later usage of the proxy class will not encounter problems of visibility of types in method signatures, but on the other, Java has been known to practice late binding and a normal class implementing an interface is loaded without problems although its method signatures reference types that are not visible from the class' class loader. Only when such method is called does the resolving happen and exception is thrown. So the question is whether such visibility checks are actually beneficial. For example, one could successfully use a proxy class by only invoking methods that reference visible types if this check was not performed. >> > I noticed this missing visibility check when updating proxies to work with modules. I don?t know the history why it only checks of proxy interfaces when the API was defined. In typical cases, when a proxy interface is visible to the specified class loader, the referenced types are likely visible. On the other hand, I?m cautious of the compatibility risk if the visibility check applies to referenced types as well. I don?t think this check has vast benefits while past proxy changes broke existing libraries that show up the incompatibility risk is somewhat hard to assess. > >> The problem is of course with the setup procedure of the dynamic module where you have to add exports from modules/packages of those referenced types and read edges to modules of those references types upfront. But this problem is resolvable. If a type is not visible from the proxy class' class loader, then we don't need an export from its module/package and we don't need a read edge to its module, do we? > True. If the type is not visible, NCFE will be thrown and this read edge and qualified exports would be redundant. Are you worrying the unused qualified exports causing security concerns? The proxy classes in a dynamic module are encapsulate and I?m not too concerned of the redundant ones. > No, not about security. Mainly about binary compatibility. For example: - library A v1 defines an interface I with some methods - library B creates a dynamic proxy implementing I. It depends on library A and libraries defining types from method signatures of the interface - program P uses B and depends on the transitive closure now comes new version of library A v2 which adds a default method to interface I with signature that requires additional dependency which is tagged as "optional". Program P does not need to call this new method on the proxy created by B. Should we force P to bundle the new dependency although it is not used? Regards, Peter From thomas.stuefe at gmail.com Wed Apr 13 09:12:45 2016 From: thomas.stuefe at gmail.com (=?UTF-8?Q?Thomas_St=C3=BCfe?=) Date: Wed, 13 Apr 2016 11:12:45 +0200 Subject: (Round 2) RFR(s): 8150460: (linux|bsd|aix)_close.c: file descriptor table may become large or may not work at all In-Reply-To: References: <56E12E1E.7080307@oracle.com> <56E2E391.4060105@Oracle.com> Message-ID: Hi Roger, Dmitry, May I ask you both to have a last look at this change before I commit? It took a while for this to go through our internal tests, hence the delay. New version: http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.03/webrev/ Delta to last version: http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02-webrev.03/webrev/ The changes are mostly cosmetic: - I tweaked a number of comments to make them clearer - If getrlimit(RLIMIT_NOFILE) returns an error, I now handle this correctly. - Just for readability, I explicitly initialize global variables instead of relying on static zero-initialization. - As Roger requested, I changed accesses to the entry table elements from using implicit pointer arithmetic to explicit array accesses with "&". Thank you for your time! Kind Regards, Thomas On Sat, Mar 12, 2016 at 8:38 AM, Thomas St?fe wrote: > Thank you Roger! > > On Fri, Mar 11, 2016 at 4:26 PM, Roger Riggs > wrote: > >> Hi Thomas, >> >> When returning the address of the fdentry, the style using &fdTable[fd] >> is preferred over >> the implicit pointer arithmetic (as it was in the previous version). >> >> Occurs in all 3 deltas: >> >> src/java.base/*/native/libnet/*_close.c: >> + result = fdTable + fd; >> >> and >> + result = fdOverflowTable[rootindex] + slabindex; >> >> The rest looks fine. >> >> Thanks, Roger >> >> >> >> >> On 3/10/2016 7:59 AM, Thomas St?fe wrote: >> >>> Thank you Dmitry! >>> >>> I will fix the typo before comitting. >>> >>> Kind Regards, Thomas >>> >>> On Thu, Mar 10, 2016 at 9:19 AM, Dmitry Samersoff < >>> dmitry.samersoff at oracle.com> wrote: >>> >>> Thomas, >>>> >>>> Looks good for me. But please wait for someone from core-libs team. >>>> >>>> PS: Could you also fix a typeo at 79, 51, 53? >>>> >>>> s/initialized/initialization/ >>>> >>>> 51 * Heap allocated during initialization - one entry per fd >>>> >>>> -Dmitry >>>> >>>> On 2016-03-10 10:59, Thomas St?fe wrote: >>>> >>>>> Hi, >>>>> >>>>> may I have a review of this new iteration for this fix? >>>>> >>>>> Thank you! >>>>> >>>>> Thomas >>>>> >>>>> On Thu, Mar 3, 2016 at 5:26 PM, Thomas St?fe >>>>> wrote: >>>>> >>>>> Hi all, >>>>>> >>>>>> https://bugs.openjdk.java.net/browse/JDK-8150460 >>>>>> >>>>>> thanks to all who took the time to review the first version of this >>>>>> fix! >>>>>> >>>>>> This is the new version: >>>>>> >>>>>> >>>>>> >>>>>> >>>> http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02/webrev/ >>>> >>>>> I reworked the fix, trying to add in all the input I got: This fix uses >>>>>> >>>>> a >>>> >>>>> simple one-dimensional array, preallocated at startup, for low-value >>>>>> >>>>> file >>>> >>>>> descriptors. Like the code did before. Only for large values of file >>>>>> descriptors it switches to an overflow table, organized as two >>>>>> >>>>> dimensional >>>> >>>>> sparse array of fixed sized slabs, which are allocated on demand. Only >>>>>> >>>>> the >>>> >>>>> overflow table is protected by a lock. >>>>>> >>>>>> For 99% of all cases we will be using the plain simple fdTable >>>>>> structure >>>>>> as before. Only for unusually large file descriptor values we will be >>>>>> >>>>> using >>>> >>>>> this overflow table. >>>>>> >>>>>> Memory footprint is kept low: for small values of RLIMIT_NOFILE, we >>>>>> will >>>>>> only allocate as much space as we need. Only if file descriptor values >>>>>> >>>>> get >>>> >>>>> large, memory is allocated in the overflow table. >>>>>> >>>>>> Note that I avoided the proposed double-checked locking solution: I >>>>>> find >>>>>> it too risky in this place and also unnecessary. When calling >>>>>> >>>>> getFdEntry(), >>>> >>>>> we will be executing a blocking IO operation afterwards, flanked by two >>>>>> mutex locks (in startOp and endOp). So, I do not think the third mutex >>>>>> >>>>> lock >>>> >>>>> in getFdEntry will add much, especially since it is only used in case >>>>>> of >>>>>> larger file descriptor values. >>>>>> >>>>>> I also added the fix to bsd_close.c and aix_close.c. I do not like >>>>>> this >>>>>> code triplication. I briefly played around with unifying this code, >>>>>> but >>>>>> this is more difficult than it seems: implementations subtly differ >>>>>> >>>>> between >>>> >>>>> the three platforms, and solaris implementation is completely >>>>>> >>>>> different. It >>>> >>>>> may be a worthwhile cleanup, but that would be a separate issue. >>>>>> >>>>>> I did some artificial tests to check how the code does with many and >>>>>> >>>>> large >>>> >>>>> file descriptor values, all seemed to work well. I also ran java/net >>>>>> >>>>> jtreg >>>> >>>>> tests on Linux and AIX. >>>>>> >>>>>> Kind Regards, Thomas >>>>>> >>>>>> >>>>>> >>>> -- >>>> Dmitry Samersoff >>>> Oracle Java development team, Saint Petersburg, Russia >>>> * I would love to change the world, but they won't give me the sources. >>>> >>>> >> > From dmitry.samersoff at oracle.com Wed Apr 13 10:00:04 2016 From: dmitry.samersoff at oracle.com (Dmitry Samersoff) Date: Wed, 13 Apr 2016 13:00:04 +0300 Subject: (Round 2) RFR(s): 8150460: (linux|bsd|aix)_close.c: file descriptor table may become large or may not work at all In-Reply-To: References: <56E12E1E.7080307@oracle.com> <56E2E391.4060105@Oracle.com> Message-ID: <570E18A4.5070906@oracle.com> Thomas, Looks good for me! -Dmitry On 2016-04-13 12:12, Thomas St?fe wrote: > Hi Roger, Dmitry, > > May I ask you both to have a last look at this change before I commit? > It took a while for this to go through our internal tests, hence the delay. > > New > version: http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.03/webrev/ > Delta to last > version: http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02-webrev.03/webrev/ > > The changes are mostly cosmetic: > > - I tweaked a number of comments to make them clearer > - If getrlimit(RLIMIT_NOFILE) returns an error, I now handle this correctly. > - Just for readability, I explicitly initialize global variables instead > of relying on static zero-initialization. > - As Roger requested, I changed accesses to the entry table elements > from using implicit pointer arithmetic to explicit array accesses with "&". > > Thank you for your time! > > Kind Regards, Thomas > > On Sat, Mar 12, 2016 at 8:38 AM, Thomas St?fe > wrote: > > Thank you Roger! > > On Fri, Mar 11, 2016 at 4:26 PM, Roger Riggs > wrote: > > Hi Thomas, > > When returning the address of the fdentry, the style using > &fdTable[fd] is preferred over > the implicit pointer arithmetic (as it was in the previous version). > > Occurs in all 3 deltas: > > src/java.base/*/native/libnet/*_close.c: > + result = fdTable + fd; > > and > + result = fdOverflowTable[rootindex] + slabindex; > > The rest looks fine. > > Thanks, Roger > > > > > On 3/10/2016 7:59 AM, Thomas St?fe wrote: > > Thank you Dmitry! > > I will fix the typo before comitting. > > Kind Regards, Thomas > > On Thu, Mar 10, 2016 at 9:19 AM, Dmitry Samersoff < > dmitry.samersoff at oracle.com > > wrote: > > Thomas, > > Looks good for me. But please wait for someone from > core-libs team. > > PS: Could you also fix a typeo at 79, 51, 53? > > s/initialized/initialization/ > > 51 * Heap allocated during initialization - one entry > per fd > > -Dmitry > > On 2016-03-10 10:59, Thomas St?fe wrote: > > Hi, > > may I have a review of this new iteration for this fix? > > Thank you! > > Thomas > > On Thu, Mar 3, 2016 at 5:26 PM, Thomas St?fe > > > wrote: > > Hi all, > > https://bugs.openjdk.java.net/browse/JDK-8150460 > > thanks to all who took the time to review the > first version of this fix! > > This is the new version: > > > > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02/webrev/ > > I reworked the fix, trying to add in all the > input I got: This fix uses > > a > > simple one-dimensional array, preallocated at > startup, for low-value > > file > > descriptors. Like the code did before. Only for > large values of file > descriptors it switches to an overflow table, > organized as two > > dimensional > > sparse array of fixed sized slabs, which are > allocated on demand. Only > > the > > overflow table is protected by a lock. > > For 99% of all cases we will be using the plain > simple fdTable structure > as before. Only for unusually large file > descriptor values we will be > > using > > this overflow table. > > Memory footprint is kept low: for small values > of RLIMIT_NOFILE, we will > only allocate as much space as we need. Only if > file descriptor values > > get > > large, memory is allocated in the overflow table. > > Note that I avoided the proposed double-checked > locking solution: I find > it too risky in this place and also unnecessary. > When calling > > getFdEntry(), > > we will be executing a blocking IO operation > afterwards, flanked by two > mutex locks (in startOp and endOp). So, I do not > think the third mutex > > lock > > in getFdEntry will add much, especially since it > is only used in case of > larger file descriptor values. > > I also added the fix to bsd_close.c and > aix_close.c. I do not like this > code triplication. I briefly played around with > unifying this code, but > this is more difficult than it seems: > implementations subtly differ > > between > > the three platforms, and solaris implementation > is completely > > different. It > > may be a worthwhile cleanup, but that would be a > separate issue. > > I did some artificial tests to check how the > code does with many and > > large > > file descriptor values, all seemed to work well. > I also ran java/net > > jtreg > > tests on Linux and AIX. > > Kind Regards, Thomas > > > > -- > Dmitry Samersoff > Oracle Java development team, Saint Petersburg, Russia > * I would love to change the world, but they won't give > me the sources. > > > > -- Dmitry Samersoff Oracle Java development team, Saint Petersburg, Russia * I would love to change the world, but they won't give me the sources. From thomas.stuefe at gmail.com Wed Apr 13 10:46:34 2016 From: thomas.stuefe at gmail.com (=?UTF-8?Q?Thomas_St=C3=BCfe?=) Date: Wed, 13 Apr 2016 12:46:34 +0200 Subject: (Round 2) RFR(s): 8150460: (linux|bsd|aix)_close.c: file descriptor table may become large or may not work at all In-Reply-To: <570E18A4.5070906@oracle.com> References: <56E12E1E.7080307@oracle.com> <56E2E391.4060105@Oracle.com> <570E18A4.5070906@oracle.com> Message-ID: Thanks Dmitry! On Wed, Apr 13, 2016 at 12:00 PM, Dmitry Samersoff < dmitry.samersoff at oracle.com> wrote: > Thomas, > > Looks good for me! > > -Dmitry > > > On 2016-04-13 12:12, Thomas St?fe wrote: > > Hi Roger, Dmitry, > > > > May I ask you both to have a last look at this change before I commit? > > It took a while for this to go through our internal tests, hence the > delay. > > > > New > > version: > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.03/webrev/ > > Delta to last > > version: > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02-webrev.03/webrev/ > > > > The changes are mostly cosmetic: > > > > - I tweaked a number of comments to make them clearer > > - If getrlimit(RLIMIT_NOFILE) returns an error, I now handle this > correctly. > > - Just for readability, I explicitly initialize global variables instead > > of relying on static zero-initialization. > > - As Roger requested, I changed accesses to the entry table elements > > from using implicit pointer arithmetic to explicit array accesses with > "&". > > > > Thank you for your time! > > > > Kind Regards, Thomas > > > > On Sat, Mar 12, 2016 at 8:38 AM, Thomas St?fe > > wrote: > > > > Thank you Roger! > > > > On Fri, Mar 11, 2016 at 4:26 PM, Roger Riggs > > wrote: > > > > Hi Thomas, > > > > When returning the address of the fdentry, the style using > > &fdTable[fd] is preferred over > > the implicit pointer arithmetic (as it was in the previous > version). > > > > Occurs in all 3 deltas: > > > > src/java.base/*/native/libnet/*_close.c: > > + result = fdTable + fd; > > > > and > > + result = fdOverflowTable[rootindex] + slabindex; > > > > The rest looks fine. > > > > Thanks, Roger > > > > > > > > > > On 3/10/2016 7:59 AM, Thomas St?fe wrote: > > > > Thank you Dmitry! > > > > I will fix the typo before comitting. > > > > Kind Regards, Thomas > > > > On Thu, Mar 10, 2016 at 9:19 AM, Dmitry Samersoff < > > dmitry.samersoff at oracle.com > > > wrote: > > > > Thomas, > > > > Looks good for me. But please wait for someone from > > core-libs team. > > > > PS: Could you also fix a typeo at 79, 51, 53? > > > > s/initialized/initialization/ > > > > 51 * Heap allocated during initialization - one entry > > per fd > > > > -Dmitry > > > > On 2016-03-10 10:59, Thomas St?fe wrote: > > > > Hi, > > > > may I have a review of this new iteration for this > fix? > > > > Thank you! > > > > Thomas > > > > On Thu, Mar 3, 2016 at 5:26 PM, Thomas St?fe > > > > > > wrote: > > > > Hi all, > > > > https://bugs.openjdk.java.net/browse/JDK-8150460 > > > > thanks to all who took the time to review the > > first version of this fix! > > > > This is the new version: > > > > > > > > > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02/webrev/ > > > > I reworked the fix, trying to add in all the > > input I got: This fix uses > > > > a > > > > simple one-dimensional array, preallocated at > > startup, for low-value > > > > file > > > > descriptors. Like the code did before. Only for > > large values of file > > descriptors it switches to an overflow table, > > organized as two > > > > dimensional > > > > sparse array of fixed sized slabs, which are > > allocated on demand. Only > > > > the > > > > overflow table is protected by a lock. > > > > For 99% of all cases we will be using the plain > > simple fdTable structure > > as before. Only for unusually large file > > descriptor values we will be > > > > using > > > > this overflow table. > > > > Memory footprint is kept low: for small values > > of RLIMIT_NOFILE, we will > > only allocate as much space as we need. Only if > > file descriptor values > > > > get > > > > large, memory is allocated in the overflow table. > > > > Note that I avoided the proposed double-checked > > locking solution: I find > > it too risky in this place and also unnecessary. > > When calling > > > > getFdEntry(), > > > > we will be executing a blocking IO operation > > afterwards, flanked by two > > mutex locks (in startOp and endOp). So, I do not > > think the third mutex > > > > lock > > > > in getFdEntry will add much, especially since it > > is only used in case of > > larger file descriptor values. > > > > I also added the fix to bsd_close.c and > > aix_close.c. I do not like this > > code triplication. I briefly played around with > > unifying this code, but > > this is more difficult than it seems: > > implementations subtly differ > > > > between > > > > the three platforms, and solaris implementation > > is completely > > > > different. It > > > > may be a worthwhile cleanup, but that would be a > > separate issue. > > > > I did some artificial tests to check how the > > code does with many and > > > > large > > > > file descriptor values, all seemed to work well. > > I also ran java/net > > > > jtreg > > > > tests on Linux and AIX. > > > > Kind Regards, Thomas > > > > > > > > -- > > Dmitry Samersoff > > Oracle Java development team, Saint Petersburg, Russia > > * I would love to change the world, but they won't give > > me the sources. > > > > > > > > > > > -- > Dmitry Samersoff > Oracle Java development team, Saint Petersburg, Russia > * I would love to change the world, but they won't give me the sources. > From dmitry.nadezhin at gmail.com Wed Apr 13 12:41:58 2016 From: dmitry.nadezhin at gmail.com (Dmitry Nadezhin) Date: Wed, 13 Apr 2016 15:41:58 +0300 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <570D90F1.7050608@oracle.com> References: <570D90F1.7050608@oracle.com> Message-ID: Joe, Here are my comments. 1) Probably in lines StrictMath:1171, StrictMath:1220, Math:1487, Math:1593 you meant {@code -0.0 * +0.0} {@code -0.0f * +0.0f} 2) Lines Math:1508-1525 could be simpler: ==== double result = a * b + c; return Double.isNaN(result) && Double.isFinite(a) && Double.isFinite(b) ? c : result; ==== JVM may use either double or double-extended-exponent value set for a * b. Values stored in the result variable might be different, but the value returned by fusedMac(double,double.double) method will be the same. For example a = 0x1p1023, b = 0x1p1023, c = Double.NEGATIVE_INFINITY; a * b is either Double.POSITIVE_INFINITY or 0x1p2046 a * b + c is either Double.NaN or Double.NEGATIVE_INFINITY result is either Double.NaN or Double.NEGATIVE_INFINITY return value is Double.NEGATIVE_INFINITY in both cases. 3) As you say, this implementation favors code simplicity over speed. There are five special cases in lines Math:1526-1530 . Three of them (a==0.0, b==0.0, c==0.0) are essential because BigDecimal can't handle signed zeroes. The other two (a==1.0, b==1.0) are optimizations. BigDecimal handles them correctly. I think that the code would be simpler without the last two cases. Otherwise, one may ask why similar special cases (a==-1.0, b==-1.0) are not considered as well. Best Regards. From paul.sandoz at oracle.com Wed Apr 13 12:44:33 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 13 Apr 2016 14:44:33 +0200 Subject: RFR 8151705 VarHandle.AccessMode enum names should conform to code style In-Reply-To: <1625A54A-7322-4855-9533-46956C20420D@oracle.com> References: <1625A54A-7322-4855-9533-46956C20420D@oracle.com> Message-ID: <45054886-27B8-4095-B00B-CF994F6F9091@oracle.com> Hi John, I like the approach to hybrid names. I?ll follow up with another issue. How about we go with: AccessMode.NAME_get; etc.? And for those that think best-practices are rules (style guide IMO are often best practices sprinkled with subjective reasoning) i can add an @apiNote explaining why the naming scheme was chosen. Paul. > On 11 Apr 2016, at 23:23, John Rose wrote: > > On Apr 7, 2016, at 6:39 AM, Paul Sandoz > wrote: >> >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8151705-VH-AccessMode-names/webrev/ >> >> I was persuaded (in internal CCC review) to change the enum VarHandle.AccessMode constant names to conform to the expected Java style. > > I'm sorry you were persuaded, because in some of these cases it is the code style that needs to flex here, not the source code names. > > When working with reflective representations of API points, there is no benefit from representing (say) a method called toString by a variable which is called TO_STRING. It just makes it hard to see the correspondences between the ground names and the reflective names. (To start with, grep and other tools will fail to find both names.) > > This is why, in the original JSR 292 code base, I have chosen to use hybrid names for fields that reflect API points. The prefix of the hybrid names does, in fact, follow the code style, but the suffix is the exact spelling of the reflected API point. I would be sad if some officious soul "fixed" these divergent names, because it would obscure the code. In fact, I wish this particular use case for hybrid identifiers were more widely recognized. > > Examples: > http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/8c293ee99d5a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java#l660 > NF_internalMemberName = new NamedFunction(DirectMethodHandle.class > .getDeclaredMethod("internalMemberName", Object.class)), > > http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/8c293ee99d5a/src/java.base/share/classes/java/lang/invoke/Invokers.java#l443 > MH_asSpreader = IMPL_LOOKUP.findVirtual(MethodHandle.class, "asSpreader", > MethodType.methodType(MethodHandle.class, Class.class, int.class)); > > As a precedent, the JVMS uses hybrid identifiers for quasi-reflective names like CONSTANT_String, etc. > > Arguably (and also arguably not), the access types in your enums are quasi-reflective references to specific methods, and so should have their names derived (as a hybrid name) from the literal method names. > > Good style includes knowing when to bend the rules. > > ? John From paul.sandoz at oracle.com Wed Apr 13 13:03:58 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 13 Apr 2016 15:03:58 +0200 Subject: RFR: 8153293 - Stream API: Preserve SORTED and DISTINCT characteristics for boxed() and asLongStream() operations In-Reply-To: <1627999138.20160412223735@gmail.com> References: <755756441.20160401222505@gmail.com> <1627999138.20160412223735@gmail.com> Message-ID: > On 12 Apr 2016, at 18:37, Tagir F. Valeev wrote: > > Hello! > > Thank you, Stefan and Paul for review. Here's updated webrev: > > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r2/ > Looks good. I will push for you this week. Paul. From ralph.goers at dslextreme.com Wed Apr 13 13:51:46 2016 From: ralph.goers at dslextreme.com (Ralph Goers) Date: Wed, 13 Apr 2016 06:51:46 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: <360DDB44-FDFC-41DE-8DF9-9BBA3AF28581@oracle.com> References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <360DDB44-FDFC-41DE-8DF9-9BBA3AF28581@oracle.com> Message-ID: I had planned on using StackWalker to generate the location information for every logging event. It seems that this change would thus cause the creation of a new StackTraceElement for every logger event. That seems wasteful. Log4j is currently in the process of trying to reduce the number of objects that are created while logging as it has a significant impact on garbage collection. So I am also in favor of getting the filename and line number directly from the StackFrame. Ralph > On Apr 12, 2016, at 5:15 PM, Mandy Chung wrote: > > >> On Apr 12, 2016, at 1:34 AM, R?mi Forax wrote: >> >> Hi Mandy, >> I really don't like this patch. >> >> Being forced to call toStackElement to get the line number is counter intuitive. >> I would prefer the two methods to not return Optional but an int and a String with the same convention as StackElement if the point of this patch is to remove the dependency to Optional. >> > > I was expecting the common usage of StackWalker API does not need file name and line number. I think it'd be useful to include StackFrame::getBci (in the future it might include live information like locals etc) and keep the optional stuff and uncommon usage to StackTraceElement. > > Mandy > > >> R?mi >> >> >> Le 11 avril 2016 23:22:39 CEST, Mandy Chung a ?crit : >>> Webrev at: >>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >>> >>> StackFrame::getFileName and StackFrame::getLineNumber are originally >>> proposed with the view of any stack walking code can migrate to the >>> StackWalker API without the use of StackTraceElement. >>> >>> File name and line number are useful for debugging and troubleshooting >>> purpose. It has additional overhead to map from a method and BCI to >>> look up the file name and line number. >>> >>> StackFrame::toStackTraceElement method returns StackTraceElement that >>> includes the file name and line number. There is no particular benefit >>> to duplicate getFileName and getLineNumber methods in StackFrame. It is >>> equivalently convenient to call >>> StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >>> >>> This patch proposes to remove StackFrame::getFileName and >>> StackFrame::getLineNumber methods since such information can be >>> obtained from StackFrame.toStackTraceElement(). >>> >>> Mandy >> > > From nadeesh.tv at oracle.com Wed Apr 13 14:19:53 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Wed, 13 Apr 2016 19:49:53 +0530 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset Message-ID: <570E5589.7080106@oracle.com> HI all, Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 Issue - java.time.format.DateTimeFormatter can't parse localized zone-offset Solution - Corrected the mistake in calculating parse end position and removed an unnecessary null check webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ PS: TCKOffsetPrinterParser.test_print_localized() already contain some test cases related to parsing and formatting. therefore did not repeat in the new test cases file -- Thanks and Regards, Nadeesh TV From michael.haupt at oracle.com Wed Apr 13 14:39:18 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 13 Apr 2016 16:39:18 +0200 Subject: RFR(S): 8150824: Exceptions when omitting trailing arguments in cleanup Message-ID: Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8150824 Webrev: http://cr.openjdk.java.net/~mhaupt/8150824/webrev.00/ The actual bug was fixed with the push for 8150829; this change merely contributes tests for the issue. Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From Roger.Riggs at Oracle.com Wed Apr 13 15:42:17 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 13 Apr 2016 11:42:17 -0400 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException Message-ID: <570E68D9.6070106@Oracle.com> Please review an increase in the default stack size of the Process reaper thread to 48K from 32k. Some tests with various VM arguments are failing intermittently. The failures are not reproducible. Webrev: http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ Issue: https://bugs.openjdk.java.net/browse/JDK-8086278 Thanks, Roger From chris.hegarty at oracle.com Wed Apr 13 15:43:07 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 13 Apr 2016 16:43:07 +0100 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported Message-ID: <570E690B.2060703@oracle.com> This review is for the second significant part of the changes for JEP 260 [1]. When created, the jdk.unsupported module [2] initially contained the sun.misc package. This issue is will move all the non-Critical APIs out of sun.reflect, leaving only the critical ones, at which point sun.reflect can be moved to the jdk.unsupported module. http://cr.openjdk.java.net/~chegar/8137058/ https://bugs.openjdk.java.net/browse/JDK-8137058 Summary of the changes: - Move all existing sun.reflect types to jdk.internal.reflect, and fix up references in the libraries, and the VM, to use the new internal location. - Update tests, as appropriate, to use the new location. - Add the minimal set of critical APIs to jdk.unsupported/sun.reflect. These ultimately delegate to the internal versions. Additionally, a few new tests have been added to exercise these. -Chris. [1] https://bugs.openjdk.java.net/browse/JDK-8132928 [2] https://bugs.openjdk.java.net/browse/JDK-8153737 From Roger.Riggs at Oracle.com Wed Apr 13 15:56:30 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 13 Apr 2016 11:56:30 -0400 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: <570E5589.7080106@oracle.com> References: <570E5589.7080106@oracle.com> Message-ID: <570E6C2E.4060208@Oracle.com> Hi Nadeesh, The bugfix looks fine. The TODO comment on the "GMT" raises the question (as a separate issue) about implementing the TODO or removing the TODO comment. I'm not sure where the localized string for "GMT" would come from but it might be a useful improvement unless it was judged to a compatibility issue. Roger On 4/13/2016 10:19 AM, nadeesh tv wrote: > HI all, > > Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 > > > Issue - java.time.format.DateTimeFormatter can't parse localized > zone-offset > > Solution - Corrected the mistake in calculating parse end position > and removed an unnecessary null check > > > webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ > > > PS: TCKOffsetPrinterParser.test_print_localized() already contain some > test cases related to parsing and formatting. therefore did not repeat > in the new test cases file > -- > Thanks and Regards, > Nadeesh TV > From Alan.Bateman at oracle.com Wed Apr 13 15:59:20 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 13 Apr 2016 16:59:20 +0100 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <570E690B.2060703@oracle.com> References: <570E690B.2060703@oracle.com> Message-ID: <570E6CD8.4080107@oracle.com> On 13/04/2016 16:43, Chris Hegarty wrote: > This review is for the second significant part of the changes for JEP > 260 [1]. When created, the jdk.unsupported module [2] initially > contained the sun.misc package. This issue is will move all the > non-Critical APIs out of sun.reflect, leaving only the critical ones, at > which point sun.reflect can be moved to the jdk.unsupported module. > > http://cr.openjdk.java.net/~chegar/8137058/ > https://bugs.openjdk.java.net/browse/JDK-8137058 > This looks good. A few comments: I assume the new sun.reflect.Reflection should have a private constructor to prevent it being instantiated. You've probably thought about this already but I assume the @Deprecated in Reflection.getCallerClass should reference the supported API. The changes to InetAddress don't seem unrelated but good. -Alan. From chris.hegarty at oracle.com Wed Apr 13 16:02:30 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 13 Apr 2016 17:02:30 +0100 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException In-Reply-To: <570E68D9.6070106@Oracle.com> References: <570E68D9.6070106@Oracle.com> Message-ID: <570E6D96.4040006@oracle.com> On 13/04/16 16:42, Roger Riggs wrote: > Please review an increase in the default stack size of the Process > reaper thread to 48K from 32k. > Some tests with various VM arguments are failing intermittently. > The failures are not reproducible. > > Webrev: > http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ Seems reasonable. While you are there, is there any reason why the reaper cannot use the overloaded Thread constructor to suppress inheriting inheritable-thread-local initial values? -Chris. > Issue: > https://bugs.openjdk.java.net/browse/JDK-8086278 > > Thanks, Roger > From mandy.chung at oracle.com Wed Apr 13 16:02:50 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 13 Apr 2016 09:02:50 -0700 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <570DE5C2.3040105@gmail.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> <2EA3B953-759F-433D-9DD1-C68DA5C270BD@oracle.com> <570DE5C2.3040105@gmail.com> Message-ID: <6044BDCF-3BFB-44B1-8CA3-707F37A8B18C@oracle.com> > On Apr 12, 2016, at 11:22 PM, Peter Levart wrote: > > No, not about security. Mainly about binary compatibility. For example: > > - library A v1 defines an interface I with some methods > - library B creates a dynamic proxy implementing I. It depends on library A and libraries defining types from method signatures of the interface > - program P uses B and depends on the transitive closure > > now comes new version of library A v2 which adds a default method to interface I with signature that requires additional dependency which is tagged as "optional". Program P does not need to call this new method on the proxy created by B. Should we force P to bundle the new dependency although it is not used? This is the compatibility concern I mentioned if we change the spec to do the visibility checks on types referenced by the method signatures. My take on this is that the benefit does not seem to justify the potential incompatibility. We could file an issue if you think we should look at further. I?d like to push webrev.01. Mandy From chris.hegarty at oracle.com Wed Apr 13 16:10:15 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 13 Apr 2016 17:10:15 +0100 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <570E6CD8.4080107@oracle.com> References: <570E690B.2060703@oracle.com> <570E6CD8.4080107@oracle.com> Message-ID: <570E6F67.3030105@oracle.com> On 13/04/16 16:59, Alan Bateman wrote: > On 13/04/2016 16:43, Chris Hegarty wrote: >> This review is for the second significant part of the changes for JEP >> 260 [1]. When created, the jdk.unsupported module [2] initially >> contained the sun.misc package. This issue is will move all the >> non-Critical APIs out of sun.reflect, leaving only the critical ones, at >> which point sun.reflect can be moved to the jdk.unsupported module. >> >> http://cr.openjdk.java.net/~chegar/8137058/ >> https://bugs.openjdk.java.net/browse/JDK-8137058 >> > This looks good. A few comments: > > I assume the new sun.reflect.Reflection should have a private > constructor to prevent it being instantiated. D'oh! of course. Updated in-place. http://cr.openjdk.java.net/~chegar/8137058/jdk/src/jdk.unsupported/share/classes/sun/reflect/Reflection.java.html > You've probably thought > about this already but I assume the @Deprecated in > Reflection.getCallerClass should reference the supported API. If it is ok, I'd like to address that separately. I think there is probably more we can do there, and it probably deserves its own discussion. > The changes to InetAddress don't seem unrelated but good. They were sitting in my repo. Just some minor reformatting. -Chris. From lance.andersen at oracle.com Wed Apr 13 16:33:07 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Wed, 13 Apr 2016 12:33:07 -0400 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: <570E6C2E.4060208@Oracle.com> References: <570E5589.7080106@oracle.com> <570E6C2E.4060208@Oracle.com> Message-ID: <002AC1A5-267B-4BA3-999C-DFF7FEC1EEE6@oracle.com> > On Apr 13, 2016, at 11:56 AM, Roger Riggs wrote: > > Hi Nadeesh, > > The bugfix looks fine. > > The TODO comment on the "GMT" raises the question (as a separate issue) > about implementing the TODO or removing the TODO comment. > > I'm not sure where the localized string for "GMT" would come from but it might be a useful improvement > unless it was judged to a compatibility issue. > Could gmtText be made static final as it is declared in 3 or 4 methods if it is not being localized? > Roger > > > > On 4/13/2016 10:19 AM, nadeesh tv wrote: >> HI all, >> >> Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 >> >> Issue - java.time.format.DateTimeFormatter can't parse localized zone-offset >> >> Solution - Corrected the mistake in calculating parse end position and removed an unnecessary null check >> >> >> webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ >> >> PS: TCKOffsetPrinterParser.test_print_localized() already contain some test cases related to parsing and formatting. therefore did not repeat in the new test cases file >> -- >> Thanks and Regards, >> Nadeesh TV >> > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From Roger.Riggs at Oracle.com Wed Apr 13 17:06:24 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 13 Apr 2016 13:06:24 -0400 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: <002AC1A5-267B-4BA3-999C-DFF7FEC1EEE6@oracle.com> References: <570E5589.7080106@oracle.com> <570E6C2E.4060208@Oracle.com> <002AC1A5-267B-4BA3-999C-DFF7FEC1EEE6@oracle.com> Message-ID: <570E7C90.4030503@Oracle.com> Hi Lance, Literal strings are interned by the compiler but it would make it clearer that it is the same string everywhere. Though I find it easier to read when the value is inline without having to do the indirection to a constant. And its really not going to change; "GMT" is too deeply embedded in the nomenclature. Roger On 4/13/2016 12:33 PM, Lance Andersen wrote: > >> On Apr 13, 2016, at 11:56 AM, Roger Riggs > > wrote: >> >> Hi Nadeesh, >> >> The bugfix looks fine. >> >> The TODO comment on the "GMT" raises the question (as a separate issue) >> about implementing the TODO or removing the TODO comment. >> >> I'm not sure where the localized string for "GMT" would come from but >> it might be a useful improvement >> unless it was judged to a compatibility issue. >> > Could gmtText be made static final as it is declared in 3 or 4 > methods if it is not being localized? >> Roger >> >> >> >> On 4/13/2016 10:19 AM, nadeesh tv wrote: >>> HI all, >>> >>> Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 >>> >>> >>> Issue - java.time.format.DateTimeFormatter can't parse localized >>> zone-offset >>> >>> Solution - Corrected the mistake in calculating parse end position >>> and removed an unnecessary null check >>> >>> >>> webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ >>> >>> >>> >>> PS: TCKOffsetPrinterParser.test_print_localized() already contain >>> some test cases related to parsing and formatting. therefore did not >>> repeat in the new test cases file >>> -- >>> Thanks and Regards, >>> Nadeesh TV >>> >> > > > > Lance > Andersen| Principal Member of Technical Staff | +1.781.442.2037 > Oracle Java Engineering > 1 Network Drive > Burlington, MA 01803 > Lance.Andersen at oracle.com > > > From Roger.Riggs at Oracle.com Wed Apr 13 17:11:11 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 13 Apr 2016 13:11:11 -0400 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException In-Reply-To: <570E6D96.4040006@oracle.com> References: <570E68D9.6070106@Oracle.com> <570E6D96.4040006@oracle.com> Message-ID: <570E7DAF.2090805@Oracle.com> Hi Chris, On 4/13/2016 12:02 PM, Chris Hegarty wrote: > On 13/04/16 16:42, Roger Riggs wrote: >> Please review an increase in the default stack size of the Process >> reaper thread to 48K from 32k. >> Some tests with various VM arguments are failing intermittently. >> The failures are not reproducible. >> >> Webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ > > Seems reasonable. > > While you are there, is there any reason why the reaper cannot > use the overloaded Thread constructor to suppress inheriting > inheritable-thread-local initial values? ok, done. I also moved the reading of the system property to the once only code instead of inside the thread factory. Nested lambda make it harder to see what is executed when. Thanks, Roger > > -Chris. > >> Issue: >> https://bugs.openjdk.java.net/browse/JDK-8086278 >> >> Thanks, Roger >> From chris.hegarty at oracle.com Wed Apr 13 17:12:12 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 13 Apr 2016 18:12:12 +0100 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException In-Reply-To: <570E7DAF.2090805@Oracle.com> References: <570E68D9.6070106@Oracle.com> <570E6D96.4040006@oracle.com> <570E7DAF.2090805@Oracle.com> Message-ID: <570E7DEC.5060204@oracle.com> On 13/04/16 18:11, Roger Riggs wrote: > Hi Chris, > > On 4/13/2016 12:02 PM, Chris Hegarty wrote: >> On 13/04/16 16:42, Roger Riggs wrote: >>> Please review an increase in the default stack size of the Process >>> reaper thread to 48K from 32k. >>> Some tests with various VM arguments are failing intermittently. >>> The failures are not reproducible. >>> >>> Webrev: >>> http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ >> >> Seems reasonable. >> >> While you are there, is there any reason why the reaper cannot >> use the overloaded Thread constructor to suppress inheriting >> inheritable-thread-local initial values? > ok, done. > > I also moved the reading of the system property to the once only code > instead of inside the thread factory. > Nested lambda make it harder to see what is executed when. Looks ok. -Chris. From mandy.chung at oracle.com Wed Apr 13 17:15:16 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 13 Apr 2016 10:15:16 -0700 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <570E690B.2060703@oracle.com> References: <570E690B.2060703@oracle.com> Message-ID: <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> > On Apr 13, 2016, at 8:43 AM, Chris Hegarty wrote: > > This review is for the second significant part of the changes for JEP > 260 [1]. When created, the jdk.unsupported module [2] initially > contained the sun.misc package. This issue is will move all the > non-Critical APIs out of sun.reflect, leaving only the critical ones, at > which point sun.reflect can be moved to the jdk.unsupported module. > > http://cr.openjdk.java.net/~chegar/8137058/ > https://bugs.openjdk.java.net/browse/JDK-8137058 > > Summary of the changes: > > - Move all existing sun.reflect types to jdk.internal.reflect, and > fix up references in the libraries, and the VM, to use the new internal > location. I hope the getCallerClass(int depth) method is moved out of jdk.internal.reflect.Reflection. JDK is not using it and it?s retained for existing libraries to migrate to the new StackWalker API. Of course the cost is to add a native library and the build infra work has made this straight-forward. I agree with Alan that the @deprecated javadoc of sun.reflect.Reflection::getCallerClass should be updated to make it clear. What about: /** * @deprecated This method is an internal API and will be removed in JDK 10. * Use {@link StackWalker} to walk the stack and obtain the caller class * with {@link StackWalker.StackFrame#getDeclaringClass} instead. */ This patch will likely impact existing libraries that filter out reflection frames (IIRC Groovy and log4j may be examples) doing Class::getName().startsWith(?sun.reflect?). It may worth call out this incompatibility in JEP 260. StackStreamFactory.java shows an example: 1085 if (c.getName().startsWith("sun.reflect") && This should be changed to ?jdk.internal.reflect?. test/java/lang/StackWalker/EmbeddedStackWalkTest.java and maybe a few other stack walker tests. You may want to check any other of any similar pattern in the JDK code/tests (I think I got them all) The hotspot change drops the package name prefix in javaClasses.hpp which is inconsistent with other classes. I found including jdk_internal_reflect_ in the class name is useful. Coleen and others from the hotspot team may have opinion on this. FX will need to adjust for this patch (cc?ing Kevin to prepare for this) Mandy From mandy.chung at oracle.com Wed Apr 13 17:27:52 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 13 Apr 2016 10:27:52 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <360DDB44-FDFC-41DE-8DF9-9BBA3AF28581@oracle.com> Message-ID: It is good to know Log4J is planning to use StackWalker. Thanks for the feedback. I will reconsider. One thing to mention is the patch went in jdk9/hs-rt that will show up in jdk9/dev some time that changes the implementation to create StackTraceElement to get filename and line number. The object allocation should be cheap that does create short-lived objects. The main motivation of JDK-8153123 was to simplify the hotspot implementation that the runtime team had concern about. There is an open issue to follow up the performance (JDK-8153683). It?d be helpful to get your feedback on using StackWalker API and the performance data. Mandy > On Apr 13, 2016, at 6:51 AM, Ralph Goers wrote: > > I had planned on using StackWalker to generate the location information for every logging event. It seems that this change would thus cause the creation of a new StackTraceElement for every logger event. That seems wasteful. Log4j is currently in the process of trying to reduce the number of objects that are created while logging as it has a significant impact on garbage collection. So I am also in favor of getting the filename and line number directly from the StackFrame. > > Ralph > >> On Apr 12, 2016, at 5:15 PM, Mandy Chung wrote: >> >> >>> On Apr 12, 2016, at 1:34 AM, R?mi Forax wrote: >>> >>> Hi Mandy, >>> I really don't like this patch. >>> >>> Being forced to call toStackElement to get the line number is counter intuitive. >>> I would prefer the two methods to not return Optional but an int and a String with the same convention as StackElement if the point of this patch is to remove the dependency to Optional. >>> >> >> I was expecting the common usage of StackWalker API does not need file name and line number. I think it'd be useful to include StackFrame::getBci (in the future it might include live information like locals etc) and keep the optional stuff and uncommon usage to StackTraceElement. >> >> Mandy >> >> >>> R?mi >>> >>> >>> Le 11 avril 2016 23:22:39 CEST, Mandy Chung a ?crit : >>>> Webrev at: >>>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >>>> >>>> StackFrame::getFileName and StackFrame::getLineNumber are originally >>>> proposed with the view of any stack walking code can migrate to the >>>> StackWalker API without the use of StackTraceElement. >>>> >>>> File name and line number are useful for debugging and troubleshooting >>>> purpose. It has additional overhead to map from a method and BCI to >>>> look up the file name and line number. >>>> >>>> StackFrame::toStackTraceElement method returns StackTraceElement that >>>> includes the file name and line number. There is no particular benefit >>>> to duplicate getFileName and getLineNumber methods in StackFrame. It is >>>> equivalently convenient to call >>>> StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >>>> >>>> This patch proposes to remove StackFrame::getFileName and >>>> StackFrame::getLineNumber methods since such information can be >>>> obtained from StackFrame.toStackTraceElement(). >>>> >>>> Mandy >>> >> >> > > From chris.hegarty at oracle.com Wed Apr 13 17:28:00 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 13 Apr 2016 18:28:00 +0100 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> Message-ID: <570E81A0.5050904@oracle.com> Mandy, On 13/04/16 18:15, Mandy Chung wrote: > >> On Apr 13, 2016, at 8:43 AM, Chris Hegarty wrote: >> >> This review is for the second significant part of the changes for JEP >> 260 [1]. When created, the jdk.unsupported module [2] initially >> contained the sun.misc package. This issue is will move all the >> non-Critical APIs out of sun.reflect, leaving only the critical ones, at >> which point sun.reflect can be moved to the jdk.unsupported module. >> >> http://cr.openjdk.java.net/~chegar/8137058/ >> https://bugs.openjdk.java.net/browse/JDK-8137058 >> >> Summary of the changes: >> >> - Move all existing sun.reflect types to jdk.internal.reflect, and >> fix up references in the libraries, and the VM, to use the new internal >> location. > > I hope the getCallerClass(int depth) method is moved out of jdk.internal.reflect.Reflection. JDK is not using it and it?s retained for existing libraries to migrate to the new StackWalker API. Of course the cost is to add a native library and the build infra work has made this straight-forward. In my patch jdk.internal.reflect.Reflection.getCallerClass(int) is retained only to avoid the need for an unsupported.so, but if you feel strongly that is should go, then I can make the change. > I agree with Alan that the @deprecated javadoc of sun.reflect.Reflection::getCallerClass should be updated to make it clear. What about: > > /** > * @deprecated This method is an internal API and will be removed in JDK 10. > * Use {@link StackWalker} to walk the stack and obtain the caller class > * with {@link StackWalker.StackFrame#getDeclaringClass} instead. > */ That seems reasonable. The version number should be present in the @Deprecated forRemoval element too. I'll make the change. > This patch will likely impact existing libraries that filter out reflection frames (IIRC Groovy and log4j may be examples) doing Class::getName().startsWith(?sun.reflect?). It may worth call out this incompatibility in JEP 260. I'll add a note. > StackStreamFactory.java shows an example: > > 1085 if (c.getName().startsWith("sun.reflect") && > > This should be changed to ?jdk.internal.reflect?. Ah I missed this. Strangely all tests are passing without this change. I'll make the change. > test/java/lang/StackWalker/EmbeddedStackWalkTest.java and maybe a few other stack walker tests. You may want to check any other of any similar pattern in the JDK code/tests (I think I got them all) I did update some StackWalker tests, but missed this one ( it passes for me ). I'll check all of them. > The hotspot change drops the package name prefix in javaClasses.hpp which is inconsistent with other classes. I found including jdk_internal_reflect_ in the class name is useful. Coleen and others from the hotspot team may have opinion on this. Ok. > FX will need to adjust for this patch (cc?ing Kevin to prepare for this) Ah ok, thanks for copying Kevin. I'll send a note to the list once the webrev is updated. -Chris. From daniel.fuchs at oracle.com Wed Apr 13 17:28:51 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Wed, 13 Apr 2016 19:28:51 +0200 Subject: RFR: 8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class. In-Reply-To: <27D6B566-3E8D-4E9A-8807-71294ABB3685@oracle.com> References: <5707C5CB.4090403@oracle.com> <27D6B566-3E8D-4E9A-8807-71294ABB3685@oracle.com> Message-ID: <570E81D3.5010409@oracle.com> Hi Mandy, On 08/04/16 22:26, Mandy Chung wrote: > >> On Apr 8, 2016, at 7:52 AM, Daniel Fuchs wrote: >> >> Hi, >> >> Please find below a patch that slightly modifies >> the JEP 264 initial implementation to take advantage >> of the module system. >> >> The change modifies the LoggerFinder abstract service >> to take the Module of the caller class as parameter >> instead of the caller class itself. >> The caller class was used in the initial 9/dev implementation >> because java.lang.reflect.Module was not yet available. >> >> http://cr.openjdk.java.net/~dfuchs/jigsaw/webrev_8148568/webrev.01/ > > Using the Module as the caller granularity is reasonable here to find the resource bundle. > > DefaultLoggerFinder.java > 135 static boolean isSystem(Module m) { > 136 ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { > > This isSystem method should check if the class loader is platform class loader (ClassLoader::getPlatformClassLoader) or its ancestor. If you don't mind I'd rather do this change in a followup fix. There are many places (possibly including tests) where we use the idiom getClassLoader() == null. All these place would need to be audited and possibly changed, or not... For consistency reason I'd prefer to start with isSystem returning getClassLoader() == null. Then we can examine whether isSystem should be relaxed to also accept getClassLoader() == ClassLoader.getPlatformClassLoader(), and which other places should do the same. I'd feel safer if the changes getClassLoader() == null => getClassLoader() == null || getClassLoader() == ClassLoader.getPlatformClassLoader() was made in a fix that only contains that. > There are several copies of this method. Better to have one single copy of this method shared for other classes to use? OK. I put it in DefaultLoggerFinder. That seems like a good place and it could be imported from there. > Nit: you can use the diamond operation PrivilegedAction<>. done. > LazyLoggers.java. > line 294 return new LazyLoggerAccessor(name, factories, module); > > I spot several long lines in LogManager.java, Logger.java, System.java and tests, maybe other files. It?d be good if you can wrap the lines to help side-by-side review. I fixed those. Tests might still have long lines. http://cr.openjdk.java.net/~dfuchs/jigsaw/webrev_8148568/webrev.02/index.html > > Other that that, looks good. > > Mandy > From mandy.chung at oracle.com Wed Apr 13 17:34:22 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 13 Apr 2016 10:34:22 -0700 Subject: RFR: 8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class. In-Reply-To: <570E81D3.5010409@oracle.com> References: <5707C5CB.4090403@oracle.com> <27D6B566-3E8D-4E9A-8807-71294ABB3685@oracle.com> <570E81D3.5010409@oracle.com> Message-ID: <84E58FBE-893D-454D-81CD-A54A6621D823@oracle.com> > On Apr 13, 2016, at 10:28 AM, Daniel Fuchs wrote: > > Hi Mandy, > > On 08/04/16 22:26, Mandy Chung wrote: >> >>> On Apr 8, 2016, at 7:52 AM, Daniel Fuchs wrote: >>> >>> Hi, >>> >>> Please find below a patch that slightly modifies >>> the JEP 264 initial implementation to take advantage >>> of the module system. >>> >>> The change modifies the LoggerFinder abstract service >>> to take the Module of the caller class as parameter >>> instead of the caller class itself. >>> The caller class was used in the initial 9/dev implementation >>> because java.lang.reflect.Module was not yet available. >>> >>> http://cr.openjdk.java.net/~dfuchs/jigsaw/webrev_8148568/webrev.01/ >> >> Using the Module as the caller granularity is reasonable here to find the resource bundle. >> >> DefaultLoggerFinder.java >> 135 static boolean isSystem(Module m) { >> 136 ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { >> >> This isSystem method should check if the class loader is platform class loader (ClassLoader::getPlatformClassLoader) or its ancestor. > > If you don't mind I'd rather do this change in a followup fix. > There are many places (possibly including tests) where we use the > idiom getClassLoader() == null. All these place would need to be > audited and possibly changed, or not? That?s fine with me. > > For consistency reason I'd prefer to start with isSystem > returning getClassLoader() == null. Then we can examine > whether isSystem should be relaxed to also accept > getClassLoader() == ClassLoader.getPlatformClassLoader(), and > which other places should do the same. > > I'd feel safer if the changes getClassLoader() == null => > getClassLoader() == null || getClassLoader() == ClassLoader.getPlatformClassLoader() > was made in a fix that only contains that. > In the practice this check is right. But the spec allows another non-null ancestor, if present, of platform class loader to define java.* classes. >> There are several copies of this method. Better to have one single copy of this method shared for other classes to use? > > OK. I put it in DefaultLoggerFinder. That seems like a good place and > it could be imported from there. > >> Nit: you can use the diamond operation PrivilegedAction<>. > > done. > > >> LazyLoggers.java. >> line 294 return new LazyLoggerAccessor(name, factories, module); >> >> I spot several long lines in LogManager.java, Logger.java, System.java and tests, maybe other files. It?d be good if you can wrap the lines to help side-by-side review. > > I fixed those. Tests might still have long lines. > > http://cr.openjdk.java.net/~dfuchs/jigsaw/webrev_8148568/webrev.02/index.html > +1 Mandy From mandy.chung at oracle.com Wed Apr 13 17:43:02 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 13 Apr 2016 10:43:02 -0700 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <570E81A0.5050904@oracle.com> References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> <570E81A0.5050904@oracle.com> Message-ID: <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> > On Apr 13, 2016, at 10:28 AM, Chris Hegarty wrote: > > Mandy, > > On 13/04/16 18:15, Mandy Chung wrote: >> >>> On Apr 13, 2016, at 8:43 AM, Chris Hegarty wrote: >>> >>> This review is for the second significant part of the changes for JEP >>> 260 [1]. When created, the jdk.unsupported module [2] initially >>> contained the sun.misc package. This issue is will move all the >>> non-Critical APIs out of sun.reflect, leaving only the critical ones, at >>> which point sun.reflect can be moved to the jdk.unsupported module. >>> >>> http://cr.openjdk.java.net/~chegar/8137058/ >>> https://bugs.openjdk.java.net/browse/JDK-8137058 >>> >>> Summary of the changes: >>> >>> - Move all existing sun.reflect types to jdk.internal.reflect, and >>> fix up references in the libraries, and the VM, to use the new internal >>> location. >> >> I hope the getCallerClass(int depth) method is moved out of jdk.internal.reflect.Reflection. JDK is not using it and it?s retained for existing libraries to migrate to the new StackWalker API. Of course the cost is to add a native library and the build infra work has made this straight-forward. > > In my patch jdk.internal.reflect.Reflection.getCallerClass(int) > is retained only to avoid the need for an unsupported.so, but > if you feel strongly that is should go, then I can make the > change. I?m less concerned of a native library but its name led me to have a second thought. I can leave with keeping jdk.internal.reflect.Reflection::getCallerClass(int depth) for another reason. > >> I agree with Alan that the @deprecated javadoc of sun.reflect.Reflection::getCallerClass should be updated to make it clear. What about: >> >> /** >> * @deprecated This method is an internal API and will be removed in JDK 10. >> * Use {@link StackWalker} to walk the stack and obtain the caller class >> * with {@link StackWalker.StackFrame#getDeclaringClass} instead. >> */ > > That seems reasonable. The version number should be present > in the @Deprecated forRemoval element too. I'll make the change. Thanks. > >> This patch will likely impact existing libraries that filter out reflection frames (IIRC Groovy and log4j may be examples) doing Class::getName().startsWith(?sun.reflect?). It may worth call out this incompatibility in JEP 260. > > I'll add a note. > >> StackStreamFactory.java shows an example: >> >> 1085 if (c.getName().startsWith("sun.reflect") && >> >> This should be changed to ?jdk.internal.reflect?. > > Ah I missed this. Strangely all tests are passing without > this change. I'll make the change. This is just like an assertion that should never reach there. It throws an internal error if a class starts with sun.reflect but not a reflective method. > >> test/java/lang/StackWalker/EmbeddedStackWalkTest.java and maybe a few other stack walker tests. You may want to check any other of any similar pattern in the JDK code/tests (I think I got them all) > > I did update some StackWalker tests, but missed this one ( it > passes for me ). I'll check all of them. It may be a check with several conditions or assertion like the above. Mandy From kedar.mhaswade at gmail.com Wed Apr 13 18:00:22 2016 From: kedar.mhaswade at gmail.com (kedar mhaswade) Date: Wed, 13 Apr 2016 11:00:22 -0700 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: <57093182.1080108@oracle.com> References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> <57093182.1080108@oracle.com> Message-ID: Thanks Joe, for the bug report! I am a bit unsure about gauging interest in this by looking at the votes on the bug report because I expected this to just work, especially since the API was already there! To me, not having this behavior in the platform is a violation of POLA [1]. I was thinking harder on the compatibility concerns raised on this thread, but the fact that JDK team itself filed this bug removed them! But I guess I will live with the status quo. 1- http://c2.com/cgi/wiki?PrincipleOfLeastAstonishment On Sat, Apr 9, 2016 at 9:44 AM, joe darcy wrote: > The Project Coin team did file > > JDK-6863378: Project Coin: Consider library support for underscores in > numbers and binary literals > https://bugs.openjdk.java.net/browse/JDK-6863378 > > back before JDK 7 shipped. This change in question wouldn't be > unreasonable, but it didn't seem critical either, hence the bug was filed > and left open to gauge interest, which generally has been slight. > > Cheers, > > -Joe > > > On 4/9/2016 7:44 AM, Charles Oliver Nutter wrote: > >> I feel like this is an obvious API gap that should be fixed. If it is a >> valid syntax in javac, it should be a valid syntax in JDK APIs. My first >> impression was that this was an obvious oversight. >> >> - Charlie (mobile) >> On Apr 9, 2016 21:04, "Christoph Engelbert" wrote: >> >> Hey Andrew, >>> >>> Not sure it would risk breaking compatibility. It?s fairly easy to >>> support >>> it by just replacing underscore before parsing. Do you think of code that >>> is expected to not parse underscore arguments? I think it?s a fair >>> request >>> to support underscore based integer representations, even though I never >>> needed it yet, anyhow it makes sense to me to give users the possibility >>> to >>> have the same integer representation in, let?s say, properties files. >>> >>> Chris >>> >>> On 09 Apr 2016, at 11:06, Andrew Haley wrote: >>>> >>>> On 08/04/16 23:36, kedar mhaswade wrote: >>>> >>>>> As library writers however, how would you explain this mismatch? >>>>> >>>> Changing valueOf(String) runs the risk of breaking existing Java code, >>>> and Java takes compatibility very seriously. Whether it's worth the >>>> risk is a matter of judgement. >>>> >>>> Andrew. >>>> >>>> >>> > From pbenedict at apache.org Wed Apr 13 18:03:38 2016 From: pbenedict at apache.org (Paul Benedict) Date: Wed, 13 Apr 2016 13:03:38 -0500 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> <570E81A0.5050904@oracle.com> <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> Message-ID: Since getCallerClass will be removed in 10, @Deprecated should also have its condemned=true Cheers, Paul On Wed, Apr 13, 2016 at 12:43 PM, Mandy Chung wrote: > > > On Apr 13, 2016, at 10:28 AM, Chris Hegarty > wrote: > > > > Mandy, > > > > On 13/04/16 18:15, Mandy Chung wrote: > >> > >>> On Apr 13, 2016, at 8:43 AM, Chris Hegarty > wrote: > >>> > >>> This review is for the second significant part of the changes for JEP > >>> 260 [1]. When created, the jdk.unsupported module [2] initially > >>> contained the sun.misc package. This issue is will move all the > >>> non-Critical APIs out of sun.reflect, leaving only the critical ones, > at > >>> which point sun.reflect can be moved to the jdk.unsupported module. > >>> > >>> http://cr.openjdk.java.net/~chegar/8137058/ > >>> https://bugs.openjdk.java.net/browse/JDK-8137058 > >>> > >>> Summary of the changes: > >>> > >>> - Move all existing sun.reflect types to jdk.internal.reflect, and > >>> fix up references in the libraries, and the VM, to use the new internal > >>> location. > >> > >> I hope the getCallerClass(int depth) method is moved out of > jdk.internal.reflect.Reflection. JDK is not using it and it?s retained for > existing libraries to migrate to the new StackWalker API. Of course the > cost is to add a native library and the build infra work has made this > straight-forward. > > > > In my patch jdk.internal.reflect.Reflection.getCallerClass(int) > > is retained only to avoid the need for an unsupported.so, but > > if you feel strongly that is should go, then I can make the > > change. > > I?m less concerned of a native library but its name led me to have a > second thought. I can leave with keeping > jdk.internal.reflect.Reflection::getCallerClass(int depth) for another > reason. > > > > >> I agree with Alan that the @deprecated javadoc of > sun.reflect.Reflection::getCallerClass should be updated to make it clear. > What about: > >> > >> /** > >> * @deprecated This method is an internal API and will be removed in > JDK 10. > >> * Use {@link StackWalker} to walk the stack and obtain the caller class > >> * with {@link StackWalker.StackFrame#getDeclaringClass} instead. > >> */ > > > > That seems reasonable. The version number should be present > > in the @Deprecated forRemoval element too. I'll make the change. > > Thanks. > > > > >> This patch will likely impact existing libraries that filter out > reflection frames (IIRC Groovy and log4j may be examples) doing > Class::getName().startsWith(?sun.reflect?). It may worth call out this > incompatibility in JEP 260. > > > > I'll add a note. > > > >> StackStreamFactory.java shows an example: > >> > >> 1085 if (c.getName().startsWith("sun.reflect") && > >> > >> This should be changed to ?jdk.internal.reflect?. > > > > Ah I missed this. Strangely all tests are passing without > > this change. I'll make the change. > > This is just like an assertion that should never reach there. It throws an > internal error if a class starts with sun.reflect but not a reflective > method. > > > > >> test/java/lang/StackWalker/EmbeddedStackWalkTest.java and maybe a few > other stack walker tests. You may want to check any other of any similar > pattern in the JDK code/tests (I think I got them all) > > > > I did update some StackWalker tests, but missed this one ( it > > passes for me ). I'll check all of them. > > It may be a check with several conditions or assertion like the above. > > Mandy From pbenedict at apache.org Wed Apr 13 18:16:45 2016 From: pbenedict at apache.org (Paul Benedict) Date: Wed, 13 Apr 2016 13:16:45 -0500 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> <57093182.1080108@oracle.com> Message-ID: I think the argument for changing Integer.valueOf(String) hinges on the belief that the method is meant to parse JLS integer syntax. If it is, the Javadocs don't speak to that responsibility. If it's an omission from the docs, I would never have guessed. Regarding how it parses today, I wouldn't be surprised if there are validation libraries out there using Integer.valueOf(String) for user-input validation. Good or bad decision, I expect them to exist. They probably have relied on it not being JLS compliant. So changing the behavior would break the assumption and their code. Cheers, Paul On Wed, Apr 13, 2016 at 1:00 PM, kedar mhaswade wrote: > Thanks Joe, for the bug report! > > I am a bit unsure about gauging interest in this by looking at the votes on > the bug report because I expected this to just work, especially since the > API was already there! To me, not having this behavior in the platform is a > violation of POLA [1]. > > I was thinking harder on the compatibility concerns raised on this thread, > but the fact that JDK team itself filed this bug removed them! > > But I guess I will live with the status quo. > > 1- http://c2.com/cgi/wiki?PrincipleOfLeastAstonishment > > On Sat, Apr 9, 2016 at 9:44 AM, joe darcy wrote: > > > The Project Coin team did file > > > > JDK-6863378: Project Coin: Consider library support for underscores > in > > numbers and binary literals > > https://bugs.openjdk.java.net/browse/JDK-6863378 > > > > back before JDK 7 shipped. This change in question wouldn't be > > unreasonable, but it didn't seem critical either, hence the bug was filed > > and left open to gauge interest, which generally has been slight. > > > > Cheers, > > > > -Joe > > > > > > On 4/9/2016 7:44 AM, Charles Oliver Nutter wrote: > > > >> I feel like this is an obvious API gap that should be fixed. If it is a > >> valid syntax in javac, it should be a valid syntax in JDK APIs. My first > >> impression was that this was an obvious oversight. > >> > >> - Charlie (mobile) > >> On Apr 9, 2016 21:04, "Christoph Engelbert" wrote: > >> > >> Hey Andrew, > >>> > >>> Not sure it would risk breaking compatibility. It?s fairly easy to > >>> support > >>> it by just replacing underscore before parsing. Do you think of code > that > >>> is expected to not parse underscore arguments? I think it?s a fair > >>> request > >>> to support underscore based integer representations, even though I > never > >>> needed it yet, anyhow it makes sense to me to give users the > possibility > >>> to > >>> have the same integer representation in, let?s say, properties files. > >>> > >>> Chris > >>> > >>> On 09 Apr 2016, at 11:06, Andrew Haley wrote: > >>>> > >>>> On 08/04/16 23:36, kedar mhaswade wrote: > >>>> > >>>>> As library writers however, how would you explain this mismatch? > >>>>> > >>>> Changing valueOf(String) runs the risk of breaking existing Java code, > >>>> and Java takes compatibility very seriously. Whether it's worth the > >>>> risk is a matter of judgement. > >>>> > >>>> Andrew. > >>>> > >>>> > >>> > > > From nadeesh.tv at oracle.com Wed Apr 13 18:44:31 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Thu, 14 Apr 2016 00:14:31 +0530 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: <570E7C90.4030503@Oracle.com> References: <570E5589.7080106@oracle.com> <570E6C2E.4060208@Oracle.com> <002AC1A5-267B-4BA3-999C-DFF7FEC1EEE6@oracle.com> <570E7C90.4030503@Oracle.com> Message-ID: <570E938F.9040104@oracle.com> Hi all, Please see the updated the webrev with a minor doc change - * O 1 appendLocalizedOffsetPrefixed(TextStyle.SHORT); - * OOOO 4 appendLocalizedOffsetPrefixed(TextStyle.FULL); + * O 1 appendLocalizedOffset(TextStyle.SHORT); + * OOOO 4 appendLocalizedOffset(TextStyle.FULL); webrev : http://cr.openjdk.java.net/~ntv/8154050/webrev.01/ On 4/13/2016 10:36 PM, Roger Riggs wrote: > Hi Lance, > > Literal strings are interned by the compiler but it would make it > clearer that it is the same string > everywhere. Though I find it easier to read when the value is inline > without having to do the indirection to a constant. > And its really not going to change; "GMT" is too deeply embedded in > the nomenclature. > > Roger > > > On 4/13/2016 12:33 PM, Lance Andersen wrote: >> >>> On Apr 13, 2016, at 11:56 AM, Roger Riggs >>> wrote: >>> >>> Hi Nadeesh, >>> >>> The bugfix looks fine. >>> >>> The TODO comment on the "GMT" raises the question (as a separate issue) >>> about implementing the TODO or removing the TODO comment. >>> >>> I'm not sure where the localized string for "GMT" would come from >>> but it might be a useful improvement >>> unless it was judged to a compatibility issue. >>> >> Could gmtText be made static final as it is declared in 3 or 4 >> methods if it is not being localized? >>> Roger >>> >>> >>> >>> On 4/13/2016 10:19 AM, nadeesh tv wrote: >>>> HI all, >>>> >>>> Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 >>>> >>>> >>>> Issue - java.time.format.DateTimeFormatter can't parse localized >>>> zone-offset >>>> >>>> Solution - Corrected the mistake in calculating parse end position >>>> and removed an unnecessary null check >>>> >>>> >>>> webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ >>>> >>>> >>>> >>>> PS: TCKOffsetPrinterParser.test_print_localized() already contain >>>> some test cases related to parsing and formatting. therefore did >>>> not repeat in the new test cases file >>>> -- >>>> Thanks and Regards, >>>> Nadeesh TV >>>> >>> >> >> >> >> Lance >> Andersen| Principal Member of Technical Staff | +1.781.442.2037 >> Oracle Java Engineering >> 1 Network Drive >> Burlington, MA 01803 >> Lance.Andersen at oracle.com >> >> >> > -- Thanks and Regards, Nadeesh TV From ralph.goers at dslextreme.com Wed Apr 13 18:49:44 2016 From: ralph.goers at dslextreme.com (Ralph Goers) Date: Wed, 13 Apr 2016 11:49:44 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <360DDB44-FDFC-41DE-8DF9-9BBA3AF28581@oracle.com> Message-ID: <07C5EC23-C429-4961-B7D3-92B7C32FB535@dslextreme.com> I did a raw test of StackWalker by itself and the performance was much better than using a Throwable to get the location information. However, I haven?t tested how it will be implemented in Log4j. We still support Java 7 (and will for some time) so we have to find a way to support using StackWalker when running on Java 9 even though we build with Java 7. Ralph > On Apr 13, 2016, at 10:27 AM, Mandy Chung wrote: > > It is good to know Log4J is planning to use StackWalker. > > Thanks for the feedback. I will reconsider. > > One thing to mention is the patch went in jdk9/hs-rt that will show up in jdk9/dev some time that changes the implementation to create StackTraceElement to get filename and line number. The object allocation should be cheap that does create short-lived objects. The main motivation of JDK-8153123 was to simplify the hotspot implementation that the runtime team had concern about. There is an open issue to follow up the performance (JDK-8153683). It?d be helpful to get your feedback on using StackWalker API and the performance data. > > Mandy > >> On Apr 13, 2016, at 6:51 AM, Ralph Goers wrote: >> >> I had planned on using StackWalker to generate the location information for every logging event. It seems that this change would thus cause the creation of a new StackTraceElement for every logger event. That seems wasteful. Log4j is currently in the process of trying to reduce the number of objects that are created while logging as it has a significant impact on garbage collection. So I am also in favor of getting the filename and line number directly from the StackFrame. >> >> Ralph >> >>> On Apr 12, 2016, at 5:15 PM, Mandy Chung wrote: >>> >>> >>>> On Apr 12, 2016, at 1:34 AM, R?mi Forax wrote: >>>> >>>> Hi Mandy, >>>> I really don't like this patch. >>>> >>>> Being forced to call toStackElement to get the line number is counter intuitive. >>>> I would prefer the two methods to not return Optional but an int and a String with the same convention as StackElement if the point of this patch is to remove the dependency to Optional. >>>> >>> >>> I was expecting the common usage of StackWalker API does not need file name and line number. I think it'd be useful to include StackFrame::getBci (in the future it might include live information like locals etc) and keep the optional stuff and uncommon usage to StackTraceElement. >>> >>> Mandy >>> >>> >>>> R?mi >>>> >>>> >>>> Le 11 avril 2016 23:22:39 CEST, Mandy Chung a ?crit : >>>>> Webrev at: >>>>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >>>>> >>>>> StackFrame::getFileName and StackFrame::getLineNumber are originally >>>>> proposed with the view of any stack walking code can migrate to the >>>>> StackWalker API without the use of StackTraceElement. >>>>> >>>>> File name and line number are useful for debugging and troubleshooting >>>>> purpose. It has additional overhead to map from a method and BCI to >>>>> look up the file name and line number. >>>>> >>>>> StackFrame::toStackTraceElement method returns StackTraceElement that >>>>> includes the file name and line number. There is no particular benefit >>>>> to duplicate getFileName and getLineNumber methods in StackFrame. It is >>>>> equivalently convenient to call >>>>> StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >>>>> >>>>> This patch proposes to remove StackFrame::getFileName and >>>>> StackFrame::getLineNumber methods since such information can be >>>>> obtained from StackFrame.toStackTraceElement(). >>>>> >>>>> Mandy >>>> >>> >>> >> >> > > From lance.andersen at oracle.com Wed Apr 13 18:52:47 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Wed, 13 Apr 2016 14:52:47 -0400 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: <570E7C90.4030503@Oracle.com> References: <570E5589.7080106@oracle.com> <570E6C2E.4060208@Oracle.com> <002AC1A5-267B-4BA3-999C-DFF7FEC1EEE6@oracle.com> <570E7C90.4030503@Oracle.com> Message-ID: <4EA07CEF-8FD8-4094-8892-F070257133BB@oracle.com> Hi Roger, > On Apr 13, 2016, at 1:06 PM, Roger Riggs wrote: > > Hi Lance, > > Literal strings are interned by the compiler but it would make it clearer that it is the same string > everywhere. Understand, I just thought it would be cleaner > Though I find it easier to read when the value is inline without having to do the indirection to a constant. > And its really not going to change; "GMT" is too deeply embedded in the nomenclature. True Best Lance > > Roger > > > On 4/13/2016 12:33 PM, Lance Andersen wrote: >> >>> On Apr 13, 2016, at 11:56 AM, Roger Riggs < Roger.Riggs at oracle.com > wrote: >>> >>> Hi Nadeesh, >>> >>> The bugfix looks fine. >>> >>> The TODO comment on the "GMT" raises the question (as a separate issue) >>> about implementing the TODO or removing the TODO comment. >>> >>> I'm not sure where the localized string for "GMT" would come from but it might be a useful improvement >>> unless it was judged to a compatibility issue. >>> >> Could gmtText be made static final as it is declared in 3 or 4 methods if it is not being localized? >>> Roger >>> >>> >>> >>> On 4/13/2016 10:19 AM, nadeesh tv wrote: >>>> HI all, >>>> >>>> Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 > >>>> >>>> Issue - java.time.format.DateTimeFormatter can't parse localized zone-offset >>>> >>>> Solution - Corrected the mistake in calculating parse end position and removed an unnecessary null check >>>> >>>> >>>> webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ > >>>> >>>> PS: TCKOffsetPrinterParser.test_print_localized() already contain some test cases related to parsing and formatting. therefore did not repeat in the new test cases file >>>> -- >>>> Thanks and Regards, >>>> Nadeesh TV >>>> >>> >> >> >> >> Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 >> Oracle Java Engineering >> 1 Network Drive >> Burlington, MA 01803 >> Lance.Andersen at oracle.com >> >> >> > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From xueming.shen at oracle.com Wed Apr 13 18:55:56 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Wed, 13 Apr 2016 11:55:56 -0700 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation Message-ID: <570E963C.3050706@oracle.com> Hi, Please hep review the cleanup changes for jrtfs implementation. issue: https://bugs.openjdk.java.net/browse/JDK-8147460 webrev: http://cr.openjdk.java.net/~sherman/8147460/webrev Simple benchmark [1] has been run both on jimage and the "exploded modules" directory, the numbers suggest we also get an encouraging performance boost on most of the frequently invoked access methods. [1] http://cr.openjdk.java.net/~sherman/8147460/MyBenchmark.java Benchmark Mode Cnt Score Error Units ------------------------------------------------------------ [jimage/existing] MyBenchmark.testExists avgt 50 18.592 ? 1.213 ms/op MyBenchmark.testIsDirectory avgt 50 17.382 ? 1.178 ms/op MyBenchmark.testIsRegularFile avgt 50 18.576 ? 1.577 ms/op MyBenchmark.testItr avgt 50 58.414 ? 1.638 ms/op MyBenchmark.testLookupPath avgt 50 18.935 ? 1.093 ms/op MyBenchmark.testLookupStr avgt 50 38.597 ? 1.663 ms/op MyBenchmark.testToRealPath avgt 50 30.119 ? 1.196 ms/op [jimage/new] MyBenchmark.testExists avgt 50 10.865 ? 1.125 ms/op MyBenchmark.testIsDirectory avgt 50 11.077 ? 1.101 ms/op MyBenchmark.testIsRegularFile avgt 50 10.967 ? 1.220 ms/op MyBenchmark.testItr avgt 50 49.249 ? 3.753 ms/op MyBenchmark.testLookupPath avgt 50 10.857 ? 1.071 ms/op MyBenchmark.testLookupStr avgt 50 34.367 ? 1.341 ms/op MyBenchmark.testToRealPath avgt 50 11.460 ? 1.081 ms/op ------------------------------------------------------------ [exploded dir/existing] MyBenchmark.testExists avgt 50 23.055 ? 1.707 ms/op MyBenchmark.testIsDirectory avgt 50 23.985 ? 1.593 ms/op MyBenchmark.testIsRegularFile avgt 50 24.200 ? 1.744 ms/op MyBenchmark.testItr avgt 50 210.002 ? 6.954 ms/op MyBenchmark.testLookupPath avgt 50 23.242 ? 1.799 ms/op MyBenchmark.testLookupStr avgt 50 43.026 ? 1.751 ms/op MyBenchmark.testToRealPath avgt 50 56.536 ? 1.679 ms/op [exploded dir/new] MyBenchmark.testExists avgt 50 11.260 ? 1.209 ms/op MyBenchmark.testIsDirectory avgt 50 11.702 ? 1.069 ms/op MyBenchmark.testIsRegularFile avgt 50 12.284 ? 1.333 ms/op MyBenchmark.testItr avgt 50 49.342 ? 1.516 ms/op MyBenchmark.testLookupPath avgt 50 11.041 ? 1.051 ms/op MyBenchmark.testLookupStr avgt 50 35.850 ? 1.618 ms/op MyBenchmark.testToRealPath avgt 50 13.016 ? 1.339 ms/op Thanks, Sherman From mandy.chung at oracle.com Wed Apr 13 19:03:14 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 13 Apr 2016 12:03:14 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: <07C5EC23-C429-4961-B7D3-92B7C32FB535@dslextreme.com> References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <360DDB44-FDFC-41DE-8DF9-9BBA3AF28581@oracle.com> <07C5EC23-C429-4961-B7D3-92B7C32FB535@dslextreme.com> Message-ID: <90BF6135-B457-4BD4-8DFF-9DE94F6D8DC7@oracle.com> If you record all stack frames, I can believe Throwable is faster because of a recent optimization JDK-8150778 that has been made in jdk9 to improve the Throwable::getStackTraceElements method. Mandy > On Apr 13, 2016, at 11:49 AM, Ralph Goers wrote: > > I did a raw test of StackWalker by itself and the performance was much better than using a Throwable to get the location information. However, I haven?t tested how it will be implemented in Log4j. We still support Java 7 (and will for some time) so we have to find a way to support using StackWalker when running on Java 9 even though we build with Java 7. > > Ralph > >> On Apr 13, 2016, at 10:27 AM, Mandy Chung wrote: >> >> It is good to know Log4J is planning to use StackWalker. >> >> Thanks for the feedback. I will reconsider. >> >> One thing to mention is the patch went in jdk9/hs-rt that will show up in jdk9/dev some time that changes the implementation to create StackTraceElement to get filename and line number. The object allocation should be cheap that does create short-lived objects. The main motivation of JDK-8153123 was to simplify the hotspot implementation that the runtime team had concern about. There is an open issue to follow up the performance (JDK-8153683). It?d be helpful to get your feedback on using StackWalker API and the performance data. >> >> Mandy >> >>> On Apr 13, 2016, at 6:51 AM, Ralph Goers wrote: >>> >>> I had planned on using StackWalker to generate the location information for every logging event. It seems that this change would thus cause the creation of a new StackTraceElement for every logger event. That seems wasteful. Log4j is currently in the process of trying to reduce the number of objects that are created while logging as it has a significant impact on garbage collection. So I am also in favor of getting the filename and line number directly from the StackFrame. >>> >>> Ralph >>> >>>> On Apr 12, 2016, at 5:15 PM, Mandy Chung wrote: >>>> >>>> >>>>> On Apr 12, 2016, at 1:34 AM, R?mi Forax wrote: >>>>> >>>>> Hi Mandy, >>>>> I really don't like this patch. >>>>> >>>>> Being forced to call toStackElement to get the line number is counter intuitive. >>>>> I would prefer the two methods to not return Optional but an int and a String with the same convention as StackElement if the point of this patch is to remove the dependency to Optional. >>>>> >>>> >>>> I was expecting the common usage of StackWalker API does not need file name and line number. I think it'd be useful to include StackFrame::getBci (in the future it might include live information like locals etc) and keep the optional stuff and uncommon usage to StackTraceElement. >>>> >>>> Mandy >>>> >>>> >>>>> R?mi >>>>> >>>>> >>>>> Le 11 avril 2016 23:22:39 CEST, Mandy Chung a ?crit : >>>>>> Webrev at: >>>>>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >>>>>> >>>>>> StackFrame::getFileName and StackFrame::getLineNumber are originally >>>>>> proposed with the view of any stack walking code can migrate to the >>>>>> StackWalker API without the use of StackTraceElement. >>>>>> >>>>>> File name and line number are useful for debugging and troubleshooting >>>>>> purpose. It has additional overhead to map from a method and BCI to >>>>>> look up the file name and line number. >>>>>> >>>>>> StackFrame::toStackTraceElement method returns StackTraceElement that >>>>>> includes the file name and line number. There is no particular benefit >>>>>> to duplicate getFileName and getLineNumber methods in StackFrame. It is >>>>>> equivalently convenient to call >>>>>> StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >>>>>> >>>>>> This patch proposes to remove StackFrame::getFileName and >>>>>> StackFrame::getLineNumber methods since such information can be >>>>>> obtained from StackFrame.toStackTraceElement(). >>>>>> >>>>>> Mandy >>>>> >>>> >>>> >>> >>> >> >> > > From brian.burkhalter at oracle.com Wed Apr 13 19:43:21 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Wed, 13 Apr 2016 12:43:21 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <570D90F1.7050608@oracle.com> References: <570D90F1.7050608@oracle.com> Message-ID: <14AB0D30-A482-4E16-9C01-4491A8EDD603@oracle.com> Joe / Dmitry, On Apr 12, 2016, at 5:21 PM, joe darcy wrote: > Please review the changes for > > JDK-4851642: Add fused mac to Java math library > http://cr.openjdk.java.net/~darcy/4851642.0/ > > Fused mac (multiply-accumulate) is a ternary floating-point operation which accepts three inputs, a, b, c, and computes > > a * b + c > > with a single rounding error rather than the usual two rounding errors (a first for the multiply, a second one for the add). A couple of points of curiosity. Firstly, is this not ?fused multiply-add? rather than ?fused multiply-accumulate?? Secondly, why the choice of name ?fusedMac()? instead of the common ?fma()? or the longer but perhaps clearer ?fusedMultiplyAdd()?? A picayune javadoc point: in the unordered lists

    should ?? be used to close the list items? On Apr 13, 2016, at 5:41 AM, Dmitry Nadezhin wrote: I concur with Dmitry?s points. With respect to the second one, > 2) Lines Math:1508-1525 could be simpler: > ==== > double result = a * b + c; > return Double.isNaN(result) && Double.isFinite(a) && Double.isFinite(b) > ? c : result; > ==== not trusting this to my own visual inspection, I wrote nested loops to run a, b, and c over double[] values = new double[] { -0.0, 0.0, +0.0, -42.0, 42.0, -Double.MAX_VALUE, Double.MAX_VALUE, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY }; and there is no difference between the webrev and Dmitry?s suggestion above for the cases where !Double.isFinite(a) || !Double.isFinite(b) || !Double.isFinite(c) == true Brian From martinrb at google.com Wed Apr 13 20:08:01 2016 From: martinrb at google.com (Martin Buchholz) Date: Wed, 13 Apr 2016 13:08:01 -0700 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException In-Reply-To: <570E68D9.6070106@Oracle.com> References: <570E68D9.6070106@Oracle.com> Message-ID: If you're actually seeing faiures with 32k, then 48k is too conservative. I suggest 128k. I tried once to increase the limit to 64k, but without a failing test it didn't get any support. The presence of native thread local variables is the biggest reason for blowing the stack; no limit is actually safe! That's a deep hotspot/glibc problem. On Wed, Apr 13, 2016 at 8:42 AM, Roger Riggs wrote: > Please review an increase in the default stack size of the Process reaper > thread to 48K from 32k. > Some tests with various VM arguments are failing intermittently. > The failures are not reproducible. > > Webrev: > http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ > > Issue: > https://bugs.openjdk.java.net/browse/JDK-8086278 > > Thanks, Roger > From martinrb at google.com Wed Apr 13 20:09:45 2016 From: martinrb at google.com (Martin Buchholz) Date: Wed, 13 Apr 2016 13:09:45 -0700 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException In-Reply-To: References: <570E68D9.6070106@Oracle.com> Message-ID: The change itself is fine. On Wed, Apr 13, 2016 at 1:08 PM, Martin Buchholz wrote: > If you're actually seeing faiures with 32k, then 48k is too > conservative. I suggest 128k. > > I tried once to increase the limit to 64k, but without a failing test > it didn't get any support. > > The presence of native thread local variables is the biggest reason > for blowing the stack; no limit is actually safe! That's a deep > hotspot/glibc problem. > > > On Wed, Apr 13, 2016 at 8:42 AM, Roger Riggs wrote: >> Please review an increase in the default stack size of the Process reaper >> thread to 48K from 32k. >> Some tests with various VM arguments are failing intermittently. >> The failures are not reproducible. >> >> Webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ >> >> Issue: >> https://bugs.openjdk.java.net/browse/JDK-8086278 >> >> Thanks, Roger >> From ecki at zusammenkunft.net Wed Apr 13 20:30:53 2016 From: ecki at zusammenkunft.net (Bernd Eckenfels) Date: Wed, 13 Apr 2016 22:30:53 +0200 Subject: Expecting Integer.valueOf(String) to accept Literal format ... In-Reply-To: References: <5708C603.8060300@redhat.com> <2BD360BD-1B96-4C00-9CF3-D2CA86F489DF@noctarius.com> <57093182.1080108@oracle.com> Message-ID: <20160413223053.000073a9.ecki@zusammenkunft.net> Am Wed, 13 Apr 2016 13:16:45 -0500 schrieb Paul Benedict : > I think the argument for changing Integer.valueOf(String) hinges on > the belief that the method is meant to parse JLS integer syntax. If > it is, the Javadocs don't speak to that responsibility. If it's an > omission from the docs, I would never have guessed. I agree it is not. It points to parseInt() which itself exactly describes its grammar: # Parses the string argument as a signed decimal integer. # The characters in the string must all be decimal digits, # except that the first character may be an ASCII minus sign # '-' ('\u002D') to indicate a negative value or an ASCII plus # sign '+' ('\u002B') to indicate a positive value. This quite concrete. The decode() method mentioning the JLS (and supporting the integer literal prefixes) is a more ikely candidate for that. But that method explicitely dislclaims its heritage: # DecimalNumeral, HexDigits, and OctalDigits are as defined in section # 3.10.1 of The Java? Language Specification, except that underscores # are not accepted between digits. So while I symphatise with having a full features JLS integer parser the spec would require a change to accept it. Maybe a new method... (it could eve take a JLS version argument :) > > Regarding how it parses today, I wouldn't be surprised if there are > validation libraries out there using Integer.valueOf(String) for > user-input validation. Good or bad decision, I expect them to exist. > They probably have relied on it not being JLS compliant. So changing > the behavior would break the assumption and their code. > > Cheers, > Paul From Roger.Riggs at Oracle.com Wed Apr 13 20:33:18 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 13 Apr 2016 16:33:18 -0400 Subject: RFR 9: 8086278 : java/lang/ProcessHandle/TreeTest.java failed - ProcessReaper StackOverflowException In-Reply-To: References: <570E68D9.6070106@Oracle.com> Message-ID: <570EAD0E.10007@Oracle.com> HI Martin, I thought if I overshot, I'd get some push back on too big stack sizes. I'll use 128k and see. Thanks, Roger On 4/13/2016 4:09 PM, Martin Buchholz wrote: > The change itself is fine. > > On Wed, Apr 13, 2016 at 1:08 PM, Martin Buchholz wrote: >> If you're actually seeing faiures with 32k, then 48k is too >> conservative. I suggest 128k. >> >> I tried once to increase the limit to 64k, but without a failing test >> it didn't get any support. >> >> The presence of native thread local variables is the biggest reason >> for blowing the stack; no limit is actually safe! That's a deep >> hotspot/glibc problem. >> >> >> On Wed, Apr 13, 2016 at 8:42 AM, Roger Riggs wrote: >>> Please review an increase in the default stack size of the Process reaper >>> thread to 48K from 32k. >>> Some tests with various VM arguments are failing intermittently. >>> The failures are not reproducible. >>> >>> Webrev: >>> http://cr.openjdk.java.net/~rriggs/webrev-reaper-stack-8086278/ >>> >>> Issue: >>> https://bugs.openjdk.java.net/browse/JDK-8086278 >>> >>> Thanks, Roger >>> From huizhe.wang at oracle.com Wed Apr 13 20:34:10 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Wed, 13 Apr 2016 13:34:10 -0700 Subject: RFR JDK9 (JAXP) 8152527: Relative rewriteSystem with xml:base at group level failed Message-ID: <570EAD42.6080209@oracle.com> Hi, Please review a fix to rewrite* matching issue. When the rewrite* entries are in a group entry, the current match with entries in a group entry needs to be recorded just as when they are outside of a group. JBS: https://bugs.openjdk.java.net/browse/JDK-8152527 webrevs: http://cr.openjdk.java.net/~joehw/jdk9/8152527/webrev/ Thanks, Joe From joel.borggren.franck at gmail.com Wed Apr 13 20:44:51 2016 From: joel.borggren.franck at gmail.com (=?UTF-8?Q?Joel_Borggr=C3=A9n=2DFranck?=) Date: Wed, 13 Apr 2016 20:44:51 +0000 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <570E690B.2060703@oracle.com> References: <570E690B.2060703@oracle.com> Message-ID: Hi Chris, FWIW changes looks good to me. cheers /Joel On Wed, 13 Apr 2016 at 17:43 Chris Hegarty wrote: > This review is for the second significant part of the changes for JEP > 260 [1]. When created, the jdk.unsupported module [2] initially > contained the sun.misc package. This issue is will move all the > non-Critical APIs out of sun.reflect, leaving only the critical ones, at > which point sun.reflect can be moved to the jdk.unsupported module. > > http://cr.openjdk.java.net/~chegar/8137058/ > https://bugs.openjdk.java.net/browse/JDK-8137058 > > Summary of the changes: > > - Move all existing sun.reflect types to jdk.internal.reflect, and > fix up references in the libraries, and the VM, to use the new internal > location. > > - Update tests, as appropriate, to use the new location. > > - Add the minimal set of critical APIs to jdk.unsupported/sun.reflect. > These ultimately delegate to the internal versions. Additionally, a > few new tests have been added to exercise these. > > -Chris. > > [1] https://bugs.openjdk.java.net/browse/JDK-8132928 > [2] https://bugs.openjdk.java.net/browse/JDK-8153737 > From nadeesh.tv at oracle.com Wed Apr 13 20:46:58 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Thu, 14 Apr 2016 02:16:58 +0530 Subject: RFR:JDK-8031085:DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS" Message-ID: <570EB042.3040709@oracle.com> HI all, BUG ID : https://bugs.openjdk.java.net/browse/JDK-8031085 Webrev : http://cr.openjdk.java.net/~ntv/8031085/webrev.00/ Issue - Fractional parts of seconds do not participate in the protocol for adjacent value parsing Solution - Changed the FractionPrinterParser to subclass of NumberPrinterParser to make it participate in adjacent value parsing 2 existing test cases TCKDateTimeFormatterBuilder.test_adjacent_lenient_fractionFollows_0digit and test_adjacent_lenient_fractionFollows_2digit were failing. Changed them accordingly. -- Thanks and Regards, Nadeesh TV From peter.levart at gmail.com Wed Apr 13 20:48:11 2016 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 13 Apr 2016 22:48:11 +0200 Subject: Review request 8153895 (proxy) redundant read edges to superinterfaces of proxy interfaces In-Reply-To: <6044BDCF-3BFB-44B1-8CA3-707F37A8B18C@oracle.com> References: <14DA227D-7A89-459C-80E7-66ADC7640232@oracle.com> <570CEB6F.8060408@gmail.com> <570CF51E.3030908@gmail.com> <2EA3B953-759F-433D-9DD1-C68DA5C270BD@oracle.com> <570DE5C2.3040105@gmail.com> <6044BDCF-3BFB-44B1-8CA3-707F37A8B18C@oracle.com> Message-ID: <570EB08B.1080203@gmail.com> On 04/13/2016 06:02 PM, Mandy Chung wrote: >> On Apr 12, 2016, at 11:22 PM, Peter Levart wrote: >> >> No, not about security. Mainly about binary compatibility. For example: >> >> - library A v1 defines an interface I with some methods >> - library B creates a dynamic proxy implementing I. It depends on library A and libraries defining types from method signatures of the interface >> - program P uses B and depends on the transitive closure >> >> now comes new version of library A v2 which adds a default method to interface I with signature that requires additional dependency which is tagged as "optional". Program P does not need to call this new method on the proxy created by B. Should we force P to bundle the new dependency although it is not used? > This is the compatibility concern I mentioned if we change the spec to do the visibility checks on types referenced by the method signatures. My take on this is that the benefit does not seem to justify the potential incompatibility. We could file an issue if you think we should look at further. > > I?d like to push webrev.01. > > Mandy > Yes, of course. This is a different issue. I think it would be better to fail lazily when some type from a method signature is not visible. Regards, Peter From kevin.rushforth at oracle.com Wed Apr 13 21:34:25 2016 From: kevin.rushforth at oracle.com (Kevin Rushforth) Date: Wed, 13 Apr 2016 14:34:25 -0700 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <570E81A0.5050904@oracle.com> References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> <570E81A0.5050904@oracle.com> Message-ID: <570EBB61.4010008@oracle.com> Hi, Chris Hegarty wrote: > Mandy, > > On 13/04/16 18:15, Mandy Chung wrote: >> >>> On Apr 13, 2016, at 8:43 AM, Chris Hegarty >>> wrote: >>> >>> This review is for the second significant part of the changes for JEP >>> 260 [1]. When created, the jdk.unsupported module [2] initially >>> contained the sun.misc package. This issue is will move all the >>> non-Critical APIs out of sun.reflect, leaving only the critical >>> ones, at >>> which point sun.reflect can be moved to the jdk.unsupported module. >>> >>> http://cr.openjdk.java.net/~chegar/8137058/ >>> https://bugs.openjdk.java.net/browse/JDK-8137058 >>> >>> Summary of the changes: >>> >>> - Move all existing sun.reflect types to jdk.internal.reflect, and >>> fix up references in the libraries, and the VM, to use the new internal >>> location. >> >> I hope the getCallerClass(int depth) method is moved out of >> jdk.internal.reflect.Reflection. JDK is not using it and it?s >> retained for existing libraries to migrate to the new StackWalker >> API. Of course the cost is to add a native library and the build >> infra work has made this straight-forward. > > In my patch jdk.internal.reflect.Reflection.getCallerClass(int) > is retained only to avoid the need for an unsupported.so, but > if you feel strongly that is should go, then I can make the > change. > >> I agree with Alan that the @deprecated javadoc of >> sun.reflect.Reflection::getCallerClass should be updated to make it >> clear. What about: >> >> /** >> * @deprecated This method is an internal API and will be removed in >> JDK 10. >> * Use {@link StackWalker} to walk the stack and obtain the caller >> class >> * with {@link StackWalker.StackFrame#getDeclaringClass} instead. >> */ > > That seems reasonable. The version number should be present > in the @Deprecated forRemoval element too. I'll make the change. > >> This patch will likely impact existing libraries that filter out >> reflection frames (IIRC Groovy and log4j may be examples) doing >> Class::getName().startsWith(?sun.reflect?). It may worth call out >> this incompatibility in JEP 260. > > I'll add a note. > >> StackStreamFactory.java shows an example: >> >> 1085 if (c.getName().startsWith("sun.reflect") && >> >> This should be changed to ?jdk.internal.reflect?. > > Ah I missed this. Strangely all tests are passing without > this change. I'll make the change. > >> test/java/lang/StackWalker/EmbeddedStackWalkTest.java and maybe a few >> other stack walker tests. You may want to check any other of any >> similar pattern in the JDK code/tests (I think I got them all) > > I did update some StackWalker tests, but missed this one ( it > passes for me ). I'll check all of them. > >> The hotspot change drops the package name prefix in javaClasses.hpp >> which is inconsistent with other classes. I found including >> jdk_internal_reflect_ in the class name is useful. Coleen and >> others from the hotspot team may have opinion on this. > > Ok. > >> FX will need to adjust for this patch (cc?ing Kevin to prepare for this) > > Ah ok, thanks for copying Kevin. Yes, thanks Mandy. JavaFX uses sun.reflect.CallerSensitive and sun.reflect.Reflection (both in FXML) so I will file an FX bug to track the need to fix the module dependences. -- Kevin > I'll send a note to the list once the webrev is updated. > > -Chris. From chris.hegarty at oracle.com Wed Apr 13 21:36:02 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 13 Apr 2016 22:36:02 +0100 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> <570E81A0.5050904@oracle.com> <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> Message-ID: > On 13 Apr 2016, at 19:03, Paul Benedict wrote: > > Since getCallerClass will be removed in 10, @Deprecated should also have its condemned=true `condemned` was renamed to `forRemoval` [1]. getCallerClass, in fact the whole class, will have `forRemoval=true`. -Chris. [1] http://mail.openjdk.java.net/pipermail/jdk9-dev/2016-April/003932.html > > Cheers, > Paul > > On Wed, Apr 13, 2016 at 12:43 PM, Mandy Chung > wrote: > > > On Apr 13, 2016, at 10:28 AM, Chris Hegarty > wrote: > > > > Mandy, > > > > On 13/04/16 18:15, Mandy Chung wrote: > >> > >>> On Apr 13, 2016, at 8:43 AM, Chris Hegarty > wrote: > >>> > >>> This review is for the second significant part of the changes for JEP > >>> 260 [1]. When created, the jdk.unsupported module [2] initially > >>> contained the sun.misc package. This issue is will move all the > >>> non-Critical APIs out of sun.reflect, leaving only the critical ones, at > >>> which point sun.reflect can be moved to the jdk.unsupported module. > >>> > >>> http://cr.openjdk.java.net/~chegar/8137058/ > >>> https://bugs.openjdk.java.net/browse/JDK-8137058 > >>> > >>> Summary of the changes: > >>> > >>> - Move all existing sun.reflect types to jdk.internal.reflect, and > >>> fix up references in the libraries, and the VM, to use the new internal > >>> location. > >> > >> I hope the getCallerClass(int depth) method is moved out of jdk.internal.reflect.Reflection. JDK is not using it and it?s retained for existing libraries to migrate to the new StackWalker API. Of course the cost is to add a native library and the build infra work has made this straight-forward. > > > > In my patch jdk.internal.reflect.Reflection.getCallerClass(int) > > is retained only to avoid the need for an unsupported.so, but > > if you feel strongly that is should go, then I can make the > > change. > > I?m less concerned of a native library but its name led me to have a second thought. I can leave with keeping jdk.internal.reflect.Reflection::getCallerClass(int depth) for another reason. > > > > >> I agree with Alan that the @deprecated javadoc of sun.reflect.Reflection::getCallerClass should be updated to make it clear. What about: > >> > >> /** > >> * @deprecated This method is an internal API and will be removed in JDK 10. > >> * Use {@link StackWalker} to walk the stack and obtain the caller class > >> * with {@link StackWalker.StackFrame#getDeclaringClass} instead. > >> */ > > > > That seems reasonable. The version number should be present > > in the @Deprecated forRemoval element too. I'll make the change. > > Thanks. > > > > >> This patch will likely impact existing libraries that filter out reflection frames (IIRC Groovy and log4j may be examples) doing Class::getName().startsWith(?sun.reflect?). It may worth call out this incompatibility in JEP 260. > > > > I'll add a note. > > > >> StackStreamFactory.java shows an example: > >> > >> 1085 if (c.getName().startsWith("sun.reflect") && > >> > >> This should be changed to ?jdk.internal.reflect?. > > > > Ah I missed this. Strangely all tests are passing without > > this change. I'll make the change. > > This is just like an assertion that should never reach there. It throws an internal error if a class starts with sun.reflect but not a reflective method. > > > > >> test/java/lang/StackWalker/EmbeddedStackWalkTest.java and maybe a few other stack walker tests. You may want to check any other of any similar pattern in the JDK code/tests (I think I got them all) > > > > I did update some StackWalker tests, but missed this one ( it > > passes for me ). I'll check all of them. > > It may be a check with several conditions or assertion like the above. > > Mandy > From joe.darcy at oracle.com Wed Apr 13 22:02:08 2016 From: joe.darcy at oracle.com (Joseph D. Darcy) Date: Wed, 13 Apr 2016 15:02:08 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <14AB0D30-A482-4E16-9C01-4491A8EDD603@oracle.com> References: <570D90F1.7050608@oracle.com> <14AB0D30-A482-4E16-9C01-4491A8EDD603@oracle.com> Message-ID: <570EC1E0.3050209@oracle.com> Hi Brian and Dmitry, On 4/13/2016 12:43 PM, Brian Burkhalter wrote: > Joe / Dmitry, > > On Apr 12, 2016, at 5:21 PM, joe darcy > wrote: > >> Please review the changes for >> >> JDK-4851642: Add fused mac to Java math library >> http://cr.openjdk.java.net/~darcy/4851642.0/ >> >> >> Fused mac (multiply-accumulate) is a ternary floating-point operation >> which accepts three inputs, a, b, c, and computes >> >> a * b + c >> >> with a single rounding error rather than the usual two rounding >> errors (a first for the multiply, a second one for the add). > > A couple of points of curiosity. Firstly, is this not ?fused > multiply-add? rather than ?fused multiply-accumulate?? Secondly, why > the choice of name ?fusedMac()? instead of the common ?fma()? or the > longer but perhaps clearer ?fusedMultiplyAdd()?? On naming, there are a few candidates. As background, I'll note that the naming in java.lang.Math at times follows the C-style naming ("cos" rather than "cosine"), but that methods we've added more recently outside of the traditional C math.h have followed more Java-style conventions. FWIW, C99 calls this "fma". So, "fma()" is a possible choice, certainly concise, but I don't think many people would find it very suggestive as to what it does, at least not with the current familiarity with fused multiply-add. In the IEEE 754 2008 standard, the operation is spelled out as "fusedMultiplyAdd", but that is a bit long. The "multiply accumulate" term is how I first heard of the operation and there is some other usage of it (https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation), but "fused multiply add" is also an accurate description. > > A picayune javadoc point: in the unordered lists
      should > ?? be used to close the list items? I don't think that is necessary. The javadoc does pass fine through doclint without warnings. > > On Apr 13, 2016, at 5:41 AM, Dmitry Nadezhin > > wrote: > > I concur with Dmitry?s points. With respect to the second one, > >> 2) Lines Math:1508-1525 could be simpler: >> ==== >> double result = a * b + c; >> return Double.isNaN(result) && Double.isFinite(a) && >> Double.isFinite(b) >> ? c : result; >> ==== > > not trusting this to my own visual inspection, I wrote nested loops to > run a, b, and c over > > double[] values = new double[] { > -0.0, 0.0, +0.0, -42.0, 42.0, > -Double.MAX_VALUE, Double.MAX_VALUE, > Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY > }; > > and there is no difference between the webrev and Dmitry?s suggestion > above for the cases where > > !Double.isFinite(a) || !Double.isFinite(b) || !Double.isFinite(c) == true > As part of favoring "simplicity over speed," I intentionally wrote the code in a way that tried to follow the structure of the specification in a straightforward manner. For example, the spec says "
    • If any argument is NaN, the result is NaN." and there is code 1508 if (Double.isNaN(a) || Double.isNaN(b) || Double.isNaN(c)) { 1509 return Double.NaN; and the spec says 1472 *
    • If one of the first two arguments is infinite and the 1473 * other is zero, the result is NaN. and there is code 1511 if ((Double.isInfinite(a) && b == 0.0) || 1512 (Double.isInfinite(b) && a == 0.0)) { 1513 return Double.NaN; etc. For this initial implementation, I think this kind of simplicity is desirable. Longer term, I wouldn't be surprised if this implementation was retired out to be a reference implementation for additional regression tests. Thanks, -Joe From lance.andersen at oracle.com Wed Apr 13 22:08:44 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Wed, 13 Apr 2016 18:08:44 -0400 Subject: RFR JDK9 (JAXP) 8152527: Relative rewriteSystem with xml:base at group level failed In-Reply-To: <570EAD42.6080209@oracle.com> References: <570EAD42.6080209@oracle.com> Message-ID: Looks OK Joe > On Apr 13, 2016, at 4:34 PM, huizhe wang wrote: > > Hi, > > Please review a fix to rewrite* matching issue. When the rewrite* entries are in a group entry, the current match with entries in a group entry needs to be recorded just as when they are outside of a group. > > JBS: https://bugs.openjdk.java.net/browse/JDK-8152527 > webrevs: http://cr.openjdk.java.net/~joehw/jdk9/8152527/webrev/ > > Thanks, > Joe > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From brian.burkhalter at oracle.com Wed Apr 13 22:08:42 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Wed, 13 Apr 2016 15:08:42 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <570EC1E0.3050209@oracle.com> References: <570D90F1.7050608@oracle.com> <14AB0D30-A482-4E16-9C01-4491A8EDD603@oracle.com> <570EC1E0.3050209@oracle.com> Message-ID: Hi Joe, On Apr 13, 2016, at 3:02 PM, Joseph D. Darcy wrote: > On 4/13/2016 12:43 PM, Brian Burkhalter wrote: >> >> A couple of points of curiosity. Firstly, is this not ?fused multiply-add? rather than ?fused multiply-accumulate?? Secondly, why the choice of name ?fusedMac()? instead of the common ?fma()? or the longer but perhaps clearer ?fusedMultiplyAdd()?? > > On naming, there are a few candidates. As background, I'll note that the naming in java.lang.Math at times follows the C-style naming ("cos" rather than "cosine"), but that methods we've added more recently outside of the traditional C math.h have followed more Java-style conventions. FWIW, C99 calls this "fma". > > So, "fma()" is a possible choice, certainly concise, but I don't think many people would find it very suggestive as to what it does, at least not with the current familiarity with fused multiply-add. > > In the IEEE 754 2008 standard, the operation is spelled out as "fusedMultiplyAdd", but that is a bit long. > > The "multiply accumulate" term is how I first heard of the operation and there is some other usage of it (https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation), but "fused multiply add" is also an accurate description. Yes, I saw this latter as well. It is the mention of the accumulator there which made me think that multiply-add is more apt. > As part of favoring "simplicity over speed," I intentionally wrote the code in a way that tried to follow the structure of the specification in a straightforward manner. [?] For this initial implementation, I think this kind of simplicity is desirable. Longer term, I wouldn't be surprised if this implementation was retired out to be a reference implementation for additional regression tests. Well that is a good point: if the eventual target is an intrinsic or other accelerated implementation then this probably does not matter that much. Brian From david.holmes at oracle.com Thu Apr 14 00:34:23 2016 From: david.holmes at oracle.com (David Holmes) Date: Thu, 14 Apr 2016 10:34:23 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570E65B6.2010809@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> Message-ID: <570EE58F.4060809@oracle.com> Hi, On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: > Hi David, > > Thanks for your comment. > > I exported new JVM function to set native thread name, and JLI uses it > in new webrev. First the launcher belongs to another team so core-libs will need to review and approve this (in particular Kumar) - now cc'd. Personally I would have used a Java upcall to Thread.setName rather than exporting JVM_SetNativeThreadName. No hotspot changes needed in that case. Thanks, David > Could you review again? > > - hotspot: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ > > - jdk: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ > > > Thanks, > > Yasumasa > > > On 2016/04/13 22:00, David Holmes wrote: >> I'll answer on this original thread as well ... >> >> Hi Yasumasa, >> >> Please see my updates to the bug (sorry have been on vacation). This >> needs to be done in the launcher to be correct as we do not set the >> name of threads that attach via JNI, which includes the "main" thread. >> >> David >> >> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>> Thanks Robbin, >>> >>> I'm waiting a sponsor and more reviewer :-) >>> >>> Yasumasa >>> 2016/03/31 5:58 "Robbin Ehn" : >>> >>>> FYI: I'm not a Reviewer. >>>> >>>> /Robbin >>>> >>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>> >>>>> Thanks, looks good. >>>>> >>>>> /Robbin >>>>> >>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I uploaded new webrev. >>>>>> Could you review it? >>>>>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>> >>>>>>>> Hi Robbin, >>>>>>>> >>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>> >: >>>>>>>> > >>>>>>>> > Hi Yasumasa, >>>>>>>> > >>>>>>>> > >>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>> >> >>>>>>>> >> Hi Robbin, >>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>> >>>>>>>> >> >>>>>>> >>: >>>>>>>> >> >>>>>>>> >> > >>>>>>>> >> > Hi Yasumasa, >>>>>>>> >> > >>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>> >> > >>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>> 13:09:16 2016 >>>>>>>> +0000 >>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>> 17:40:09 2016 >>>>>>>> +0100 >>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>> >> > // must do this before set_active_handles >>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>> >> > >>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>> >> > >>>>>>>> >> > here instead? Am I missing something? >>>>>>>> >> >>>>>>>> >> Native thread name is the same to thread name in Thread class. >>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>> will be >>>>>>>> set at >>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>> >> Thread name for "main" is set in create_initial_thread(). >>>>>>>> >> I think that the place of setting thrrad name should be the >>>>>>>> same. >>>>>>>> > >>>>>>>> > >>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>> nicer, no? >>>>>>>> > >>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 09:43:05 >>>>>>>> 2016 >>>>>>>> +0200 >>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 10:51:12 >>>>>>>> 2016 >>>>>>>> +0200 >>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>> > // Creates the initial Thread >>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>> JavaThread* >>>>>>>> thread, >>>>>>>> > TRAPS) { >>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>> > Klass* k = >>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>> true, >>>>>>>> CHECK_NULL); >>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>> > instanceHandle thread_oop = >>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>> > java_lang_Thread::set_priority(thread_oop(), NormPriority); >>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>> > - >>>>>>>> > - Handle string = java_lang_String::create_from_str("main", >>>>>>>> CHECK_NULL); >>>>>>>> > + >>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>> > + >>>>>>>> > + Handle string = >>>>>>>> java_lang_String::create_from_str(initial_thread_name, CHECK_NULL); >>>>>>>> > >>>>>>>> > JavaValue result(T_VOID); >>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>> >>>>>>>> Okay, I will upload new webrev later. >>>>>>>> >>>>>>> >>>>>>> Thanks! >>>>>>> >>>>>>> >>>>>>>> >> > The launcher seem to name itself 'java' and naming this >>>>>>>> thread >>>>>>>> just >>>>>>>> >> > 'main' is confusing to me. >>>>>>>> >> > >>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>> process) is >>>>>>>> 'java' but >>>>>>>> >> > first JavaThread is 'main'. >>>>>>>> >> >>>>>>>> >> The native main thread in the process is not JavaThread. It is >>>>>>>> waiting >>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>> >> set_native_thread_name() is for JavaThread. So I think that >>>>>>>> we do >>>>>>>> not >>>>>>>> >> need to call it for native main thread. >>>>>>>> > >>>>>>>> > >>>>>>>> > Not sure if we can change it anyhow, since we want java and >>>>>>>> native >>>>>>>> name to be the same and java thread name might have some >>>>>>>> dependents. >>>>>>>> > >>>>>>>> > The name is visible in e.g. /proc. >>>>>>>> > >>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>> > PID TID COMMAND >>>>>>>> > 6423 6423 java >>>>>>>> > 6423 6424 main >>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>> > >>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>> >>>>>>>> I do not think so. >>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>> commons-daemon, JNI application, etc. >>>>>>>> >>>>>>>> If you want to change native main thread name, I think that we >>>>>>>> have to >>>>>>>> change Java launcher code. >>>>>>>> Should I include it in new webrev? >>>>>>>> >>>>>>> >>>>>>> No >>>>>>> >>>>>>> Thanks again! >>>>>>> >>>>>>> /Robbin >>>>>>> >>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> > Thanks >>>>>>>> > >>>>>>>> > /Robbin >>>>>>>> > >>>>>>>> > >>>>>>>> >> >>>>>>>> >> Thanks, >>>>>>>> >> >>>>>>>> >> Yasumasa >>>>>>>> >> >>>>>>>> >> > Thanks! >>>>>>>> >> > >>>>>>>> >> > /Robbin >>>>>>>> >> > >>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>> >> > > Hi all, >>>>>>>> >> > > >>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>> pthread_setname_np(). >>>>>>>> >> > > However, main thread does not have it. >>>>>>>> >> > > >>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>> JavaThread. >>>>>>>> >> > > For consistency, main thread should have native thread >>>>>>>> name. >>>>>>>> >> > > >>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>> >> > > >>>>>>>> >> > > >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>> >> > > >>>>>>>> >> > > I cannot access JPRT. >>>>>>>> >> > > So I need a sponsor. >>>>>>>> >> > > >>>>>>>> >> > > >>>>>>>> >> > > Thanks, >>>>>>>> >> > > >>>>>>>> >> > > Yasumasa >>>>>>>> >> > > >>>>>>>> >> >>>>>>>> >>>>>>>> From stuart.marks at oracle.com Thu Apr 14 01:50:14 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Wed, 13 Apr 2016 18:50:14 -0700 Subject: RFR(m): 8145468 deprecations for java.lang Message-ID: <570EF756.2090602@oracle.com> Hi all, Please review this first round of deprecation changes for the java.lang package. This changeset includes the following: - a set of APIs being newly deprecated - a set of already-deprecated APIs that are "upgraded" to forRemoval=true - addition of the "since" element to all deprecations - cleanup of some of the warnings caused by new deprecations Webrevs: http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ The newly deprecated APIs include all of the constructors for the boxed primitives. We don't intend to remove these yet, so they don't declare a value for the forRemoval element, implying the default value of false. The constructors being deprecated are as follows: Boolean(boolean) Boolean(String) Byte(byte) Byte(String) Character(char) Double(double) Double(String) Float(float) Float(double) Float(String) Integer(int) Integer(String) Long(long) Long(String) Short(short) Short(String) The methods being deprecated with forRemoval=true are listed below. All of these methods have already been deprecated. They are all ill-defined, or they don't work, or they don't do anything useful. Runtime.getLocalizedInputStream(InputStream) Runtime.getLocalizedOutputStream(OutputStream) Runtime.runFinalizersOnExit(boolean) SecurityManager.checkAwtEventQueueAccess() SecurityManager.checkMemberAccess(Class, int) SecurityManager.checkSystemClipboardAccess() SecurityManager.checkTopLevelWindow(Object) System.runFinalizersOnExit(boolean) Thread.countStackFrames() Thread.destroy() Thread.stop(Throwable) Most of the files in the changeset are cleanups. Some of them are simply the addition of the "since" element to the @Deprecated annotation, to indicate the version in which the API became deprecated. The rest of the changes are cleanup of warnings that were created by the deprecation of the boxed primitive constructors. There are a total of a couple hundred such uses sprinkled around the JDK. I've taken care of a portion of them, with the exception of the java.desktop module, which alone has over 100 uses of boxed primitive constructors. I've disabled deprecation warnings for the java.desktop module for the time being; these uses can be cleaned up later. I've filed JDK-8154213 to cover this cleanup task. For the warnings cleanups I did, I mostly did conversions of the form: new Double(dval) to Double.valueOf(dval) This is a very safe transformation. It changes the behavior only in the cases where the code relies on getting a new instance of the box object instead of one that might come out of a cache. I didn't see any such code (and I should hope there's no such code in the JDK!). I applied autoboxing only sparingly, in the cases where it was an obviously safe thing to do, or where nearby code already uses autoboxing. Autoboxing actually generates a call to the appropriate valueOf() method, so the bytecode would be the same in most cases. The only difference is clutter in the source code. On the other hand, there's some risk in converting to autoboxing, as the implicitly autoboxed type might end up different from an explicit call to valueOf(). This isn't always obvious, so that's why I mostly avoided autoboxing. Thanks, s'marks From yasuenag at gmail.com Thu Apr 14 03:52:03 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Thu, 14 Apr 2016 12:52:03 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570EE58F.4060809@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> Message-ID: <570F13E3.6000802@gmail.com> Hi, On 2016/04/14 9:34, David Holmes wrote: > Hi, > > On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >> Hi David, >> >> Thanks for your comment. >> >> I exported new JVM function to set native thread name, and JLI uses it >> in new webrev. > > First the launcher belongs to another team so core-libs will need to review and approve this (in particular Kumar) - now cc'd. Thanks! I'm waiting to review :-) > Personally I would have used a Java upcall to Thread.setName rather than exporting JVM_SetNativeThreadName. No hotspot changes needed in that case. As I wrote [1] in JBS, I changed to use Thread#setName() in Thread#init(), but I could not change native thread name. I guess that caller of main() is JNI attached thread. Thus I think that we have to provide a function to set native thread name. Thanks, Yasumasa [1] https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 > Thanks, > David > >> Could you review again? >> >> - hotspot: >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >> >> - jdk: >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/13 22:00, David Holmes wrote: >>> I'll answer on this original thread as well ... >>> >>> Hi Yasumasa, >>> >>> Please see my updates to the bug (sorry have been on vacation). This >>> needs to be done in the launcher to be correct as we do not set the >>> name of threads that attach via JNI, which includes the "main" thread. >>> >>> David >>> >>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>> Thanks Robbin, >>>> >>>> I'm waiting a sponsor and more reviewer :-) >>>> >>>> Yasumasa >>>> 2016/03/31 5:58 "Robbin Ehn" : >>>> >>>>> FYI: I'm not a Reviewer. >>>>> >>>>> /Robbin >>>>> >>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>> >>>>>> Thanks, looks good. >>>>>> >>>>>> /Robbin >>>>>> >>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> I uploaded new webrev. >>>>>>> Could you review it? >>>>>>> >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>> >>>>>>>>> Hi Robbin, >>>>>>>>> >>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>> >: >>>>>>>>> > >>>>>>>>> > Hi Yasumasa, >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>> >> >>>>>>>>> >> Hi Robbin, >>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>> >>>>>>>>> >> >>>>>>>> >>: >>>>>>>>> >> >>>>>>>>> >> > >>>>>>>>> >> > Hi Yasumasa, >>>>>>>>> >> > >>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>> >> > >>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>> 13:09:16 2016 >>>>>>>>> +0000 >>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>> 17:40:09 2016 >>>>>>>>> +0100 >>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>> >> > >>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>> >> > >>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>> >> >>>>>>>>> >> Native thread name is the same to thread name in Thread class. >>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>> will be >>>>>>>>> set at >>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>> >> Thread name for "main" is set in create_initial_thread(). >>>>>>>>> >> I think that the place of setting thrrad name should be the >>>>>>>>> same. >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>> nicer, no? >>>>>>>>> > >>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 09:43:05 >>>>>>>>> 2016 >>>>>>>>> +0200 >>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 10:51:12 >>>>>>>>> 2016 >>>>>>>>> +0200 >>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>> > // Creates the initial Thread >>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>> JavaThread* >>>>>>>>> thread, >>>>>>>>> > TRAPS) { >>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>> > Klass* k = >>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>> true, >>>>>>>>> CHECK_NULL); >>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>> > instanceHandle thread_oop = >>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), NormPriority); >>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>> > - >>>>>>>>> > - Handle string = java_lang_String::create_from_str("main", >>>>>>>>> CHECK_NULL); >>>>>>>>> > + >>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>> > + >>>>>>>>> > + Handle string = >>>>>>>>> java_lang_String::create_from_str(initial_thread_name, CHECK_NULL); >>>>>>>>> > >>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>> >>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>> >>>>>>>> >>>>>>>> Thanks! >>>>>>>> >>>>>>>> >>>>>>>>> >> > The launcher seem to name itself 'java' and naming this >>>>>>>>> thread >>>>>>>>> just >>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>> >> > >>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>> process) is >>>>>>>>> 'java' but >>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>> >> >>>>>>>>> >> The native main thread in the process is not JavaThread. It is >>>>>>>>> waiting >>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>> >> set_native_thread_name() is for JavaThread. So I think that >>>>>>>>> we do >>>>>>>>> not >>>>>>>>> >> need to call it for native main thread. >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > Not sure if we can change it anyhow, since we want java and >>>>>>>>> native >>>>>>>>> name to be the same and java thread name might have some >>>>>>>>> dependents. >>>>>>>>> > >>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>> > >>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>> > PID TID COMMAND >>>>>>>>> > 6423 6423 java >>>>>>>>> > 6423 6424 main >>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>> > >>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>> >>>>>>>>> I do not think so. >>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>> >>>>>>>>> If you want to change native main thread name, I think that we >>>>>>>>> have to >>>>>>>>> change Java launcher code. >>>>>>>>> Should I include it in new webrev? >>>>>>>>> >>>>>>>> >>>>>>>> No >>>>>>>> >>>>>>>> Thanks again! >>>>>>>> >>>>>>>> /Robbin >>>>>>>> >>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> > Thanks >>>>>>>>> > >>>>>>>>> > /Robbin >>>>>>>>> > >>>>>>>>> > >>>>>>>>> >> >>>>>>>>> >> Thanks, >>>>>>>>> >> >>>>>>>>> >> Yasumasa >>>>>>>>> >> >>>>>>>>> >> > Thanks! >>>>>>>>> >> > >>>>>>>>> >> > /Robbin >>>>>>>>> >> > >>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>> >> > > Hi all, >>>>>>>>> >> > > >>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>> pthread_setname_np(). >>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>> >> > > >>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>> JavaThread. >>>>>>>>> >> > > For consistency, main thread should have native thread >>>>>>>>> name. >>>>>>>>> >> > > >>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>> >> > > >>>>>>>>> >> > > >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>> >> > > >>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>> >> > > So I need a sponsor. >>>>>>>>> >> > > >>>>>>>>> >> > > >>>>>>>>> >> > > Thanks, >>>>>>>>> >> > > >>>>>>>>> >> > > Yasumasa >>>>>>>>> >> > > >>>>>>>>> >> >>>>>>>>> >>>>>>>>> From paul.sandoz at oracle.com Thu Apr 14 08:53:22 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 14 Apr 2016 10:53:22 +0200 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570E963C.3050706@oracle.com> References: <570E963C.3050706@oracle.com> Message-ID: <22DBD32E-046E-4103-ADA5-9CD9A5DBA35E@oracle.com> Hi Sherman, Not a full review, I browsed the code very quickly and noticed one thing: JrtFileSystem ? 167 private static final Set supportedFileAttributeViews 168 = Collections.unmodifiableSet( 169 new HashSet(Arrays.asList("basic", "jrt"))); Use Set.of. Paul. > On 13 Apr 2016, at 20:55, Xueming Shen wrote: > > Hi, > > Please hep review the cleanup changes for jrtfs implementation. > > issue: https://bugs.openjdk.java.net/browse/JDK-8147460 > webrev: http://cr.openjdk.java.net/~sherman/8147460/webrev > > Simple benchmark [1] has been run both on jimage and the "exploded modules" > directory, the numbers suggest we also get an encouraging performance boost > on most of the frequently invoked access methods. > > [1] http://cr.openjdk.java.net/~sherman/8147460/MyBenchmark.java > > Benchmark Mode Cnt Score Error Units > ------------------------------------------------------------ > [jimage/existing] > MyBenchmark.testExists avgt 50 18.592 ? 1.213 ms/op > MyBenchmark.testIsDirectory avgt 50 17.382 ? 1.178 ms/op > MyBenchmark.testIsRegularFile avgt 50 18.576 ? 1.577 ms/op > MyBenchmark.testItr avgt 50 58.414 ? 1.638 ms/op > MyBenchmark.testLookupPath avgt 50 18.935 ? 1.093 ms/op > MyBenchmark.testLookupStr avgt 50 38.597 ? 1.663 ms/op > MyBenchmark.testToRealPath avgt 50 30.119 ? 1.196 ms/op > > [jimage/new] > MyBenchmark.testExists avgt 50 10.865 ? 1.125 ms/op > MyBenchmark.testIsDirectory avgt 50 11.077 ? 1.101 ms/op > MyBenchmark.testIsRegularFile avgt 50 10.967 ? 1.220 ms/op > MyBenchmark.testItr avgt 50 49.249 ? 3.753 ms/op > MyBenchmark.testLookupPath avgt 50 10.857 ? 1.071 ms/op > MyBenchmark.testLookupStr avgt 50 34.367 ? 1.341 ms/op > MyBenchmark.testToRealPath avgt 50 11.460 ? 1.081 ms/op > > ------------------------------------------------------------ > [exploded dir/existing] > MyBenchmark.testExists avgt 50 23.055 ? 1.707 ms/op > MyBenchmark.testIsDirectory avgt 50 23.985 ? 1.593 ms/op > MyBenchmark.testIsRegularFile avgt 50 24.200 ? 1.744 ms/op > MyBenchmark.testItr avgt 50 210.002 ? 6.954 ms/op > MyBenchmark.testLookupPath avgt 50 23.242 ? 1.799 ms/op > MyBenchmark.testLookupStr avgt 50 43.026 ? 1.751 ms/op > MyBenchmark.testToRealPath avgt 50 56.536 ? 1.679 ms/op > > [exploded dir/new] > MyBenchmark.testExists avgt 50 11.260 ? 1.209 ms/op > MyBenchmark.testIsDirectory avgt 50 11.702 ? 1.069 ms/op > MyBenchmark.testIsRegularFile avgt 50 12.284 ? 1.333 ms/op > MyBenchmark.testItr avgt 50 49.342 ? 1.516 ms/op > MyBenchmark.testLookupPath avgt 50 11.041 ? 1.051 ms/op > MyBenchmark.testLookupStr avgt 50 35.850 ? 1.618 ms/op > MyBenchmark.testToRealPath avgt 50 13.016 ? 1.339 ms/op > > Thanks, > Sherman > From paul.sandoz at oracle.com Thu Apr 14 09:00:21 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 14 Apr 2016 11:00:21 +0200 Subject: RFR(S): 8150824: Exceptions when omitting trailing arguments in cleanup In-Reply-To: References: Message-ID: <41A8CC89-B7BF-4A70-BDDE-8B1D622D1E61@oracle.com> > On 13 Apr 2016, at 16:39, Michael Haupt wrote: > > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8150824 > Webrev: http://cr.openjdk.java.net/~mhaupt/8150824/webrev.00/ > > The actual bug was fixed with the push for 8150829; this change merely contributes tests for the issue. > +1 Paul. > Thanks, > > Michael > From sundararajan.athijegannathan at oracle.com Thu Apr 14 09:09:05 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 14 Apr 2016 14:39:05 +0530 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <22DBD32E-046E-4103-ADA5-9CD9A5DBA35E@oracle.com> References: <570E963C.3050706@oracle.com> <22DBD32E-046E-4103-ADA5-9CD9A5DBA35E@oracle.com> Message-ID: <570F5E31.8030007@oracle.com> jrt-fs.jar code has to run on jdk8 as well. Cannot use jdk9 API. -Sundar On 4/14/2016 2:23 PM, Paul Sandoz wrote: > Hi Sherman, > > Not a full review, I browsed the code very quickly and noticed one thing: > > JrtFileSystem > ? > > 167 private static final Set supportedFileAttributeViews > 168 = Collections.unmodifiableSet( > 169 new HashSet(Arrays.asList("basic", "jrt"))); > > Use Set.of. > > Paul. > > >> On 13 Apr 2016, at 20:55, Xueming Shen wrote: >> >> Hi, >> >> Please hep review the cleanup changes for jrtfs implementation. >> >> issue: https://bugs.openjdk.java.net/browse/JDK-8147460 >> webrev: http://cr.openjdk.java.net/~sherman/8147460/webrev >> >> Simple benchmark [1] has been run both on jimage and the "exploded modules" >> directory, the numbers suggest we also get an encouraging performance boost >> on most of the frequently invoked access methods. >> >> [1] http://cr.openjdk.java.net/~sherman/8147460/MyBenchmark.java >> >> Benchmark Mode Cnt Score Error Units >> ------------------------------------------------------------ >> [jimage/existing] >> MyBenchmark.testExists avgt 50 18.592 ? 1.213 ms/op >> MyBenchmark.testIsDirectory avgt 50 17.382 ? 1.178 ms/op >> MyBenchmark.testIsRegularFile avgt 50 18.576 ? 1.577 ms/op >> MyBenchmark.testItr avgt 50 58.414 ? 1.638 ms/op >> MyBenchmark.testLookupPath avgt 50 18.935 ? 1.093 ms/op >> MyBenchmark.testLookupStr avgt 50 38.597 ? 1.663 ms/op >> MyBenchmark.testToRealPath avgt 50 30.119 ? 1.196 ms/op >> >> [jimage/new] >> MyBenchmark.testExists avgt 50 10.865 ? 1.125 ms/op >> MyBenchmark.testIsDirectory avgt 50 11.077 ? 1.101 ms/op >> MyBenchmark.testIsRegularFile avgt 50 10.967 ? 1.220 ms/op >> MyBenchmark.testItr avgt 50 49.249 ? 3.753 ms/op >> MyBenchmark.testLookupPath avgt 50 10.857 ? 1.071 ms/op >> MyBenchmark.testLookupStr avgt 50 34.367 ? 1.341 ms/op >> MyBenchmark.testToRealPath avgt 50 11.460 ? 1.081 ms/op >> >> ------------------------------------------------------------ >> [exploded dir/existing] >> MyBenchmark.testExists avgt 50 23.055 ? 1.707 ms/op >> MyBenchmark.testIsDirectory avgt 50 23.985 ? 1.593 ms/op >> MyBenchmark.testIsRegularFile avgt 50 24.200 ? 1.744 ms/op >> MyBenchmark.testItr avgt 50 210.002 ? 6.954 ms/op >> MyBenchmark.testLookupPath avgt 50 23.242 ? 1.799 ms/op >> MyBenchmark.testLookupStr avgt 50 43.026 ? 1.751 ms/op >> MyBenchmark.testToRealPath avgt 50 56.536 ? 1.679 ms/op >> >> [exploded dir/new] >> MyBenchmark.testExists avgt 50 11.260 ? 1.209 ms/op >> MyBenchmark.testIsDirectory avgt 50 11.702 ? 1.069 ms/op >> MyBenchmark.testIsRegularFile avgt 50 12.284 ? 1.333 ms/op >> MyBenchmark.testItr avgt 50 49.342 ? 1.516 ms/op >> MyBenchmark.testLookupPath avgt 50 11.041 ? 1.051 ms/op >> MyBenchmark.testLookupStr avgt 50 35.850 ? 1.618 ms/op >> MyBenchmark.testToRealPath avgt 50 13.016 ? 1.339 ms/op >> >> Thanks, >> Sherman >> From Alan.Bateman at oracle.com Thu Apr 14 09:18:36 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 14 Apr 2016 10:18:36 +0100 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <22DBD32E-046E-4103-ADA5-9CD9A5DBA35E@oracle.com> References: <570E963C.3050706@oracle.com> <22DBD32E-046E-4103-ADA5-9CD9A5DBA35E@oracle.com> Message-ID: <570F606C.7080505@oracle.com> On 14/04/2016 09:53, Paul Sandoz wrote: > Hi Sherman, > > Not a full review, I browsed the code very quickly and noticed one thing: > > JrtFileSystem > ? > > 167 private static final Set supportedFileAttributeViews > 168 = Collections.unmodifiableSet( > 169 new HashSet(Arrays.asList("basic", "jrt"))); > > Use Set.of. One constraint that Sherman didn't mention is that jrtfs is compiled to JDK N-1, currently JDK 8, so that tools/IDEs can run on JDK 8 and access the classes/resources in a target JDK 9 runtime image. I thought we put a comment at the top of each source file on this but I need to check. It will be caught by the build anyway. -Alan. From paul.sandoz at oracle.com Thu Apr 14 09:31:45 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 14 Apr 2016 11:31:45 +0200 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570F5E31.8030007@oracle.com> References: <570E963C.3050706@oracle.com> <22DBD32E-046E-4103-ADA5-9CD9A5DBA35E@oracle.com> <570F5E31.8030007@oracle.com> Message-ID: > On 14 Apr 2016, at 11:09, Sundararajan Athijegannathan wrote: > > jrt-fs.jar code has to run on jdk8 as well. Cannot use jdk9 API. > Ah, ok. Thanks, Paul. From sundararajan.athijegannathan at oracle.com Thu Apr 14 10:26:08 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Thu, 14 Apr 2016 15:56:08 +0530 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570E963C.3050706@oracle.com> References: <570E963C.3050706@oracle.com> Message-ID: <570F7040.7020901@oracle.com> Looks good -Sundar On 4/14/2016 12:25 AM, Xueming Shen wrote: > Hi, > > Please hep review the cleanup changes for jrtfs implementation. > > issue: https://bugs.openjdk.java.net/browse/JDK-8147460 > webrev: http://cr.openjdk.java.net/~sherman/8147460/webrev > > Simple benchmark [1] has been run both on jimage and the "exploded > modules" > directory, the numbers suggest we also get an encouraging performance > boost > on most of the frequently invoked access methods. > > [1] http://cr.openjdk.java.net/~sherman/8147460/MyBenchmark.java > > Benchmark Mode Cnt Score Error Units > ------------------------------------------------------------ > [jimage/existing] > MyBenchmark.testExists avgt 50 18.592 ? 1.213 ms/op > MyBenchmark.testIsDirectory avgt 50 17.382 ? 1.178 ms/op > MyBenchmark.testIsRegularFile avgt 50 18.576 ? 1.577 ms/op > MyBenchmark.testItr avgt 50 58.414 ? 1.638 ms/op > MyBenchmark.testLookupPath avgt 50 18.935 ? 1.093 ms/op > MyBenchmark.testLookupStr avgt 50 38.597 ? 1.663 ms/op > MyBenchmark.testToRealPath avgt 50 30.119 ? 1.196 ms/op > > [jimage/new] > MyBenchmark.testExists avgt 50 10.865 ? 1.125 ms/op > MyBenchmark.testIsDirectory avgt 50 11.077 ? 1.101 ms/op > MyBenchmark.testIsRegularFile avgt 50 10.967 ? 1.220 ms/op > MyBenchmark.testItr avgt 50 49.249 ? 3.753 ms/op > MyBenchmark.testLookupPath avgt 50 10.857 ? 1.071 ms/op > MyBenchmark.testLookupStr avgt 50 34.367 ? 1.341 ms/op > MyBenchmark.testToRealPath avgt 50 11.460 ? 1.081 ms/op > > ------------------------------------------------------------ > [exploded dir/existing] > MyBenchmark.testExists avgt 50 23.055 ? 1.707 ms/op > MyBenchmark.testIsDirectory avgt 50 23.985 ? 1.593 ms/op > MyBenchmark.testIsRegularFile avgt 50 24.200 ? 1.744 ms/op > MyBenchmark.testItr avgt 50 210.002 ? 6.954 ms/op > MyBenchmark.testLookupPath avgt 50 23.242 ? 1.799 ms/op > MyBenchmark.testLookupStr avgt 50 43.026 ? 1.751 ms/op > MyBenchmark.testToRealPath avgt 50 56.536 ? 1.679 ms/op > > [exploded dir/new] > MyBenchmark.testExists avgt 50 11.260 ? 1.209 ms/op > MyBenchmark.testIsDirectory avgt 50 11.702 ? 1.069 ms/op > MyBenchmark.testIsRegularFile avgt 50 12.284 ? 1.333 ms/op > MyBenchmark.testItr avgt 50 49.342 ? 1.516 ms/op > MyBenchmark.testLookupPath avgt 50 11.041 ? 1.051 ms/op > MyBenchmark.testLookupStr avgt 50 35.850 ? 1.618 ms/op > MyBenchmark.testToRealPath avgt 50 13.016 ? 1.339 ms/op > > Thanks, > Sherman > From david.holmes at oracle.com Thu Apr 14 12:32:30 2016 From: david.holmes at oracle.com (David Holmes) Date: Thu, 14 Apr 2016 22:32:30 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570F13E3.6000802@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> Message-ID: <570F8DDE.5000002@oracle.com> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: > Hi, > > On 2016/04/14 9:34, David Holmes wrote: >> Hi, >> >> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>> Thanks for your comment. >>> >>> I exported new JVM function to set native thread name, and JLI uses it >>> in new webrev. >> >> First the launcher belongs to another team so core-libs will need to >> review and approve this (in particular Kumar) - now cc'd. > > Thanks! > I'm waiting to review :-) > > >> Personally I would have used a Java upcall to Thread.setName rather >> than exporting JVM_SetNativeThreadName. No hotspot changes needed in >> that case. > > As I wrote [1] in JBS, I changed to use Thread#setName() in Thread#init(), > but I could not change native thread name. At Thread.init time the thread is not alive, which is why the native name is not set. > I guess that caller of main() is JNI attached thread. That is an interesting question which I haven't had time to check - sorry. If the main thread is considered a JNI-attached thread then my suggestion wont work. If it isn't then my suggestion should work (but it means we have an inconsistency in our treatment of JNI-attached threads :( ) I'll wait to see what Kumar thinks about this. I don't like exposing a new JVM function this way. Thanks, David ----- > Thus I think that we have to provide a function to set native thread name. > > > Thanks, > > Yasumasa > > > [1] > https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 > > >> Thanks, >> David >> >>> Could you review again? >>> >>> - hotspot: >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>> >>> - jdk: >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/13 22:00, David Holmes wrote: >>>> I'll answer on this original thread as well ... >>>> >>>> Hi Yasumasa, >>>> >>>> Please see my updates to the bug (sorry have been on vacation). This >>>> needs to be done in the launcher to be correct as we do not set the >>>> name of threads that attach via JNI, which includes the "main" thread. >>>> >>>> David >>>> >>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>> Thanks Robbin, >>>>> >>>>> I'm waiting a sponsor and more reviewer :-) >>>>> >>>>> Yasumasa >>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>> >>>>>> FYI: I'm not a Reviewer. >>>>>> >>>>>> /Robbin >>>>>> >>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>> >>>>>>> Thanks, looks good. >>>>>>> >>>>>>> /Robbin >>>>>>> >>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> I uploaded new webrev. >>>>>>>> Could you review it? >>>>>>>> >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>> >>>>>>>>>> Hi Robbin, >>>>>>>>>> >>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>> >: >>>>>>>>>> > >>>>>>>>>> > Hi Yasumasa, >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>> >> >>>>>>>>>> >> Hi Robbin, >>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>> >>>>>>>>>> >> >>>>>>>>> >>: >>>>>>>>>> >> >>>>>>>>>> >> > >>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>> >> > >>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>> >> > >>>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>> 13:09:16 2016 >>>>>>>>>> +0000 >>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>> 17:40:09 2016 >>>>>>>>>> +0100 >>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>> >> > >>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>> >>>>>>>>>> >> > >>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>> >> >>>>>>>>>> >> Native thread name is the same to thread name in Thread >>>>>>>>>> class. >>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>>> will be >>>>>>>>>> set at >>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>> >> Thread name for "main" is set in create_initial_thread(). >>>>>>>>>> >> I think that the place of setting thrrad name should be the >>>>>>>>>> same. >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>> nicer, no? >>>>>>>>>> > >>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 09:43:05 >>>>>>>>>> 2016 >>>>>>>>>> +0200 >>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 10:51:12 >>>>>>>>>> 2016 >>>>>>>>>> +0200 >>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>> > // Creates the initial Thread >>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>> JavaThread* >>>>>>>>>> thread, >>>>>>>>>> > TRAPS) { >>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>> > Klass* k = >>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>> true, >>>>>>>>>> CHECK_NULL); >>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>> NormPriority); >>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>> > - >>>>>>>>>> > - Handle string = java_lang_String::create_from_str("main", >>>>>>>>>> CHECK_NULL); >>>>>>>>>> > + >>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>> > + >>>>>>>>>> > + Handle string = >>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>> CHECK_NULL); >>>>>>>>>> > >>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>> >>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks! >>>>>>>>> >>>>>>>>> >>>>>>>>>> >> > The launcher seem to name itself 'java' and naming this >>>>>>>>>> thread >>>>>>>>>> just >>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>> >> > >>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>> process) is >>>>>>>>>> 'java' but >>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>> >> >>>>>>>>>> >> The native main thread in the process is not JavaThread. >>>>>>>>>> It is >>>>>>>>>> waiting >>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I think that >>>>>>>>>> we do >>>>>>>>>> not >>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > Not sure if we can change it anyhow, since we want java and >>>>>>>>>> native >>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>> dependents. >>>>>>>>>> > >>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>> > >>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>> > PID TID COMMAND >>>>>>>>>> > 6423 6423 java >>>>>>>>>> > 6423 6424 main >>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>> > >>>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>>> >>>>>>>>>> I do not think so. >>>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>> >>>>>>>>>> If you want to change native main thread name, I think that we >>>>>>>>>> have to >>>>>>>>>> change Java launcher code. >>>>>>>>>> Should I include it in new webrev? >>>>>>>>>> >>>>>>>>> >>>>>>>>> No >>>>>>>>> >>>>>>>>> Thanks again! >>>>>>>>> >>>>>>>>> /Robbin >>>>>>>>> >>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> > Thanks >>>>>>>>>> > >>>>>>>>>> > /Robbin >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> >> >>>>>>>>>> >> Thanks, >>>>>>>>>> >> >>>>>>>>>> >> Yasumasa >>>>>>>>>> >> >>>>>>>>>> >> > Thanks! >>>>>>>>>> >> > >>>>>>>>>> >> > /Robbin >>>>>>>>>> >> > >>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>> >> > > Hi all, >>>>>>>>>> >> > > >>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>> pthread_setname_np(). >>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>> >> > > >>>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>>> JavaThread. >>>>>>>>>> >> > > For consistency, main thread should have native thread >>>>>>>>>> name. >>>>>>>>>> >> > > >>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>> >> > > >>>>>>>>>> >> > > >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>> >> > > >>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>> >> > > >>>>>>>>>> >> > > >>>>>>>>>> >> > > Thanks, >>>>>>>>>> >> > > >>>>>>>>>> >> > > Yasumasa >>>>>>>>>> >> > > >>>>>>>>>> >> >>>>>>>>>> >>>>>>>>>> From forax at univ-mlv.fr Thu Apr 14 13:21:18 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Thu, 14 Apr 2016 15:21:18 +0200 (CEST) Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> Hi Stuart, you are not the first one to try to change the integers defined in org.objectweb.asm.Opcodes, those values are compared by ref (not by value) inside ASM. You're patch will change the behavior of any Interpreters that also use some Integers created by Integer.valueOf() because valueOf may cache the Integer references. I will add a comment in the ASM trunk for avoid such refactoring in the future. reagrds, R?mi ----- Mail original ----- > De: "Stuart Marks" > ?: "core-libs-dev" > Envoy?: Jeudi 14 Avril 2016 03:50:14 > Objet: RFR(m): 8145468 deprecations for java.lang > > Hi all, > > Please review this first round of deprecation changes for the java.lang > package. > This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > The newly deprecated APIs include all of the constructors for the boxed > primitives. We don't intend to remove these yet, so they don't declare a > value > for the forRemoval element, implying the default value of false. The > constructors being deprecated are as follows: > > Boolean(boolean) > Boolean(String) > Byte(byte) > Byte(String) > Character(char) > Double(double) > Double(String) > Float(float) > Float(double) > Float(String) > Integer(int) > Integer(String) > Long(long) > Long(String) > Short(short) > Short(String) > > The methods being deprecated with forRemoval=true are listed below. All of > these > methods have already been deprecated. They are all ill-defined, or they don't > work, or they don't do anything useful. > > Runtime.getLocalizedInputStream(InputStream) > Runtime.getLocalizedOutputStream(OutputStream) > Runtime.runFinalizersOnExit(boolean) > SecurityManager.checkAwtEventQueueAccess() > SecurityManager.checkMemberAccess(Class, int) > SecurityManager.checkSystemClipboardAccess() > SecurityManager.checkTopLevelWindow(Object) > System.runFinalizersOnExit(boolean) > Thread.countStackFrames() > Thread.destroy() > Thread.stop(Throwable) > > Most of the files in the changeset are cleanups. Some of them are simply the > addition of the "since" element to the @Deprecated annotation, to indicate > the > version in which the API became deprecated. > > The rest of the changes are cleanup of warnings that were created by the > deprecation of the boxed primitive constructors. There are a total of a > couple > hundred such uses sprinkled around the JDK. I've taken care of a portion of > them, with the exception of the java.desktop module, which alone has over 100 > uses of boxed primitive constructors. I've disabled deprecation warnings for > the > java.desktop module for the time being; these uses can be cleaned up later. > I've > filed JDK-8154213 to cover this cleanup task. > > For the warnings cleanups I did, I mostly did conversions of the form: > > new Double(dval) > > to > > Double.valueOf(dval) > > This is a very safe transformation. It changes the behavior only in the cases > where the code relies on getting a new instance of the box object instead of > one > that might come out of a cache. I didn't see any such code (and I should hope > there's no such code in the JDK!). > > I applied autoboxing only sparingly, in the cases where it was an obviously > safe > thing to do, or where nearby code already uses autoboxing. Autoboxing > actually > generates a call to the appropriate valueOf() method, so the bytecode would > be > the same in most cases. The only difference is clutter in the source code. On > the other hand, there's some risk in converting to autoboxing, as the > implicitly > autoboxed type might end up different from an explicit call to valueOf(). > This > isn't always obvious, so that's why I mostly avoided autoboxing. > > Thanks, > > s'marks > > From yasuenag at gmail.com Thu Apr 14 13:32:46 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Thu, 14 Apr 2016 22:32:46 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570F8DDE.5000002@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> Message-ID: <570F9BFE.8010400@gmail.com> > That is an interesting question which I haven't had time to check - sorry. If the main thread is considered a JNI-attached thread then my suggestion wont work. If it isn't then my suggestion should work (but it means we have an inconsistency in our treatment of JNI-attached threads :( ) I ran following program on JDK 9 EA b112, and I confirmed native thread name (test) was set. --------- public class Sleep{ public static void main(String[] args) throws Exception{ Thread.currentThread().setName("test"); Thread.sleep(3600000); } } --------- > I'll wait to see what Kumar thinks about this. I don't like exposing a new JVM function this way. I will update webrev after hearing Kumar's comment. Thanks, Yasumasa On 2016/04/14 21:32, David Holmes wrote: > On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >> Hi, >> >> On 2016/04/14 9:34, David Holmes wrote: >>> Hi, >>> >>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>> Thanks for your comment. >>>> >>>> I exported new JVM function to set native thread name, and JLI uses it >>>> in new webrev. >>> >>> First the launcher belongs to another team so core-libs will need to >>> review and approve this (in particular Kumar) - now cc'd. >> >> Thanks! >> I'm waiting to review :-) >> >> >>> Personally I would have used a Java upcall to Thread.setName rather >>> than exporting JVM_SetNativeThreadName. No hotspot changes needed in >>> that case. >> >> As I wrote [1] in JBS, I changed to use Thread#setName() in Thread#init(), >> but I could not change native thread name. > > At Thread.init time the thread is not alive, which is why the native name is not set. > >> I guess that caller of main() is JNI attached thread. > > That is an interesting question which I haven't had time to check - sorry. If the main thread is considered a JNI-attached thread then my suggestion wont work. If it isn't then my suggestion should work (but it means we have an inconsistency in our treatment of JNI-attached threads :( ) > > I'll wait to see what Kumar thinks about this. I don't like exposing a new JVM function this way. > > Thanks, > David > ----- > >> Thus I think that we have to provide a function to set native thread name. >> >> >> Thanks, >> >> Yasumasa >> >> >> [1] >> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >> >> >>> Thanks, >>> David >>> >>>> Could you review again? >>>> >>>> - hotspot: >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>> >>>> - jdk: >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/13 22:00, David Holmes wrote: >>>>> I'll answer on this original thread as well ... >>>>> >>>>> Hi Yasumasa, >>>>> >>>>> Please see my updates to the bug (sorry have been on vacation). This >>>>> needs to be done in the launcher to be correct as we do not set the >>>>> name of threads that attach via JNI, which includes the "main" thread. >>>>> >>>>> David >>>>> >>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>> Thanks Robbin, >>>>>> >>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>> >>>>>> Yasumasa >>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>> >>>>>>> FYI: I'm not a Reviewer. >>>>>>> >>>>>>> /Robbin >>>>>>> >>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>> >>>>>>>> Thanks, looks good. >>>>>>>> >>>>>>>> /Robbin >>>>>>>> >>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> I uploaded new webrev. >>>>>>>>> Could you review it? >>>>>>>>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>> >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>> >>>>>>>>>>> Hi Robbin, >>>>>>>>>>> >>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>> >: >>>>>>>>>>> > >>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> >> >>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>> >>>>>>>>>>> >> >>>>>>>>>> >>: >>>>>>>>>>> >> >>>>>>>>>>> >> > >>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>> >> > >>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>> >> > >>>>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>> +0000 >>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>> +0100 >>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>> >> > >>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>> >>>>>>>>>>> >> > >>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>> >> >>>>>>>>>>> >> Native thread name is the same to thread name in Thread >>>>>>>>>>> class. >>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>>>> will be >>>>>>>>>>> set at >>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>> >> Thread name for "main" is set in create_initial_thread(). >>>>>>>>>>> >> I think that the place of setting thrrad name should be the >>>>>>>>>>> same. >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>> nicer, no? >>>>>>>>>>> > >>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 09:43:05 >>>>>>>>>>> 2016 >>>>>>>>>>> +0200 >>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 10:51:12 >>>>>>>>>>> 2016 >>>>>>>>>>> +0200 >>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>> JavaThread* >>>>>>>>>>> thread, >>>>>>>>>>> > TRAPS) { >>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>> > Klass* k = >>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>> true, >>>>>>>>>>> CHECK_NULL); >>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>> NormPriority); >>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>> > - >>>>>>>>>>> > - Handle string = java_lang_String::create_from_str("main", >>>>>>>>>>> CHECK_NULL); >>>>>>>>>>> > + >>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>> > + >>>>>>>>>>> > + Handle string = >>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>> CHECK_NULL); >>>>>>>>>>> > >>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>> >>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks! >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming this >>>>>>>>>>> thread >>>>>>>>>>> just >>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>> >> > >>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>> process) is >>>>>>>>>>> 'java' but >>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>> >> >>>>>>>>>>> >> The native main thread in the process is not JavaThread. >>>>>>>>>>> It is >>>>>>>>>>> waiting >>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I think that >>>>>>>>>>> we do >>>>>>>>>>> not >>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > Not sure if we can change it anyhow, since we want java and >>>>>>>>>>> native >>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>> dependents. >>>>>>>>>>> > >>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>> > >>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>> > 6423 6423 java >>>>>>>>>>> > 6423 6424 main >>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>> > >>>>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>>>> >>>>>>>>>>> I do not think so. >>>>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>> >>>>>>>>>>> If you want to change native main thread name, I think that we >>>>>>>>>>> have to >>>>>>>>>>> change Java launcher code. >>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> No >>>>>>>>>> >>>>>>>>>> Thanks again! >>>>>>>>>> >>>>>>>>>> /Robbin >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> > Thanks >>>>>>>>>>> > >>>>>>>>>>> > /Robbin >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> >> >>>>>>>>>>> >> Thanks, >>>>>>>>>>> >> >>>>>>>>>>> >> Yasumasa >>>>>>>>>>> >> >>>>>>>>>>> >> > Thanks! >>>>>>>>>>> >> > >>>>>>>>>>> >> > /Robbin >>>>>>>>>>> >> > >>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> >> > > Hi all, >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>>>> JavaThread. >>>>>>>>>>> >> > > For consistency, main thread should have native thread >>>>>>>>>>> name. >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > Thanks, >>>>>>>>>>> >> > > >>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>> >> > > >>>>>>>>>>> >> >>>>>>>>>>> >>>>>>>>>>> From lance.andersen at oracle.com Thu Apr 14 13:49:51 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Thu, 14 Apr 2016 09:49:51 -0400 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: Hi Stuart, Outside of the comments from Remi regarding ASM, the other changes look fine to me and the wordsmithing looks good. I assume we are going to want to go back and add the JDK release of deprecation for all methods. If so, I will get to the JDBC ones shortly. Best Lance > On Apr 13, 2016, at 9:50 PM, Stuart Marks wrote: > > Hi all, > > Please review this first round of deprecation changes for the java.lang package. This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > The newly deprecated APIs include all of the constructors for the boxed primitives. We don't intend to remove these yet, so they don't declare a value for the forRemoval element, implying the default value of false. The constructors being deprecated are as follows: > > Boolean(boolean) > Boolean(String) > Byte(byte) > Byte(String) > Character(char) > Double(double) > Double(String) > Float(float) > Float(double) > Float(String) > Integer(int) > Integer(String) > Long(long) > Long(String) > Short(short) > Short(String) > > The methods being deprecated with forRemoval=true are listed below. All of these methods have already been deprecated. They are all ill-defined, or they don't work, or they don't do anything useful. > > Runtime.getLocalizedInputStream(InputStream) > Runtime.getLocalizedOutputStream(OutputStream) > Runtime.runFinalizersOnExit(boolean) > SecurityManager.checkAwtEventQueueAccess() > SecurityManager.checkMemberAccess(Class, int) > SecurityManager.checkSystemClipboardAccess() > SecurityManager.checkTopLevelWindow(Object) > System.runFinalizersOnExit(boolean) > Thread.countStackFrames() > Thread.destroy() > Thread.stop(Throwable) > > Most of the files in the changeset are cleanups. Some of them are simply the addition of the "since" element to the @Deprecated annotation, to indicate the version in which the API became deprecated. > > The rest of the changes are cleanup of warnings that were created by the deprecation of the boxed primitive constructors. There are a total of a couple hundred such uses sprinkled around the JDK. I've taken care of a portion of them, with the exception of the java.desktop module, which alone has over 100 uses of boxed primitive constructors. I've disabled deprecation warnings for the java.desktop module for the time being; these uses can be cleaned up later. I've filed JDK-8154213 to cover this cleanup task. > > For the warnings cleanups I did, I mostly did conversions of the form: > > new Double(dval) > > to > > Double.valueOf(dval) > > This is a very safe transformation. It changes the behavior only in the cases where the code relies on getting a new instance of the box object instead of one that might come out of a cache. I didn't see any such code (and I should hope there's no such code in the JDK!). > > I applied autoboxing only sparingly, in the cases where it was an obviously safe thing to do, or where nearby code already uses autoboxing. Autoboxing actually generates a call to the appropriate valueOf() method, so the bytecode would be the same in most cases. The only difference is clutter in the source code. On the other hand, there's some risk in converting to autoboxing, as the implicitly autoboxed type might end up different from an explicit call to valueOf(). This isn't always obvious, so that's why I mostly avoided autoboxing. > > Thanks, > > s'marks > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From Roger.Riggs at Oracle.com Thu Apr 14 14:24:03 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Thu, 14 Apr 2016 10:24:03 -0400 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570F9BFE.8010400@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> Message-ID: <570FA803.1010105@Oracle.com> Hi, Comments: jvm.h: The function names are too similar but perform different functions: -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName - The first function applies to the current thread, the second one a specific java thread. It would seem useful for there to be a comment somewhere about what the new function does. windows/native/libjli/java_md.c: line 408 casts to (void*) instead of (SetNativeThreadName0_t) as is done on unix and mac. - macosx/native/libjli/java_md_macosx.c: - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at line 730 - 738 Incorrect indentation; if possible keep the cast on the same line as dlsym... $.02, Roger On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >> That is an interesting question which I haven't had time to check - >> sorry. If the main thread is considered a JNI-attached thread then my >> suggestion wont work. If it isn't then my suggestion should work (but >> it means we have an inconsistency in our treatment of JNI-attached >> threads :( ) > > I ran following program on JDK 9 EA b112, and I confirmed native > thread name (test) was set. > --------- > public class Sleep{ > public static void main(String[] args) throws Exception{ > Thread.currentThread().setName("test"); > Thread.sleep(3600000); > } > } > --------- > > >> I'll wait to see what Kumar thinks about this. I don't like exposing >> a new JVM function this way. > > I will update webrev after hearing Kumar's comment. > > > Thanks, > > Yasumasa > > > On 2016/04/14 21:32, David Holmes wrote: >> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>> Hi, >>> >>> On 2016/04/14 9:34, David Holmes wrote: >>>> Hi, >>>> >>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>> Thanks for your comment. >>>>> >>>>> I exported new JVM function to set native thread name, and JLI >>>>> uses it >>>>> in new webrev. >>>> >>>> First the launcher belongs to another team so core-libs will need to >>>> review and approve this (in particular Kumar) - now cc'd. >>> >>> Thanks! >>> I'm waiting to review :-) >>> >>> >>>> Personally I would have used a Java upcall to Thread.setName rather >>>> than exporting JVM_SetNativeThreadName. No hotspot changes needed in >>>> that case. >>> >>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>> Thread#init(), >>> but I could not change native thread name. >> >> At Thread.init time the thread is not alive, which is why the native >> name is not set. >> >>> I guess that caller of main() is JNI attached thread. >> >> That is an interesting question which I haven't had time to check - >> sorry. If the main thread is considered a JNI-attached thread then my >> suggestion wont work. If it isn't then my suggestion should work (but >> it means we have an inconsistency in our treatment of JNI-attached >> threads :( ) >> >> I'll wait to see what Kumar thinks about this. I don't like exposing >> a new JVM function this way. >> >> Thanks, >> David >> ----- >> >>> Thus I think that we have to provide a function to set native thread >>> name. >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> [1] >>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>> >>> >>> >>>> Thanks, >>>> David >>>> >>>>> Could you review again? >>>>> >>>>> - hotspot: >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>> >>>>> - jdk: >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>> I'll answer on this original thread as well ... >>>>>> >>>>>> Hi Yasumasa, >>>>>> >>>>>> Please see my updates to the bug (sorry have been on vacation). This >>>>>> needs to be done in the launcher to be correct as we do not set the >>>>>> name of threads that attach via JNI, which includes the "main" >>>>>> thread. >>>>>> >>>>>> David >>>>>> >>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>> Thanks Robbin, >>>>>>> >>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>> >>>>>>> Yasumasa >>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>> >>>>>>>> FYI: I'm not a Reviewer. >>>>>>>> >>>>>>>> /Robbin >>>>>>>> >>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>> >>>>>>>>> Thanks, looks good. >>>>>>>>> >>>>>>>>> /Robbin >>>>>>>>> >>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>> >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> I uploaded new webrev. >>>>>>>>>> Could you review it? >>>>>>>>>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>> >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>> >>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>> >: >>>>>>>>>>>> > >>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >> >>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>> >>>>>>>>>>>> >> >>>>>>>>>>> >>: >>>>>>>>>>>> >> >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>> +0000 >>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>> +0100 >>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>> >> > >>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>> >> >>>>>>>>>>>> >> Native thread name is the same to thread name in Thread >>>>>>>>>>>> class. >>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>>>>> will be >>>>>>>>>>>> set at >>>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>>> >> Thread name for "main" is set in create_initial_thread(). >>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>> be the >>>>>>>>>>>> same. >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>>> nicer, no? >>>>>>>>>>>> > >>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>> 09:43:05 >>>>>>>>>>>> 2016 >>>>>>>>>>>> +0200 >>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>> 10:51:12 >>>>>>>>>>>> 2016 >>>>>>>>>>>> +0200 >>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>>> JavaThread* >>>>>>>>>>>> thread, >>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>> > Klass* k = >>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>> >>>>>>>>>>>> true, >>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>> NormPriority); >>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>> > - >>>>>>>>>>>> > - Handle string = >>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>> > + >>>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>> > + >>>>>>>>>>>> > + Handle string = >>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>> > >>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>> >>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks! >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming >>>>>>>>>>>> this >>>>>>>>>>>> thread >>>>>>>>>>>> just >>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>> process) is >>>>>>>>>>>> 'java' but >>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>> >> >>>>>>>>>>>> >> The native main thread in the process is not JavaThread. >>>>>>>>>>>> It is >>>>>>>>>>>> waiting >>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I think >>>>>>>>>>>> that >>>>>>>>>>>> we do >>>>>>>>>>>> not >>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > Not sure if we can change it anyhow, since we want java >>>>>>>>>>>> and >>>>>>>>>>>> native >>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>> dependents. >>>>>>>>>>>> > >>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>> > >>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>> > >>>>>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>>>>> >>>>>>>>>>>> I do not think so. >>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>> >>>>>>>>>>>> If you want to change native main thread name, I think that we >>>>>>>>>>>> have to >>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> No >>>>>>>>>>> >>>>>>>>>>> Thanks again! >>>>>>>>>>> >>>>>>>>>>> /Robbin >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> > Thanks >>>>>>>>>>>> > >>>>>>>>>>>> > /Robbin >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> >> >>>>>>>>>>>> >> Thanks, >>>>>>>>>>>> >> >>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>> >> >>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>> >> > >>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>>>>> JavaThread. >>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>> thread >>>>>>>>>>>> name. >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>> >> > > >>>>>>>>>>>> >> >>>>>>>>>>>> >>>>>>>>>>>> From peter.levart at gmail.com Thu Apr 14 14:25:07 2016 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 14 Apr 2016 16:25:07 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <796EA2FB-95D5-4406-AF1C-2603B1915E62@oracle.com> References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> <796EA2FB-95D5-4406-AF1C-2603B1915E62@oracle.com> Message-ID: <570FA843.70204@gmail.com> Hi Paul, I wanted to try using VarHandles for code internal to JDK but there's a problem with MethodHandles.lookup(). It doesn't allow the caller class loaded by the bootstrap class loader and located in either java.* or sun.* (but not sun.invoke.*) packages: private static void checkUnprivilegedlookupClass(Class lookupClass, int allowedModes) { String name = lookupClass.getName(); if (name.startsWith("java.lang.invoke.")) throw newIllegalArgumentException("illegal lookupClass: "+lookupClass); // For caller-sensitive MethodHandles.lookup() // disallow lookup more restricted packages if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) { if (name.startsWith("java.") || (name.startsWith("sun.") && !name.startsWith("sun.invoke."))) { throw newIllegalArgumentException("illegal lookupClass: " + lookupClass); } } } ...strangely, other bootstrap class loaded callers located in jdk.* are allowed. Why such distinction? Is there or will there be an official way to use VarHandles in JDK code and not having to resort to work-arounds like MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP").setAccessible(true)? Regards, Peter From heinz at javaspecialists.eu Thu Apr 14 14:37:00 2016 From: heinz at javaspecialists.eu (Dr Heinz M. Kabutz) Date: Thu, 14 Apr 2016 16:37:00 +0200 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: <570FAB0C.7070505@javaspecialists.eu> Hi Stuart, in previous versions of Java, escape analysis did not seem to work particularly well with Integer.valueOf(int) values, since the objects of course could come from the Integer Cache. Thus if the Integer object did not escape from your method, it could get eliminated entirely. Not exactly sure what -XX:+EliminateAutoBox does, but my guess would be that there is some relation here. So even though your changes look sensible, I'm just worried about deprecating the constructors taking a primitive as a parameter. I haven't looked at this particular issue for a number of years, so it's entirely possible that it is a non-issue now :) Regards Heinz -- Dr Heinz M. Kabutz (PhD CompSci) Author of "The Java(tm) Specialists' Newsletter" Sun/Oracle Java Champion since 2005 JavaOne Rock Star Speaker 2012 http://www.javaspecialists.eu Tel: +30 69 75 595 262 Skype: kabutz Stuart Marks wrote: > Hi all, > > Please review this first round of deprecation changes for the > java.lang package. This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to > forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > The newly deprecated APIs include all of the constructors for the > boxed primitives. We don't intend to remove these yet, so they don't > declare a value for the forRemoval element, implying the default value > of false. The constructors being deprecated are as follows: > > Boolean(boolean) > Boolean(String) > Byte(byte) > Byte(String) > Character(char) > Double(double) > Double(String) > Float(float) > Float(double) > Float(String) > Integer(int) > Integer(String) > Long(long) > Long(String) > Short(short) > Short(String) > > The methods being deprecated with forRemoval=true are listed below. > All of these methods have already been deprecated. They are all > ill-defined, or they don't work, or they don't do anything useful. > > Runtime.getLocalizedInputStream(InputStream) > Runtime.getLocalizedOutputStream(OutputStream) > Runtime.runFinalizersOnExit(boolean) > SecurityManager.checkAwtEventQueueAccess() > SecurityManager.checkMemberAccess(Class, int) > SecurityManager.checkSystemClipboardAccess() > SecurityManager.checkTopLevelWindow(Object) > System.runFinalizersOnExit(boolean) > Thread.countStackFrames() > Thread.destroy() > Thread.stop(Throwable) > > Most of the files in the changeset are cleanups. Some of them are > simply the addition of the "since" element to the @Deprecated > annotation, to indicate the version in which the API became deprecated. > > The rest of the changes are cleanup of warnings that were created by > the deprecation of the boxed primitive constructors. There are a total > of a couple hundred such uses sprinkled around the JDK. I've taken > care of a portion of them, with the exception of the java.desktop > module, which alone has over 100 uses of boxed primitive constructors. > I've disabled deprecation warnings for the java.desktop module for the > time being; these uses can be cleaned up later. I've filed JDK-8154213 > to cover this cleanup task. > > For the warnings cleanups I did, I mostly did conversions of the form: > > new Double(dval) > > to > > Double.valueOf(dval) > > This is a very safe transformation. It changes the behavior only in > the cases where the code relies on getting a new instance of the box > object instead of one that might come out of a cache. I didn't see any > such code (and I should hope there's no such code in the JDK!). > > I applied autoboxing only sparingly, in the cases where it was an > obviously safe thing to do, or where nearby code already uses > autoboxing. Autoboxing actually generates a call to the appropriate > valueOf() method, so the bytecode would be the same in most cases. The > only difference is clutter in the source code. On the other hand, > there's some risk in converting to autoboxing, as the implicitly > autoboxed type might end up different from an explicit call to > valueOf(). This isn't always obvious, so that's why I mostly avoided > autoboxing. > > Thanks, > > s'marks > > From paul.sandoz at oracle.com Thu Apr 14 14:40:14 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 14 Apr 2016 16:40:14 +0200 Subject: RFR: 8153334: Replace BufferedInputStreams use of AtomicReferenceFieldUpdater with Unsafe In-Reply-To: <570FA843.70204@gmail.com> References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> <796EA2FB-95D5-4406-AF1C-2603B1915E62@oracle.com> <570FA843.70204@gmail.com> Message-ID: <99D56D3E-5386-4A16-A646-3AAAE9A4C629@oracle.com> Hi Peter, You found that annoying restriction :-) at this point i think this is mostly redundant. This is something i planned to update and limit the restriction to code within j.l.invoke and sun.invoke packages. I'll follow up with a patch soon to unblock, but feel free to beat me to it if you wish. Paul. > On 14 Apr 2016, at 16:25, Peter Levart wrote: > > Hi Paul, > > I wanted to try using VarHandles for code internal to JDK but there's a problem with MethodHandles.lookup(). It doesn't allow the caller class loaded by the bootstrap class loader and located in either java.* or sun.* (but not sun.invoke.*) packages: > > > private static void checkUnprivilegedlookupClass(Class lookupClass, int allowedModes) { > String name = lookupClass.getName(); > if (name.startsWith("java.lang.invoke.")) > throw newIllegalArgumentException("illegal lookupClass: "+lookupClass); > > // For caller-sensitive MethodHandles.lookup() > // disallow lookup more restricted packages > if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) { > if (name.startsWith("java.") || > (name.startsWith("sun.") && !name.startsWith("sun.invoke."))) { > throw newIllegalArgumentException("illegal lookupClass: " + lookupClass); > } > } > } > > > ...strangely, other bootstrap class loaded callers located in jdk.* are allowed. Why such distinction? Is there or will there be an official way to use VarHandles in JDK code and not having to resort to work-arounds like MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP").setAccessible(true)? > > > Regards, Peter > From Alan.Bateman at oracle.com Thu Apr 14 14:54:04 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 14 Apr 2016 15:54:04 +0100 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: <570FAF0C.6080903@oracle.com> On 14/04/2016 02:50, Stuart Marks wrote: > Hi all, > > Please review this first round of deprecation changes for the > java.lang package. This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to > forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > This looks good. There are a few more in SecurityManager where forRemoval=true might be appropriate but it would take effort to dig into all that. The methods where you've added it make sense, these are exactly the SecurityManager methods that have been degraded over several releases. -Alan From yasuenag at gmail.com Thu Apr 14 15:11:36 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Fri, 15 Apr 2016 00:11:36 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570FA803.1010105@Oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> Message-ID: <570FB328.5020902@gmail.com> Roger, Thanks for your comment! David, >>> I'll wait to see what Kumar thinks about this. I don't like exposing a new JVM function this way. I tried to call Thread#setName() after initializing VM (before calling main method), I could set native thread name. However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set native thread name for DestroyJavaVM. Thanks, Yasumasa On 2016/04/14 23:24, Roger Riggs wrote: > Hi, > > Comments: > > jvm.h: The function names are too similar but perform different functions: > > -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName > > - The first function applies to the current thread, the second one a specific java thread. > It would seem useful for there to be a comment somewhere about what the new function does. > > windows/native/libjli/java_md.c: line 408 casts to (void*) instead of (SetNativeThreadName0_t) > as is done on unix and mac. > > - macosx/native/libjli/java_md_macosx.c: > - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at line 730 > - 738 Incorrect indentation; if possible keep the cast on the same line as dlsym... > > $.02, Roger > > > On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>> That is an interesting question which I haven't had time to check - sorry. If the main thread is considered a JNI-attached thread then my suggestion wont work. If it isn't then my suggestion should work (but it means we have an inconsistency in our treatment of JNI-attached threads :( ) >> >> I ran following program on JDK 9 EA b112, and I confirmed native thread name (test) was set. >> --------- >> public class Sleep{ >> public static void main(String[] args) throws Exception{ >> Thread.currentThread().setName("test"); >> Thread.sleep(3600000); >> } >> } >> --------- >> >> >>> I'll wait to see what Kumar thinks about this. I don't like exposing a new JVM function this way. >> >> I will update webrev after hearing Kumar's comment. >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/14 21:32, David Holmes wrote: >>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>> Hi, >>>> >>>> On 2016/04/14 9:34, David Holmes wrote: >>>>> Hi, >>>>> >>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>> Thanks for your comment. >>>>>> >>>>>> I exported new JVM function to set native thread name, and JLI uses it >>>>>> in new webrev. >>>>> >>>>> First the launcher belongs to another team so core-libs will need to >>>>> review and approve this (in particular Kumar) - now cc'd. >>>> >>>> Thanks! >>>> I'm waiting to review :-) >>>> >>>> >>>>> Personally I would have used a Java upcall to Thread.setName rather >>>>> than exporting JVM_SetNativeThreadName. No hotspot changes needed in >>>>> that case. >>>> >>>> As I wrote [1] in JBS, I changed to use Thread#setName() in Thread#init(), >>>> but I could not change native thread name. >>> >>> At Thread.init time the thread is not alive, which is why the native name is not set. >>> >>>> I guess that caller of main() is JNI attached thread. >>> >>> That is an interesting question which I haven't had time to check - sorry. If the main thread is considered a JNI-attached thread then my suggestion wont work. If it isn't then my suggestion should work (but it means we have an inconsistency in our treatment of JNI-attached threads :( ) >>> >>> I'll wait to see what Kumar thinks about this. I don't like exposing a new JVM function this way. >>> >>> Thanks, >>> David >>> ----- >>> >>>> Thus I think that we have to provide a function to set native thread name. >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> [1] >>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>> >>>> >>>>> Thanks, >>>>> David >>>>> >>>>>> Could you review again? >>>>>> >>>>>> - hotspot: >>>>>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>> >>>>>> - jdk: >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>> I'll answer on this original thread as well ... >>>>>>> >>>>>>> Hi Yasumasa, >>>>>>> >>>>>>> Please see my updates to the bug (sorry have been on vacation). This >>>>>>> needs to be done in the launcher to be correct as we do not set the >>>>>>> name of threads that attach via JNI, which includes the "main" thread. >>>>>>> >>>>>>> David >>>>>>> >>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>> Thanks Robbin, >>>>>>>> >>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>> >>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>> >>>>>>>>> /Robbin >>>>>>>>> >>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>> >>>>>>>>>> Thanks, looks good. >>>>>>>>>> >>>>>>>>>> /Robbin >>>>>>>>>> >>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>> >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>> Could you review it? >>>>>>>>>>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>> >>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>> >: >>>>>>>>>>>>> > >>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>> >>>>>>>>>>>>> >> >>>>>>>>>>>> >>: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>> +0000 >>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>> +0100 >>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>> >> > >>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>> >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Native thread name is the same to thread name in Thread >>>>>>>>>>>>> class. >>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>>>>>> will be >>>>>>>>>>>>> set at >>>>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>>>> >> Thread name for "main" is set in create_initial_thread(). >>>>>>>>>>>>> >> I think that the place of setting thrrad name should be the >>>>>>>>>>>>> same. >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>> > >>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 09:43:05 >>>>>>>>>>>>> 2016 >>>>>>>>>>>>> +0200 >>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 10:51:12 >>>>>>>>>>>>> 2016 >>>>>>>>>>>>> +0200 >>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>> thread, >>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>> true, >>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>> > - >>>>>>>>>>>>> > - Handle string = java_lang_String::create_from_str("main", >>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>> > + >>>>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>> > + >>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>> > >>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>> >>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks! >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming this >>>>>>>>>>>>> thread >>>>>>>>>>>>> just >>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>> process) is >>>>>>>>>>>>> 'java' but >>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> The native main thread in the process is not JavaThread. >>>>>>>>>>>>> It is >>>>>>>>>>>>> waiting >>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I think that >>>>>>>>>>>>> we do >>>>>>>>>>>>> not >>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want java and >>>>>>>>>>>>> native >>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>> dependents. >>>>>>>>>>>>> > >>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>> > >>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>> > >>>>>>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>>>>>> >>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>> >>>>>>>>>>>>> If you want to change native main thread name, I think that we >>>>>>>>>>>>> have to >>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> No >>>>>>>>>>>> >>>>>>>>>>>> Thanks again! >>>>>>>>>>>> >>>>>>>>>>>> /Robbin >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> > Thanks >>>>>>>>>>>>> > >>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>> >> > >>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>> >> > > For consistency, main thread should have native thread >>>>>>>>>>>>> name. >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >> >>>>>>>>>>>>> >>>>>>>>>>>>> > From paul.sandoz at oracle.com Thu Apr 14 15:30:25 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 14 Apr 2016 17:30:25 +0200 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: Hi, Looks good. Minor comments. CachedRowSetImpl ? 1966 return ((Float.valueOf(value.toString())).floatValue()); Use Float.parseFloat ? 2010 return ((Double.valueOf(value.toString().trim())).doubleValue()); Use Double.parseDouble ? ExpressionExecuter ? 86 Double lval = Double.valueOf(((Number)evaluate(l)).doubleValue()); 87 Double rval = Double.valueOf(((Number)evaluate(r)).doubleValue()); 88 double result = op.eval(lval.doubleValue(), rval.doubleValue()); 89 if (debug) { 90 System.out.println("Performed Operation: " + lval + op + rval 91 + " = " + result); 92 } 93 return Double.valueOf(result); How about: double lval = ((Number)evaluate(l)).doubleValue(); double rval = ((Number)evaluate(r)).doubleValue(); double result = op.eval(lval, rval); ? Paul. > On 14 Apr 2016, at 03:50, Stuart Marks wrote: > > Hi all, > > Please review this first round of deprecation changes for the java.lang package. This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > The newly deprecated APIs include all of the constructors for the boxed primitives. We don't intend to remove these yet, so they don't declare a value for the forRemoval element, implying the default value of false. The constructors being deprecated are as follows: > > Boolean(boolean) > Boolean(String) > Byte(byte) > Byte(String) > Character(char) > Double(double) > Double(String) > Float(float) > Float(double) > Float(String) > Integer(int) > Integer(String) > Long(long) > Long(String) > Short(short) > Short(String) > > The methods being deprecated with forRemoval=true are listed below. All of these methods have already been deprecated. They are all ill-defined, or they don't work, or they don't do anything useful. > > Runtime.getLocalizedInputStream(InputStream) > Runtime.getLocalizedOutputStream(OutputStream) > Runtime.runFinalizersOnExit(boolean) > SecurityManager.checkAwtEventQueueAccess() > SecurityManager.checkMemberAccess(Class, int) > SecurityManager.checkSystemClipboardAccess() > SecurityManager.checkTopLevelWindow(Object) > System.runFinalizersOnExit(boolean) > Thread.countStackFrames() > Thread.destroy() > Thread.stop(Throwable) > > Most of the files in the changeset are cleanups. Some of them are simply the addition of the "since" element to the @Deprecated annotation, to indicate the version in which the API became deprecated. > > The rest of the changes are cleanup of warnings that were created by the deprecation of the boxed primitive constructors. There are a total of a couple hundred such uses sprinkled around the JDK. I've taken care of a portion of them, with the exception of the java.desktop module, which alone has over 100 uses of boxed primitive constructors. I've disabled deprecation warnings for the java.desktop module for the time being; these uses can be cleaned up later. I've filed JDK-8154213 to cover this cleanup task. > > For the warnings cleanups I did, I mostly did conversions of the form: > > new Double(dval) > > to > > Double.valueOf(dval) > > This is a very safe transformation. It changes the behavior only in the cases where the code relies on getting a new instance of the box object instead of one that might come out of a cache. I didn't see any such code (and I should hope there's no such code in the JDK!). > > I applied autoboxing only sparingly, in the cases where it was an obviously safe thing to do, or where nearby code already uses autoboxing. Autoboxing actually generates a call to the appropriate valueOf() method, so the bytecode would be the same in most cases. The only difference is clutter in the source code. On the other hand, there's some risk in converting to autoboxing, as the implicitly autoboxed type might end up different from an explicit call to valueOf(). This isn't always obvious, so that's why I mostly avoided autoboxing. > > Thanks, > > s'marks > From chris.hegarty at oracle.com Thu Apr 14 15:38:03 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 14 Apr 2016 16:38:03 +0100 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> <570E81A0.5050904@oracle.com> <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> Message-ID: <8492DC62-0397-44E7-A987-24364140EC5C@oracle.com> Mandy, The webrev has been updated in-place http://cr.openjdk.java.net/~chegar/8137058/ http://cr.openjdk.java.net/~chegar/8137058/jdk_incremental.diffs All 'core', 'pit', and 'hotspot' testsets have been successfully run on Mac, Linux, Windows, and Solaris. On 13 Apr 2016, at 18:43, Mandy Chung wrote: >>> This patch will likely impact existing libraries that filter out reflection frames (IIRC Groovy and log4j may be examples) doing Class::getName().startsWith(?sun.reflect?). It may worth call out this incompatibility in JEP 260. I added the following note to the Risks and Assumptions section of JEP 260: Beyond the proposed critical APIs for `sun.reflect`, said package contains the machinery that implements the `java.lang(.reflect)` subsystem. That machinery will be moved to an internal, non-exported, package in the base module. Consequently, the stack trace of reflective calls will appear somewhat different. That is, stack frames that represent the reflective implementation will see their class name ( `StackTraceElement.getClassName()` ) change from `sun.reflect.XXX` to `jdk.internal.reflect.XXX`. Any code analysing, or filtering, based on the stack trace element's class name should be updated appropriately, to handle this. See [8137058](https://bugs.openjdk.java.net/browse/JDK-8137058) for further details. -Chris. From martinrb at google.com Thu Apr 14 17:10:19 2016 From: martinrb at google.com (Martin Buchholz) Date: Thu, 14 Apr 2016 10:10:19 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: I've been tempted by the dark side, when a class needs a value AND a lock (or an "identity"). Instead of doing final String val = "foo"; final Object lock = new Object(); one can "optimize" this ("why can't we have both?") to final String valAndLock = new String("foo"); and there are surely folks out there doing this. We should probably never remove those constructors. From brian.goetz at oracle.com Thu Apr 14 17:13:42 2016 From: brian.goetz at oracle.com (Brian Goetz) Date: Thu, 14 Apr 2016 13:13:42 -0400 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> References: <570EF756.2090602@oracle.com> <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> Message-ID: Or, better, don?t do that in ASM, and instead use .equals()? > On Apr 14, 2016, at 9:21 AM, Remi Forax wrote: > > Hi Stuart, > you are not the first one to try to change the integers defined in org.objectweb.asm.Opcodes, those values are compared by ref (not by value) inside ASM. > You're patch will change the behavior of any Interpreters that also use some Integers created by Integer.valueOf() because valueOf may cache the Integer references. > > I will add a comment in the ASM trunk for avoid such refactoring in the future. > > reagrds, > R?mi > > > ----- Mail original ----- >> De: "Stuart Marks" >> ?: "core-libs-dev" >> Envoy?: Jeudi 14 Avril 2016 03:50:14 >> Objet: RFR(m): 8145468 deprecations for java.lang >> >> Hi all, >> >> Please review this first round of deprecation changes for the java.lang >> package. >> This changeset includes the following: >> >> - a set of APIs being newly deprecated >> - a set of already-deprecated APIs that are "upgraded" to forRemoval=true >> - addition of the "since" element to all deprecations >> - cleanup of some of the warnings caused by new deprecations >> >> Webrevs: >> >> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ >> >> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ >> >> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ >> >> The newly deprecated APIs include all of the constructors for the boxed >> primitives. We don't intend to remove these yet, so they don't declare a >> value >> for the forRemoval element, implying the default value of false. The >> constructors being deprecated are as follows: >> >> Boolean(boolean) >> Boolean(String) >> Byte(byte) >> Byte(String) >> Character(char) >> Double(double) >> Double(String) >> Float(float) >> Float(double) >> Float(String) >> Integer(int) >> Integer(String) >> Long(long) >> Long(String) >> Short(short) >> Short(String) >> >> The methods being deprecated with forRemoval=true are listed below. All of >> these >> methods have already been deprecated. They are all ill-defined, or they don't >> work, or they don't do anything useful. >> >> Runtime.getLocalizedInputStream(InputStream) >> Runtime.getLocalizedOutputStream(OutputStream) >> Runtime.runFinalizersOnExit(boolean) >> SecurityManager.checkAwtEventQueueAccess() >> SecurityManager.checkMemberAccess(Class, int) >> SecurityManager.checkSystemClipboardAccess() >> SecurityManager.checkTopLevelWindow(Object) >> System.runFinalizersOnExit(boolean) >> Thread.countStackFrames() >> Thread.destroy() >> Thread.stop(Throwable) >> >> Most of the files in the changeset are cleanups. Some of them are simply the >> addition of the "since" element to the @Deprecated annotation, to indicate >> the >> version in which the API became deprecated. >> >> The rest of the changes are cleanup of warnings that were created by the >> deprecation of the boxed primitive constructors. There are a total of a >> couple >> hundred such uses sprinkled around the JDK. I've taken care of a portion of >> them, with the exception of the java.desktop module, which alone has over 100 >> uses of boxed primitive constructors. I've disabled deprecation warnings for >> the >> java.desktop module for the time being; these uses can be cleaned up later. >> I've >> filed JDK-8154213 to cover this cleanup task. >> >> For the warnings cleanups I did, I mostly did conversions of the form: >> >> new Double(dval) >> >> to >> >> Double.valueOf(dval) >> >> This is a very safe transformation. It changes the behavior only in the cases >> where the code relies on getting a new instance of the box object instead of >> one >> that might come out of a cache. I didn't see any such code (and I should hope >> there's no such code in the JDK!). >> >> I applied autoboxing only sparingly, in the cases where it was an obviously >> safe >> thing to do, or where nearby code already uses autoboxing. Autoboxing >> actually >> generates a call to the appropriate valueOf() method, so the bytecode would >> be >> the same in most cases. The only difference is clutter in the source code. On >> the other hand, there's some risk in converting to autoboxing, as the >> implicitly >> autoboxed type might end up different from an explicit call to valueOf(). >> This >> isn't always obvious, so that's why I mostly avoided autoboxing. >> >> Thanks, >> >> s'marks >> >> From xueming.shen at oracle.com Thu Apr 14 17:47:36 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Thu, 14 Apr 2016 10:47:36 -0700 Subject: Fwd: RFR: JDK-8147460: Clean-up jrtfs implementation Message-ID: <570FD7B8.1090904@oracle.com> [re-post, including jigsaw list] Hi, Please hep review the cleanup changes for jrtfs implementation. issue: https://bugs.openjdk.java.net/browse/JDK-8147460 webrev: http://cr.openjdk.java.net/~sherman/8147460/webrev Simple benchmark [1] has been run both on jimage and the "exploded modules" directory, the numbers suggest we also get an encouraging performance boost on most of the frequently invoked access methods. [1] http://cr.openjdk.java.net/~sherman/8147460/MyBenchmark.java Benchmark Mode Cnt Score Error Units ------------------------------------------------------------ [jimage/existing] MyBenchmark.testExists avgt 50 18.592 ? 1.213 ms/op MyBenchmark.testIsDirectory avgt 50 17.382 ? 1.178 ms/op MyBenchmark.testIsRegularFile avgt 50 18.576 ? 1.577 ms/op MyBenchmark.testItr avgt 50 58.414 ? 1.638 ms/op MyBenchmark.testLookupPath avgt 50 18.935 ? 1.093 ms/op MyBenchmark.testLookupStr avgt 50 38.597 ? 1.663 ms/op MyBenchmark.testToRealPath avgt 50 30.119 ? 1.196 ms/op [jimage/new] MyBenchmark.testExists avgt 50 10.865 ? 1.125 ms/op MyBenchmark.testIsDirectory avgt 50 11.077 ? 1.101 ms/op MyBenchmark.testIsRegularFile avgt 50 10.967 ? 1.220 ms/op MyBenchmark.testItr avgt 50 49.249 ? 3.753 ms/op MyBenchmark.testLookupPath avgt 50 10.857 ? 1.071 ms/op MyBenchmark.testLookupStr avgt 50 34.367 ? 1.341 ms/op MyBenchmark.testToRealPath avgt 50 11.460 ? 1.081 ms/op ------------------------------------------------------------ [exploded dir/existing] MyBenchmark.testExists avgt 50 23.055 ? 1.707 ms/op MyBenchmark.testIsDirectory avgt 50 23.985 ? 1.593 ms/op MyBenchmark.testIsRegularFile avgt 50 24.200 ? 1.744 ms/op MyBenchmark.testItr avgt 50 210.002 ? 6.954 ms/op MyBenchmark.testLookupPath avgt 50 23.242 ? 1.799 ms/op MyBenchmark.testLookupStr avgt 50 43.026 ? 1.751 ms/op MyBenchmark.testToRealPath avgt 50 56.536 ? 1.679 ms/op [exploded dir/new] MyBenchmark.testExists avgt 50 11.260 ? 1.209 ms/op MyBenchmark.testIsDirectory avgt 50 11.702 ? 1.069 ms/op MyBenchmark.testIsRegularFile avgt 50 12.284 ? 1.333 ms/op MyBenchmark.testItr avgt 50 49.342 ? 1.516 ms/op MyBenchmark.testLookupPath avgt 50 11.041 ? 1.051 ms/op MyBenchmark.testLookupStr avgt 50 35.850 ? 1.618 ms/op MyBenchmark.testToRealPath avgt 50 13.016 ? 1.339 ms/op Thanks, Sherman From james.laskey at oracle.com Thu Apr 14 17:55:17 2016 From: james.laskey at oracle.com (Jim Laskey (Oracle)) Date: Thu, 14 Apr 2016 14:55:17 -0300 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570FD7B8.1090904@oracle.com> References: <570FD7B8.1090904@oracle.com> Message-ID: +1 > On Apr 14, 2016, at 2:47 PM, Xueming Shen wrote: > > > [re-post, including jigsaw list] > > Hi, > > Please hep review the cleanup changes for jrtfs implementation. > > issue: https://bugs.openjdk.java.net/browse/JDK-8147460 > webrev: http://cr.openjdk.java.net/~sherman/8147460/webrev > > Simple benchmark [1] has been run both on jimage and the "exploded modules" > directory, the numbers suggest we also get an encouraging performance boost > on most of the frequently invoked access methods. > > [1] http://cr.openjdk.java.net/~sherman/8147460/MyBenchmark.java > > Benchmark Mode Cnt Score Error Units > ------------------------------------------------------------ > [jimage/existing] > MyBenchmark.testExists avgt 50 18.592 ? 1.213 ms/op > MyBenchmark.testIsDirectory avgt 50 17.382 ? 1.178 ms/op > MyBenchmark.testIsRegularFile avgt 50 18.576 ? 1.577 ms/op > MyBenchmark.testItr avgt 50 58.414 ? 1.638 ms/op > MyBenchmark.testLookupPath avgt 50 18.935 ? 1.093 ms/op > MyBenchmark.testLookupStr avgt 50 38.597 ? 1.663 ms/op > MyBenchmark.testToRealPath avgt 50 30.119 ? 1.196 ms/op > > [jimage/new] > MyBenchmark.testExists avgt 50 10.865 ? 1.125 ms/op > MyBenchmark.testIsDirectory avgt 50 11.077 ? 1.101 ms/op > MyBenchmark.testIsRegularFile avgt 50 10.967 ? 1.220 ms/op > MyBenchmark.testItr avgt 50 49.249 ? 3.753 ms/op > MyBenchmark.testLookupPath avgt 50 10.857 ? 1.071 ms/op > MyBenchmark.testLookupStr avgt 50 34.367 ? 1.341 ms/op > MyBenchmark.testToRealPath avgt 50 11.460 ? 1.081 ms/op > > ------------------------------------------------------------ > [exploded dir/existing] > MyBenchmark.testExists avgt 50 23.055 ? 1.707 ms/op > MyBenchmark.testIsDirectory avgt 50 23.985 ? 1.593 ms/op > MyBenchmark.testIsRegularFile avgt 50 24.200 ? 1.744 ms/op > MyBenchmark.testItr avgt 50 210.002 ? 6.954 ms/op > MyBenchmark.testLookupPath avgt 50 23.242 ? 1.799 ms/op > MyBenchmark.testLookupStr avgt 50 43.026 ? 1.751 ms/op > MyBenchmark.testToRealPath avgt 50 56.536 ? 1.679 ms/op > > [exploded dir/new] > MyBenchmark.testExists avgt 50 11.260 ? 1.209 ms/op > MyBenchmark.testIsDirectory avgt 50 11.702 ? 1.069 ms/op > MyBenchmark.testIsRegularFile avgt 50 12.284 ? 1.333 ms/op > MyBenchmark.testItr avgt 50 49.342 ? 1.516 ms/op > MyBenchmark.testLookupPath avgt 50 11.041 ? 1.051 ms/op > MyBenchmark.testLookupStr avgt 50 35.850 ? 1.618 ms/op > MyBenchmark.testToRealPath avgt 50 13.016 ? 1.339 ms/op > > Thanks, > Sherman > > From mandy.chung at oracle.com Thu Apr 14 17:55:54 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 14 Apr 2016 12:55:54 -0500 Subject: RFR [9] 8137058: Clear out all non-Critical APIs from sun.reflect and move to jdk.unsupported In-Reply-To: <8492DC62-0397-44E7-A987-24364140EC5C@oracle.com> References: <570E690B.2060703@oracle.com> <5C58C15B-48AA-4AA1-8C10-45268968B1BB@oracle.com> <570E81A0.5050904@oracle.com> <0980D0EB-BAF1-4C76-9A82-D3F6BCCFA423@oracle.com> <8492DC62-0397-44E7-A987-24364140EC5C@oracle.com> Message-ID: > On Apr 14, 2016, at 10:38 AM, Chris Hegarty wrote: > > Mandy, > > The webrev has been updated in-place > http://cr.openjdk.java.net/~chegar/8137058/ > http://cr.openjdk.java.net/~chegar/8137058/jdk_incremental.diffs > Looks good. Thanks for making the change. > All 'core', 'pit', and 'hotspot' testsets have been successfully run on > Mac, Linux, Windows, and Solaris. > > On 13 Apr 2016, at 18:43, Mandy Chung wrote: > >>>> This patch will likely impact existing libraries that filter out reflection frames (IIRC Groovy and log4j may be examples) doing Class::getName().startsWith(?sun.reflect?). It may worth call out this incompatibility in JEP 260. > > I added the following note to the Risks and Assumptions section of JEP 260: > > Beyond the proposed critical APIs for `sun.reflect`, said package contains > the machinery that implements the `java.lang(.reflect)` subsystem. That > machinery will be moved to an internal, non-exported, package in the base > module. Consequently, the stack trace of reflective calls will appear > somewhat different. That is, stack frames that represent the reflective > implementation will see their class name ( `StackTraceElement.getClassName()` ) > change from `sun.reflect.XXX` to `jdk.internal.reflect.XXX`. Any code > analysing, or filtering, based on the stack trace element's class name > should be updated appropriately, to handle this. See > [8137058](https://bugs.openjdk.java.net/browse/JDK-8137058) for further > details. Thanks for this. Mandy From kumar.x.srinivasan at oracle.com Thu Apr 14 18:09:46 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Thu, 14 Apr 2016 11:09:46 -0700 Subject: RFR: 8154212: launcher SEGV when _JAVA_LAUNCHER_DEBUG is set Message-ID: <570FDCEA.6070101@oracle.com> Hi Alan, Adds the missing name in the launchModeNames array purely for display/debugging purposes. Please review: http://cr.openjdk.java.net/~ksrini/8154212/webrev.00/ Bug: https://bugs.openjdk.java.net/browse/JDK-8154212 Thanks Kumar PS: running jprt tests in parallel. From Alan.Bateman at oracle.com Thu Apr 14 18:17:55 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 14 Apr 2016 19:17:55 +0100 Subject: RFR: 8154212: launcher SEGV when _JAVA_LAUNCHER_DEBUG is set In-Reply-To: <570FDCEA.6070101@oracle.com> References: <570FDCEA.6070101@oracle.com> Message-ID: <570FDED3.7070106@oracle.com> On 14/04/2016 19:09, Kumar Srinivasan wrote: > Hi Alan, > > Adds the missing name in the launchModeNames array > purely for display/debugging purposes. > > Please review: > http://cr.openjdk.java.net/~ksrini/8154212/webrev.00/ > Sorry, I missed that when we changed the launcher. The patch and adding test coverage looks good. -Alan From Roger.Riggs at Oracle.com Thu Apr 14 18:18:28 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Thu, 14 Apr 2016 14:18:28 -0400 Subject: (Round 2) RFR(s): 8150460: (linux|bsd|aix)_close.c: file descriptor table may become large or may not work at all In-Reply-To: References: <56E12E1E.7080307@oracle.com> <56E2E391.4060105@Oracle.com> <570E18A4.5070906@oracle.com> Message-ID: <570FDEF4.5070809@Oracle.com> +1, looks fine to me also. Roger On 4/13/2016 6:46 AM, Thomas St?fe wrote: > Thanks Dmitry! > > On Wed, Apr 13, 2016 at 12:00 PM, Dmitry Samersoff > > wrote: > > Thomas, > > Looks good for me! > > -Dmitry > > > On 2016-04-13 12:12, Thomas St?fe wrote: > > Hi Roger, Dmitry, > > > > May I ask you both to have a last look at this change before I > commit? > > It took a while for this to go through our internal tests, hence > the delay. > > > > New > > version: > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.03/webrev/ > > > Delta to last > > version: > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02-webrev.03/webrev/ > > > > > The changes are mostly cosmetic: > > > > - I tweaked a number of comments to make them clearer > > - If getrlimit(RLIMIT_NOFILE) returns an error, I now handle > this correctly. > > - Just for readability, I explicitly initialize global variables > instead > > of relying on static zero-initialization. > > - As Roger requested, I changed accesses to the entry table elements > > from using implicit pointer arithmetic to explicit array > accesses with "&". > > > > Thank you for your time! > > > > Kind Regards, Thomas > > > > On Sat, Mar 12, 2016 at 8:38 AM, Thomas St?fe > > > >> wrote: > > > > Thank you Roger! > > > > On Fri, Mar 11, 2016 at 4:26 PM, Roger Riggs > > > >> wrote: > > > > Hi Thomas, > > > > When returning the address of the fdentry, the style using > > &fdTable[fd] is preferred over > > the implicit pointer arithmetic (as it was in the > previous version). > > > > Occurs in all 3 deltas: > > > > src/java.base/*/native/libnet/*_close.c: > > + result = fdTable + fd; > > > > and > > + result = fdOverflowTable[rootindex] + slabindex; > > > > The rest looks fine. > > > > Thanks, Roger > > > > > > > > > > On 3/10/2016 7:59 AM, Thomas St?fe wrote: > > > > Thank you Dmitry! > > > > I will fix the typo before comitting. > > > > Kind Regards, Thomas > > > > On Thu, Mar 10, 2016 at 9:19 AM, Dmitry Samersoff < > > dmitry.samersoff at oracle.com > > >> > wrote: > > > > Thomas, > > > > Looks good for me. But please wait for someone from > > core-libs team. > > > > PS: Could you also fix a typeo at 79, 51, 53? > > > > s/initialized/initialization/ > > > > 51 * Heap allocated during initialization - > one entry > > per fd > > > > -Dmitry > > > > On 2016-03-10 10:59, Thomas St?fe wrote: > > > > Hi, > > > > may I have a review of this new iteration > for this fix? > > > > Thank you! > > > > Thomas > > > > On Thu, Mar 3, 2016 at 5:26 PM, Thomas St?fe > > > > >> > > wrote: > > > > Hi all, > > > > https://bugs.openjdk.java.net/browse/JDK-8150460 > > > > thanks to all who took the time to > review the > > first version of this fix! > > > > This is the new version: > > > > > > > > > http://cr.openjdk.java.net/~stuefe/webrevs/8150460-linux_close-fdTable/webrev.02/webrev/ > > > > > I reworked the fix, trying to add in all the > > input I got: This fix uses > > > > a > > > > simple one-dimensional array, > preallocated at > > startup, for low-value > > > > file > > > > descriptors. Like the code did before. > Only for > > large values of file > > descriptors it switches to an overflow > table, > > organized as two > > > > dimensional > > > > sparse array of fixed sized slabs, which are > > allocated on demand. Only > > > > the > > > > overflow table is protected by a lock. > > > > For 99% of all cases we will be using > the plain > > simple fdTable structure > > as before. Only for unusually large file > > descriptor values we will be > > > > using > > > > this overflow table. > > > > Memory footprint is kept low: for small > values > > of RLIMIT_NOFILE, we will > > only allocate as much space as we need. > Only if > > file descriptor values > > > > get > > > > large, memory is allocated in the > overflow table. > > > > Note that I avoided the proposed > double-checked > > locking solution: I find > > it too risky in this place and also > unnecessary. > > When calling > > > > getFdEntry(), > > > > we will be executing a blocking IO operation > > afterwards, flanked by two > > mutex locks (in startOp and endOp). So, > I do not > > think the third mutex > > > > lock > > > > in getFdEntry will add much, especially > since it > > is only used in case of > > larger file descriptor values. > > > > I also added the fix to bsd_close.c and > > aix_close.c. I do not like this > > code triplication. I briefly played > around with > > unifying this code, but > > this is more difficult than it seems: > > implementations subtly differ > > > > between > > > > the three platforms, and solaris > implementation > > is completely > > > > different. It > > > > may be a worthwhile cleanup, but that > would be a > > separate issue. > > > > I did some artificial tests to check how the > > code does with many and > > > > large > > > > file descriptor values, all seemed to > work well. > > I also ran java/net > > > > jtreg > > > > tests on Linux and AIX. > > > > Kind Regards, Thomas > > > > > > > > -- > > Dmitry Samersoff > > Oracle Java development team, Saint Petersburg, > Russia > > * I would love to change the world, but they > won't give > > me the sources. > > > > > > > > > > > -- > Dmitry Samersoff > Oracle Java development team, Saint Petersburg, Russia > * I would love to change the world, but they won't give me the > sources. > > From forax at univ-mlv.fr Thu Apr 14 18:17:29 2016 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Thu, 14 Apr 2016 18:17:29 +0000 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: References: <570EF756.2090602@oracle.com> <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> Message-ID: <1D345E5F-7D97-4024-A226-5EA39BF06724@univ-mlv.fr> The Analyzer/Interpreter API is public so using equals instead of == will likely summon some strange bugs. It will also have an impact in term of performance because currently there is no virtual call in the part of the algo that does the analysis. cheers, R?mi Le 14 avril 2016 19:13:42 CEST, Brian Goetz a ?crit : >Or, better, don?t do that in ASM, and instead use .equals()? > >> On Apr 14, 2016, at 9:21 AM, Remi Forax wrote: >> >> Hi Stuart, >> you are not the first one to try to change the integers defined in >org.objectweb.asm.Opcodes, those values are compared by ref (not by >value) inside ASM. >> You're patch will change the behavior of any Interpreters that also >use some Integers created by Integer.valueOf() because valueOf may >cache the Integer references. >> >> I will add a comment in the ASM trunk for avoid such refactoring in >the future. >> >> reagrds, >> R?mi >> >> >> ----- Mail original ----- >>> De: "Stuart Marks" >>> ?: "core-libs-dev" >>> Envoy?: Jeudi 14 Avril 2016 03:50:14 >>> Objet: RFR(m): 8145468 deprecations for java.lang >>> >>> Hi all, >>> >>> Please review this first round of deprecation changes for the >java.lang >>> package. >>> This changeset includes the following: >>> >>> - a set of APIs being newly deprecated >>> - a set of already-deprecated APIs that are "upgraded" to >forRemoval=true >>> - addition of the "since" element to all deprecations >>> - cleanup of some of the warnings caused by new deprecations >>> >>> Webrevs: >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ >>> >>> >http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ >>> >>> The newly deprecated APIs include all of the constructors for the >boxed >>> primitives. We don't intend to remove these yet, so they don't >declare a >>> value >>> for the forRemoval element, implying the default value of false. The >>> constructors being deprecated are as follows: >>> >>> Boolean(boolean) >>> Boolean(String) >>> Byte(byte) >>> Byte(String) >>> Character(char) >>> Double(double) >>> Double(String) >>> Float(float) >>> Float(double) >>> Float(String) >>> Integer(int) >>> Integer(String) >>> Long(long) >>> Long(String) >>> Short(short) >>> Short(String) >>> >>> The methods being deprecated with forRemoval=true are listed below. >All of >>> these >>> methods have already been deprecated. They are all ill-defined, or >they don't >>> work, or they don't do anything useful. >>> >>> Runtime.getLocalizedInputStream(InputStream) >>> Runtime.getLocalizedOutputStream(OutputStream) >>> Runtime.runFinalizersOnExit(boolean) >>> SecurityManager.checkAwtEventQueueAccess() >>> SecurityManager.checkMemberAccess(Class, int) >>> SecurityManager.checkSystemClipboardAccess() >>> SecurityManager.checkTopLevelWindow(Object) >>> System.runFinalizersOnExit(boolean) >>> Thread.countStackFrames() >>> Thread.destroy() >>> Thread.stop(Throwable) >>> >>> Most of the files in the changeset are cleanups. Some of them are >simply the >>> addition of the "since" element to the @Deprecated annotation, to >indicate >>> the >>> version in which the API became deprecated. >>> >>> The rest of the changes are cleanup of warnings that were created by >the >>> deprecation of the boxed primitive constructors. There are a total >of a >>> couple >>> hundred such uses sprinkled around the JDK. I've taken care of a >portion of >>> them, with the exception of the java.desktop module, which alone has >over 100 >>> uses of boxed primitive constructors. I've disabled deprecation >warnings for >>> the >>> java.desktop module for the time being; these uses can be cleaned up >later. >>> I've >>> filed JDK-8154213 to cover this cleanup task. >>> >>> For the warnings cleanups I did, I mostly did conversions of the >form: >>> >>> new Double(dval) >>> >>> to >>> >>> Double.valueOf(dval) >>> >>> This is a very safe transformation. It changes the behavior only in >the cases >>> where the code relies on getting a new instance of the box object >instead of >>> one >>> that might come out of a cache. I didn't see any such code (and I >should hope >>> there's no such code in the JDK!). >>> >>> I applied autoboxing only sparingly, in the cases where it was an >obviously >>> safe >>> thing to do, or where nearby code already uses autoboxing. >Autoboxing >>> actually >>> generates a call to the appropriate valueOf() method, so the >bytecode would >>> be >>> the same in most cases. The only difference is clutter in the source >code. On >>> the other hand, there's some risk in converting to autoboxing, as >the >>> implicitly >>> autoboxed type might end up different from an explicit call to >valueOf(). >>> This >>> isn't always obvious, so that's why I mostly avoided autoboxing. >>> >>> Thanks, >>> >>> s'marks >>> >>> From Alan.Bateman at oracle.com Thu Apr 14 18:57:41 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 14 Apr 2016 19:57:41 +0100 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570E963C.3050706@oracle.com> References: <570E963C.3050706@oracle.com> Message-ID: <570FE825.8050605@oracle.com> On 13/04/2016 19:55, Xueming Shen wrote: > Hi, > > Please hep review the cleanup changes for jrtfs implementation. > I'm skimmed through the changes and it looks very good. My only concern is that we might have not enough tests for jrtfs to exercise it completely. I just checked the coverage it is indeed quite low. I'll create a bug for this. In passing, in JrtDirectoryStream then the spec allows for read ahead and so the original implementation was okay to return this when closed. What you have is fine, just pointing out that both behaviors are allowed. -Alan From brian.goetz at oracle.com Thu Apr 14 19:06:28 2016 From: brian.goetz at oracle.com (Brian Goetz) Date: Thu, 14 Apr 2016 15:06:28 -0400 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <1D345E5F-7D97-4024-A226-5EA39BF06724@univ-mlv.fr> References: <570EF756.2090602@oracle.com> <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> <1D345E5F-7D97-4024-A226-5EA39BF06724@univ-mlv.fr> Message-ID: <30667471-069E-4175-9357-085AC95DDBB9@oracle.com> Sure, there is some inconvenience. But neither of these reasons seem to rise to the level of "good reasons not to fix it". Depending on the identity of boxes is problematic and will surely get worse in the future. Best to get clean now! Sent from my iPhone > On Apr 14, 2016, at 2:17 PM, R?mi Forax wrote: > > The Analyzer/Interpreter API is public so using equals instead of == will likely summon some strange bugs. > > It will also have an impact in term of performance because currently there is no virtual call in the part of the algo that does the analysis. > > cheers, > R?mi > > Le 14 avril 2016 19:13:42 CEST, Brian Goetz a ?crit : >> Or, better, don?t do that in ASM, and instead use .equals()? >> >>> On Apr 14, 2016, at 9:21 AM, Remi Forax wrote: >>> >>> Hi Stuart, >>> you are not the first one to try to change the integers defined in >> org.objectweb.asm.Opcodes, those values are compared by ref (not by >> value) inside ASM. >>> You're patch will change the behavior of any Interpreters that also >> use some Integers created by Integer.valueOf() because valueOf may >> cache the Integer references. >>> >>> I will add a comment in the ASM trunk for avoid such refactoring in >> the future. >>> >>> reagrds, >>> R?mi >>> >>> >>> ----- Mail original ----- >>>> De: "Stuart Marks" >>>> ?: "core-libs-dev" >>>> Envoy?: Jeudi 14 Avril 2016 03:50:14 >>>> Objet: RFR(m): 8145468 deprecations for java.lang >>>> >>>> Hi all, >>>> >>>> Please review this first round of deprecation changes for the >> java.lang >>>> package. >>>> This changeset includes the following: >>>> >>>> - a set of APIs being newly deprecated >>>> - a set of already-deprecated APIs that are "upgraded" to >> forRemoval=true >>>> - addition of the "since" element to all deprecations >>>> - cleanup of some of the warnings caused by new deprecations >>>> >>>> Webrevs: >>>> >>>> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ >> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ >>>> >>>> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ >>>> >>>> The newly deprecated APIs include all of the constructors for the >> boxed >>>> primitives. We don't intend to remove these yet, so they don't >> declare a >>>> value >>>> for the forRemoval element, implying the default value of false. The >>>> constructors being deprecated are as follows: >>>> >>>> Boolean(boolean) >>>> Boolean(String) >>>> Byte(byte) >>>> Byte(String) >>>> Character(char) >>>> Double(double) >>>> Double(String) >>>> Float(float) >>>> Float(double) >>>> Float(String) >>>> Integer(int) >>>> Integer(String) >>>> Long(long) >>>> Long(String) >>>> Short(short) >>>> Short(String) >>>> >>>> The methods being deprecated with forRemoval=true are listed below. >> All of >>>> these >>>> methods have already been deprecated. They are all ill-defined, or >> they don't >>>> work, or they don't do anything useful. >>>> >>>> Runtime.getLocalizedInputStream(InputStream) >>>> Runtime.getLocalizedOutputStream(OutputStream) >>>> Runtime.runFinalizersOnExit(boolean) >>>> SecurityManager.checkAwtEventQueueAccess() >>>> SecurityManager.checkMemberAccess(Class, int) >>>> SecurityManager.checkSystemClipboardAccess() >>>> SecurityManager.checkTopLevelWindow(Object) >>>> System.runFinalizersOnExit(boolean) >>>> Thread.countStackFrames() >>>> Thread.destroy() >>>> Thread.stop(Throwable) >>>> >>>> Most of the files in the changeset are cleanups. Some of them are >> simply the >>>> addition of the "since" element to the @Deprecated annotation, to >> indicate >>>> the >>>> version in which the API became deprecated. >>>> >>>> The rest of the changes are cleanup of warnings that were created by >> the >>>> deprecation of the boxed primitive constructors. There are a total >> of a >>>> couple >>>> hundred such uses sprinkled around the JDK. I've taken care of a >> portion of >>>> them, with the exception of the java.desktop module, which alone has >> over 100 >>>> uses of boxed primitive constructors. I've disabled deprecation >> warnings for >>>> the >>>> java.desktop module for the time being; these uses can be cleaned up >> later. >>>> I've >>>> filed JDK-8154213 to cover this cleanup task. >>>> >>>> For the warnings cleanups I did, I mostly did conversions of the >> form: >>>> >>>> new Double(dval) >>>> >>>> to >>>> >>>> Double.valueOf(dval) >>>> >>>> This is a very safe transformation. It changes the behavior only in >> the cases >>>> where the code relies on getting a new instance of the box object >> instead of >>>> one >>>> that might come out of a cache. I didn't see any such code (and I >> should hope >>>> there's no such code in the JDK!). >>>> >>>> I applied autoboxing only sparingly, in the cases where it was an >> obviously >>>> safe >>>> thing to do, or where nearby code already uses autoboxing. >> Autoboxing >>>> actually >>>> generates a call to the appropriate valueOf() method, so the >> bytecode would >>>> be >>>> the same in most cases. The only difference is clutter in the source >> code. On >>>> the other hand, there's some risk in converting to autoboxing, as >> the >>>> implicitly >>>> autoboxed type might end up different from an explicit call to >> valueOf(). >>>> This >>>> isn't always obvious, so that's why I mostly avoided autoboxing. >>>> >>>> Thanks, >>>> >>>> s'marks > From xueming.shen at oracle.com Thu Apr 14 19:07:08 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Thu, 14 Apr 2016 12:07:08 -0700 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570FE825.8050605@oracle.com> References: <570E963C.3050706@oracle.com> <570FE825.8050605@oracle.com> Message-ID: <570FEA5C.5040403@oracle.com> On 04/14/2016 11:57 AM, Alan Bateman wrote: > > > On 13/04/2016 19:55, Xueming Shen wrote: >> Hi, >> >> Please hep review the cleanup changes for jrtfs implementation. >> > I'm skimmed through the changes and it looks very good. > > My only concern is that we might have not enough tests for jrtfs to exercise it completely. I just checked the coverage it is indeed quite low. I'll create a bug for this. > > In passing, in JrtDirectoryStream then the spec allows for read ahead and so the original implementation was okay to return this when closed. What you have is fine, just pointing out that both behaviors are allowed. > Thanks Alan, There is a test that passing a null filter into Files.newDirectoryStream(path, filter) and then FileSystemProvider.newDirectoryStream(...), to mean "no filter". My reading of the spec suggests it should get a NPE. (to use the nweDirectoryStream(dir) for accept all). Can you confirm? Sherman From Alan.Bateman at oracle.com Thu Apr 14 19:21:34 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 14 Apr 2016 20:21:34 +0100 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570FEA5C.5040403@oracle.com> References: <570E963C.3050706@oracle.com> <570FE825.8050605@oracle.com> <570FEA5C.5040403@oracle.com> Message-ID: <570FEDBE.3090404@oracle.com> On 14/04/2016 20:07, Xueming Shen wrote: > : > > There is a test that passing a null filter into > Files.newDirectoryStream(path, filter) > and then FileSystemProvider.newDirectoryStream(...), to mean "no > filter". My reading > of the spec suggests it should get a NPE. (to use the > nweDirectoryStream(dir) for > accept all). Can you confirm? Yes, it should fail, it does not mean "no filter". -Alan From martinrb at google.com Thu Apr 14 20:30:44 2016 From: martinrb at google.com (Martin Buchholz) Date: Thu, 14 Apr 2016 13:30:44 -0700 Subject: RFR: 8154212: launcher SEGV when _JAVA_LAUNCHER_DEBUG is set In-Reply-To: <570FDCEA.6070101@oracle.com> References: <570FDCEA.6070101@oracle.com> Message-ID: Thanks! I would avoid ever using an empty environment; too much chance for trouble; I vaguely recall windows being unhappy without SystemRoot, for example. So I would always inherit the current environment (but maybe that's what doExec does?!) + final Map envMap = new HashMap<>(); On Thu, Apr 14, 2016 at 11:09 AM, Kumar Srinivasan wrote: > Hi Alan, > > Adds the missing name in the launchModeNames array > purely for display/debugging purposes. > > Please review: > http://cr.openjdk.java.net/~ksrini/8154212/webrev.00/ > > Bug: > https://bugs.openjdk.java.net/browse/JDK-8154212 > > Thanks > Kumar > > PS: running jprt tests in parallel. From stuart.marks at oracle.com Thu Apr 14 22:17:08 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 14 Apr 2016 15:17:08 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> References: <570EF756.2090602@oracle.com> <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> Message-ID: <571016E4.1070706@oracle.com> On 4/14/16 6:21 AM, Remi Forax wrote: > you are not the first one to try to change the integers defined in org.objectweb.asm.Opcodes, those values are compared by ref (not by value) inside ASM. > You're patch will change the behavior of any Interpreters that also use some Integers created by Integer.valueOf() because valueOf may cache the Integer references. > > I will add a comment in the ASM trunk for avoid such refactoring in the future. Hi Remi, Oh! This is the kind of issue that I was concerned about. Most code doesn't depend on identity semantics, and it's sometimes hard to tell if it does. I'll revert the autoboxing changes. Since we still need to get rid of the warnings, we'll need to suppress them. I think adding @SuppressWarnings at the top of the file is a little cleaner than adding it in front of each declaration, even though it's farther away. What do you think of the diff below? (I agree with Brian's comments about cleaning up this code, but I think that should be done separately from this changeset.) Thanks, s'marks diff -r 36025112dfdb src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java Thu Apr 14 12:17:23 2016 -0700 +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java Thu Apr 14 15:14:46 2016 -0700 @@ -70,6 +70,7 @@ * @author Eric Bruneton * @author Eugene Kuleshov */ + at SuppressWarnings("deprecation") // for Integer(int) constructor public interface Opcodes { // ASM API versions @@ -176,6 +177,8 @@ */ int F_SAME1 = 4; + // For reference comparison purposes, construct new instances + // instead of using valueOf() or autoboxing. Integer TOP = new Integer(0); Integer INTEGER = new Integer(1); Integer FLOAT = new Integer(2); From stuart.marks at oracle.com Thu Apr 14 22:22:24 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 14 Apr 2016 15:22:24 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: References: <570EF756.2090602@oracle.com> Message-ID: <57101820.9070008@oracle.com> On 4/14/16 6:49 AM, Lance Andersen wrote: > Outside of the comments from Remi regarding ASM, the other changes look fine to > me and the wordsmithing looks good. Hi Lance, thanks for the looking this over. > I assume we are going to want to go back and add the JDK release of deprecation > for all methods. If so, I will get to the JDBC ones shortly. It's not strictly required to add the since="x" element to every occurrence of the @Deprecated annotation, but it would be nice to do so if there is time. This is mainly up to the maintainer of each area. It also requires some research to determine the release value to put there. At some point we'll want to make sure that everything in the JDK is fully annotated, but that's a longer term effort. s'marks From stuart.marks at oracle.com Thu Apr 14 22:43:29 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 14 Apr 2016 15:43:29 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570FAB0C.7070505@javaspecialists.eu> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> Message-ID: <57101D11.6060109@oracle.com> On 4/14/16 7:37 AM, Dr Heinz M. Kabutz wrote: > in previous versions of Java, escape analysis did not seem to work particularly > well with Integer.valueOf(int) values, since the objects of course could come > from the Integer Cache. Thus if the Integer object did not escape from your > method, it could get eliminated entirely. Not exactly sure what > -XX:+EliminateAutoBox does, but my guess would be that there is some relation > here. So even though your changes look sensible, I'm just worried about > deprecating the constructors taking a primitive as a parameter. I haven't > looked at this particular issue for a number of years, so it's entirely possible > that it is a non-issue now :) Hi Heinz, I had a sidebar with Shipilev on this, and this is indeed still potentially an issue. Alexey's example was: set.contains(new Integer(i)) // 1 vs set.contains(Integer.valueOf(i)) // 2 EA is able to optimize away the allocation in line 1, but the additional complexity of dealing with the Integer cache in valueOf() defeats EA for line 2. (Autoboxing pretty much desugars to line 2.) But there are a few things to note. We're proposing to deprecate the boxed primitive constructors, but *not* for removal. This encourages people to migrate their code away from the constructors. There's no intent at the present time to remove the constructors. I believe it's still preferable for general-purpose programming to use autoboxing or valueOf() in preference to the constructors. For situations that are extremely performance critical, one can still use the constructor. The only difference is that this will generate a warning. I'd say that anyone who understands EA and who knows when calling the constructor will make a difference will also know how to add @SuppressWarnings in the right place. Of course, these people will suffer when value types come along. :-) I took a quick look through the valueOf() changes, and it doesn't look like any of these are really performance critical. Indeed, most of them create the boxed values for the purpose of storing into a field of reference type or into a collection, so an object will always have to be allocated on the heap. The EA issue doesn't apply to these cases; indeed, valueOf() is probably preferable for these cases, in order to benefit from the box caches. This is a good issue to keep an eye out for, though. Thanks for mentioning it. s'marks From vladimir.x.ivanov at oracle.com Thu Apr 14 23:10:02 2016 From: vladimir.x.ivanov at oracle.com (Vladimir Ivanov) Date: Fri, 15 Apr 2016 02:10:02 +0300 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <57101D11.6060109@oracle.com> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> Message-ID: <5710234A.2060001@oracle.com> > > On 4/14/16 7:37 AM, Dr Heinz M. Kabutz wrote: >> in previous versions of Java, escape analysis did not seem to work >> particularly >> well with Integer.valueOf(int) values, since the objects of course >> could come >> from the Integer Cache. Thus if the Integer object did not escape >> from your >> method, it could get eliminated entirely. Not exactly sure what >> -XX:+EliminateAutoBox does, but my guess would be that there is some >> relation >> here. So even though your changes look sensible, I'm just worried about >> deprecating the constructors taking a primitive as a parameter. I >> haven't >> looked at this particular issue for a number of years, so it's >> entirely possible >> that it is a non-issue now :) > > Hi Heinz, > > I had a sidebar with Shipilev on this, and this is indeed still > potentially an issue. Alexey's example was: > > set.contains(new Integer(i)) // 1 > > vs > > set.contains(Integer.valueOf(i)) // 2 > > EA is able to optimize away the allocation in line 1, but the additional > complexity of dealing with the Integer cache in valueOf() defeats EA for > line 2. (Autoboxing pretty much desugars to line 2.) I'd say it's a motivating example to improve EA implementation in C2, but not to avoid deprecation of public constructors in primitive type boxes. It shouldn't matter for C2 whether Integer.valueOf() or Integer:: is used. If it does, it's a bug. Best regards, Vladimir Ivanov > > But there are a few things to note. > > We're proposing to deprecate the boxed primitive constructors, but *not* > for removal. This encourages people to migrate their code away from the > constructors. There's no intent at the present time to remove the > constructors. > > I believe it's still preferable for general-purpose programming to use > autoboxing or valueOf() in preference to the constructors. > > For situations that are extremely performance critical, one can still > use the constructor. The only difference is that this will generate a > warning. I'd say that anyone who understands EA and who knows when > calling the constructor will make a difference will also know how to add > @SuppressWarnings in the right place. > > Of course, these people will suffer when value types come along. :-) > > I took a quick look through the valueOf() changes, and it doesn't look > like any of these are really performance critical. Indeed, most of them > create the boxed values for the purpose of storing into a field of > reference type or into a collection, so an object will always have to be > allocated on the heap. The EA issue doesn't apply to these cases; > indeed, valueOf() is probably preferable for these cases, in order to > benefit from the box caches. > > This is a good issue to keep an eye out for, though. Thanks for > mentioning it. > > s'marks From stuart.marks at oracle.com Thu Apr 14 23:13:10 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 14 Apr 2016 16:13:10 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: References: <570EF756.2090602@oracle.com> Message-ID: <57102406.6020408@oracle.com> On 4/14/16 8:30 AM, Paul Sandoz wrote: > CachedRowSetImpl > ? > > 1966 return ((Float.valueOf(value.toString())).floatValue()); > > Use Float.parseFloat ? > > > 2010 return ((Double.valueOf(value.toString().trim())).doubleValue()); > > Use Double.parseDouble ? I'm mostly reluctant to do general cleanups, as it can easily cause one to go off into the weeds. However, I believe that changing new Float(str).floatValue() or Float.valueOf(str).floatValue() to Float.parseFloat(str) and new Double(str).doubleValue() or Double.valueOf(str).doubleValue() to Double.parseDouble(str) is generally safe. Essentially the string-arg versions of the constructors and valueOf() methods just turn around and call parseFloat/Double internally and store the primitive result in a field; and floatValue() and doubleValue() simply get this field value. This is in Lance's area; Lance, are you OK with this? > ExpressionExecuter > ? > > 86 Double lval = Double.valueOf(((Number)evaluate(l)).doubleValue()); > 87 Double rval = Double.valueOf(((Number)evaluate(r)).doubleValue()); > 88 double result = op.eval(lval.doubleValue(), rval.doubleValue()); > 89 if (debug) { > 90 System.out.println("Performed Operation: " + lval + op + rval > 91 + " = " + result); > 92 } > 93 return Double.valueOf(result); > > How about: > > double lval = ((Number)evaluate(l)).doubleValue(); > double rval = ((Number)evaluate(r)).doubleValue(); > double result = op.eval(lval, rval); Similar here. Yes, I'll go ahead and make these changes. s'marks From stuart.marks at oracle.com Thu Apr 14 23:25:01 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 14 Apr 2016 16:25:01 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: References: <570EF756.2090602@oracle.com> Message-ID: <571026CD.2040507@oracle.com> On 4/14/16 10:10 AM, Martin Buchholz wrote: > I've been tempted by the dark side, when a class needs a value AND a > lock (or an "identity"). Instead of doing > > final String val = "foo"; > final Object lock = new Object(); > > one can "optimize" this ("why can't we have both?") to > > final String valAndLock = new String("foo"); > > and there are surely folks out there doing this. We should probably > never remove those constructors. Only at the end do you realize the power of the Dark Side. The String constructors aren't part of this round of deprecations. The main effort here is to try to clear some room to "valorize" (as John Rose puts it) the boxed primitives, and to make it clear that depending on identity semantics for the boxes is something that's officially frowned upon. (ASM notwithstanding. Ahem.) So that's why we're focusing on the boxed primitive constructors. Valorizing Strings is altogether a different matter. I'm not entirely sure how this will turn out. But weren't not yet at the point of deprecating the String(String) constructor, much less deprecating it for removal. So this kind of evil hack will remain safe for the time being. s'marks From xueming.shen at oracle.com Thu Apr 14 23:44:03 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Thu, 14 Apr 2016 16:44:03 -0700 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <570FE825.8050605@oracle.com> References: <570E963C.3050706@oracle.com> <570FE825.8050605@oracle.com> Message-ID: <57102B43.8000404@oracle.com> On 04/14/2016 11:57 AM, Alan Bateman wrote: > > > On 13/04/2016 19:55, Xueming Shen wrote: >> Hi, >> >> Please hep review the cleanup changes for jrtfs implementation. >> > I'm skimmed through the changes and it looks very good. > > My only concern is that we might have not enough tests for jrtfs to exercise it completely. I just checked the coverage it is indeed quite low. I'll create a bug for this. I did not realize that the PathOps.java does not include all the path tests we have in its nio version. I updated it with all of the "unix version" tests. It did trigger couple corner cases (the diff against yesterday's version in JrtPath.java attached ) http://cr.openjdk.java.net/~sherman/8147460/webrev/ sherman ---------------------------------------------------------------------------------------------------------------------- JrtPath.java: 91,93c91 < if (path.length() == 0) < return this; < if (path.length() == 1 && path.charAt(0) == '/') --- > if (path.length() == 0 || path.length() == 1 && path.charAt(0) == '/') 210,212d207 < if (path.length() == 0) { < return o; < } 240a236 > int pos = 0; 243c239 < if (sb.length() < len) { // no tailing slash at the end --- > if (pos < len) { // no tailing slash at the end 267c263 < if (this.path.length() == 0 || o.isAbsolute()) { --- > if (o.isAbsolute()) { 270,272d265 < if (o.path.length() == 0) { < return this; < } 299,301d291 < if (off == 0) { < return tp.length() == 0; < } From joe.darcy at oracle.com Fri Apr 15 00:14:05 2016 From: joe.darcy at oracle.com (joe darcy) Date: Thu, 14 Apr 2016 17:14:05 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <570D90F1.7050608@oracle.com> References: <570D90F1.7050608@oracle.com> Message-ID: <5710324D.3090403@oracle.com> Hello, In response to the review comments from Dmitry and Brian, I've prepared another iteration of the webrev: http://cr.openjdk.java.net/~darcy/4851642.1/ Summary of the changes: * Renamed the method to "fma" to follow the precedent of the C library. * Added API note citing IEEE 754 operation. * More test cases * More comments * Restructured handling of finite double value to be more straightforward. Thanks, -Joe On 4/12/2016 5:21 PM, joe darcy wrote: > Hello, > > Please review the changes for > > JDK-4851642: Add fused mac to Java math library > http://cr.openjdk.java.net/~darcy/4851642.0/ > > Fused mac (multiply-accumulate) is a ternary floating-point operation > which accepts three inputs, a, b, c, and computes > > a * b + c > > with a single rounding error rather than the usual two rounding errors > (a first for the multiply, a second one for the add). The fused mac > operation was added in the 2008 update to the IEEE 754 floating-point > standard and hardware support for the operation is becoming more and > more common in different processor families. > > When present as a hardware instruction, a fused mac can speed up loops > such as those for polynomial evaluation. A fused mac can also be used > to support a correctly rounding floating-point divide and support > various higher-precision operations such as "doubled-double" arithmetic. > > With the increasing availability of fused mac as a hardware primitive, > the time has come to add fused mac to the Java math library. Fused mac > is an ideal candidate to be intrinsified where hardware support is > available. However, this initial implementation does not attempt to > add any such intrinsics support in HotSpot; a follow-up RFE has been > filed for that work (JDK-8154122). The current library implementation > favors code simplicity over speed; a more performant implementation > could be written by directly decomposing the floating-point inputs > rather than turning to BigDecimal and may be written in the future. > More extensive tests could be added in the future as well. > > Thanks, > > -Joe From brian.burkhalter at oracle.com Fri Apr 15 00:55:06 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Thu, 14 Apr 2016 17:55:06 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <5710324D.3090403@oracle.com> References: <570D90F1.7050608@oracle.com> <5710324D.3090403@oracle.com> Message-ID: <0320DE7B-8F3C-4AA1-8BAE-FD3025149044@oracle.com> Hi Joe, This all looks good aside from the ?@code fusedMac? in the javadoc of which I believe you are aware. Brian On Apr 14, 2016, at 5:14 PM, joe darcy wrote: > In response to the review comments from Dmitry and Brian, I've prepared another iteration of the webrev: > > http://cr.openjdk.java.net/~darcy/4851642.1/ > > Summary of the changes: > > * Renamed the method to "fma" to follow the precedent of the C library. > * Added API note citing IEEE 754 operation. > * More test cases > * More comments > * Restructured handling of finite double value to be more straightforward. From joe.darcy at oracle.com Fri Apr 15 00:57:20 2016 From: joe.darcy at oracle.com (Joseph D. Darcy) Date: Thu, 14 Apr 2016 17:57:20 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <0320DE7B-8F3C-4AA1-8BAE-FD3025149044@oracle.com> References: <570D90F1.7050608@oracle.com> <5710324D.3090403@oracle.com> <0320DE7B-8F3C-4AA1-8BAE-FD3025149044@oracle.com> Message-ID: <57103C70.50806@oracle.com> Hi Brian, On 4/14/2016 5:55 PM, Brian Burkhalter wrote: > Hi Joe, > > This all looks good aside from the ?@code fusedMac? in the javadoc of > which I believe you are aware. > Doh! s/fusedMac/fma in my working copy. Thanks for the review, -Joe From dmitry.nadezhin at gmail.com Fri Apr 15 02:43:49 2016 From: dmitry.nadezhin at gmail.com (Dmitry Nadezhin) Date: Fri, 15 Apr 2016 05:43:49 +0300 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <5710324D.3090403@oracle.com> References: <570D90F1.7050608@oracle.com> <5710324D.3090403@oracle.com> Message-ID: Hi Joe, It looks good except a guard expression in the line Math:1550 (tmp == 0.0 && a == 0.0 || b == 0.0) Variables a and b occur asymmetrically in this expression. A symmetrical expression would be either (a == 0.0 || b == 0.0) or (product.signum() == 0) On Fri, Apr 15, 2016 at 3:14 AM, joe darcy wrote: > Hello, > > In response to the review comments from Dmitry and Brian, I've prepared > another iteration of the webrev: > > http://cr.openjdk.java.net/~darcy/4851642.1/ > > Summary of the changes: > > * Renamed the method to "fma" to follow the precedent of the C library. > * Added API note citing IEEE 754 operation. > * More test cases > * More comments > * Restructured handling of finite double value to be more straightforward. > > Thanks, > > -Joe > > > On 4/12/2016 5:21 PM, joe darcy wrote: > >> Hello, >> >> Please review the changes for >> >> JDK-4851642: Add fused mac to Java math library >> http://cr.openjdk.java.net/~darcy/4851642.0/ >> >> Fused mac (multiply-accumulate) is a ternary floating-point operation >> which accepts three inputs, a, b, c, and computes >> >> a * b + c >> >> with a single rounding error rather than the usual two rounding errors (a >> first for the multiply, a second one for the add). The fused mac operation >> was added in the 2008 update to the IEEE 754 floating-point standard and >> hardware support for the operation is becoming more and more common in >> different processor families. >> >> When present as a hardware instruction, a fused mac can speed up loops >> such as those for polynomial evaluation. A fused mac can also be used to >> support a correctly rounding floating-point divide and support various >> higher-precision operations such as "doubled-double" arithmetic. >> >> With the increasing availability of fused mac as a hardware primitive, >> the time has come to add fused mac to the Java math library. Fused mac is >> an ideal candidate to be intrinsified where hardware support is available. >> However, this initial implementation does not attempt to add any such >> intrinsics support in HotSpot; a follow-up RFE has been filed for that work >> (JDK-8154122). The current library implementation favors code simplicity >> over speed; a more performant implementation could be written by directly >> decomposing the floating-point inputs rather than turning to BigDecimal and >> may be written in the future. More extensive tests could be added in the >> future as well. >> >> Thanks, >> >> -Joe >> > > From david.holmes at oracle.com Fri Apr 15 04:32:19 2016 From: david.holmes at oracle.com (David Holmes) Date: Fri, 15 Apr 2016 14:32:19 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <570FB328.5020902@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> Message-ID: <57106ED3.5090002@oracle.com> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: > Roger, > Thanks for your comment! > > David, > >>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>> a new JVM function this way. > > I tried to call Thread#setName() after initializing VM (before calling > main method), > I could set native thread name. > However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set > native thread name for DestroyJavaVM. Right - I came to the same realization earlier this morning. Which, unfortunately, takes me back to the basic premise here that we don't set the name of threads not created by the JVM. The fact that the "main" thread is not tagged as being a JNI-attached thread seems accidental to me - so JVM_SetNativeThreadName is only working by accident for the initial attach, and can't be used for the DestroyJavaVM part - which leaves the thread inconsistently named at the native level. I'm afraid my view here is that the launcher has to be treated like any other process that might host a JVM. If it wants to name its native threads then it is free to do so, but I would not be exporting a function from the JVM to do that - it would have to use the OS specific API's for that on a platform-by-platform basis. Sorry. David ----- > > > Thanks, > > Yasumasa > > > On 2016/04/14 23:24, Roger Riggs wrote: >> Hi, >> >> Comments: >> >> jvm.h: The function names are too similar but perform different >> functions: >> >> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >> >> - The first function applies to the current thread, the second one a >> specific java thread. >> It would seem useful for there to be a comment somewhere about what >> the new function does. >> >> windows/native/libjli/java_md.c: line 408 casts to (void*) instead of >> (SetNativeThreadName0_t) >> as is done on unix and mac. >> >> - macosx/native/libjli/java_md_macosx.c: >> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at line 730 >> - 738 Incorrect indentation; if possible keep the cast on the same >> line as dlsym... >> >> $.02, Roger >> >> >> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>> That is an interesting question which I haven't had time to check - >>>> sorry. If the main thread is considered a JNI-attached thread then >>>> my suggestion wont work. If it isn't then my suggestion should work >>>> (but it means we have an inconsistency in our treatment of >>>> JNI-attached threads :( ) >>> >>> I ran following program on JDK 9 EA b112, and I confirmed native >>> thread name (test) was set. >>> --------- >>> public class Sleep{ >>> public static void main(String[] args) throws Exception{ >>> Thread.currentThread().setName("test"); >>> Thread.sleep(3600000); >>> } >>> } >>> --------- >>> >>> >>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>> a new JVM function this way. >>> >>> I will update webrev after hearing Kumar's comment. >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/14 21:32, David Holmes wrote: >>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>> Hi, >>>>> >>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>> Hi, >>>>>> >>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>> Hi David, >>>>>>> >>>>>>> Thanks for your comment. >>>>>>> >>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>> uses it >>>>>>> in new webrev. >>>>>> >>>>>> First the launcher belongs to another team so core-libs will need to >>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>> >>>>> Thanks! >>>>> I'm waiting to review :-) >>>>> >>>>> >>>>>> Personally I would have used a Java upcall to Thread.setName rather >>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes needed in >>>>>> that case. >>>>> >>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>> Thread#init(), >>>>> but I could not change native thread name. >>>> >>>> At Thread.init time the thread is not alive, which is why the native >>>> name is not set. >>>> >>>>> I guess that caller of main() is JNI attached thread. >>>> >>>> That is an interesting question which I haven't had time to check - >>>> sorry. If the main thread is considered a JNI-attached thread then >>>> my suggestion wont work. If it isn't then my suggestion should work >>>> (but it means we have an inconsistency in our treatment of >>>> JNI-attached threads :( ) >>>> >>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>> a new JVM function this way. >>>> >>>> Thanks, >>>> David >>>> ----- >>>> >>>>> Thus I think that we have to provide a function to set native >>>>> thread name. >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> [1] >>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>> >>>>> >>>>> >>>>>> Thanks, >>>>>> David >>>>>> >>>>>>> Could you review again? >>>>>>> >>>>>>> - hotspot: >>>>>>> >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>> >>>>>>> - jdk: >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>> I'll answer on this original thread as well ... >>>>>>>> >>>>>>>> Hi Yasumasa, >>>>>>>> >>>>>>>> Please see my updates to the bug (sorry have been on vacation). >>>>>>>> This >>>>>>>> needs to be done in the launcher to be correct as we do not set the >>>>>>>> name of threads that attach via JNI, which includes the "main" >>>>>>>> thread. >>>>>>>> >>>>>>>> David >>>>>>>> >>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>> Thanks Robbin, >>>>>>>>> >>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>> >>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>> >>>>>>>>>> /Robbin >>>>>>>>>> >>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>> >>>>>>>>>>> Thanks, looks good. >>>>>>>>>>> >>>>>>>>>>> /Robbin >>>>>>>>>>> >>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>> Could you review it? >>>>>>>>>>>> >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>> >>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>> >: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Native thread name is the same to thread name in Thread >>>>>>>>>>>>>> class. >>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>>>>>>> will be >>>>>>>>>>>>>> set at >>>>>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>>>> be the >>>>>>>>>>>>>> same. >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>> thread, >>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>> >>>>>>>>>>>>>> true, >>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>> > - >>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>> > + >>>>>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>> > + >>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming >>>>>>>>>>>>>> this >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> just >>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>>> process) is >>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> The native main thread in the process is not JavaThread. >>>>>>>>>>>>>> It is >>>>>>>>>>>>>> waiting >>>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>> think that >>>>>>>>>>>>>> we do >>>>>>>>>>>>>> not >>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>> java and >>>>>>>>>>>>>> native >>>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>>>>>>> >>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>> >>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>> that we >>>>>>>>>>>>>> have to >>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> No >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>> >>>>>>>>>>>>> /Robbin >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> name. >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >> From joe.darcy at oracle.com Fri Apr 15 05:00:24 2016 From: joe.darcy at oracle.com (joe darcy) Date: Thu, 14 Apr 2016 22:00:24 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: References: <570D90F1.7050608@oracle.com> <5710324D.3090403@oracle.com> Message-ID: <57107568.7040101@oracle.com> Hi Dmitry, On 4/14/2016 7:43 PM, Dmitry Nadezhin wrote: > Hi Joe, > > It looks good except a guard expression in the line Math:1550 > (tmp == 0.0 && a == 0.0 || b == 0.0) > Variables a and b occur asymmetrically in this expression. > A symmetrical expression would be either > (a == 0.0 || b == 0.0) > or > (product.signum() == 0) Thank you for the careful review. I wrote some additional tests to cover those cases. I believe the current code is functionally correct since (a == 0.0 || b == 0.0) implies tmp == 0.0, but I've changed the guard to (a == 0.0 || b == 0.0) and added some more comments. The code in question is now: } else { // All inputs finite BigDecimal product = (new BigDecimal(a)).multiply(new BigDecimal(b)); if (c == 0.0) { // Positive or negative zero // If the product is an exact zero, use a // floating-point expression to compute the sign // of the zero final result. The product is an // exact zero if and only if at least one of a and // b is zero. if (a == 0.0 || b == 0.0) { return a * b + c; } else { // The sign of a zero addend doesn't matter if // the product is nonzero. The sign of a zero // addend is not factored in the result if the // exact product is nonzero but underflows to // zero; see IEEE-754 2008 section 6.3 "The // sign bit". return product.doubleValue(); } } else { return product.add(new BigDecimal(c)).doubleValue(); } } Final webrev with minor adjustments at http://cr.openjdk.java.net/~darcy/4851642.2/ Thanks, -Joe > > On Fri, Apr 15, 2016 at 3:14 AM, joe darcy > wrote: > > Hello, > > In response to the review comments from Dmitry and Brian, I've > prepared another iteration of the webrev: > > http://cr.openjdk.java.net/~darcy/4851642.1/ > > > Summary of the changes: > > * Renamed the method to "fma" to follow the precedent of the C > library. > * Added API note citing IEEE 754 operation. > * More test cases > * More comments > * Restructured handling of finite double value to be more > straightforward. > > Thanks, > > -Joe > > > On 4/12/2016 5:21 PM, joe darcy wrote: > > Hello, > > Please review the changes for > > JDK-4851642: Add fused mac to Java math library > http://cr.openjdk.java.net/~darcy/4851642.0/ > > > Fused mac (multiply-accumulate) is a ternary floating-point > operation which accepts three inputs, a, b, c, and computes > > a * b + c > > with a single rounding error rather than the usual two > rounding errors (a first for the multiply, a second one for > the add). The fused mac operation was added in the 2008 update > to the IEEE 754 floating-point standard and hardware support > for the operation is becoming more and more common in > different processor families. > > When present as a hardware instruction, a fused mac can speed > up loops such as those for polynomial evaluation. A fused mac > can also be used to support a correctly rounding > floating-point divide and support various higher-precision > operations such as "doubled-double" arithmetic. > > With the increasing availability of fused mac as a hardware > primitive, the time has come to add fused mac to the Java math > library. Fused mac is an ideal candidate to be intrinsified > where hardware support is available. However, this initial > implementation does not attempt to add any such intrinsics > support in HotSpot; a follow-up RFE has been filed for that > work (JDK-8154122). The current library implementation favors > code simplicity over speed; a more performant implementation > could be written by directly decomposing the floating-point > inputs rather than turning to BigDecimal and may be written in > the future. More extensive tests could be added in the future > as well. > > Thanks, > > -Joe > > > From heinz at javaspecialists.eu Fri Apr 15 05:26:03 2016 From: heinz at javaspecialists.eu (Dr Heinz M. Kabutz) Date: Fri, 15 Apr 2016 07:26:03 +0200 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <5710234A.2060001@oracle.com> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> <5710234A.2060001@oracle.com> Message-ID: <57107B6B.5070100@javaspecialists.eu> Vladimir Ivanov wrote: >> >> On 4/14/16 7:37 AM, Dr Heinz M. Kabutz wrote: >>> in previous versions of Java, escape analysis did not seem to work >>> particularly >>> well with Integer.valueOf(int) values, since the objects of course >>> could come >>> from the Integer Cache. Thus if the Integer object did not escape >>> from your >>> method, it could get eliminated entirely. Not exactly sure what >>> -XX:+EliminateAutoBox does, but my guess would be that there is some >>> relation >>> here. So even though your changes look sensible, I'm just worried >>> about >>> deprecating the constructors taking a primitive as a parameter. I >>> haven't >>> looked at this particular issue for a number of years, so it's >>> entirely possible >>> that it is a non-issue now :) >> >> Hi Heinz, >> >> I had a sidebar with Shipilev on this, and this is indeed still >> potentially an issue. Alexey's example was: >> >> set.contains(new Integer(i)) // 1 >> >> vs >> >> set.contains(Integer.valueOf(i)) // 2 >> >> EA is able to optimize away the allocation in line 1, but the additional >> complexity of dealing with the Integer cache in valueOf() defeats EA for >> line 2. (Autoboxing pretty much desugars to line 2.) > > I'd say it's a motivating example to improve EA implementation in C2, > but not to avoid deprecation of public constructors in primitive type > boxes. It shouldn't matter for C2 whether Integer.valueOf() or > Integer:: is used. If it does, it's a bug. > > Best regards, > Vladimir Ivanov To do that would probably require a change to the Java Language Specification to allow us to get rid of the IntegerCache. Unfortunately it is defined to have a range of -128 to 127 at least in the cache, so this probably makes it really hard or impossible to optimize this with EA. I always found it amusing that the killer application for EA, getting rid of autoboxed Integer objects, didn't really work :-) Stuart, I'm not a great fan of @SuppressWarning() and would personally prefer the constructors for integer types to stay non-deprecated. Boolean's constructor is fine to deprecate, as are Double and Float. Heinz Heinz From weijun.wang at oracle.com Fri Apr 15 05:48:24 2016 From: weijun.wang at oracle.com (Wang Weijun) Date: Fri, 15 Apr 2016 13:48:24 +0800 Subject: Fwd: How do I import a sun.* class in jshell References: <1DB2C016-7A0D-4D75-B1FC-12A9F6C6AD9F@oracle.com> Message-ID: Does anyone here know the answer? It will be quite useful for me if I am either authoring an internal class or using it when implementing a public API. Thanks Max > Begin forwarded message: > > From: Wang Weijun > Subject: How do I import a sun.* class in jshell > Date: April 13, 2016 at 5:22:02 PM GMT+8 > To: kulla-dev at openjdk.java.net > > > $ jshell -J-XaddExports:java.base/sun.security.provider=ALL-UNNAMED > | Welcome to JShell -- Version 9-internal > | Type /help for help > > -> import sun.security.provider.SecureRandom > | Error: > | package sun.security.provider does not exist > | import sun.security.provider.SecureRandom; > | ^--------------------------------^ > > Thanks > Max > From peter.levart at gmail.com Fri Apr 15 07:33:28 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 15 Apr 2016 09:33:28 +0200 Subject: MethodNadles.lookup() for bootstrap class loader loaded classes In-Reply-To: <99D56D3E-5386-4A16-A646-3AAAE9A4C629@oracle.com> References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> <796EA2FB-95D5-4406-AF1C-2603B1915E62@oracle.com> <570FA843.70204@gmail.com> <99D56D3E-5386-4A16-A646-3AAAE9A4C629@oracle.com> Message-ID: <57109948.40303@gmail.com> Hi Paul, On 04/14/2016 04:40 PM, Paul Sandoz wrote: > Hi Peter, > > You found that annoying restriction :-) at this point i think this is mostly redundant. > > This is something i planned to update and limit the restriction to code within j.l.invoke and sun.invoke packages. sun.invoke is explicitly allowed currently. > > I'll follow up with a patch soon to unblock, but feel free to beat me to it if you wish. I don't quite understand this restriction. Seems to be that it was written at the time where the only classes loaded by bootstrap class loader were located in packages java.** and sun.** (was that actually true at some point?) and the restriction explicitly excludes classes in sun.invoke.** packages as though they are the only trusted code to be able to obtain such lookup. Does a Lookup with a lookup class loaded by the bootstrap class loader and allowedModes == ALL_MODES possess any special privileges that a Lookup with a lookup class loaded by the application class loader and allowedModes == ALL_MODES doesn't? Regards, Peter > > Paul. > >> On 14 Apr 2016, at 16:25, Peter Levart wrote: >> >> Hi Paul, >> >> I wanted to try using VarHandles for code internal to JDK but there's a problem with MethodHandles.lookup(). It doesn't allow the caller class loaded by the bootstrap class loader and located in either java.* or sun.* (but not sun.invoke.*) packages: >> >> >> private static void checkUnprivilegedlookupClass(Class lookupClass, int allowedModes) { >> String name = lookupClass.getName(); >> if (name.startsWith("java.lang.invoke.")) >> throw newIllegalArgumentException("illegal lookupClass: "+lookupClass); >> >> // For caller-sensitive MethodHandles.lookup() >> // disallow lookup more restricted packages >> if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) { >> if (name.startsWith("java.") || >> (name.startsWith("sun.") && !name.startsWith("sun.invoke."))) { >> throw newIllegalArgumentException("illegal lookupClass: " + lookupClass); >> } >> } >> } >> >> >> ...strangely, other bootstrap class loaded callers located in jdk.* are allowed. Why such distinction? Is there or will there be an official way to use VarHandles in JDK code and not having to resort to work-arounds like MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP").setAccessible(true)? >> >> >> Regards, Peter >> From forax at univ-mlv.fr Fri Apr 15 07:34:12 2016 From: forax at univ-mlv.fr (forax at univ-mlv.fr) Date: Fri, 15 Apr 2016 09:34:12 +0200 (CEST) Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <30667471-069E-4175-9357-085AC95DDBB9@oracle.com> References: <570EF756.2090602@oracle.com> <660821180.3280591.1460640078661.JavaMail.zimbra@u-pem.fr> <1D345E5F-7D97-4024-A226-5EA39BF06724@univ-mlv.fr> <30667471-069E-4175-9357-085AC95DDBB9@oracle.com> Message-ID: <1714538282.289990.1460705652232.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Brian Goetz" > ?: "R?mi Forax" > Cc: "Stuart Marks" , "core-libs-dev" > Envoy?: Jeudi 14 Avril 2016 21:06:28 > Objet: Re: RFR(m): 8145468 deprecations for java.lang > > Sure, there is some inconvenience. But neither of these reasons seem to rise > to the level of "good reasons not to fix it". > These Integers are not integers, they are objects that implement a kind of extensible state pattern (like using an interface and an enum in a more modern Java style) that happen to use the integer value has a debug info (the value are the same as the value defined for the StackMapTable see the JVM spec 4.7.4). The right fix should be to use real objects instead of java.lang.Integers here but there is no way to fix that without breaking the backward compatibility because those public constants are typed Integer. > Depending on the identity of boxes is problematic and will surely get worse > in the future. Best to get clean now! If java.lang.Integer is retrofitted to be a value type in the future, sure it's an issue, in that case, we will have to re-consider that in the future, but i will not break the backward compatibility of ASM just because in the future java.lang.Integer may be a value type. That's said i fully agree that the constructor of java.lang.Integer should be deprecated, new code should not use java.lang.Integer the way ASM currently uses it. > > Sent from my iPhone R?mi > > > On Apr 14, 2016, at 2:17 PM, R?mi Forax wrote: > > > > The Analyzer/Interpreter API is public so using equals instead of == will > > likely summon some strange bugs. > > > > It will also have an impact in term of performance because currently there > > is no virtual call in the part of the algo that does the analysis. > > > > cheers, > > R?mi > > > > Le 14 avril 2016 19:13:42 CEST, Brian Goetz a > > ?crit : > >> Or, better, don?t do that in ASM, and instead use .equals()? > >> > >>> On Apr 14, 2016, at 9:21 AM, Remi Forax wrote: > >>> > >>> Hi Stuart, > >>> you are not the first one to try to change the integers defined in > >> org.objectweb.asm.Opcodes, those values are compared by ref (not by > >> value) inside ASM. > >>> You're patch will change the behavior of any Interpreters that also > >> use some Integers created by Integer.valueOf() because valueOf may > >> cache the Integer references. > >>> > >>> I will add a comment in the ASM trunk for avoid such refactoring in > >> the future. > >>> > >>> reagrds, > >>> R?mi > >>> > >>> > >>> ----- Mail original ----- > >>>> De: "Stuart Marks" > >>>> ?: "core-libs-dev" > >>>> Envoy?: Jeudi 14 Avril 2016 03:50:14 > >>>> Objet: RFR(m): 8145468 deprecations for java.lang > >>>> > >>>> Hi all, > >>>> > >>>> Please review this first round of deprecation changes for the > >> java.lang > >>>> package. > >>>> This changeset includes the following: > >>>> > >>>> - a set of APIs being newly deprecated > >>>> - a set of already-deprecated APIs that are "upgraded" to > >> forRemoval=true > >>>> - addition of the "since" element to all deprecations > >>>> - cleanup of some of the warnings caused by new deprecations > >>>> > >>>> Webrevs: > >>>> > >>>> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > >> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > >>>> > >>>> http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > >>>> > >>>> The newly deprecated APIs include all of the constructors for the > >> boxed > >>>> primitives. We don't intend to remove these yet, so they don't > >> declare a > >>>> value > >>>> for the forRemoval element, implying the default value of false. The > >>>> constructors being deprecated are as follows: > >>>> > >>>> Boolean(boolean) > >>>> Boolean(String) > >>>> Byte(byte) > >>>> Byte(String) > >>>> Character(char) > >>>> Double(double) > >>>> Double(String) > >>>> Float(float) > >>>> Float(double) > >>>> Float(String) > >>>> Integer(int) > >>>> Integer(String) > >>>> Long(long) > >>>> Long(String) > >>>> Short(short) > >>>> Short(String) > >>>> > >>>> The methods being deprecated with forRemoval=true are listed below. > >> All of > >>>> these > >>>> methods have already been deprecated. They are all ill-defined, or > >> they don't > >>>> work, or they don't do anything useful. > >>>> > >>>> Runtime.getLocalizedInputStream(InputStream) > >>>> Runtime.getLocalizedOutputStream(OutputStream) > >>>> Runtime.runFinalizersOnExit(boolean) > >>>> SecurityManager.checkAwtEventQueueAccess() > >>>> SecurityManager.checkMemberAccess(Class, int) > >>>> SecurityManager.checkSystemClipboardAccess() > >>>> SecurityManager.checkTopLevelWindow(Object) > >>>> System.runFinalizersOnExit(boolean) > >>>> Thread.countStackFrames() > >>>> Thread.destroy() > >>>> Thread.stop(Throwable) > >>>> > >>>> Most of the files in the changeset are cleanups. Some of them are > >> simply the > >>>> addition of the "since" element to the @Deprecated annotation, to > >> indicate > >>>> the > >>>> version in which the API became deprecated. > >>>> > >>>> The rest of the changes are cleanup of warnings that were created by > >> the > >>>> deprecation of the boxed primitive constructors. There are a total > >> of a > >>>> couple > >>>> hundred such uses sprinkled around the JDK. I've taken care of a > >> portion of > >>>> them, with the exception of the java.desktop module, which alone has > >> over 100 > >>>> uses of boxed primitive constructors. I've disabled deprecation > >> warnings for > >>>> the > >>>> java.desktop module for the time being; these uses can be cleaned up > >> later. > >>>> I've > >>>> filed JDK-8154213 to cover this cleanup task. > >>>> > >>>> For the warnings cleanups I did, I mostly did conversions of the > >> form: > >>>> > >>>> new Double(dval) > >>>> > >>>> to > >>>> > >>>> Double.valueOf(dval) > >>>> > >>>> This is a very safe transformation. It changes the behavior only in > >> the cases > >>>> where the code relies on getting a new instance of the box object > >> instead of > >>>> one > >>>> that might come out of a cache. I didn't see any such code (and I > >> should hope > >>>> there's no such code in the JDK!). > >>>> > >>>> I applied autoboxing only sparingly, in the cases where it was an > >> obviously > >>>> safe > >>>> thing to do, or where nearby code already uses autoboxing. > >> Autoboxing > >>>> actually > >>>> generates a call to the appropriate valueOf() method, so the > >> bytecode would > >>>> be > >>>> the same in most cases. The only difference is clutter in the source > >> code. On > >>>> the other hand, there's some risk in converting to autoboxing, as > >> the > >>>> implicitly > >>>> autoboxed type might end up different from an explicit call to > >> valueOf(). > >>>> This > >>>> isn't always obvious, so that's why I mostly avoided autoboxing. > >>>> > >>>> Thanks, > >>>> > >>>> s'marks > > > From forax at univ-mlv.fr Fri Apr 15 07:49:39 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Fri, 15 Apr 2016 09:49:39 +0200 (CEST) Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <57107B6B.5070100@javaspecialists.eu> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> <5710234A.2060001@oracle.com> <57107B6B.5070100@javaspecialists.eu> Message-ID: <156109556.331763.1460706579669.JavaMail.zimbra@u-pem.fr> Hi Heinz, i think we should go nuclear on this, deprecate the Integer constructor *and* remove the line in the spec that says that Integer.valueOf (and Byte, Short, Character, Long) uses a cache and admit that the Java spec should not have a premature optimization carved in it. About your example about EA, do you agree that if the set is declared as a Set, there is no such issue anymore ? R?mi ----- Mail original ----- > De: "Dr Heinz M. Kabutz" > ?: "Vladimir Ivanov" > Cc: "core-libs-dev" > Envoy?: Vendredi 15 Avril 2016 07:26:03 > Objet: Re: RFR(m): 8145468 deprecations for java.lang > > Vladimir Ivanov wrote: > >> > >> On 4/14/16 7:37 AM, Dr Heinz M. Kabutz wrote: > >>> in previous versions of Java, escape analysis did not seem to work > >>> particularly > >>> well with Integer.valueOf(int) values, since the objects of course > >>> could come > >>> from the Integer Cache. Thus if the Integer object did not escape > >>> from your > >>> method, it could get eliminated entirely. Not exactly sure what > >>> -XX:+EliminateAutoBox does, but my guess would be that there is some > >>> relation > >>> here. So even though your changes look sensible, I'm just worried > >>> about > >>> deprecating the constructors taking a primitive as a parameter. I > >>> haven't > >>> looked at this particular issue for a number of years, so it's > >>> entirely possible > >>> that it is a non-issue now :) > >> > >> Hi Heinz, > >> > >> I had a sidebar with Shipilev on this, and this is indeed still > >> potentially an issue. Alexey's example was: > >> > >> set.contains(new Integer(i)) // 1 > >> > >> vs > >> > >> set.contains(Integer.valueOf(i)) // 2 > >> > >> EA is able to optimize away the allocation in line 1, but the additional > >> complexity of dealing with the Integer cache in valueOf() defeats EA for > >> line 2. (Autoboxing pretty much desugars to line 2.) > > > > I'd say it's a motivating example to improve EA implementation in C2, > > but not to avoid deprecation of public constructors in primitive type > > boxes. It shouldn't matter for C2 whether Integer.valueOf() or > > Integer:: is used. If it does, it's a bug. > > > > Best regards, > > Vladimir Ivanov > To do that would probably require a change to the Java Language > Specification to allow us to get rid of the IntegerCache. Unfortunately > it is defined to have a range of -128 to 127 at least in the cache, so > this probably makes it really hard or impossible to optimize this with > EA. I always found it amusing that the killer application for EA, > getting rid of autoboxed Integer objects, didn't really work :-) > > Stuart, I'm not a great fan of @SuppressWarning() and would personally > prefer the constructors for integer types to stay non-deprecated. > Boolean's constructor is fine to deprecate, as are Double and Float. > > Heinz > > Heinz > From michael.haupt at oracle.com Fri Apr 15 08:34:18 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 15 Apr 2016 10:34:18 +0200 Subject: RFR(S): 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void Message-ID: <07267AB9-6227-48FE-A4DE-91BD7D2ED70E@oracle.com> Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8150956 Webrev: http://cr.openjdk.java.net/~mhaupt/8150956/webrev.00/ Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From yasuenag at gmail.com Fri Apr 15 08:53:24 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Fri, 15 Apr 2016 17:53:24 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57106ED3.5090002@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> Message-ID: <5710AC04.3080909@gmail.com> Hi David, > The fact that the "main" thread is not tagged as being a JNI-attached thread seems accidental to me Should I file it to JBS? I think that we can fix as below: --------------- diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 @@ -3592,7 +3592,7 @@ #endif // INCLUDE_JVMCI // Attach the main thread to this os thread - JavaThread* main_thread = new JavaThread(); + JavaThread* main_thread = new JavaThread(true); main_thread->set_thread_state(_thread_in_vm); main_thread->initialize_thread_current(); // must do this before set_active_handles @@ -3776,6 +3776,9 @@ // Notify JVMTI agents that VM initialization is complete - nop if no agents. JvmtiExport::post_vm_initialized(); + // Change attach status to "attached" + main_thread->set_done_attaching_via_jni(); + if (TRACE_START() != JNI_OK) { vm_exit_during_initialization("Failed to start tracing backend."); } --------------- > If it wants to name its native threads then it is free to do so, Currently, JVM_SetNativeThreadName() cannot change native thread name when the caller thread is JNI-attached thread. However, I think that it should be changed if Java developer calls Thread#setName() explicitly. It is not the same of changing native thread name at Threads::create_vm(). If it is allowed, I want to fix SetNativeThreadName() as below. What do you think about this? --------------- --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 @@ -3187,7 +3187,7 @@ JavaThread* thr = java_lang_Thread::thread(java_thread); // Thread naming only supported for the current thread, doesn't work for // target threads. - if (Thread::current() == thr && !thr->has_attached_via_jni()) { + if (Thread::current() == thr) { // we don't set the name of an attached thread to avoid stepping // on other programs const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); --------------- Thanks, Yasumasa On 2016/04/15 13:32, David Holmes wrote: > > > On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >> Roger, >> Thanks for your comment! >> >> David, >> >>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>> a new JVM function this way. >> >> I tried to call Thread#setName() after initializing VM (before calling >> main method), >> I could set native thread name. >> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set >> native thread name for DestroyJavaVM. > > Right - I came to the same realization earlier this morning. Which, unfortunately, takes me back to the basic premise here that we don't set the name of threads not created by the JVM. The fact that the "main" thread is not tagged as being a JNI-attached thread seems accidental to me - so JVM_SetNativeThreadName is only working by accident for the initial attach, and can't be used for the DestroyJavaVM part - which leaves the thread inconsistently named at the native level. > > I'm afraid my view here is that the launcher has to be treated like any other process that might host a JVM. If it wants to name its native threads then it is free to do so, but I would not be exporting a function from the JVM to do that - it would have to use the OS specific API's for that on a platform-by-platform basis. > > Sorry. > > David > ----- > > >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/14 23:24, Roger Riggs wrote: >>> Hi, >>> >>> Comments: >>> >>> jvm.h: The function names are too similar but perform different >>> functions: >>> >>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>> >>> - The first function applies to the current thread, the second one a >>> specific java thread. >>> It would seem useful for there to be a comment somewhere about what >>> the new function does. >>> >>> windows/native/libjli/java_md.c: line 408 casts to (void*) instead of >>> (SetNativeThreadName0_t) >>> as is done on unix and mac. >>> >>> - macosx/native/libjli/java_md_macosx.c: >>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at line 730 >>> - 738 Incorrect indentation; if possible keep the cast on the same >>> line as dlsym... >>> >>> $.02, Roger >>> >>> >>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>> That is an interesting question which I haven't had time to check - >>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>> (but it means we have an inconsistency in our treatment of >>>>> JNI-attached threads :( ) >>>> >>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>> thread name (test) was set. >>>> --------- >>>> public class Sleep{ >>>> public static void main(String[] args) throws Exception{ >>>> Thread.currentThread().setName("test"); >>>> Thread.sleep(3600000); >>>> } >>>> } >>>> --------- >>>> >>>> >>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>> a new JVM function this way. >>>> >>>> I will update webrev after hearing Kumar's comment. >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/14 21:32, David Holmes wrote: >>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>> Hi, >>>>>> >>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>> Hi, >>>>>>> >>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>> Hi David, >>>>>>>> >>>>>>>> Thanks for your comment. >>>>>>>> >>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>> uses it >>>>>>>> in new webrev. >>>>>>> >>>>>>> First the launcher belongs to another team so core-libs will need to >>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>> >>>>>> Thanks! >>>>>> I'm waiting to review :-) >>>>>> >>>>>> >>>>>>> Personally I would have used a Java upcall to Thread.setName rather >>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes needed in >>>>>>> that case. >>>>>> >>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>> Thread#init(), >>>>>> but I could not change native thread name. >>>>> >>>>> At Thread.init time the thread is not alive, which is why the native >>>>> name is not set. >>>>> >>>>>> I guess that caller of main() is JNI attached thread. >>>>> >>>>> That is an interesting question which I haven't had time to check - >>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>> (but it means we have an inconsistency in our treatment of >>>>> JNI-attached threads :( ) >>>>> >>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>> a new JVM function this way. >>>>> >>>>> Thanks, >>>>> David >>>>> ----- >>>>> >>>>>> Thus I think that we have to provide a function to set native >>>>>> thread name. >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> [1] >>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>> >>>>>> >>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> >>>>>>>> Could you review again? >>>>>>>> >>>>>>>> - hotspot: >>>>>>>> >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>> >>>>>>>> - jdk: >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>> >>>>>>>>> Hi Yasumasa, >>>>>>>>> >>>>>>>>> Please see my updates to the bug (sorry have been on vacation). >>>>>>>>> This >>>>>>>>> needs to be done in the launcher to be correct as we do not set the >>>>>>>>> name of threads that attach via JNI, which includes the "main" >>>>>>>>> thread. >>>>>>>>> >>>>>>>>> David >>>>>>>>> >>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>> Thanks Robbin, >>>>>>>>>> >>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>> >>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>> >>>>>>>>>>> /Robbin >>>>>>>>>>> >>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>> >>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>> >>>>>>>>>>>> /Robbin >>>>>>>>>>>> >>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>> >: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Native thread name is the same to thread name in Thread >>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>> >> If you create new thread in Java app, native thread name >>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming >>>>>>>>>>>>>>> this >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> just >>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> The native main thread in the process is not JavaThread. >>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>> not >>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > It would be nice with something like 'Java Main Thread'. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. Apache >>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> No >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>> >>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main thread is >>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> From paul.sandoz at oracle.com Fri Apr 15 09:08:07 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 15 Apr 2016 11:08:07 +0200 Subject: MethodNadles.lookup() for bootstrap class loader loaded classes In-Reply-To: <57109948.40303@gmail.com> References: <57006917.4090200@oracle.com> <5703D682.1080300@oracle.com> <5BA27ADF-6577-4E85-B1B9-81DA5F93EF24@oracle.com> <1893890061.1837846.1459937403446.JavaMail.zimbra@u-pem.fr> <1396002249.1867527.1459942858286.JavaMail.zimbra@u-pem.fr> <1118297661.1921574.1459949327057.JavaMail.zimbra@u-pem.fr> <796EA2FB-95D5-4406-AF1C-2603B1915E62@oracle.com> <570FA843.70204@gmail.com> <99D56D3E-5386-4A16-A646-3AAAE9A4C629@oracle.com> <57109948.40303@gmail.com> Message-ID: <8D85AC15-0BBA-47FB-86F5-DB47F7354B51@oracle.com> > On 15 Apr 2016, at 09:33, Peter Levart wrote: > > Hi Paul, > > On 04/14/2016 04:40 PM, Paul Sandoz wrote: >> Hi Peter, >> >> You found that annoying restriction :-) at this point i think this is mostly redundant. >> >> This is something i planned to update and limit the restriction to code within j.l.invoke and sun.invoke packages. > > sun.invoke is explicitly allowed currently. > Ah, yes i missed the ?!?. >> >> I'll follow up with a patch soon to unblock, but feel free to beat me to it if you wish. > > I don't quite understand this restriction. Seems to be that it was written at the time where the only classes loaded by bootstrap class loader were located in packages java.** and sun.** (was that actually true at some point?) and the restriction explicitly excludes classes in sun.invoke.** packages as though they are the only trusted code to be able to obtain such lookup. Does a Lookup with a lookup class loaded by the bootstrap class loader and allowedModes == ALL_MODES possess any special privileges that a Lookup with a lookup class loaded by the application class loader and allowedModes == ALL_MODES doesn?t? > No as far as i know. The case i am most concerned more so about is usage within the Lookup.in method. I am inquiring off-list as to changes to checkUnprivilegedlookupClass. Paul. From felix.yang at oracle.com Fri Apr 15 09:29:22 2016 From: felix.yang at oracle.com (Felix Yang) Date: Fri, 15 Apr 2016 17:29:22 +0800 Subject: RFR 8146758, NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces In-Reply-To: <56DDA68A.6000907@oracle.com> References: <56DDA68A.6000907@oracle.com> Message-ID: <5710B472.80506@oracle.com> Hi all, please review the following fix. It is an intermittent failure because of Teredo Tunneling Pseudo-Interface. Bug: https://bugs.openjdk.java.net/browse/JDK-8146758 Webrev: http://cr.openjdk.java.net/~xiaofeya/8146758/webrev.00/ Thanks, Felix From paul.sandoz at oracle.com Fri Apr 15 09:30:04 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 15 Apr 2016 11:30:04 +0200 Subject: RFR(S): 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void In-Reply-To: <07267AB9-6227-48FE-A4DE-91BD7D2ED70E@oracle.com> References: <07267AB9-6227-48FE-A4DE-91BD7D2ED70E@oracle.com> Message-ID: <42361C09-0A61-4B14-9FDF-6BA15191F4E8@oracle.com> > On 15 Apr 2016, at 10:34, Michael Haupt wrote: > > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8150956 > Webrev: http://cr.openjdk.java.net/~mhaupt/8150956/webrev.00/ > +1 Paul. From paul.sandoz at oracle.com Fri Apr 15 09:35:33 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 15 Apr 2016 11:35:33 +0200 Subject: RFR 8146758, NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces In-Reply-To: <5710B472.80506@oracle.com> References: <56DDA68A.6000907@oracle.com> <5710B472.80506@oracle.com> Message-ID: > On 15 Apr 2016, at 11:29, Felix Yang wrote: > > Hi all, > please review the following fix. It is an intermittent failure because of Teredo Tunneling Pseudo-Interface. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8146758 > Webrev: http://cr.openjdk.java.net/~xiaofeya/8146758/webrev.00/ > +1 Paul. From kubota.yuji at gmail.com Fri Apr 15 10:03:58 2016 From: kubota.yuji at gmail.com (KUBOTA Yuji) Date: Fri, 15 Apr 2016 19:03:58 +0900 Subject: PING: RFR: JDK-4347142: Need method to set Password protection to Zip entries In-Reply-To: <5707E1E8.9060202@gmail.com> References: <56F9A4F4.6040108@oracle.com> <5707E1E8.9060202@gmail.com> Message-ID: Hi Anthony, Sherman and all. Anthony, thank you for your comment! I and Yasumasa have recognized that the zipfs should be handled as Anthony said. However, we fear to make conflict of concept / implementation if we enhance the zipfs API now because it will be fixed in the near future. So I believe we should implement separately at the following steps. 1. Add the API of "traditional encrypt" which have enough expandability for adding other encrypt engine as AE-1/2. The expandability will implement by adding a new stream which based on provided sample by Sherman. 2. Add AE-1/AE-2 using as samples as Sherman's implementation. 3. Add enhancement to support zipfs after the API of zipfs is fixed. Instead of implementing many encryption at a time, we believe that adding the zip encryption API with "expandability" (as a first step) is more constructive. In addition to this, implementing "Traditional Encryption" is meaningful because it has definitely worth in some scene as Tomoyuki said. For a second step, I read the WinZip document and feel that WinZip's AE-1/AE-2 may be free from the risk I have anticipated. Although, I feel we should confirm the pkware-winzip agreement and third-party licensing issue with more relevant document, e.g., press release on the agreement, etc,... So we believe it is better not to implement them now but to leave them and make possible to add them later. Thanks, Yuji 2016-04-09 1:52 GMT+09:00 Anthony Vanelverdinghe : > Hi Yuji, Sherman et al. > > PKWARE's "Strong Encryption Specification" [1] indeed warns about patents, > but how/why does this affect Winzip's AE-1 and AE-2 [2]? > > I don't mind if decryption support is added for the "Traditional > Encryption". However, I believe it would be wrong to introduce encryption > support for a known-to-be-broken encryption method in the JDK. Using the > argument of "it's good enough for our case", I could also argue that Base64 > qualifies as an encryption method, or that SSLv2 is an appropriate choice to > secure network connections. > > However, if this is to be added, it should be supported by the zipfs > FileSystemProvider as well. The passphrase handler could be passed by a > property in the environment, e.g. Function> which > would provide the passphrase for a given path, or Optional.empty() if the > Path is unencrypted. > > Kind regards, Anthony > > [1] https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT > [2] http://www.winzip.com/win/en/aes_info.htm > > > On 8/04/2016 13:04, KUBOTA Yuji wrote: >> >> Hi Sherman and all, >> >> Thank you for all comments about this proposal! >> >> Thank Tomoyuki and Stephen for sharing your needs. >> >> Thank Bernd for sharing your information. However, I am >> afraid that AE1 and AE2 may have a risk of patent issue, >> while "Traditional PKWare encryption" is explicitly free >> from the risk according to the PKWare documents. >> Therefore, I think this proposed implementation to support >> legacy zip specification is meaningful as Tomoyuki said. >> >> We got some positive opinions / needs. I am glad if you >> consider the proposal acceptable for JDK. >> If this proposed implementation is acceptable, I and >> Yasumasa will improve it by corresponding to comments >> which given by Sherman and Stephen. >> >> Thanks! >> Yuji >> >> 2016-03-29 6:41 GMT+09:00 Xueming Shen : >>> >>> Yasumasa >>> >>> It's a tricky call. To be honest, as I said at the very beginning, I'm >>> not >>> sure whether >>> or not it's a good idea and worth the efffort to push this into the >>> j.u.zip >>> package to >>> support the "traditional PKWare encryption", which is known to be >>> "seriously >>> flawed, >>> and in particular is vulnerable to known-plaintext attacks" (from wiki), >>> while I fully >>> understood it is not a concern in your "problem-free" use scenario. Just >>> wonder >>> if there is anyone else on the list that has/had the need for such >>> encryption feature >>> in the past. It would be preferred to have more input (agree, disagree) >>> to >>> make the >>> final decision. >>> >>> Here are some comments regarding the proposed implementation, >>> >>> (1) The changes in native code are probably no longer needed. The native >>> path is >>> left there for vm directly access. >>> (2) I'm concerned about the footprint increase for the ZipEntry class >>> (the >>> proposed >>> change is adding 3 more fields into the entry class). Given this is >>> something rarely >>> needed/used, and we might have hundreds and thousands of zip/jar >>> entries during >>> startup/runtime, it might be desired to avoid adding these fields >>> into >>> ZipEntry class. >>> A possible alternative to have a dedicated entry class extended >>> from >>> the ZipEntry >>> to hold those extra fields and methods, EncryptionZipEntry for >>> example. >>> So the >>> proposed encryption support code will not have any impact to the >>> existing use of >>> ZipInput/OutputStream/File. >>> (3) I'm also not comfortable to add the "encryption engine" logic into >>> the >>> in/deflater >>> stream classes, while it might be convenient to do so from >>> implementation point >>> of view. Given the encryption is something between the raw bites in >>> the >>> zip file >>> and the in/deflating layer, it might need an extra layer there, >>> though >>> I'm not sure >>> if it's easy to do so. >>> >>> The webrev below is what I think might be better for the ZipFile and >>> ZipOutputStream >>> to have an extra layer in between to handle the encryption. Not try to >>> test >>> if it really >>> works, just throw in the idea for discussion. >>> >>> http://cr.openjdk.java.net/~sherman/zencrypt/webrev/ >>> >>> No, I did not try the ZIS, the "pushback" stream there might be a little >>> tricky:-) >>> >>> -Sherman >>> >>> >>> On 03/28/2016 02:34 AM, Yasumasa Suenaga wrote: >>>> >>>> PING: Could you review it? >>>> We want to move forward this enhancement. >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> 2016/03/19 22:01 "Yasumasa Suenaga": >>>> >>>>> Hi Alan, >>>>> >>>>>> I think the main issue here is to decide whether the API >>>>>> should be extended for encryption or not. >>>>> >>>>> We've discussed on the premise that we add the API for supporting ZIP >>>>> encryption. >>>>> In this context, Sherman tried to implement AES encryption extending >>>>> current API. [1] >>>>> >>>>> IMHO, ZIP encryption should be implemented as extention of current ZIP >>>>> API >>>>> because encryption/decryption will process for each ZIP entries. >>>>> >>>>> According to Developers' Guide, guideline for adding new API is TBD. >>>>> [2] >>>>> What should I do next? >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumsa >>>>> >>>>> >>>>> [1] >>>>> >>>>> >>>>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-January/037903.html >>>>> [2] http://openjdk.java.net/guide/changePlanning.html#api >>>>> >>>>> >>>>> On 2016/03/19 0:25, Alan Bateman wrote: >>>>>> >>>>>> On 18/03/2016 15:02, Yasumasa Suenaga wrote: >>>>>>> >>>>>>> Hi all, >>>>>>> >>>>>>> We (including me and Yuji Kubota (ykubota: OpenJDK jdk9 Author)) >>>>> >>>>> discussed >>>>>>> >>>>>>> about this issue from Nov. 2015. [1] >>>>>>> We heard several comments and we applied them to our patch. >>>>>>> >>>>>>> I have not heard new comment for our latest patch. >>>>>>> So I send review request for it. Could you review it? >>>>>>> >>>>>>> webrev: >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-4347142/webrev.04/ >>>>>>> >>>>>>> Usage of new API: >>>>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-4347142/webrev.04/Test.java >>>>>> >>>>>> Yasumasa - I think the main issue here is to decide whether the API >>>>>> should be extended for encryption or not. If exposing it in the API >>>>>> make >>>>>> sense then I assume that alternative names to >>>>>> java.util.zip.ZipCryption >>>>>> needs to be explored. >>>>>> >>>>>> -Alan. >>>>>> > From david.holmes at oracle.com Fri Apr 15 10:16:30 2016 From: david.holmes at oracle.com (David Holmes) Date: Fri, 15 Apr 2016 20:16:30 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5710AC04.3080909@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> Message-ID: <5710BF7E.6090206@oracle.com> Hi Yasumasa, On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: > Hi David, > >> The fact that the "main" thread is not tagged as being a JNI-attached >> thread seems accidental to me > > Should I file it to JBS? I think it is a bug based on the comment here: JavaThread(bool is_attaching_via_jni = false); // for main thread and JNI attached threads Though that will introduce a change in behaviour by itself as setName will no longer set the native name for the main thread. > I think that we can fix as below: > --------------- > diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp > --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 > +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 > @@ -3592,7 +3592,7 @@ > #endif // INCLUDE_JVMCI > > // Attach the main thread to this os thread > - JavaThread* main_thread = new JavaThread(); > + JavaThread* main_thread = new JavaThread(true); > main_thread->set_thread_state(_thread_in_vm); > main_thread->initialize_thread_current(); > // must do this before set_active_handles > @@ -3776,6 +3776,9 @@ > // Notify JVMTI agents that VM initialization is complete - nop if > no agents. > JvmtiExport::post_vm_initialized(); > > + // Change attach status to "attached" > + main_thread->set_done_attaching_via_jni(); > + I think we can do this straight after the JavaThread constructor. > if (TRACE_START() != JNI_OK) { > vm_exit_during_initialization("Failed to start tracing backend."); > } > --------------- > > >> If it wants to name its native threads then it is free to do so, > > Currently, JVM_SetNativeThreadName() cannot change native thread name > when the caller thread is JNI-attached thread. > However, I think that it should be changed if Java developer calls > Thread#setName() explicitly. > It is not the same of changing native thread name at Threads::create_vm(). > > If it is allowed, I want to fix SetNativeThreadName() as below. > What do you think about this? The decision to not change the name of JNI-attached threads was a deliberate one** - this functionality originated with the OSX port and it was reported that the initial feedback with this feature was to ensure it didn't mess with thread names that had been set by the host process. If we do as you propose then we will just have an inconsistency for people to complain about: "why does my native thread only have a name if I call cur.setName(cur.getName()) ?" ** If you follow the bugs and related discussions on this, the semantics and limitations (truncation, current thread only, non-JNI threads only) of setting the native thread name were supposed to be documented in the release notes - but as far as I can see that never happened. :( My position on this remains that if it is desirable for the main thread (and DestroyJavaVM thread) to have native names then the launcher needs to be setting them using the available platform APIs. Unfortunately this is complicated - as evidenced by the VM code for this - due to the need to verify API availability. Any change in behaviour in relation to Thread.setName would have to go through our CCC process I think. But a change in the launcher would not. Sorry. David ----- > --------------- > --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 > +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 > @@ -3187,7 +3187,7 @@ > JavaThread* thr = java_lang_Thread::thread(java_thread); > // Thread naming only supported for the current thread, doesn't work > for > // target threads. > - if (Thread::current() == thr && !thr->has_attached_via_jni()) { > + if (Thread::current() == thr) { > // we don't set the name of an attached thread to avoid stepping > // on other programs > const char *thread_name = > java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); > --------------- > > > Thanks, > > Yasumasa > > > On 2016/04/15 13:32, David Holmes wrote: >> >> >> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>> Roger, >>> Thanks for your comment! >>> >>> David, >>> >>>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>>> a new JVM function this way. >>> >>> I tried to call Thread#setName() after initializing VM (before calling >>> main method), >>> I could set native thread name. >>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set >>> native thread name for DestroyJavaVM. >> >> Right - I came to the same realization earlier this morning. Which, >> unfortunately, takes me back to the basic premise here that we don't >> set the name of threads not created by the JVM. The fact that the >> "main" thread is not tagged as being a JNI-attached thread seems >> accidental to me - so JVM_SetNativeThreadName is only working by >> accident for the initial attach, and can't be used for the >> DestroyJavaVM part - which leaves the thread inconsistently named at >> the native level. >> >> I'm afraid my view here is that the launcher has to be treated like >> any other process that might host a JVM. If it wants to name its >> native threads then it is free to do so, but I would not be exporting >> a function from the JVM to do that - it would have to use the OS >> specific API's for that on a platform-by-platform basis. >> >> Sorry. >> >> David >> ----- >> >> >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/14 23:24, Roger Riggs wrote: >>>> Hi, >>>> >>>> Comments: >>>> >>>> jvm.h: The function names are too similar but perform different >>>> functions: >>>> >>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>> >>>> - The first function applies to the current thread, the second one a >>>> specific java thread. >>>> It would seem useful for there to be a comment somewhere about what >>>> the new function does. >>>> >>>> windows/native/libjli/java_md.c: line 408 casts to (void*) instead of >>>> (SetNativeThreadName0_t) >>>> as is done on unix and mac. >>>> >>>> - macosx/native/libjli/java_md_macosx.c: >>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>> line 730 >>>> - 738 Incorrect indentation; if possible keep the cast on the same >>>> line as dlsym... >>>> >>>> $.02, Roger >>>> >>>> >>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>> That is an interesting question which I haven't had time to check - >>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>> (but it means we have an inconsistency in our treatment of >>>>>> JNI-attached threads :( ) >>>>> >>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>> thread name (test) was set. >>>>> --------- >>>>> public class Sleep{ >>>>> public static void main(String[] args) throws Exception{ >>>>> Thread.currentThread().setName("test"); >>>>> Thread.sleep(3600000); >>>>> } >>>>> } >>>>> --------- >>>>> >>>>> >>>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>>> a new JVM function this way. >>>>> >>>>> I will update webrev after hearing Kumar's comment. >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>> Hi, >>>>>>> >>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>> Hi David, >>>>>>>>> >>>>>>>>> Thanks for your comment. >>>>>>>>> >>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>> uses it >>>>>>>>> in new webrev. >>>>>>>> >>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>> need to >>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>> >>>>>>> Thanks! >>>>>>> I'm waiting to review :-) >>>>>>> >>>>>>> >>>>>>>> Personally I would have used a Java upcall to Thread.setName rather >>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>> needed in >>>>>>>> that case. >>>>>>> >>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>> Thread#init(), >>>>>>> but I could not change native thread name. >>>>>> >>>>>> At Thread.init time the thread is not alive, which is why the native >>>>>> name is not set. >>>>>> >>>>>>> I guess that caller of main() is JNI attached thread. >>>>>> >>>>>> That is an interesting question which I haven't had time to check - >>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>> (but it means we have an inconsistency in our treatment of >>>>>> JNI-attached threads :( ) >>>>>> >>>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>>> a new JVM function this way. >>>>>> >>>>>> Thanks, >>>>>> David >>>>>> ----- >>>>>> >>>>>>> Thus I think that we have to provide a function to set native >>>>>>> thread name. >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> [1] >>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> Thanks, >>>>>>>> David >>>>>>>> >>>>>>>>> Could you review again? >>>>>>>>> >>>>>>>>> - hotspot: >>>>>>>>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>> >>>>>>>>> >>>>>>>>> - jdk: >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>> >>>>>>>>>> Hi Yasumasa, >>>>>>>>>> >>>>>>>>>> Please see my updates to the bug (sorry have been on vacation). >>>>>>>>>> This >>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>> set the >>>>>>>>>> name of threads that attach via JNI, which includes the "main" >>>>>>>>>> thread. >>>>>>>>>> >>>>>>>>>> David >>>>>>>>>> >>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> Thanks Robbin, >>>>>>>>>>> >>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>> >>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>> >>>>>>>>>>>> /Robbin >>>>>>>>>>>> >>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>> >>>>>>>>>>>>> /Robbin >>>>>>>>>>>>> >>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>> >> If you create new thread in Java app, native thread >>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming >>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> No >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>> From lance.andersen at oracle.com Fri Apr 15 10:38:05 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Fri, 15 Apr 2016 06:38:05 -0400 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <57102406.6020408@oracle.com> References: <570EF756.2090602@oracle.com> <57102406.6020408@oracle.com> Message-ID: <86D7F1A0-7FC8-47F0-82C8-B953A166F928@oracle.com> Hi Stuart, Yes I am fine with the change. I can go back and do this after your push if you prefer, just let me know Best Lance > On Apr 14, 2016, at 7:13 PM, Stuart Marks wrote: > > > > On 4/14/16 8:30 AM, Paul Sandoz wrote: >> CachedRowSetImpl >> ? >> >> 1966 return ((Float.valueOf(value.toString())).floatValue()); >> >> Use Float.parseFloat ? >> >> >> 2010 return ((Double.valueOf(value.toString().trim())).doubleValue()); >> >> Use Double.parseDouble ? > > I'm mostly reluctant to do general cleanups, as it can easily cause one to go off into the weeds. However, I believe that changing > > new Float(str).floatValue() or > Float.valueOf(str).floatValue() to Float.parseFloat(str) > > and > > new Double(str).doubleValue() or > Double.valueOf(str).doubleValue() to Double.parseDouble(str) > > is generally safe. Essentially the string-arg versions of the constructors and valueOf() methods just turn around and call parseFloat/Double internally and store the primitive result in a field; and floatValue() and doubleValue() simply get this field value. > > This is in Lance's area; Lance, are you OK with this? > >> ExpressionExecuter >> ? >> >> 86 Double lval = Double.valueOf(((Number)evaluate(l)).doubleValue()); >> 87 Double rval = Double.valueOf(((Number)evaluate(r)).doubleValue()); >> 88 double result = op.eval(lval.doubleValue(), rval.doubleValue()); >> 89 if (debug) { >> 90 System.out.println("Performed Operation: " + lval + op + rval >> 91 + " = " + result); >> 92 } >> 93 return Double.valueOf(result); >> >> How about: >> >> double lval = ((Number)evaluate(l)).doubleValue(); >> double rval = ((Number)evaluate(r)).doubleValue(); >> double result = op.eval(lval, rval); > > Similar here. > > Yes, I'll go ahead and make these changes. > > s'marks Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From chris.hegarty at oracle.com Fri Apr 15 10:45:43 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 15 Apr 2016 11:45:43 +0100 Subject: RFR 8146758, NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces In-Reply-To: <5710B472.80506@oracle.com> References: <56DDA68A.6000907@oracle.com> <5710B472.80506@oracle.com> Message-ID: <5710C657.4060700@oracle.com> On 15/04/16 10:29, Felix Yang wrote: > Hi all, > please review the following fix. It is an intermittent failure > because of Teredo Tunneling Pseudo-Interface. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8146758 > Webrev: http://cr.openjdk.java.net/~xiaofeya/8146758/webrev.00/ Looks ok to me. -Chris. From scolebourne at joda.org Fri Apr 15 10:51:49 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Fri, 15 Apr 2016 11:51:49 +0100 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <156109556.331763.1460706579669.JavaMail.zimbra@u-pem.fr> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> <5710234A.2060001@oracle.com> <57107B6B.5070100@javaspecialists.eu> <156109556.331763.1460706579669.JavaMail.zimbra@u-pem.fr> Message-ID: FWIW. I would prefer to see these constructors removed and the JLS simplified at the earliest possible date. Not using these classes as the value types for primitives in Valhalla would be very confusing. Stephen On 15 April 2016 at 08:49, Remi Forax wrote: > Hi Heinz, > i think we should go nuclear on this, deprecate the Integer constructor *and* remove the line in the spec that says that Integer.valueOf (and Byte, Short, Character, Long) uses a cache and admit that the Java spec should not have a premature optimization carved in it. > > About your example about EA, do you agree that if the set is declared as a Set, there is no such issue anymore ? > > R?mi > > ----- Mail original ----- >> De: "Dr Heinz M. Kabutz" >> ?: "Vladimir Ivanov" >> Cc: "core-libs-dev" >> Envoy?: Vendredi 15 Avril 2016 07:26:03 >> Objet: Re: RFR(m): 8145468 deprecations for java.lang >> >> Vladimir Ivanov wrote: >> >> >> >> On 4/14/16 7:37 AM, Dr Heinz M. Kabutz wrote: >> >>> in previous versions of Java, escape analysis did not seem to work >> >>> particularly >> >>> well with Integer.valueOf(int) values, since the objects of course >> >>> could come >> >>> from the Integer Cache. Thus if the Integer object did not escape >> >>> from your >> >>> method, it could get eliminated entirely. Not exactly sure what >> >>> -XX:+EliminateAutoBox does, but my guess would be that there is some >> >>> relation >> >>> here. So even though your changes look sensible, I'm just worried >> >>> about >> >>> deprecating the constructors taking a primitive as a parameter. I >> >>> haven't >> >>> looked at this particular issue for a number of years, so it's >> >>> entirely possible >> >>> that it is a non-issue now :) >> >> >> >> Hi Heinz, >> >> >> >> I had a sidebar with Shipilev on this, and this is indeed still >> >> potentially an issue. Alexey's example was: >> >> >> >> set.contains(new Integer(i)) // 1 >> >> >> >> vs >> >> >> >> set.contains(Integer.valueOf(i)) // 2 >> >> >> >> EA is able to optimize away the allocation in line 1, but the additional >> >> complexity of dealing with the Integer cache in valueOf() defeats EA for >> >> line 2. (Autoboxing pretty much desugars to line 2.) >> > >> > I'd say it's a motivating example to improve EA implementation in C2, >> > but not to avoid deprecation of public constructors in primitive type >> > boxes. It shouldn't matter for C2 whether Integer.valueOf() or >> > Integer:: is used. If it does, it's a bug. >> > >> > Best regards, >> > Vladimir Ivanov >> To do that would probably require a change to the Java Language >> Specification to allow us to get rid of the IntegerCache. Unfortunately >> it is defined to have a range of -128 to 127 at least in the cache, so >> this probably makes it really hard or impossible to optimize this with >> EA. I always found it amusing that the killer application for EA, >> getting rid of autoboxed Integer objects, didn't really work :-) >> >> Stuart, I'm not a great fan of @SuppressWarning() and would personally >> prefer the constructors for integer types to stay non-deprecated. >> Boolean's constructor is fine to deprecate, as are Double and Float. >> >> Heinz >> >> Heinz >> From vladimir.x.ivanov at oracle.com Fri Apr 15 11:42:40 2016 From: vladimir.x.ivanov at oracle.com (Vladimir Ivanov) Date: Fri, 15 Apr 2016 14:42:40 +0300 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <57107B6B.5070100@javaspecialists.eu> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> <5710234A.2060001@oracle.com> <57107B6B.5070100@javaspecialists.eu> Message-ID: <5710D3B0.6010903@oracle.com> >>> I had a sidebar with Shipilev on this, and this is indeed still >>> potentially an issue. Alexey's example was: >>> >>> set.contains(new Integer(i)) // 1 >>> >>> vs >>> >>> set.contains(Integer.valueOf(i)) // 2 >>> >>> EA is able to optimize away the allocation in line 1, but the additional >>> complexity of dealing with the Integer cache in valueOf() defeats EA for >>> line 2. (Autoboxing pretty much desugars to line 2.) >> >> I'd say it's a motivating example to improve EA implementation in C2, >> but not to avoid deprecation of public constructors in primitive type >> boxes. It shouldn't matter for C2 whether Integer.valueOf() or >> Integer:: is used. If it does, it's a bug. >> > To do that would probably require a change to the Java Language > Specification to allow us to get rid of the IntegerCache. Unfortunately > it is defined to have a range of -128 to 127 at least in the cache, so > this probably makes it really hard or impossible to optimize this with > EA. I always found it amusing that the killer application for EA, > getting rid of autoboxed Integer objects, didn't really work :-) Still, I'd separate optimization and specification aspects. This case is neither "really hard" nor impossible to optimize. What is hard is to ensure the optimization covers all interesting cases :-) AFAIK C2 should already do a pretty decent job of eliminating box/unbox pairs (e.g., Integer.valueOf().intValue()) and the cache is not a problem here. What can cause problems is when box identity intervenes. For example, even for non-escaping objects the runtime has to be able to materialize them at safepoints. In order to preserve identity invariants, the runtime has to take into account how the box is created (constructor vs factory method). Probably, that's the missing case right now. But there's nothing insurmountable to fix it - the runtime should just consult the cache in the rare cases when rematerialization is necessary. Best regards, Vladimir Ivanov From Alan.Bateman at oracle.com Fri Apr 15 12:53:45 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 15 Apr 2016 13:53:45 +0100 Subject: RFR: JDK-8147460: Clean-up jrtfs implementation In-Reply-To: <57102B43.8000404@oracle.com> References: <570E963C.3050706@oracle.com> <570FE825.8050605@oracle.com> <57102B43.8000404@oracle.com> Message-ID: <5710E459.1020200@oracle.com> On 15/04/2016 00:44, Xueming Shen wrote: > > I did not realize that the PathOps.java does not include all the path > tests > we have in its nio version. I updated it with all of the "unix > version" tests. > It did trigger couple corner cases (the diff against yesterday's > version in > JrtPath.java attached ) > > http://cr.openjdk.java.net/~sherman/8147460/webrev/ > Thanks, it good to have that test updated as there are many corner cases. A few other areas that don't seem to have tests is the jrt implementation of FileStore and regex usage with DirectoryStream but we can expand on this once you get this update in. -Alan From yasuenag at gmail.com Fri Apr 15 13:20:06 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Fri, 15 Apr 2016 22:20:06 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5710BF7E.6090206@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> Message-ID: <5710EA86.6010400@gmail.com> Hi David, > I think it is a bug based on the comment here: > > JavaThread(bool is_attaching_via_jni = false); // for main thread and JNI attached threads I filed it to JBS as JDK-8154331. I will send review request to hotspot-runtime-dev. > Though that will introduce a change in behaviour by itself as setName will no longer set the native name for the main thread. I know. I checked changeset history. JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is backported JDK 8. However, this function seems to be called from Thread#setNativeName() only. In addition, Thread#setNativeName() is private method. Thus I think that we can add an argument to JVM_SetNativeThreadName() for force setting. (e.g. "bool forced") It makes a change of JVM API. However, this function is NOT public, so I think we can add one more argument. What do you think about this? If it is accepted, we can set native thread name from Java launcher. Thanks, Yasumasa On 2016/04/15 19:16, David Holmes wrote: > Hi Yasumasa, > > On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >> Hi David, >> >>> The fact that the "main" thread is not tagged as being a JNI-attached >>> thread seems accidental to me >> >> Should I file it to JBS? > > I think it is a bug based on the comment here: > > JavaThread(bool is_attaching_via_jni = false); // for main thread and JNI attached threads > > Though that will introduce a change in behaviour by itself as setName will no longer set the native name for the main thread. > >> I think that we can fix as below: >> --------------- >> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >> @@ -3592,7 +3592,7 @@ >> #endif // INCLUDE_JVMCI >> >> // Attach the main thread to this os thread >> - JavaThread* main_thread = new JavaThread(); >> + JavaThread* main_thread = new JavaThread(true); >> main_thread->set_thread_state(_thread_in_vm); >> main_thread->initialize_thread_current(); >> // must do this before set_active_handles >> @@ -3776,6 +3776,9 @@ >> // Notify JVMTI agents that VM initialization is complete - nop if >> no agents. >> JvmtiExport::post_vm_initialized(); >> >> + // Change attach status to "attached" >> + main_thread->set_done_attaching_via_jni(); >> + > > I think we can do this straight after the JavaThread constructor. > >> if (TRACE_START() != JNI_OK) { >> vm_exit_during_initialization("Failed to start tracing backend."); >> } >> --------------- >> >> >>> If it wants to name its native threads then it is free to do so, >> >> Currently, JVM_SetNativeThreadName() cannot change native thread name >> when the caller thread is JNI-attached thread. >> However, I think that it should be changed if Java developer calls >> Thread#setName() explicitly. >> It is not the same of changing native thread name at Threads::create_vm(). >> >> If it is allowed, I want to fix SetNativeThreadName() as below. >> What do you think about this? > > The decision to not change the name of JNI-attached threads was a deliberate one** - this functionality originated with the OSX port and it was reported that the initial feedback with this feature was to ensure it didn't mess with thread names that had been set by the host process. If we do as you propose then we will just have an inconsistency for people to complain about: "why does my native thread only have a name if I call cur.setName(cur.getName()) ?" > > ** If you follow the bugs and related discussions on this, the semantics and limitations (truncation, current thread only, non-JNI threads only) of setting the native thread name were supposed to be documented in the release notes - but as far as I can see that never happened. :( > > My position on this remains that if it is desirable for the main thread (and DestroyJavaVM thread) to have native names then the launcher needs to be setting them using the available platform APIs. Unfortunately this is complicated - as evidenced by the VM code for this - due to the need to verify API availability. > > Any change in behaviour in relation to Thread.setName would have to go through our CCC process I think. But a change in the launcher would not. > > Sorry. > > David > ----- > >> --------------- >> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >> @@ -3187,7 +3187,7 @@ >> JavaThread* thr = java_lang_Thread::thread(java_thread); >> // Thread naming only supported for the current thread, doesn't work >> for >> // target threads. >> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >> + if (Thread::current() == thr) { >> // we don't set the name of an attached thread to avoid stepping >> // on other programs >> const char *thread_name = >> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >> --------------- >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/15 13:32, David Holmes wrote: >>> >>> >>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>> Roger, >>>> Thanks for your comment! >>>> >>>> David, >>>> >>>>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>>>> a new JVM function this way. >>>> >>>> I tried to call Thread#setName() after initializing VM (before calling >>>> main method), >>>> I could set native thread name. >>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set >>>> native thread name for DestroyJavaVM. >>> >>> Right - I came to the same realization earlier this morning. Which, >>> unfortunately, takes me back to the basic premise here that we don't >>> set the name of threads not created by the JVM. The fact that the >>> "main" thread is not tagged as being a JNI-attached thread seems >>> accidental to me - so JVM_SetNativeThreadName is only working by >>> accident for the initial attach, and can't be used for the >>> DestroyJavaVM part - which leaves the thread inconsistently named at >>> the native level. >>> >>> I'm afraid my view here is that the launcher has to be treated like >>> any other process that might host a JVM. If it wants to name its >>> native threads then it is free to do so, but I would not be exporting >>> a function from the JVM to do that - it would have to use the OS >>> specific API's for that on a platform-by-platform basis. >>> >>> Sorry. >>> >>> David >>> ----- >>> >>> >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>> Hi, >>>>> >>>>> Comments: >>>>> >>>>> jvm.h: The function names are too similar but perform different >>>>> functions: >>>>> >>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>> >>>>> - The first function applies to the current thread, the second one a >>>>> specific java thread. >>>>> It would seem useful for there to be a comment somewhere about what >>>>> the new function does. >>>>> >>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) instead of >>>>> (SetNativeThreadName0_t) >>>>> as is done on unix and mac. >>>>> >>>>> - macosx/native/libjli/java_md_macosx.c: >>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>> line 730 >>>>> - 738 Incorrect indentation; if possible keep the cast on the same >>>>> line as dlsym... >>>>> >>>>> $.02, Roger >>>>> >>>>> >>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>> That is an interesting question which I haven't had time to check - >>>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>> JNI-attached threads :( ) >>>>>> >>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>> thread name (test) was set. >>>>>> --------- >>>>>> public class Sleep{ >>>>>> public static void main(String[] args) throws Exception{ >>>>>> Thread.currentThread().setName("test"); >>>>>> Thread.sleep(3600000); >>>>>> } >>>>>> } >>>>>> --------- >>>>>> >>>>>> >>>>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>>>> a new JVM function this way. >>>>>> >>>>>> I will update webrev after hearing Kumar's comment. >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi David, >>>>>>>>>> >>>>>>>>>> Thanks for your comment. >>>>>>>>>> >>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>> uses it >>>>>>>>>> in new webrev. >>>>>>>>> >>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>> need to >>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>> >>>>>>>> Thanks! >>>>>>>> I'm waiting to review :-) >>>>>>>> >>>>>>>> >>>>>>>>> Personally I would have used a Java upcall to Thread.setName rather >>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>> needed in >>>>>>>>> that case. >>>>>>>> >>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>> Thread#init(), >>>>>>>> but I could not change native thread name. >>>>>>> >>>>>>> At Thread.init time the thread is not alive, which is why the native >>>>>>> name is not set. >>>>>>> >>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>> >>>>>>> That is an interesting question which I haven't had time to check - >>>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>> JNI-attached threads :( ) >>>>>>> >>>>>>> I'll wait to see what Kumar thinks about this. I don't like exposing >>>>>>> a new JVM function this way. >>>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>> thread name. >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> [1] >>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> David >>>>>>>>> >>>>>>>>>> Could you review again? >>>>>>>>>> >>>>>>>>>> - hotspot: >>>>>>>>>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> - jdk: >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>> >>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>> >>>>>>>>>>> Please see my updates to the bug (sorry have been on vacation). >>>>>>>>>>> This >>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>> set the >>>>>>>>>>> name of threads that attach via JNI, which includes the "main" >>>>>>>>>>> thread. >>>>>>>>>>> >>>>>>>>>>> David >>>>>>>>>>> >>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>> >>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>> >>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>> >>>>>>>>>>>>> /Robbin >>>>>>>>>>>>> >>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>> >>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu Mar 24 >>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native thread >>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte in VM. >>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like this is >>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle thread_group, >>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>> > + thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and naming >>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>> From sean.coffey at oracle.com Fri Apr 15 14:13:39 2016 From: sean.coffey at oracle.com (=?UTF-8?Q?Se=c3=a1n_Coffey?=) Date: Fri, 15 Apr 2016 15:13:39 +0100 Subject: RFR: 8154304: NullpointerException at LdapReferralException.getReferralContext Message-ID: <5710F713.7030402@oracle.com> I need to correct another issue related to JDK-8149450. If a getReferralContext call is made on a ReferralContext that doesn't contain any referrals (URI fields) then a null scenario is possible. There's a question mark around how compliant the LDAP BER response is but I'd like the JDK to handle the NPE and communicate back by throwing NamingException : bug ID :https://bugs.openjdk.java.net/browse/JDK-8154304 webrev : http://cr.openjdk.java.net/~coffeys/webrev.8154304.jdk9/webrev/ -- Regards, Sean. From xuelei.fan at oracle.com Fri Apr 15 14:46:12 2016 From: xuelei.fan at oracle.com (Xuelei Fan) Date: Fri, 15 Apr 2016 22:46:12 +0800 Subject: RFR: 8154304: NullpointerException at LdapReferralException.getReferralContext In-Reply-To: <5710F713.7030402@oracle.com> References: <5710F713.7030402@oracle.com> Message-ID: <5710FEB4.1060206@oracle.com> Looks nice to me. It would be nice to update the copyright date, too. Thanks, Xuelei On 4/15/2016 10:13 PM, Se?n Coffey wrote: > I need to correct another issue related to JDK-8149450. If a > getReferralContext call is made on a ReferralContext that doesn't > contain any referrals (URI fields) then a null scenario is possible. > There's a question mark around how compliant the LDAP BER response is > but I'd like the JDK to handle the NPE and communicate back by throwing > NamingException : > > bug ID :https://bugs.openjdk.java.net/browse/JDK-8154304 > webrev : http://cr.openjdk.java.net/~coffeys/webrev.8154304.jdk9/webrev/ > > -- > Regards, > Sean. > From felix.yang at oracle.com Fri Apr 15 14:56:59 2016 From: felix.yang at oracle.com (Felix Yang) Date: Fri, 15 Apr 2016 22:56:59 +0800 Subject: RFR 8146758, NetworkInterfaceStreamTest.java fails intermittently at comparing network interfaces In-Reply-To: <5710C657.4060700@oracle.com> References: <56DDA68A.6000907@oracle.com> <5710B472.80506@oracle.com> <5710C657.4060700@oracle.com> Message-ID: <5711013B.2000706@oracle.com> Hi Chris, thanks for the review. Could you sponsor the change? Thanks, Felix On 2016/4/15 18:45, Chris Hegarty wrote: > On 15/04/16 10:29, Felix Yang wrote: >> Hi all, >> please review the following fix. It is an intermittent failure >> because of Teredo Tunneling Pseudo-Interface. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8146758 >> Webrev: http://cr.openjdk.java.net/~xiaofeya/8146758/webrev.00/ > > Looks ok to me. > > -Chris. From brian.burkhalter at oracle.com Fri Apr 15 15:25:00 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Fri, 15 Apr 2016 08:25:00 -0700 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <57107568.7040101@oracle.com> References: <570D90F1.7050608@oracle.com> <5710324D.3090403@oracle.com> <57107568.7040101@oracle.com> Message-ID: <464E678E-3A33-4978-BEEA-DCA261397D69@oracle.com> Hi Joe, Dmitry, On Apr 14, 2016, at 10:00 PM, joe darcy wrote: > Thank you for the careful review. I second that. > Final webrev with minor adjustments at > > http://cr.openjdk.java.net/~darcy/4851642.2/ I think this looks good. Brian From chris.hegarty at oracle.com Fri Apr 15 18:14:44 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 15 Apr 2016 19:14:44 +0100 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: <1BABDEBF-BA50-438D-8E6E-11CFCB92C436@oracle.com> Partial review. The changes to j.l.Thread* look good to me. -Chris. On 14 Apr 2016, at 02:50, Stuart Marks wrote: > Hi all, > > Please review this first round of deprecation changes for the java.lang package. This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > The newly deprecated APIs include all of the constructors for the boxed primitives. We don't intend to remove these yet, so they don't declare a value for the forRemoval element, implying the default value of false. The constructors being deprecated are as follows: > > Boolean(boolean) > Boolean(String) > Byte(byte) > Byte(String) > Character(char) > Double(double) > Double(String) > Float(float) > Float(double) > Float(String) > Integer(int) > Integer(String) > Long(long) > Long(String) > Short(short) > Short(String) > > The methods being deprecated with forRemoval=true are listed below. All of these methods have already been deprecated. They are all ill-defined, or they don't work, or they don't do anything useful. > > Runtime.getLocalizedInputStream(InputStream) > Runtime.getLocalizedOutputStream(OutputStream) > Runtime.runFinalizersOnExit(boolean) > SecurityManager.checkAwtEventQueueAccess() > SecurityManager.checkMemberAccess(Class, int) > SecurityManager.checkSystemClipboardAccess() > SecurityManager.checkTopLevelWindow(Object) > System.runFinalizersOnExit(boolean) > Thread.countStackFrames() > Thread.destroy() > Thread.stop(Throwable) > > Most of the files in the changeset are cleanups. Some of them are simply the addition of the "since" element to the @Deprecated annotation, to indicate the version in which the API became deprecated. > > The rest of the changes are cleanup of warnings that were created by the deprecation of the boxed primitive constructors. There are a total of a couple hundred such uses sprinkled around the JDK. I've taken care of a portion of them, with the exception of the java.desktop module, which alone has over 100 uses of boxed primitive constructors. I've disabled deprecation warnings for the java.desktop module for the time being; these uses can be cleaned up later. I've filed JDK-8154213 to cover this cleanup task. > > For the warnings cleanups I did, I mostly did conversions of the form: > > new Double(dval) > > to > > Double.valueOf(dval) > > This is a very safe transformation. It changes the behavior only in the cases where the code relies on getting a new instance of the box object instead of one that might come out of a cache. I didn't see any such code (and I should hope there's no such code in the JDK!). > > I applied autoboxing only sparingly, in the cases where it was an obviously safe thing to do, or where nearby code already uses autoboxing. Autoboxing actually generates a call to the appropriate valueOf() method, so the bytecode would be the same in most cases. The only difference is clutter in the source code. On the other hand, there's some risk in converting to autoboxing, as the implicitly autoboxed type might end up different from an explicit call to valueOf(). This isn't always obvious, so that's why I mostly avoided autoboxing. > > Thanks, > > s'marks > From stuart.marks at oracle.com Fri Apr 15 20:34:45 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 15 Apr 2016 13:34:45 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <57107B6B.5070100@javaspecialists.eu> References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> <5710234A.2060001@oracle.com> <57107B6B.5070100@javaspecialists.eu> Message-ID: <57115065.4050504@oracle.com> On 4/14/16 10:26 PM, Dr Heinz M. Kabutz wrote: > Vladimir Ivanov wrote: >> I'd say it's a motivating example to improve EA implementation in C2, but not >> to avoid deprecation of public constructors in primitive type boxes. It >> shouldn't matter for C2 whether Integer.valueOf() or Integer:: is used. >> If it does, it's a bug. >> > To do that would probably require a change to the Java Language Specification to > allow us to get rid of the IntegerCache. Unfortunately it is defined to have a > range of -128 to 127 at least in the cache, so this probably makes it really > hard or impossible to optimize this with EA. I always found it amusing that the > killer application for EA, getting rid of autoboxed Integer objects, didn't > really work :-) > > Stuart, I'm not a great fan of @SuppressWarning() and would personally prefer > the constructors for integer types to stay non-deprecated. Boolean's constructor > is fine to deprecate, as are Double and Float. Vladimir, Heinz, Thanks for thinking about this. I'd love to see EA improved. It might be possible to do so without any changes to the specs... but we can also change the specs, within limits, if it will make it easier to do EA or other optimizations. I'll note that in Integer.valueOf(), the cache range is from -128 to 127 inclusive. The lower bound is a constant, but the upper bound is set by a property and thus isn't a constant! This is set by -XX:AutoBoxCacheMax and also by -XX:+AggressiveOpts I think. Would turning the upper bound into a compile time constant make things any easier? It's not clear to me the ability to set the cache range is of any use. In any case the main goal here is to pave the way toward value objects, and to get their full benefit, code needs to migrate away from constructs that expose the identity of the boxed values. This applies to all of the boxed primitives. s'marks From stuart.marks at oracle.com Fri Apr 15 20:45:47 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 15 Apr 2016 13:45:47 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: References: <570EF756.2090602@oracle.com> <570FAB0C.7070505@javaspecialists.eu> <57101D11.6060109@oracle.com> <5710234A.2060001@oracle.com> <57107B6B.5070100@javaspecialists.eu> <156109556.331763.1460706579669.JavaMail.zimbra@u-pem.fr> Message-ID: <571152FB.10901@oracle.com> Hi Stephen, Remi, I would *love* to just get rid of the caches of integral boxed types and get rid of their constructors. Unfortunately people have been using the constructors for 20 years, but the valueOf(i) methods were added with autoboxing in Java 5, "only" 11.5 years ago. We did think about deprecating with forRemoval=true, but after some analysis we felt that, practically speaking, we wouldn't actually be able to remove them soon (i.e., in the next release after 9) so we decided not to specify forRemoval=true. The caching requirements were added to JLS 3/e (Java 5) and were adjusted in Java 8, I think. The *specification* of caching in the valueOf(i) methods wasn't added until Java 7, though I think they've always actually done the caching since Java 5. But note the JLS doesn't specify the use of valueOf(); it merely makes some equality and identity requirements. So there's some squishiness here. I doubt we'd be able to get rid of the caching entirely, but we might be able to adjust it someone to facilitate optimizations that Vladimir mentioned, or to ease the transition to value types in the future. s'marks On 4/15/16 3:51 AM, Stephen Colebourne wrote: > FWIW. I would prefer to see these constructors removed and the JLS > simplified at the earliest possible date. Not using these classes as > the value types for primitives in Valhalla would be very confusing. > Stephen > > > On 15 April 2016 at 08:49, Remi Forax wrote: >> Hi Heinz, >> i think we should go nuclear on this, deprecate the Integer constructor *and* remove the line in the spec that says that Integer.valueOf (and Byte, Short, Character, Long) uses a cache and admit that the Java spec should not have a premature optimization carved in it. >> >> About your example about EA, do you agree that if the set is declared as a Set, there is no such issue anymore ? From stuart.marks at oracle.com Fri Apr 15 20:47:04 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 15 Apr 2016 13:47:04 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <86D7F1A0-7FC8-47F0-82C8-B953A166F928@oracle.com> References: <570EF756.2090602@oracle.com> <57102406.6020408@oracle.com> <86D7F1A0-7FC8-47F0-82C8-B953A166F928@oracle.com> Message-ID: <57115348.209@oracle.com> On 4/15/16 3:38 AM, Lance Andersen wrote: > Yes I am fine with the change. I can go back and do this after your push if > you prefer, just let me know Thanks. I'm going to post an updated webrev with some other changes, so I'll just include the cleanups that Paul suggested. s'marks From kumar.x.srinivasan at oracle.com Fri Apr 15 21:13:37 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Fri, 15 Apr 2016 14:13:37 -0700 Subject: RFR: 8151056: ASM enable original deprecated methods. (simple fix) Message-ID: <57115981.2070203@oracle.com> Hello, Please review this simple fix [1] to re-instate the original deprecated methods, as a background, there were commented out because of an internal dependency [2], and since has been fixed. Thanks Kumar [1] http://cr.openjdk.java.net/~ksrini/8151056/webrev.00/ [2] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-March/039256.html From david.holmes at oracle.com Fri Apr 15 22:26:38 2016 From: david.holmes at oracle.com (David Holmes) Date: Sat, 16 Apr 2016 08:26:38 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5710EA86.6010400@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> Message-ID: <57116A9E.9070003@oracle.com> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: > Hi David, > >> I think it is a bug based on the comment here: >> >> JavaThread(bool is_attaching_via_jni = false); // for main thread and >> JNI attached threads > > I filed it to JBS as JDK-8154331. > I will send review request to hotspot-runtime-dev. > > >> Though that will introduce a change in behaviour by itself as setName >> will no longer set the native name for the main thread. > > I know. That change in behaviour may be a problem, it could be considered a regression that setName stops setting the native thread main, even though we never really intended it to work in the first place. :( Such a change needs to go through CCC. > I checked changeset history. > JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is > backported JDK 8. Yes this all came in as part of the OSX port in 7u2. > However, this function seems to be called from Thread#setNativeName() only. > In addition, Thread#setNativeName() is private method. > > Thus I think that we can add an argument to JVM_SetNativeThreadName() > for force setting. > (e.g. "bool forced") > > It makes a change of JVM API. > However, this function is NOT public, so I think we can add one more > argument. > > What do you think about this? > If it is accepted, we can set native thread name from Java launcher. The private/public aspect of the Java API is not really at issue. Yes we would add another arg to the JVM function to allow it to apply to JNI-attached threads as well (I'd prefer the arg reflect that not just "force"). However this is still a change to the exported JVM interface and so has to be approved. Further, we expect the launcher to use the supported JNI interface (as other processes would), not the internal JVM interface that exists for the JDK sources to communicate with the JVM. David ----- > > Thanks, > > Yasumasa > > > On 2016/04/15 19:16, David Holmes wrote: >> Hi Yasumasa, >> >> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>> thread seems accidental to me >>> >>> Should I file it to JBS? >> >> I think it is a bug based on the comment here: >> >> JavaThread(bool is_attaching_via_jni = false); // for main thread and >> JNI attached threads >> >> Though that will introduce a change in behaviour by itself as setName >> will no longer set the native name for the main thread. >> >>> I think that we can fix as below: >>> --------------- >>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>> @@ -3592,7 +3592,7 @@ >>> #endif // INCLUDE_JVMCI >>> >>> // Attach the main thread to this os thread >>> - JavaThread* main_thread = new JavaThread(); >>> + JavaThread* main_thread = new JavaThread(true); >>> main_thread->set_thread_state(_thread_in_vm); >>> main_thread->initialize_thread_current(); >>> // must do this before set_active_handles >>> @@ -3776,6 +3776,9 @@ >>> // Notify JVMTI agents that VM initialization is complete - nop if >>> no agents. >>> JvmtiExport::post_vm_initialized(); >>> >>> + // Change attach status to "attached" >>> + main_thread->set_done_attaching_via_jni(); >>> + >> >> I think we can do this straight after the JavaThread constructor. >> >>> if (TRACE_START() != JNI_OK) { >>> vm_exit_during_initialization("Failed to start tracing backend."); >>> } >>> --------------- >>> >>> >>>> If it wants to name its native threads then it is free to do so, >>> >>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>> when the caller thread is JNI-attached thread. >>> However, I think that it should be changed if Java developer calls >>> Thread#setName() explicitly. >>> It is not the same of changing native thread name at >>> Threads::create_vm(). >>> >>> If it is allowed, I want to fix SetNativeThreadName() as below. >>> What do you think about this? >> >> The decision to not change the name of JNI-attached threads was a >> deliberate one** - this functionality originated with the OSX port and >> it was reported that the initial feedback with this feature was to >> ensure it didn't mess with thread names that had been set by the host >> process. If we do as you propose then we will just have an >> inconsistency for people to complain about: "why does my native thread >> only have a name if I call cur.setName(cur.getName()) ?" >> >> ** If you follow the bugs and related discussions on this, the >> semantics and limitations (truncation, current thread only, non-JNI >> threads only) of setting the native thread name were supposed to be >> documented in the release notes - but as far as I can see that never >> happened. :( >> >> My position on this remains that if it is desirable for the main >> thread (and DestroyJavaVM thread) to have native names then the >> launcher needs to be setting them using the available platform APIs. >> Unfortunately this is complicated - as evidenced by the VM code for >> this - due to the need to verify API availability. >> >> Any change in behaviour in relation to Thread.setName would have to go >> through our CCC process I think. But a change in the launcher would not. >> >> Sorry. >> >> David >> ----- >> >>> --------------- >>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>> @@ -3187,7 +3187,7 @@ >>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>> // Thread naming only supported for the current thread, doesn't work >>> for >>> // target threads. >>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>> + if (Thread::current() == thr) { >>> // we don't set the name of an attached thread to avoid stepping >>> // on other programs >>> const char *thread_name = >>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>> --------------- >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/15 13:32, David Holmes wrote: >>>> >>>> >>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>> Roger, >>>>> Thanks for your comment! >>>>> >>>>> David, >>>>> >>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>> exposing >>>>>>>> a new JVM function this way. >>>>> >>>>> I tried to call Thread#setName() after initializing VM (before calling >>>>> main method), >>>>> I could set native thread name. >>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set >>>>> native thread name for DestroyJavaVM. >>>> >>>> Right - I came to the same realization earlier this morning. Which, >>>> unfortunately, takes me back to the basic premise here that we don't >>>> set the name of threads not created by the JVM. The fact that the >>>> "main" thread is not tagged as being a JNI-attached thread seems >>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>> accident for the initial attach, and can't be used for the >>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>> the native level. >>>> >>>> I'm afraid my view here is that the launcher has to be treated like >>>> any other process that might host a JVM. If it wants to name its >>>> native threads then it is free to do so, but I would not be exporting >>>> a function from the JVM to do that - it would have to use the OS >>>> specific API's for that on a platform-by-platform basis. >>>> >>>> Sorry. >>>> >>>> David >>>> ----- >>>> >>>> >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>> Hi, >>>>>> >>>>>> Comments: >>>>>> >>>>>> jvm.h: The function names are too similar but perform different >>>>>> functions: >>>>>> >>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>> >>>>>> - The first function applies to the current thread, the second one a >>>>>> specific java thread. >>>>>> It would seem useful for there to be a comment somewhere about what >>>>>> the new function does. >>>>>> >>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) instead of >>>>>> (SetNativeThreadName0_t) >>>>>> as is done on unix and mac. >>>>>> >>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>> line 730 >>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>> same >>>>>> line as dlsym... >>>>>> >>>>>> $.02, Roger >>>>>> >>>>>> >>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>> That is an interesting question which I haven't had time to check - >>>>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>> JNI-attached threads :( ) >>>>>>> >>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>> thread name (test) was set. >>>>>>> --------- >>>>>>> public class Sleep{ >>>>>>> public static void main(String[] args) throws Exception{ >>>>>>> Thread.currentThread().setName("test"); >>>>>>> Thread.sleep(3600000); >>>>>>> } >>>>>>> } >>>>>>> --------- >>>>>>> >>>>>>> >>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>> exposing >>>>>>>> a new JVM function this way. >>>>>>> >>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi David, >>>>>>>>>>> >>>>>>>>>>> Thanks for your comment. >>>>>>>>>>> >>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>> uses it >>>>>>>>>>> in new webrev. >>>>>>>>>> >>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>> need to >>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>> >>>>>>>>> Thanks! >>>>>>>>> I'm waiting to review :-) >>>>>>>>> >>>>>>>>> >>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>> rather >>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>> needed in >>>>>>>>>> that case. >>>>>>>>> >>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>> Thread#init(), >>>>>>>>> but I could not change native thread name. >>>>>>>> >>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>> native >>>>>>>> name is not set. >>>>>>>> >>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>> >>>>>>>> That is an interesting question which I haven't had time to check - >>>>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>> JNI-attached threads :( ) >>>>>>>> >>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>> exposing >>>>>>>> a new JVM function this way. >>>>>>>> >>>>>>>> Thanks, >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>> thread name. >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> [1] >>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> David >>>>>>>>>> >>>>>>>>>>> Could you review again? >>>>>>>>>>> >>>>>>>>>>> - hotspot: >>>>>>>>>>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> - jdk: >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>> >>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>> >>>>>>>>>>>> Please see my updates to the bug (sorry have been on vacation). >>>>>>>>>>>> This >>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>> set the >>>>>>>>>>>> name of threads that attach via JNI, which includes the "main" >>>>>>>>>>>> thread. >>>>>>>>>>>> >>>>>>>>>>>> David >>>>>>>>>>>> >>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>> >>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>> >>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>> >>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native thread >>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>> From brian.burkhalter at oracle.com Fri Apr 15 22:35:57 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Fri, 15 Apr 2016 15:35:57 -0700 Subject: JDK 9 RFR of 8154183: Message-ID: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> Please review at your convenience. Issue: https://bugs.openjdk.java.net/browse/JDK-8154183 Patch: http://cr.openjdk.java.net/~bpb/8154183/webrev.00/ Summary: 1) Reinstate the ObjectInputStream part of the fix for https://bugs.openjdk.java.net/browse/JDK-4150728 which was inadvertently reverted in a subsequent merge. 2) Apply the same clarifications and addition of missing exception/throws tags to both variants of readFully(). Thanks, Brian From stuart.marks at oracle.com Fri Apr 15 22:36:34 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 15 Apr 2016 15:36:34 -0700 Subject: RFR(m): 8145468u1 deprecations for java.lang Message-ID: <57116CF2.4080108@oracle.com> Hi all, Here's a small update to the jdk repo webrev for this change. There are no changes to any API deprecations or other specification changes. The changes are confined to the warnings cleanup work. http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.1.jdk/ The files changed relative to the previous webrev are as follows. src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java - revert autoboxing per Remi, add @SuppressWarnings and comments src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java src/jdk.jcmd/share/classes/sun/tools/jstat/ExpressionExecuter.java - cleanups as suggested by Paul src/java.base/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java - cleanups to windows files that I had missed previously There are also no changes to langtools or top repo; those webrevs are unchanged: http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ Thanks, s'marks From brian.burkhalter at oracle.com Fri Apr 15 22:46:28 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Fri, 15 Apr 2016 15:46:28 -0700 Subject: JDK 9 RFR of 8154183: (spec) {Data, }InputStream.read(byte[], int, int) - spec of offset argument confusing In-Reply-To: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> References: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> Message-ID: <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> Re-posted with correct subject line. On Apr 15, 2016, at 3:35 PM, Brian Burkhalter wrote: > Please review at your convenience. > > Issue: https://bugs.openjdk.java.net/browse/JDK-8154183 > Patch: http://cr.openjdk.java.net/~bpb/8154183/webrev.00/ > > Summary: > 1) Reinstate the ObjectInputStream part of the fix forhttps://bugs.openjdk.java.net/browse/JDK-4150728 which was inadvertently reverted in a subsequent merge. > 2) Apply the same clarifications and addition of missing exception/throws tags to both variants of readFully(). Thanks, Brian From martinrb at google.com Fri Apr 15 23:09:04 2016 From: martinrb at google.com (Martin Buchholz) Date: Fri, 15 Apr 2016 16:09:04 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <571026CD.2040507@oracle.com> References: <570EF756.2090602@oracle.com> <571026CD.2040507@oracle.com> Message-ID: I don't think it's practical to ever remove the boxed primitive constructors. Even less so for String, because the String(String) constructor used to be an important optimization! On Thu, Apr 14, 2016 at 4:25 PM, Stuart Marks wrote: > On 4/14/16 10:10 AM, Martin Buchholz wrote: >> >> I've been tempted by the dark side, when a class needs a value AND a >> lock (or an "identity"). Instead of doing >> >> final String val = "foo"; >> final Object lock = new Object(); >> >> one can "optimize" this ("why can't we have both?") to >> >> final String valAndLock = new String("foo"); >> >> and there are surely folks out there doing this. We should probably >> never remove those constructors. > > > Only at the end do you realize the power of the Dark Side. > > The String constructors aren't part of this round of deprecations. The main > effort here is to try to clear some room to "valorize" (as John Rose puts > it) the boxed primitives, and to make it clear that depending on identity > semantics for the boxes is something that's officially frowned upon. (ASM > notwithstanding. Ahem.) So that's why we're focusing on the boxed primitive > constructors. > > Valorizing Strings is altogether a different matter. I'm not entirely sure > how this will turn out. But weren't not yet at the point of deprecating the > String(String) constructor, much less deprecating it for removal. So this > kind of evil hack will remain safe for the time being. > > s'marks From dmitry.nadezhin at gmail.com Sat Apr 16 02:17:50 2016 From: dmitry.nadezhin at gmail.com (Dmitry Nadezhin) Date: Sat, 16 Apr 2016 05:17:50 +0300 Subject: JDK 9 RFR of JDK-4851642: Add fused mac to Java math library In-Reply-To: <57107568.7040101@oracle.com> References: <570D90F1.7050608@oracle.com> <5710324D.3090403@oracle.com> <57107568.7040101@oracle.com> Message-ID: I think that the final webrev http://cr.openjdk.java.net/~darcy/4851642.2/ is good. Thanks. On Fri, Apr 15, 2016 at 8:00 AM, joe darcy wrote: > Hi Dmitry, > > On 4/14/2016 7:43 PM, Dmitry Nadezhin wrote: > > Hi Joe, > > It looks good except a guard expression in the line Math:1550 > (tmp == 0.0 && a == 0.0 || b == 0.0) > Variables a and b occur asymmetrically in this expression. > A symmetrical expression would be either > (a == 0.0 || b == 0.0) > or > (product.signum() == 0) > > > Thank you for the careful review. I wrote some additional tests to cover > those cases. I believe the current code is functionally correct since (a == > 0.0 || b == 0.0) implies tmp == 0.0, but I've changed the guard to > > (a == 0.0 || b == 0.0) > > and added some more comments. The code in question is now: > > } else { // All inputs finite > BigDecimal product = (new BigDecimal(a)).multiply(new > BigDecimal(b)); > if (c == 0.0) { // Positive or negative zero > // If the product is an exact zero, use a > // floating-point expression to compute the sign > // of the zero final result. The product is an > // exact zero if and only if at least one of a and > // b is zero. > if (a == 0.0 || b == 0.0) { > return a * b + c; > } else { > // The sign of a zero addend doesn't matter if > // the product is nonzero. The sign of a zero > // addend is not factored in the result if the > // exact product is nonzero but underflows to > // zero; see IEEE-754 2008 section 6.3 "The > // sign bit". > return product.doubleValue(); > } > } else { > return product.add(new BigDecimal(c)).doubleValue(); > } > } > > Final webrev with minor adjustments at > > http://cr.openjdk.java.net/~darcy/4851642.2/ > > Thanks, > > -Joe > > > On Fri, Apr 15, 2016 at 3:14 AM, joe darcy wrote: > >> Hello, >> >> In response to the review comments from Dmitry and Brian, I've prepared >> another iteration of the webrev: >> >> http://cr.openjdk.java.net/~darcy/4851642.1/ >> >> Summary of the changes: >> >> * Renamed the method to "fma" to follow the precedent of the C library. >> * Added API note citing IEEE 754 operation. >> * More test cases >> * More comments >> * Restructured handling of finite double value to be more straightforward. >> >> Thanks, >> >> -Joe >> >> >> On 4/12/2016 5:21 PM, joe darcy wrote: >> >>> Hello, >>> >>> Please review the changes for >>> >>> JDK-4851642: Add fused mac to Java math library >>> http://cr.openjdk.java.net/~darcy/4851642.0/ >>> >>> Fused mac (multiply-accumulate) is a ternary floating-point operation >>> which accepts three inputs, a, b, c, and computes >>> >>> a * b + c >>> >>> with a single rounding error rather than the usual two rounding errors >>> (a first for the multiply, a second one for the add). The fused mac >>> operation was added in the 2008 update to the IEEE 754 floating-point >>> standard and hardware support for the operation is becoming more and more >>> common in different processor families. >>> >>> When present as a hardware instruction, a fused mac can speed up loops >>> such as those for polynomial evaluation. A fused mac can also be used to >>> support a correctly rounding floating-point divide and support various >>> higher-precision operations such as "doubled-double" arithmetic. >>> >>> With the increasing availability of fused mac as a hardware primitive, >>> the time has come to add fused mac to the Java math library. Fused mac is >>> an ideal candidate to be intrinsified where hardware support is available. >>> However, this initial implementation does not attempt to add any such >>> intrinsics support in HotSpot; a follow-up RFE has been filed for that work >>> (JDK-8154122). The current library implementation favors code simplicity >>> over speed; a more performant implementation could be written by directly >>> decomposing the floating-point inputs rather than turning to BigDecimal and >>> may be written in the future. More extensive tests could be added in the >>> future as well. >>> >>> Thanks, >>> >>> -Joe >>> >> >> > > From yasuenag at gmail.com Sat Apr 16 05:27:36 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Sat, 16 Apr 2016 14:27:36 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57116A9E.9070003@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> Message-ID: <5711CD48.7010403@gmail.com> Hi David, > That change in behaviour may be a problem, it could be considered a regression that setName stops setting the native thread main, even though we never really intended it to work in the first place. :( Such a change needs to go through CCC. I understood. Can I send CCC request? (I'm jdk 9 commiter, but I'm not employee at Oracle.) I want to continue to discuss about it on JDK-8154331 [1]. > Further, we expect the launcher to use the supported JNI interface (as other processes would), not the internal JVM interface that exists for the JDK sources to communicate with the JVM. I think that we do not use JVM interface if we add new method in LauncherHelper as below: ---------------- diff -r f02139a1ac84 src/java.base/share/classes/sun/launcher/LauncherHelper.java --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java Wed Apr 13 14:19:30 2016 +0000 +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java Sat Apr 16 11:25:53 2016 +0900 @@ -960,4 +960,8 @@ else return md.toNameAndVersion() + " (" + loc + ")"; } + + static void setNativeThreadName(String name) { + Thread.currentThread().setName(name); + } } diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 2016 +0000 +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 2016 +0900 @@ -125,6 +125,7 @@ static void PrintUsage(JNIEnv* env, jboolean doXUsage); static void ShowSettings(JNIEnv* env, char *optString); static void ListModules(JNIEnv* env, char *optString); +static void SetNativeThreadName(JNIEnv* env, char *name); static void SetPaths(int argc, char **argv); @@ -325,6 +326,7 @@ * mainThread.isAlive() to work as expected. */ #define LEAVE() \ + SetNativeThreadName(env, "DestroyJavaVM"); \ do { \ if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ JLI_ReportErrorMessage(JVM_ERROR2); \ @@ -488,6 +490,9 @@ mainArgs = CreateApplicationArgs(env, argv, argc); CHECK_EXCEPTION_NULL_LEAVE(mainArgs); + /* Set native thread name. */ + SetNativeThreadName(env, "main"); + /* Invoke main method. */ (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); @@ -1686,6 +1691,22 @@ joptString); } +/** + * Set native thread name as possible. + */ +static void +SetNativeThreadName(JNIEnv *env, char *name) +{ + jmethodID setNativeThreadNameID; + jstring nameString; + jclass cls = GetLauncherHelperClass(env); + NULL_CHECK(cls); + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, + "setNativeThreadName", "(Ljava/lang/String;)V")); + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, nameString); +} + /* * Prints default usage or the Xusage message, see sun.launcher.LauncherHelper.java */ ---------------- So I want to add new arg to JVM_SetNativeThreadName(). > However this is still a change to the exported JVM interface and so has to be approved. Do you mean that this change needs CCC? Thanks, Yasumasa [1] http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html On 2016/04/16 7:26, David Holmes wrote: > On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >> Hi David, >> >>> I think it is a bug based on the comment here: >>> >>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>> JNI attached threads >> >> I filed it to JBS as JDK-8154331. >> I will send review request to hotspot-runtime-dev. >> >> >>> Though that will introduce a change in behaviour by itself as setName >>> will no longer set the native name for the main thread. >> >> I know. > > That change in behaviour may be a problem, it could be considered a regression that setName stops setting the native thread main, even though we never really intended it to work in the first place. :( Such a change needs to go through CCC. > >> I checked changeset history. >> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >> backported JDK 8. > > Yes this all came in as part of the OSX port in 7u2. > >> However, this function seems to be called from Thread#setNativeName() only. >> In addition, Thread#setNativeName() is private method. >> >> Thus I think that we can add an argument to JVM_SetNativeThreadName() >> for force setting. >> (e.g. "bool forced") >> >> It makes a change of JVM API. >> However, this function is NOT public, so I think we can add one more >> argument. >> >> What do you think about this? >> If it is accepted, we can set native thread name from Java launcher. > > The private/public aspect of the Java API is not really at issue. Yes we would add another arg to the JVM function to allow it to apply to JNI-attached threads as well (I'd prefer the arg reflect that not just "force"). However this is still a change to the exported JVM interface and so has to be approved. Further, we expect the launcher to use the supported JNI interface (as other processes would), not the internal JVM interface that exists for the JDK sources to communicate with the JVM. > > David > ----- > >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/15 19:16, David Holmes wrote: >>> Hi Yasumasa, >>> >>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>>> thread seems accidental to me >>>> >>>> Should I file it to JBS? >>> >>> I think it is a bug based on the comment here: >>> >>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>> JNI attached threads >>> >>> Though that will introduce a change in behaviour by itself as setName >>> will no longer set the native name for the main thread. >>> >>>> I think that we can fix as below: >>>> --------------- >>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>>> @@ -3592,7 +3592,7 @@ >>>> #endif // INCLUDE_JVMCI >>>> >>>> // Attach the main thread to this os thread >>>> - JavaThread* main_thread = new JavaThread(); >>>> + JavaThread* main_thread = new JavaThread(true); >>>> main_thread->set_thread_state(_thread_in_vm); >>>> main_thread->initialize_thread_current(); >>>> // must do this before set_active_handles >>>> @@ -3776,6 +3776,9 @@ >>>> // Notify JVMTI agents that VM initialization is complete - nop if >>>> no agents. >>>> JvmtiExport::post_vm_initialized(); >>>> >>>> + // Change attach status to "attached" >>>> + main_thread->set_done_attaching_via_jni(); >>>> + >>> >>> I think we can do this straight after the JavaThread constructor. >>> >>>> if (TRACE_START() != JNI_OK) { >>>> vm_exit_during_initialization("Failed to start tracing backend."); >>>> } >>>> --------------- >>>> >>>> >>>>> If it wants to name its native threads then it is free to do so, >>>> >>>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>>> when the caller thread is JNI-attached thread. >>>> However, I think that it should be changed if Java developer calls >>>> Thread#setName() explicitly. >>>> It is not the same of changing native thread name at >>>> Threads::create_vm(). >>>> >>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>> What do you think about this? >>> >>> The decision to not change the name of JNI-attached threads was a >>> deliberate one** - this functionality originated with the OSX port and >>> it was reported that the initial feedback with this feature was to >>> ensure it didn't mess with thread names that had been set by the host >>> process. If we do as you propose then we will just have an >>> inconsistency for people to complain about: "why does my native thread >>> only have a name if I call cur.setName(cur.getName()) ?" >>> >>> ** If you follow the bugs and related discussions on this, the >>> semantics and limitations (truncation, current thread only, non-JNI >>> threads only) of setting the native thread name were supposed to be >>> documented in the release notes - but as far as I can see that never >>> happened. :( >>> >>> My position on this remains that if it is desirable for the main >>> thread (and DestroyJavaVM thread) to have native names then the >>> launcher needs to be setting them using the available platform APIs. >>> Unfortunately this is complicated - as evidenced by the VM code for >>> this - due to the need to verify API availability. >>> >>> Any change in behaviour in relation to Thread.setName would have to go >>> through our CCC process I think. But a change in the launcher would not. >>> >>> Sorry. >>> >>> David >>> ----- >>> >>>> --------------- >>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>>> @@ -3187,7 +3187,7 @@ >>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>> // Thread naming only supported for the current thread, doesn't work >>>> for >>>> // target threads. >>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>> + if (Thread::current() == thr) { >>>> // we don't set the name of an attached thread to avoid stepping >>>> // on other programs >>>> const char *thread_name = >>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>> --------------- >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/15 13:32, David Holmes wrote: >>>>> >>>>> >>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>> Roger, >>>>>> Thanks for your comment! >>>>>> >>>>>> David, >>>>>> >>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>> exposing >>>>>>>>> a new JVM function this way. >>>>>> >>>>>> I tried to call Thread#setName() after initializing VM (before calling >>>>>> main method), >>>>>> I could set native thread name. >>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't set >>>>>> native thread name for DestroyJavaVM. >>>>> >>>>> Right - I came to the same realization earlier this morning. Which, >>>>> unfortunately, takes me back to the basic premise here that we don't >>>>> set the name of threads not created by the JVM. The fact that the >>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>> accident for the initial attach, and can't be used for the >>>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>>> the native level. >>>>> >>>>> I'm afraid my view here is that the launcher has to be treated like >>>>> any other process that might host a JVM. If it wants to name its >>>>> native threads then it is free to do so, but I would not be exporting >>>>> a function from the JVM to do that - it would have to use the OS >>>>> specific API's for that on a platform-by-platform basis. >>>>> >>>>> Sorry. >>>>> >>>>> David >>>>> ----- >>>>> >>>>> >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>> Hi, >>>>>>> >>>>>>> Comments: >>>>>>> >>>>>>> jvm.h: The function names are too similar but perform different >>>>>>> functions: >>>>>>> >>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>> >>>>>>> - The first function applies to the current thread, the second one a >>>>>>> specific java thread. >>>>>>> It would seem useful for there to be a comment somewhere about what >>>>>>> the new function does. >>>>>>> >>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) instead of >>>>>>> (SetNativeThreadName0_t) >>>>>>> as is done on unix and mac. >>>>>>> >>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>> line 730 >>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>> same >>>>>>> line as dlsym... >>>>>>> >>>>>>> $.02, Roger >>>>>>> >>>>>>> >>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>> That is an interesting question which I haven't had time to check - >>>>>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>> JNI-attached threads :( ) >>>>>>>> >>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>> thread name (test) was set. >>>>>>>> --------- >>>>>>>> public class Sleep{ >>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>> Thread.currentThread().setName("test"); >>>>>>>> Thread.sleep(3600000); >>>>>>>> } >>>>>>>> } >>>>>>>> --------- >>>>>>>> >>>>>>>> >>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>> exposing >>>>>>>>> a new JVM function this way. >>>>>>>> >>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Hi David, >>>>>>>>>>>> >>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>> >>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>>> uses it >>>>>>>>>>>> in new webrev. >>>>>>>>>>> >>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>> need to >>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>> >>>>>>>>>> Thanks! >>>>>>>>>> I'm waiting to review :-) >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>> rather >>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>> needed in >>>>>>>>>>> that case. >>>>>>>>>> >>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>> Thread#init(), >>>>>>>>>> but I could not change native thread name. >>>>>>>>> >>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>> native >>>>>>>>> name is not set. >>>>>>>>> >>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>> >>>>>>>>> That is an interesting question which I haven't had time to check - >>>>>>>>> sorry. If the main thread is considered a JNI-attached thread then >>>>>>>>> my suggestion wont work. If it isn't then my suggestion should work >>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>> JNI-attached threads :( ) >>>>>>>>> >>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>> exposing >>>>>>>>> a new JVM function this way. >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> David >>>>>>>>> ----- >>>>>>>>> >>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>> thread name. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> [1] >>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> David >>>>>>>>>>> >>>>>>>>>>>> Could you review again? >>>>>>>>>>>> >>>>>>>>>>>> - hotspot: >>>>>>>>>>>> >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> - jdk: >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>> >>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>> >>>>>>>>>>>>> Please see my updates to the bug (sorry have been on vacation). >>>>>>>>>>>>> This >>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>> set the >>>>>>>>>>>>> name of threads that attach via JNI, which includes the "main" >>>>>>>>>>>>> thread. >>>>>>>>>>>>> >>>>>>>>>>>>> David >>>>>>>>>>>>> >>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>> >>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>> >>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native thread >>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name should >>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus the >>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with pthread_join(). >>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have some >>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have native >>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>> From david.holmes at oracle.com Sat Apr 16 07:09:08 2016 From: david.holmes at oracle.com (David Holmes) Date: Sat, 16 Apr 2016 17:09:08 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5711CD48.7010403@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> Message-ID: <5711E514.3060408@oracle.com> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: > Hi David, > >> That change in behaviour may be a problem, it could be considered a >> regression that setName stops setting the native thread main, even >> though we never really intended it to work in the first place. :( Such >> a change needs to go through CCC. > > I understood. > Can I send CCC request? > (I'm jdk 9 commiter, but I'm not employee at Oracle.) Sorry you can't file a CCC request, you would need a sponsor for that. But at this stage I don't think I agree with the proposed change because of the change in behaviour - there's no way to restore the "broken" behaviour. > I want to continue to discuss about it on JDK-8154331 [1]. Okay we can do that. > >> Further, we expect the launcher to use the supported JNI interface (as >> other processes would), not the internal JVM interface that exists for >> the JDK sources to communicate with the JVM. > > I think that we do not use JVM interface if we add new method in > LauncherHelper as below: > ---------------- > diff -r f02139a1ac84 > src/java.base/share/classes/sun/launcher/LauncherHelper.java > --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java > Wed Apr 13 14:19:30 2016 +0000 > +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java > Sat Apr 16 11:25:53 2016 +0900 > @@ -960,4 +960,8 @@ > else > return md.toNameAndVersion() + " (" + loc + ")"; > } > + > + static void setNativeThreadName(String name) { > + Thread.currentThread().setName(name); > + } You could also make that call via JNI directly, so not sure the helper adds much here. But it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? David ----- > } > diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c > --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 > 2016 +0000 > +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 > 2016 +0900 > @@ -125,6 +125,7 @@ > static void PrintUsage(JNIEnv* env, jboolean doXUsage); > static void ShowSettings(JNIEnv* env, char *optString); > static void ListModules(JNIEnv* env, char *optString); > +static void SetNativeThreadName(JNIEnv* env, char *name); > > static void SetPaths(int argc, char **argv); > > @@ -325,6 +326,7 @@ > * mainThread.isAlive() to work as expected. > */ > #define LEAVE() \ > + SetNativeThreadName(env, "DestroyJavaVM"); \ > do { \ > if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ > JLI_ReportErrorMessage(JVM_ERROR2); \ > @@ -488,6 +490,9 @@ > mainArgs = CreateApplicationArgs(env, argv, argc); > CHECK_EXCEPTION_NULL_LEAVE(mainArgs); > > + /* Set native thread name. */ > + SetNativeThreadName(env, "main"); > + > /* Invoke main method. */ > (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); > > @@ -1686,6 +1691,22 @@ > joptString); > } > > +/** > + * Set native thread name as possible. > + */ > +static void > +SetNativeThreadName(JNIEnv *env, char *name) > +{ > + jmethodID setNativeThreadNameID; > + jstring nameString; > + jclass cls = GetLauncherHelperClass(env); > + NULL_CHECK(cls); > + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, > + "setNativeThreadName", "(Ljava/lang/String;)V")); > + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, > nameString); > +} > + > /* > * Prints default usage or the Xusage message, see > sun.launcher.LauncherHelper.java > */ > ---------------- > > So I want to add new arg to JVM_SetNativeThreadName(). > >> However this is still a change to the exported JVM interface and so >> has to be approved. > > Do you mean that this change needs CCC? > > > Thanks, > > Yasumasa > > > [1] > http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html > > > > On 2016/04/16 7:26, David Holmes wrote: >> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> I think it is a bug based on the comment here: >>>> >>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>> JNI attached threads >>> >>> I filed it to JBS as JDK-8154331. >>> I will send review request to hotspot-runtime-dev. >>> >>> >>>> Though that will introduce a change in behaviour by itself as setName >>>> will no longer set the native name for the main thread. >>> >>> I know. >> >> That change in behaviour may be a problem, it could be considered a >> regression that setName stops setting the native thread main, even >> though we never really intended it to work in the first place. :( Such >> a change needs to go through CCC. >> >>> I checked changeset history. >>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>> backported JDK 8. >> >> Yes this all came in as part of the OSX port in 7u2. >> >>> However, this function seems to be called from Thread#setNativeName() >>> only. >>> In addition, Thread#setNativeName() is private method. >>> >>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>> for force setting. >>> (e.g. "bool forced") >>> >>> It makes a change of JVM API. >>> However, this function is NOT public, so I think we can add one more >>> argument. >>> >>> What do you think about this? >>> If it is accepted, we can set native thread name from Java launcher. >> >> The private/public aspect of the Java API is not really at issue. Yes >> we would add another arg to the JVM function to allow it to apply to >> JNI-attached threads as well (I'd prefer the arg reflect that not just >> "force"). However this is still a change to the exported JVM interface >> and so has to be approved. Further, we expect the launcher to use the >> supported JNI interface (as other processes would), not the internal >> JVM interface that exists for the JDK sources to communicate with the >> JVM. >> >> David >> ----- >> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/15 19:16, David Holmes wrote: >>>> Hi Yasumasa, >>>> >>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>>>> thread seems accidental to me >>>>> >>>>> Should I file it to JBS? >>>> >>>> I think it is a bug based on the comment here: >>>> >>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>> JNI attached threads >>>> >>>> Though that will introduce a change in behaviour by itself as setName >>>> will no longer set the native name for the main thread. >>>> >>>>> I think that we can fix as below: >>>>> --------------- >>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>> @@ -3592,7 +3592,7 @@ >>>>> #endif // INCLUDE_JVMCI >>>>> >>>>> // Attach the main thread to this os thread >>>>> - JavaThread* main_thread = new JavaThread(); >>>>> + JavaThread* main_thread = new JavaThread(true); >>>>> main_thread->set_thread_state(_thread_in_vm); >>>>> main_thread->initialize_thread_current(); >>>>> // must do this before set_active_handles >>>>> @@ -3776,6 +3776,9 @@ >>>>> // Notify JVMTI agents that VM initialization is complete - nop if >>>>> no agents. >>>>> JvmtiExport::post_vm_initialized(); >>>>> >>>>> + // Change attach status to "attached" >>>>> + main_thread->set_done_attaching_via_jni(); >>>>> + >>>> >>>> I think we can do this straight after the JavaThread constructor. >>>> >>>>> if (TRACE_START() != JNI_OK) { >>>>> vm_exit_during_initialization("Failed to start tracing >>>>> backend."); >>>>> } >>>>> --------------- >>>>> >>>>> >>>>>> If it wants to name its native threads then it is free to do so, >>>>> >>>>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>>>> when the caller thread is JNI-attached thread. >>>>> However, I think that it should be changed if Java developer calls >>>>> Thread#setName() explicitly. >>>>> It is not the same of changing native thread name at >>>>> Threads::create_vm(). >>>>> >>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>> What do you think about this? >>>> >>>> The decision to not change the name of JNI-attached threads was a >>>> deliberate one** - this functionality originated with the OSX port and >>>> it was reported that the initial feedback with this feature was to >>>> ensure it didn't mess with thread names that had been set by the host >>>> process. If we do as you propose then we will just have an >>>> inconsistency for people to complain about: "why does my native thread >>>> only have a name if I call cur.setName(cur.getName()) ?" >>>> >>>> ** If you follow the bugs and related discussions on this, the >>>> semantics and limitations (truncation, current thread only, non-JNI >>>> threads only) of setting the native thread name were supposed to be >>>> documented in the release notes - but as far as I can see that never >>>> happened. :( >>>> >>>> My position on this remains that if it is desirable for the main >>>> thread (and DestroyJavaVM thread) to have native names then the >>>> launcher needs to be setting them using the available platform APIs. >>>> Unfortunately this is complicated - as evidenced by the VM code for >>>> this - due to the need to verify API availability. >>>> >>>> Any change in behaviour in relation to Thread.setName would have to go >>>> through our CCC process I think. But a change in the launcher would >>>> not. >>>> >>>> Sorry. >>>> >>>> David >>>> ----- >>>> >>>>> --------------- >>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>> @@ -3187,7 +3187,7 @@ >>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>> // Thread naming only supported for the current thread, doesn't >>>>> work >>>>> for >>>>> // target threads. >>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>> + if (Thread::current() == thr) { >>>>> // we don't set the name of an attached thread to avoid stepping >>>>> // on other programs >>>>> const char *thread_name = >>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>> --------------- >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>> >>>>>> >>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>> Roger, >>>>>>> Thanks for your comment! >>>>>>> >>>>>>> David, >>>>>>> >>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>> exposing >>>>>>>>>> a new JVM function this way. >>>>>>> >>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>> calling >>>>>>> main method), >>>>>>> I could set native thread name. >>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>> set >>>>>>> native thread name for DestroyJavaVM. >>>>>> >>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>> unfortunately, takes me back to the basic premise here that we don't >>>>>> set the name of threads not created by the JVM. The fact that the >>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>> accident for the initial attach, and can't be used for the >>>>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>>>> the native level. >>>>>> >>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>> any other process that might host a JVM. If it wants to name its >>>>>> native threads then it is free to do so, but I would not be exporting >>>>>> a function from the JVM to do that - it would have to use the OS >>>>>> specific API's for that on a platform-by-platform basis. >>>>>> >>>>>> Sorry. >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>> >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> Comments: >>>>>>>> >>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>> functions: >>>>>>>> >>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>> >>>>>>>> - The first function applies to the current thread, the second >>>>>>>> one a >>>>>>>> specific java thread. >>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>> what >>>>>>>> the new function does. >>>>>>>> >>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>> instead of >>>>>>>> (SetNativeThreadName0_t) >>>>>>>> as is done on unix and mac. >>>>>>>> >>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>> line 730 >>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>> same >>>>>>>> line as dlsym... >>>>>>>> >>>>>>>> $.02, Roger >>>>>>>> >>>>>>>> >>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>> check - >>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>> then >>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>> work >>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>> JNI-attached threads :( ) >>>>>>>>> >>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>> thread name (test) was set. >>>>>>>>> --------- >>>>>>>>> public class Sleep{ >>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>> Thread.sleep(3600000); >>>>>>>>> } >>>>>>>>> } >>>>>>>>> --------- >>>>>>>>> >>>>>>>>> >>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>> exposing >>>>>>>>>> a new JVM function this way. >>>>>>>>> >>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Hi David, >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>> >>>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>>>> uses it >>>>>>>>>>>>> in new webrev. >>>>>>>>>>>> >>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>> need to >>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>> >>>>>>>>>>> Thanks! >>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>> rather >>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>> needed in >>>>>>>>>>>> that case. >>>>>>>>>>> >>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>> Thread#init(), >>>>>>>>>>> but I could not change native thread name. >>>>>>>>>> >>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>> native >>>>>>>>>> name is not set. >>>>>>>>>> >>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>> >>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>> check - >>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>> then >>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>> work >>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>> >>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>> exposing >>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> David >>>>>>>>>> ----- >>>>>>>>>> >>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>> thread name. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> [1] >>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> David >>>>>>>>>>>> >>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>> >>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> - jdk: >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>> This >>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>> set the >>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>> "main" >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>> From david.holmes at oracle.com Sat Apr 16 07:11:03 2016 From: david.holmes at oracle.com (David Holmes) Date: Sat, 16 Apr 2016 17:11:03 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5711CD48.7010403@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> Message-ID: <5711E587.4050805@oracle.com> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: > Hi David, > >> That change in behaviour may be a problem, it could be considered a >> regression that setName stops setting the native thread main, even >> though we never really intended it to work in the first place. :( Such >> a change needs to go through CCC. > > I understood. > Can I send CCC request? > (I'm jdk 9 commiter, but I'm not employee at Oracle.) Sorry you can't file a CCC request, you would need a sponsor for that. But at this stage I don't think I agree with the proposed change because of the change in behaviour - there's no way to restore the "broken" behaviour. > I want to continue to discuss about it on JDK-8154331 [1]. Okay we can do that. > >> Further, we expect the launcher to use the supported JNI interface (as >> other processes would), not the internal JVM interface that exists for >> the JDK sources to communicate with the JVM. > > I think that we do not use JVM interface if we add new method in > LauncherHelper as below: > ---------------- > diff -r f02139a1ac84 > src/java.base/share/classes/sun/launcher/LauncherHelper.java > --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java > Wed Apr 13 14:19:30 2016 +0000 > +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java > Sat Apr 16 11:25:53 2016 +0900 > @@ -960,4 +960,8 @@ > else > return md.toNameAndVersion() + " (" + loc + ")"; > } > + > + static void setNativeThreadName(String name) { > + Thread.currentThread().setName(name); > + } You could also make that call via JNI directly, so not sure the helper adds much here. But it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? David ----- > } > diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c > --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 > 2016 +0000 > +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 > 2016 +0900 > @@ -125,6 +125,7 @@ > static void PrintUsage(JNIEnv* env, jboolean doXUsage); > static void ShowSettings(JNIEnv* env, char *optString); > static void ListModules(JNIEnv* env, char *optString); > +static void SetNativeThreadName(JNIEnv* env, char *name); > > static void SetPaths(int argc, char **argv); > > @@ -325,6 +326,7 @@ > * mainThread.isAlive() to work as expected. > */ > #define LEAVE() \ > + SetNativeThreadName(env, "DestroyJavaVM"); \ > do { \ > if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ > JLI_ReportErrorMessage(JVM_ERROR2); \ > @@ -488,6 +490,9 @@ > mainArgs = CreateApplicationArgs(env, argv, argc); > CHECK_EXCEPTION_NULL_LEAVE(mainArgs); > > + /* Set native thread name. */ > + SetNativeThreadName(env, "main"); > + > /* Invoke main method. */ > (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); > > @@ -1686,6 +1691,22 @@ > joptString); > } > > +/** > + * Set native thread name as possible. > + */ > +static void > +SetNativeThreadName(JNIEnv *env, char *name) > +{ > + jmethodID setNativeThreadNameID; > + jstring nameString; > + jclass cls = GetLauncherHelperClass(env); > + NULL_CHECK(cls); > + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, > + "setNativeThreadName", "(Ljava/lang/String;)V")); > + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, > nameString); > +} > + > /* > * Prints default usage or the Xusage message, see > sun.launcher.LauncherHelper.java > */ > ---------------- > > So I want to add new arg to JVM_SetNativeThreadName(). > >> However this is still a change to the exported JVM interface and so >> has to be approved. > > Do you mean that this change needs CCC? > > > Thanks, > > Yasumasa > > > [1] > http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html > > > > On 2016/04/16 7:26, David Holmes wrote: >> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> I think it is a bug based on the comment here: >>>> >>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>> JNI attached threads >>> >>> I filed it to JBS as JDK-8154331. >>> I will send review request to hotspot-runtime-dev. >>> >>> >>>> Though that will introduce a change in behaviour by itself as setName >>>> will no longer set the native name for the main thread. >>> >>> I know. >> >> That change in behaviour may be a problem, it could be considered a >> regression that setName stops setting the native thread main, even >> though we never really intended it to work in the first place. :( Such >> a change needs to go through CCC. >> >>> I checked changeset history. >>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>> backported JDK 8. >> >> Yes this all came in as part of the OSX port in 7u2. >> >>> However, this function seems to be called from Thread#setNativeName() >>> only. >>> In addition, Thread#setNativeName() is private method. >>> >>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>> for force setting. >>> (e.g. "bool forced") >>> >>> It makes a change of JVM API. >>> However, this function is NOT public, so I think we can add one more >>> argument. >>> >>> What do you think about this? >>> If it is accepted, we can set native thread name from Java launcher. >> >> The private/public aspect of the Java API is not really at issue. Yes >> we would add another arg to the JVM function to allow it to apply to >> JNI-attached threads as well (I'd prefer the arg reflect that not just >> "force"). However this is still a change to the exported JVM interface >> and so has to be approved. Further, we expect the launcher to use the >> supported JNI interface (as other processes would), not the internal >> JVM interface that exists for the JDK sources to communicate with the >> JVM. >> >> David >> ----- >> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/15 19:16, David Holmes wrote: >>>> Hi Yasumasa, >>>> >>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>>>> thread seems accidental to me >>>>> >>>>> Should I file it to JBS? >>>> >>>> I think it is a bug based on the comment here: >>>> >>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>> JNI attached threads >>>> >>>> Though that will introduce a change in behaviour by itself as setName >>>> will no longer set the native name for the main thread. >>>> >>>>> I think that we can fix as below: >>>>> --------------- >>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>> @@ -3592,7 +3592,7 @@ >>>>> #endif // INCLUDE_JVMCI >>>>> >>>>> // Attach the main thread to this os thread >>>>> - JavaThread* main_thread = new JavaThread(); >>>>> + JavaThread* main_thread = new JavaThread(true); >>>>> main_thread->set_thread_state(_thread_in_vm); >>>>> main_thread->initialize_thread_current(); >>>>> // must do this before set_active_handles >>>>> @@ -3776,6 +3776,9 @@ >>>>> // Notify JVMTI agents that VM initialization is complete - nop if >>>>> no agents. >>>>> JvmtiExport::post_vm_initialized(); >>>>> >>>>> + // Change attach status to "attached" >>>>> + main_thread->set_done_attaching_via_jni(); >>>>> + >>>> >>>> I think we can do this straight after the JavaThread constructor. >>>> >>>>> if (TRACE_START() != JNI_OK) { >>>>> vm_exit_during_initialization("Failed to start tracing >>>>> backend."); >>>>> } >>>>> --------------- >>>>> >>>>> >>>>>> If it wants to name its native threads then it is free to do so, >>>>> >>>>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>>>> when the caller thread is JNI-attached thread. >>>>> However, I think that it should be changed if Java developer calls >>>>> Thread#setName() explicitly. >>>>> It is not the same of changing native thread name at >>>>> Threads::create_vm(). >>>>> >>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>> What do you think about this? >>>> >>>> The decision to not change the name of JNI-attached threads was a >>>> deliberate one** - this functionality originated with the OSX port and >>>> it was reported that the initial feedback with this feature was to >>>> ensure it didn't mess with thread names that had been set by the host >>>> process. If we do as you propose then we will just have an >>>> inconsistency for people to complain about: "why does my native thread >>>> only have a name if I call cur.setName(cur.getName()) ?" >>>> >>>> ** If you follow the bugs and related discussions on this, the >>>> semantics and limitations (truncation, current thread only, non-JNI >>>> threads only) of setting the native thread name were supposed to be >>>> documented in the release notes - but as far as I can see that never >>>> happened. :( >>>> >>>> My position on this remains that if it is desirable for the main >>>> thread (and DestroyJavaVM thread) to have native names then the >>>> launcher needs to be setting them using the available platform APIs. >>>> Unfortunately this is complicated - as evidenced by the VM code for >>>> this - due to the need to verify API availability. >>>> >>>> Any change in behaviour in relation to Thread.setName would have to go >>>> through our CCC process I think. But a change in the launcher would >>>> not. >>>> >>>> Sorry. >>>> >>>> David >>>> ----- >>>> >>>>> --------------- >>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>> @@ -3187,7 +3187,7 @@ >>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>> // Thread naming only supported for the current thread, doesn't >>>>> work >>>>> for >>>>> // target threads. >>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>> + if (Thread::current() == thr) { >>>>> // we don't set the name of an attached thread to avoid stepping >>>>> // on other programs >>>>> const char *thread_name = >>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>> --------------- >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>> >>>>>> >>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>> Roger, >>>>>>> Thanks for your comment! >>>>>>> >>>>>>> David, >>>>>>> >>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>> exposing >>>>>>>>>> a new JVM function this way. >>>>>>> >>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>> calling >>>>>>> main method), >>>>>>> I could set native thread name. >>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>> set >>>>>>> native thread name for DestroyJavaVM. >>>>>> >>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>> unfortunately, takes me back to the basic premise here that we don't >>>>>> set the name of threads not created by the JVM. The fact that the >>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>> accident for the initial attach, and can't be used for the >>>>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>>>> the native level. >>>>>> >>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>> any other process that might host a JVM. If it wants to name its >>>>>> native threads then it is free to do so, but I would not be exporting >>>>>> a function from the JVM to do that - it would have to use the OS >>>>>> specific API's for that on a platform-by-platform basis. >>>>>> >>>>>> Sorry. >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>> >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> Comments: >>>>>>>> >>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>> functions: >>>>>>>> >>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>> >>>>>>>> - The first function applies to the current thread, the second >>>>>>>> one a >>>>>>>> specific java thread. >>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>> what >>>>>>>> the new function does. >>>>>>>> >>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>> instead of >>>>>>>> (SetNativeThreadName0_t) >>>>>>>> as is done on unix and mac. >>>>>>>> >>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>> line 730 >>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>> same >>>>>>>> line as dlsym... >>>>>>>> >>>>>>>> $.02, Roger >>>>>>>> >>>>>>>> >>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>> check - >>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>> then >>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>> work >>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>> JNI-attached threads :( ) >>>>>>>>> >>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>> thread name (test) was set. >>>>>>>>> --------- >>>>>>>>> public class Sleep{ >>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>> Thread.sleep(3600000); >>>>>>>>> } >>>>>>>>> } >>>>>>>>> --------- >>>>>>>>> >>>>>>>>> >>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>> exposing >>>>>>>>>> a new JVM function this way. >>>>>>>>> >>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Hi David, >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>> >>>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>>>> uses it >>>>>>>>>>>>> in new webrev. >>>>>>>>>>>> >>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>> need to >>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>> >>>>>>>>>>> Thanks! >>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>> rather >>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>> needed in >>>>>>>>>>>> that case. >>>>>>>>>>> >>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>> Thread#init(), >>>>>>>>>>> but I could not change native thread name. >>>>>>>>>> >>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>> native >>>>>>>>>> name is not set. >>>>>>>>>> >>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>> >>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>> check - >>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>> then >>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>> work >>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>> >>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>> exposing >>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> David >>>>>>>>>> ----- >>>>>>>>>> >>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>> thread name. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> [1] >>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> David >>>>>>>>>>>> >>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>> >>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> - jdk: >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>> This >>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>> set the >>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>> "main" >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>> From yasuenag at gmail.com Sat Apr 16 09:29:36 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Sat, 16 Apr 2016 18:29:36 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5711E587.4050805@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> Message-ID: <57120600.6090005@gmail.com> Hi David, I uploaded new webrev: - hotspot: http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ - jdk: http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ > it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? I added a flag for setting native thread name to JNI-attached thread. This change can set native thread name if main thread changes to JNI-attached thread. Thanks, Yasumasa On 2016/04/16 16:11, David Holmes wrote: > On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >> Hi David, >> >>> That change in behaviour may be a problem, it could be considered a >>> regression that setName stops setting the native thread main, even >>> though we never really intended it to work in the first place. :( Such >>> a change needs to go through CCC. >> >> I understood. >> Can I send CCC request? >> (I'm jdk 9 commiter, but I'm not employee at Oracle.) > > Sorry you can't file a CCC request, you would need a sponsor for that. But at this stage I don't think I agree with the proposed change because of the change in behaviour - there's no way to restore the "broken" behaviour. > >> I want to continue to discuss about it on JDK-8154331 [1]. > > Okay we can do that. > >> >>> Further, we expect the launcher to use the supported JNI interface (as >>> other processes would), not the internal JVM interface that exists for >>> the JDK sources to communicate with the JVM. >> >> I think that we do not use JVM interface if we add new method in >> LauncherHelper as below: >> ---------------- >> diff -r f02139a1ac84 >> src/java.base/share/classes/sun/launcher/LauncherHelper.java >> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >> Wed Apr 13 14:19:30 2016 +0000 >> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >> Sat Apr 16 11:25:53 2016 +0900 >> @@ -960,4 +960,8 @@ >> else >> return md.toNameAndVersion() + " (" + loc + ")"; >> } >> + >> + static void setNativeThreadName(String name) { >> + Thread.currentThread().setName(name); >> + } > > You could also make that call via JNI directly, so not sure the helper adds much here. But it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? > > David > ----- > >> } >> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >> 2016 +0000 >> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >> 2016 +0900 >> @@ -125,6 +125,7 @@ >> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >> static void ShowSettings(JNIEnv* env, char *optString); >> static void ListModules(JNIEnv* env, char *optString); >> +static void SetNativeThreadName(JNIEnv* env, char *name); >> >> static void SetPaths(int argc, char **argv); >> >> @@ -325,6 +326,7 @@ >> * mainThread.isAlive() to work as expected. >> */ >> #define LEAVE() \ >> + SetNativeThreadName(env, "DestroyJavaVM"); \ >> do { \ >> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >> JLI_ReportErrorMessage(JVM_ERROR2); \ >> @@ -488,6 +490,9 @@ >> mainArgs = CreateApplicationArgs(env, argv, argc); >> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >> >> + /* Set native thread name. */ >> + SetNativeThreadName(env, "main"); >> + >> /* Invoke main method. */ >> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >> >> @@ -1686,6 +1691,22 @@ >> joptString); >> } >> >> +/** >> + * Set native thread name as possible. >> + */ >> +static void >> +SetNativeThreadName(JNIEnv *env, char *name) >> +{ >> + jmethodID setNativeThreadNameID; >> + jstring nameString; >> + jclass cls = GetLauncherHelperClass(env); >> + NULL_CHECK(cls); >> + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, >> + "setNativeThreadName", "(Ljava/lang/String;)V")); >> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >> nameString); >> +} >> + >> /* >> * Prints default usage or the Xusage message, see >> sun.launcher.LauncherHelper.java >> */ >> ---------------- >> >> So I want to add new arg to JVM_SetNativeThreadName(). >> >>> However this is still a change to the exported JVM interface and so >>> has to be approved. >> >> Do you mean that this change needs CCC? >> >> >> Thanks, >> >> Yasumasa >> >> >> [1] >> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >> >> >> >> On 2016/04/16 7:26, David Holmes wrote: >>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> I think it is a bug based on the comment here: >>>>> >>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>> JNI attached threads >>>> >>>> I filed it to JBS as JDK-8154331. >>>> I will send review request to hotspot-runtime-dev. >>>> >>>> >>>>> Though that will introduce a change in behaviour by itself as setName >>>>> will no longer set the native name for the main thread. >>>> >>>> I know. >>> >>> That change in behaviour may be a problem, it could be considered a >>> regression that setName stops setting the native thread main, even >>> though we never really intended it to work in the first place. :( Such >>> a change needs to go through CCC. >>> >>>> I checked changeset history. >>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>> backported JDK 8. >>> >>> Yes this all came in as part of the OSX port in 7u2. >>> >>>> However, this function seems to be called from Thread#setNativeName() >>>> only. >>>> In addition, Thread#setNativeName() is private method. >>>> >>>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>>> for force setting. >>>> (e.g. "bool forced") >>>> >>>> It makes a change of JVM API. >>>> However, this function is NOT public, so I think we can add one more >>>> argument. >>>> >>>> What do you think about this? >>>> If it is accepted, we can set native thread name from Java launcher. >>> >>> The private/public aspect of the Java API is not really at issue. Yes >>> we would add another arg to the JVM function to allow it to apply to >>> JNI-attached threads as well (I'd prefer the arg reflect that not just >>> "force"). However this is still a change to the exported JVM interface >>> and so has to be approved. Further, we expect the launcher to use the >>> supported JNI interface (as other processes would), not the internal >>> JVM interface that exists for the JDK sources to communicate with the >>> JVM. >>> >>> David >>> ----- >>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/15 19:16, David Holmes wrote: >>>>> Hi Yasumasa, >>>>> >>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>>>>> thread seems accidental to me >>>>>> >>>>>> Should I file it to JBS? >>>>> >>>>> I think it is a bug based on the comment here: >>>>> >>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>> JNI attached threads >>>>> >>>>> Though that will introduce a change in behaviour by itself as setName >>>>> will no longer set the native name for the main thread. >>>>> >>>>>> I think that we can fix as below: >>>>>> --------------- >>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>>> @@ -3592,7 +3592,7 @@ >>>>>> #endif // INCLUDE_JVMCI >>>>>> >>>>>> // Attach the main thread to this os thread >>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>> main_thread->initialize_thread_current(); >>>>>> // must do this before set_active_handles >>>>>> @@ -3776,6 +3776,9 @@ >>>>>> // Notify JVMTI agents that VM initialization is complete - nop if >>>>>> no agents. >>>>>> JvmtiExport::post_vm_initialized(); >>>>>> >>>>>> + // Change attach status to "attached" >>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>> + >>>>> >>>>> I think we can do this straight after the JavaThread constructor. >>>>> >>>>>> if (TRACE_START() != JNI_OK) { >>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>> backend."); >>>>>> } >>>>>> --------------- >>>>>> >>>>>> >>>>>>> If it wants to name its native threads then it is free to do so, >>>>>> >>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>>>>> when the caller thread is JNI-attached thread. >>>>>> However, I think that it should be changed if Java developer calls >>>>>> Thread#setName() explicitly. >>>>>> It is not the same of changing native thread name at >>>>>> Threads::create_vm(). >>>>>> >>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>> What do you think about this? >>>>> >>>>> The decision to not change the name of JNI-attached threads was a >>>>> deliberate one** - this functionality originated with the OSX port and >>>>> it was reported that the initial feedback with this feature was to >>>>> ensure it didn't mess with thread names that had been set by the host >>>>> process. If we do as you propose then we will just have an >>>>> inconsistency for people to complain about: "why does my native thread >>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>> >>>>> ** If you follow the bugs and related discussions on this, the >>>>> semantics and limitations (truncation, current thread only, non-JNI >>>>> threads only) of setting the native thread name were supposed to be >>>>> documented in the release notes - but as far as I can see that never >>>>> happened. :( >>>>> >>>>> My position on this remains that if it is desirable for the main >>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>> launcher needs to be setting them using the available platform APIs. >>>>> Unfortunately this is complicated - as evidenced by the VM code for >>>>> this - due to the need to verify API availability. >>>>> >>>>> Any change in behaviour in relation to Thread.setName would have to go >>>>> through our CCC process I think. But a change in the launcher would >>>>> not. >>>>> >>>>> Sorry. >>>>> >>>>> David >>>>> ----- >>>>> >>>>>> --------------- >>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>>> @@ -3187,7 +3187,7 @@ >>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>> // Thread naming only supported for the current thread, doesn't >>>>>> work >>>>>> for >>>>>> // target threads. >>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>>> + if (Thread::current() == thr) { >>>>>> // we don't set the name of an attached thread to avoid stepping >>>>>> // on other programs >>>>>> const char *thread_name = >>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>> --------------- >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>> >>>>>>> >>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>> Roger, >>>>>>>> Thanks for your comment! >>>>>>>> >>>>>>>> David, >>>>>>>> >>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>> exposing >>>>>>>>>>> a new JVM function this way. >>>>>>>> >>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>> calling >>>>>>>> main method), >>>>>>>> I could set native thread name. >>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>>> set >>>>>>>> native thread name for DestroyJavaVM. >>>>>>> >>>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>>> unfortunately, takes me back to the basic premise here that we don't >>>>>>> set the name of threads not created by the JVM. The fact that the >>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>> accident for the initial attach, and can't be used for the >>>>>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>>>>> the native level. >>>>>>> >>>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>> native threads then it is free to do so, but I would not be exporting >>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>> >>>>>>> Sorry. >>>>>>> >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> Comments: >>>>>>>>> >>>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>>> functions: >>>>>>>>> >>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>> >>>>>>>>> - The first function applies to the current thread, the second >>>>>>>>> one a >>>>>>>>> specific java thread. >>>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>>> what >>>>>>>>> the new function does. >>>>>>>>> >>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>> instead of >>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>> as is done on unix and mac. >>>>>>>>> >>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>>> line 730 >>>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>>> same >>>>>>>>> line as dlsym... >>>>>>>>> >>>>>>>>> $.02, Roger >>>>>>>>> >>>>>>>>> >>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>> check - >>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>> then >>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>> work >>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>> >>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>>> thread name (test) was set. >>>>>>>>>> --------- >>>>>>>>>> public class Sleep{ >>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>> } >>>>>>>>>> } >>>>>>>>>> --------- >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>> exposing >>>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>> >>>>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>>>>> uses it >>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>> >>>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>>> need to >>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>> >>>>>>>>>>>> Thanks! >>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>>> rather >>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>> needed in >>>>>>>>>>>>> that case. >>>>>>>>>>>> >>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>> Thread#init(), >>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>> >>>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>>> native >>>>>>>>>>> name is not set. >>>>>>>>>>> >>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>> >>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>> check - >>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>> then >>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>> work >>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>> >>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>> exposing >>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> David >>>>>>>>>>> ----- >>>>>>>>>>> >>>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>>> thread name. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> [1] >>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> David >>>>>>>>>>>>> >>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>> >>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>> This >>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> David >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> From sean.coffey at oracle.com Sat Apr 16 12:16:34 2016 From: sean.coffey at oracle.com (=?UTF-8?Q?Se=c3=a1n_Coffey?=) Date: Sat, 16 Apr 2016 13:16:34 +0100 Subject: RFR: 8154304: NullpointerException at LdapReferralException.getReferralContext In-Reply-To: <5710FEB4.1060206@oracle.com> References: <5710F713.7030402@oracle.com> <5710FEB4.1060206@oracle.com> Message-ID: <57122D22.6000101@oracle.com> Thanks. Corrected copyright and pushed. http://hg.openjdk.java.net/jdk9/dev/jdk/rev/e2b04e57b51a Regards, Sean. On 15/04/2016 15:46, Xuelei Fan wrote: > Looks nice to me. It would be nice to update the copyright date, too. > > Thanks, > Xuelei > > On 4/15/2016 10:13 PM, Se?n Coffey wrote: >> I need to correct another issue related to JDK-8149450. If a >> getReferralContext call is made on a ReferralContext that doesn't >> contain any referrals (URI fields) then a null scenario is possible. >> There's a question mark around how compliant the LDAP BER response is >> but I'd like the JDK to handle the NPE and communicate back by throwing >> NamingException : >> >> bug ID :https://bugs.openjdk.java.net/browse/JDK-8154304 >> webrev : http://cr.openjdk.java.net/~coffeys/webrev.8154304.jdk9/webrev/ >> >> -- >> Regards, >> Sean. >> From amaembo at gmail.com Sat Apr 16 13:05:43 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Sat, 16 Apr 2016 19:05:43 +0600 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less Message-ID: <1689211029.20160416190543@gmail.com> Hello! Please review and sponsor the following patch: https://bugs.openjdk.java.net/browse/JDK-8154387 http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r1/ The rationale is to speed-up the parallel processing for unordered streams with low limit value. Such problems occur when you want to perform expensive filtering and select at most x elements which pass the filter (order does not matter). Currently unordered limit operation buffers up to 128 elements for each parallel task before it checks whether limit is reached. This is actually harmful when requested limit is lower: much more elements are requested from the upstream than necessary. Here's simple JMH test which illustrates the problem: http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ It extracts the requested number of probable-primes from the list of 10000 BigInteger numbers. The results with 9ea+111: Benchmark (limit) Mode Cnt Score Error Units LimitTest.parLimit 2 avgt 30 108,971 ? 0,643 us/op LimitTest.parLimit 20 avgt 30 934,176 ? 14,003 us/op LimitTest.parLimit 200 avgt 30 8772,417 ? 190,609 us/op LimitTest.parLimit 2000 avgt 30 41775,463 ? 1800,537 us/op LimitTest.parUnorderedLimit 2 avgt 30 2557,798 ? 13,161 us/op LimitTest.parUnorderedLimit 20 avgt 30 2578,283 ? 23,547 us/op LimitTest.parUnorderedLimit 200 avgt 30 4577,318 ? 40,793 us/op LimitTest.parUnorderedLimit 2000 avgt 30 12279,346 ? 523,823 us/op LimitTest.seqLimit 2 avgt 30 34,831 ? 0,190 us/op LimitTest.seqLimit 20 avgt 30 369,729 ? 1,427 us/op LimitTest.seqLimit 200 avgt 30 3690,544 ? 13,907 us/op LimitTest.seqLimit 2000 avgt 30 36681,637 ? 156,538 us/op When the limit is 2 or 20, parallel unordered version is slower than parallel ordered! Even for limit = 200 it's still slower than sequential operation. The idea of the patch is to tweak the CHUNK_SIZE using the given limit and parallelism level. I used the following formula: this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, (skip + limit) / ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; This does not affect cases when limit is big or not set at all (in skip mode). However it greatly improves cases when limit is small: Benchmark (limit) Mode Cnt Score Error Units LimitTest.parLimit 2 avgt 30 109,502 ? 0,750 us/op LimitTest.parLimit 20 avgt 30 954,716 ? 39,276 us/op LimitTest.parLimit 200 avgt 30 8706,226 ? 184,330 us/op LimitTest.parLimit 2000 avgt 30 42126,346 ? 3163,444 us/op LimitTest.parUnorderedLimit 2 avgt 30 39,303 ? 0,177 us/op !!! LimitTest.parUnorderedLimit 20 avgt 30 266,107 ? 0,492 us/op !!! LimitTest.parUnorderedLimit 200 avgt 30 2547,177 ? 58,538 us/op !!! LimitTest.parUnorderedLimit 2000 avgt 30 12216,402 ? 430,574 us/op LimitTest.seqLimit 2 avgt 30 34,993 ? 0,704 us/op LimitTest.seqLimit 20 avgt 30 369,497 ? 1,754 us/op LimitTest.seqLimit 200 avgt 30 3716,059 ? 61,054 us/op LimitTest.seqLimit 2000 avgt 30 36814,356 ? 161,531 us/op Here you can see that unordered cases are significantly improved. Now they are always faster than parallel ordered and faster than sequential for limit >= 20. I did not think up how to test this patch as it does not change visible behavior, only speed. However all the existing tests pass. What do you think? With best regards, Tagir Valeev. From david.holmes at oracle.com Sat Apr 16 22:20:41 2016 From: david.holmes at oracle.com (David Holmes) Date: Sun, 17 Apr 2016 08:20:41 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57120600.6090005@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> Message-ID: <5712BAB9.5040400@oracle.com> Hi Yasumasa, On 16/04/2016 7:29 PM, Yasumasa Suenaga wrote: > Hi David, > > I uploaded new webrev: > > - hotspot: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ > > - jdk: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ Ah sneaky! :) Using JNI to by-pass access control so we can set up a private method to do the name setting, yet avoid any API change that would require a CCC request. I think I like it. :) Need to hear from core-libs and/or launcher folk as this touches a number of pieces of code. Thanks, David ----- > >> it won't work unless you change the semantics of setName so I'm not >> sure what you were thinking here. To take advantage of an arg taking >> JVM_SetNativThreadName you would need to call it directly as no Java >> code will call it . ??? > > I added a flag for setting native thread name to JNI-attached thread. > This change can set native thread name if main thread changes to > JNI-attached thread. > > > Thanks, > > Yasumasa > > > On 2016/04/16 16:11, David Holmes wrote: >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> That change in behaviour may be a problem, it could be considered a >>>> regression that setName stops setting the native thread main, even >>>> though we never really intended it to work in the first place. :( Such >>>> a change needs to go through CCC. >>> >>> I understood. >>> Can I send CCC request? >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >> >> Sorry you can't file a CCC request, you would need a sponsor for that. >> But at this stage I don't think I agree with the proposed change >> because of the change in behaviour - there's no way to restore the >> "broken" behaviour. >> >>> I want to continue to discuss about it on JDK-8154331 [1]. >> >> Okay we can do that. >> >>> >>>> Further, we expect the launcher to use the supported JNI interface (as >>>> other processes would), not the internal JVM interface that exists for >>>> the JDK sources to communicate with the JVM. >>> >>> I think that we do not use JVM interface if we add new method in >>> LauncherHelper as below: >>> ---------------- >>> diff -r f02139a1ac84 >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> Wed Apr 13 14:19:30 2016 +0000 >>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> Sat Apr 16 11:25:53 2016 +0900 >>> @@ -960,4 +960,8 @@ >>> else >>> return md.toNameAndVersion() + " (" + loc + ")"; >>> } >>> + >>> + static void setNativeThreadName(String name) { >>> + Thread.currentThread().setName(name); >>> + } >> >> You could also make that call via JNI directly, so not sure the helper >> adds much here. But it won't work unless you change the semantics of >> setName so I'm not sure what you were thinking here. To take advantage >> of an arg taking JVM_SetNativThreadName you would need to call it >> directly as no Java code will call it . ??? >> >> David >> ----- >> >>> } >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>> 2016 +0000 >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>> 2016 +0900 >>> @@ -125,6 +125,7 @@ >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>> static void ShowSettings(JNIEnv* env, char *optString); >>> static void ListModules(JNIEnv* env, char *optString); >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>> >>> static void SetPaths(int argc, char **argv); >>> >>> @@ -325,6 +326,7 @@ >>> * mainThread.isAlive() to work as expected. >>> */ >>> #define LEAVE() \ >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>> do { \ >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>> @@ -488,6 +490,9 @@ >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>> >>> + /* Set native thread name. */ >>> + SetNativeThreadName(env, "main"); >>> + >>> /* Invoke main method. */ >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>> >>> @@ -1686,6 +1691,22 @@ >>> joptString); >>> } >>> >>> +/** >>> + * Set native thread name as possible. >>> + */ >>> +static void >>> +SetNativeThreadName(JNIEnv *env, char *name) >>> +{ >>> + jmethodID setNativeThreadNameID; >>> + jstring nameString; >>> + jclass cls = GetLauncherHelperClass(env); >>> + NULL_CHECK(cls); >>> + NULL_CHECK(setNativeThreadNameID = >>> (*env)->GetStaticMethodID(env, cls, >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>> nameString); >>> +} >>> + >>> /* >>> * Prints default usage or the Xusage message, see >>> sun.launcher.LauncherHelper.java >>> */ >>> ---------------- >>> >>> So I want to add new arg to JVM_SetNativeThreadName(). >>> >>>> However this is still a change to the exported JVM interface and so >>>> has to be approved. >>> >>> Do you mean that this change needs CCC? >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> [1] >>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>> >>> >>> >>> >>> On 2016/04/16 7:26, David Holmes wrote: >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> I think it is a bug based on the comment here: >>>>>> >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>> JNI attached threads >>>>> >>>>> I filed it to JBS as JDK-8154331. >>>>> I will send review request to hotspot-runtime-dev. >>>>> >>>>> >>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>> will no longer set the native name for the main thread. >>>>> >>>>> I know. >>>> >>>> That change in behaviour may be a problem, it could be considered a >>>> regression that setName stops setting the native thread main, even >>>> though we never really intended it to work in the first place. :( Such >>>> a change needs to go through CCC. >>>> >>>>> I checked changeset history. >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>> backported JDK 8. >>>> >>>> Yes this all came in as part of the OSX port in 7u2. >>>> >>>>> However, this function seems to be called from Thread#setNativeName() >>>>> only. >>>>> In addition, Thread#setNativeName() is private method. >>>>> >>>>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>>>> for force setting. >>>>> (e.g. "bool forced") >>>>> >>>>> It makes a change of JVM API. >>>>> However, this function is NOT public, so I think we can add one more >>>>> argument. >>>>> >>>>> What do you think about this? >>>>> If it is accepted, we can set native thread name from Java launcher. >>>> >>>> The private/public aspect of the Java API is not really at issue. Yes >>>> we would add another arg to the JVM function to allow it to apply to >>>> JNI-attached threads as well (I'd prefer the arg reflect that not just >>>> "force"). However this is still a change to the exported JVM interface >>>> and so has to be approved. Further, we expect the launcher to use the >>>> supported JNI interface (as other processes would), not the internal >>>> JVM interface that exists for the JDK sources to communicate with the >>>> JVM. >>>> >>>> David >>>> ----- >>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>> Hi Yasumasa, >>>>>> >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>> Hi David, >>>>>>> >>>>>>>> The fact that the "main" thread is not tagged as being a >>>>>>>> JNI-attached >>>>>>>> thread seems accidental to me >>>>>>> >>>>>>> Should I file it to JBS? >>>>>> >>>>>> I think it is a bug based on the comment here: >>>>>> >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>> JNI attached threads >>>>>> >>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>> will no longer set the native name for the main thread. >>>>>> >>>>>>> I think that we can fix as below: >>>>>>> --------------- >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 >>>>>>> +0200 >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 >>>>>>> +0900 >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>> #endif // INCLUDE_JVMCI >>>>>>> >>>>>>> // Attach the main thread to this os thread >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>> main_thread->initialize_thread_current(); >>>>>>> // must do this before set_active_handles >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>> // Notify JVMTI agents that VM initialization is complete - >>>>>>> nop if >>>>>>> no agents. >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>> >>>>>>> + // Change attach status to "attached" >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>> + >>>>>> >>>>>> I think we can do this straight after the JavaThread constructor. >>>>>> >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>> backend."); >>>>>>> } >>>>>>> --------------- >>>>>>> >>>>>>> >>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>> >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread >>>>>>> name >>>>>>> when the caller thread is JNI-attached thread. >>>>>>> However, I think that it should be changed if Java developer calls >>>>>>> Thread#setName() explicitly. >>>>>>> It is not the same of changing native thread name at >>>>>>> Threads::create_vm(). >>>>>>> >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>> What do you think about this? >>>>>> >>>>>> The decision to not change the name of JNI-attached threads was a >>>>>> deliberate one** - this functionality originated with the OSX port >>>>>> and >>>>>> it was reported that the initial feedback with this feature was to >>>>>> ensure it didn't mess with thread names that had been set by the host >>>>>> process. If we do as you propose then we will just have an >>>>>> inconsistency for people to complain about: "why does my native >>>>>> thread >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>> >>>>>> ** If you follow the bugs and related discussions on this, the >>>>>> semantics and limitations (truncation, current thread only, non-JNI >>>>>> threads only) of setting the native thread name were supposed to be >>>>>> documented in the release notes - but as far as I can see that never >>>>>> happened. :( >>>>>> >>>>>> My position on this remains that if it is desirable for the main >>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>> launcher needs to be setting them using the available platform APIs. >>>>>> Unfortunately this is complicated - as evidenced by the VM code for >>>>>> this - due to the need to verify API availability. >>>>>> >>>>>> Any change in behaviour in relation to Thread.setName would have >>>>>> to go >>>>>> through our CCC process I think. But a change in the launcher would >>>>>> not. >>>>>> >>>>>> Sorry. >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>>> --------------- >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 >>>>>>> +0200 >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 >>>>>>> +0900 >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>> // Thread naming only supported for the current thread, doesn't >>>>>>> work >>>>>>> for >>>>>>> // target threads. >>>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>>>> + if (Thread::current() == thr) { >>>>>>> // we don't set the name of an attached thread to avoid >>>>>>> stepping >>>>>>> // on other programs >>>>>>> const char *thread_name = >>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>> >>>>>>> --------------- >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>> >>>>>>>> >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>> Roger, >>>>>>>>> Thanks for your comment! >>>>>>>>> >>>>>>>>> David, >>>>>>>>> >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>> exposing >>>>>>>>>>>> a new JVM function this way. >>>>>>>>> >>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>> calling >>>>>>>>> main method), >>>>>>>>> I could set native thread name. >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>>>> set >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>> >>>>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>>>> unfortunately, takes me back to the basic premise here that we >>>>>>>> don't >>>>>>>> set the name of threads not created by the JVM. The fact that the >>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>>>>> named at >>>>>>>> the native level. >>>>>>>> >>>>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>> native threads then it is free to do so, but I would not be >>>>>>>> exporting >>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>> >>>>>>>> Sorry. >>>>>>>> >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> Comments: >>>>>>>>>> >>>>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>>>> functions: >>>>>>>>>> >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>> >>>>>>>>>> - The first function applies to the current thread, the second >>>>>>>>>> one a >>>>>>>>>> specific java thread. >>>>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>>>> what >>>>>>>>>> the new function does. >>>>>>>>>> >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>> instead of >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>> as is done on unix and mac. >>>>>>>>>> >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>>>> line 730 >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>>>> same >>>>>>>>>> line as dlsym... >>>>>>>>>> >>>>>>>>>> $.02, Roger >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>> check - >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>> then >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>> work >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>> >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>> --------- >>>>>>>>>>> public class Sleep{ >>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>> } >>>>>>>>>>> } >>>>>>>>>>> --------- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>> exposing >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I exported new JVM function to set native thread name, >>>>>>>>>>>>>>> and JLI >>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>> >>>>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>>>> need to >>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>>>> rather >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>> needed in >>>>>>>>>>>>>> that case. >>>>>>>>>>>>> >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>> >>>>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>>>> native >>>>>>>>>>>> name is not set. >>>>>>>>>>>> >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>> >>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>> check - >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>> then >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>> work >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>> >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>> exposing >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> David >>>>>>>>>>>> ----- >>>>>>>>>>>> >>>>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>>>> thread name. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> [1] >>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>>>>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>>>>>>>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>>>>>>>>>>>>>>>>>>>>> Mar 29 >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>>>>>>>>>>>>>>>>>>>>> Mar 30 >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>>>>>>>>>>>>>>>>>>>>> "main"; >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>>>>>>>> thread); >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we >>>>>>>>>>>>>>>>>>>>>> want >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - >>>>>>>>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I >>>>>>>>>>>>>>>>>>>>>> think >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> From yasuenag at gmail.com Sun Apr 17 03:38:44 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Sun, 17 Apr 2016 12:38:44 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5712BAB9.5040400@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5712BAB9.5040400@oracle.com> Message-ID: <57130544.8000601@gmail.com> Hi David, > Need to hear from core-libs and/or launcher folk as this touches a number of pieces of code. I'm waiting more reviewer(s) . BTW, Should I make patches which are based on jdk9/dev repos? My proposal includes hotspot changes. So I want to know whether I can push all changes jdk9/dev/{jdk,hotspot} after reviewing. I can update my webrev to adapt to jdk9/dev repos if need. Thanks, Yasumasa On 2016/04/17 7:20, David Holmes wrote: > Hi Yasumasa, > > On 16/04/2016 7:29 PM, Yasumasa Suenaga wrote: >> Hi David, >> >> I uploaded new webrev: >> >> - hotspot: >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >> >> - jdk: >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ > > Ah sneaky! :) Using JNI to by-pass access control so we can set up a private method to do the name setting, yet avoid any API change that would require a CCC request. I think I like it. :) > > Need to hear from core-libs and/or launcher folk as this touches a number of pieces of code. > > Thanks, > David > ----- > >> >>> it won't work unless you change the semantics of setName so I'm not >>> sure what you were thinking here. To take advantage of an arg taking >>> JVM_SetNativThreadName you would need to call it directly as no Java >>> code will call it . ??? >> >> I added a flag for setting native thread name to JNI-attached thread. >> This change can set native thread name if main thread changes to >> JNI-attached thread. >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/16 16:11, David Holmes wrote: >>> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> That change in behaviour may be a problem, it could be considered a >>>>> regression that setName stops setting the native thread main, even >>>>> though we never really intended it to work in the first place. :( Such >>>>> a change needs to go through CCC. >>>> >>>> I understood. >>>> Can I send CCC request? >>>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>> >>> Sorry you can't file a CCC request, you would need a sponsor for that. >>> But at this stage I don't think I agree with the proposed change >>> because of the change in behaviour - there's no way to restore the >>> "broken" behaviour. >>> >>>> I want to continue to discuss about it on JDK-8154331 [1]. >>> >>> Okay we can do that. >>> >>>> >>>>> Further, we expect the launcher to use the supported JNI interface (as >>>>> other processes would), not the internal JVM interface that exists for >>>>> the JDK sources to communicate with the JVM. >>>> >>>> I think that we do not use JVM interface if we add new method in >>>> LauncherHelper as below: >>>> ---------------- >>>> diff -r f02139a1ac84 >>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> Wed Apr 13 14:19:30 2016 +0000 >>>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> Sat Apr 16 11:25:53 2016 +0900 >>>> @@ -960,4 +960,8 @@ >>>> else >>>> return md.toNameAndVersion() + " (" + loc + ")"; >>>> } >>>> + >>>> + static void setNativeThreadName(String name) { >>>> + Thread.currentThread().setName(name); >>>> + } >>> >>> You could also make that call via JNI directly, so not sure the helper >>> adds much here. But it won't work unless you change the semantics of >>> setName so I'm not sure what you were thinking here. To take advantage >>> of an arg taking JVM_SetNativThreadName you would need to call it >>> directly as no Java code will call it . ??? >>> >>> David >>> ----- >>> >>>> } >>>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>>> 2016 +0000 >>>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>>> 2016 +0900 >>>> @@ -125,6 +125,7 @@ >>>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>> static void ShowSettings(JNIEnv* env, char *optString); >>>> static void ListModules(JNIEnv* env, char *optString); >>>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>> >>>> static void SetPaths(int argc, char **argv); >>>> >>>> @@ -325,6 +326,7 @@ >>>> * mainThread.isAlive() to work as expected. >>>> */ >>>> #define LEAVE() \ >>>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> do { \ >>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>> @@ -488,6 +490,9 @@ >>>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>> >>>> + /* Set native thread name. */ >>>> + SetNativeThreadName(env, "main"); >>>> + >>>> /* Invoke main method. */ >>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>> >>>> @@ -1686,6 +1691,22 @@ >>>> joptString); >>>> } >>>> >>>> +/** >>>> + * Set native thread name as possible. >>>> + */ >>>> +static void >>>> +SetNativeThreadName(JNIEnv *env, char *name) >>>> +{ >>>> + jmethodID setNativeThreadNameID; >>>> + jstring nameString; >>>> + jclass cls = GetLauncherHelperClass(env); >>>> + NULL_CHECK(cls); >>>> + NULL_CHECK(setNativeThreadNameID = >>>> (*env)->GetStaticMethodID(env, cls, >>>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>>> nameString); >>>> +} >>>> + >>>> /* >>>> * Prints default usage or the Xusage message, see >>>> sun.launcher.LauncherHelper.java >>>> */ >>>> ---------------- >>>> >>>> So I want to add new arg to JVM_SetNativeThreadName(). >>>> >>>>> However this is still a change to the exported JVM interface and so >>>>> has to be approved. >>>> >>>> Do you mean that this change needs CCC? >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> [1] >>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>> >>>> >>>> >>>> >>>> On 2016/04/16 7:26, David Holmes wrote: >>>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>>> I think it is a bug based on the comment here: >>>>>>> >>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>>> JNI attached threads >>>>>> >>>>>> I filed it to JBS as JDK-8154331. >>>>>> I will send review request to hotspot-runtime-dev. >>>>>> >>>>>> >>>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>>> will no longer set the native name for the main thread. >>>>>> >>>>>> I know. >>>>> >>>>> That change in behaviour may be a problem, it could be considered a >>>>> regression that setName stops setting the native thread main, even >>>>> though we never really intended it to work in the first place. :( Such >>>>> a change needs to go through CCC. >>>>> >>>>>> I checked changeset history. >>>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>>> backported JDK 8. >>>>> >>>>> Yes this all came in as part of the OSX port in 7u2. >>>>> >>>>>> However, this function seems to be called from Thread#setNativeName() >>>>>> only. >>>>>> In addition, Thread#setNativeName() is private method. >>>>>> >>>>>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>>>>> for force setting. >>>>>> (e.g. "bool forced") >>>>>> >>>>>> It makes a change of JVM API. >>>>>> However, this function is NOT public, so I think we can add one more >>>>>> argument. >>>>>> >>>>>> What do you think about this? >>>>>> If it is accepted, we can set native thread name from Java launcher. >>>>> >>>>> The private/public aspect of the Java API is not really at issue. Yes >>>>> we would add another arg to the JVM function to allow it to apply to >>>>> JNI-attached threads as well (I'd prefer the arg reflect that not just >>>>> "force"). However this is still a change to the exported JVM interface >>>>> and so has to be approved. Further, we expect the launcher to use the >>>>> supported JNI interface (as other processes would), not the internal >>>>> JVM interface that exists for the JDK sources to communicate with the >>>>> JVM. >>>>> >>>>> David >>>>> ----- >>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>> Hi Yasumasa, >>>>>>> >>>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi David, >>>>>>>> >>>>>>>>> The fact that the "main" thread is not tagged as being a >>>>>>>>> JNI-attached >>>>>>>>> thread seems accidental to me >>>>>>>> >>>>>>>> Should I file it to JBS? >>>>>>> >>>>>>> I think it is a bug based on the comment here: >>>>>>> >>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>>> JNI attached threads >>>>>>> >>>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>>> will no longer set the native name for the main thread. >>>>>>> >>>>>>>> I think that we can fix as below: >>>>>>>> --------------- >>>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 >>>>>>>> +0200 >>>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 >>>>>>>> +0900 >>>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>> #endif // INCLUDE_JVMCI >>>>>>>> >>>>>>>> // Attach the main thread to this os thread >>>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>> main_thread->initialize_thread_current(); >>>>>>>> // must do this before set_active_handles >>>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>> // Notify JVMTI agents that VM initialization is complete - >>>>>>>> nop if >>>>>>>> no agents. >>>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>> >>>>>>>> + // Change attach status to "attached" >>>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>> + >>>>>>> >>>>>>> I think we can do this straight after the JavaThread constructor. >>>>>>> >>>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>>> backend."); >>>>>>>> } >>>>>>>> --------------- >>>>>>>> >>>>>>>> >>>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>>> >>>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread >>>>>>>> name >>>>>>>> when the caller thread is JNI-attached thread. >>>>>>>> However, I think that it should be changed if Java developer calls >>>>>>>> Thread#setName() explicitly. >>>>>>>> It is not the same of changing native thread name at >>>>>>>> Threads::create_vm(). >>>>>>>> >>>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>>> What do you think about this? >>>>>>> >>>>>>> The decision to not change the name of JNI-attached threads was a >>>>>>> deliberate one** - this functionality originated with the OSX port >>>>>>> and >>>>>>> it was reported that the initial feedback with this feature was to >>>>>>> ensure it didn't mess with thread names that had been set by the host >>>>>>> process. If we do as you propose then we will just have an >>>>>>> inconsistency for people to complain about: "why does my native >>>>>>> thread >>>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>>> >>>>>>> ** If you follow the bugs and related discussions on this, the >>>>>>> semantics and limitations (truncation, current thread only, non-JNI >>>>>>> threads only) of setting the native thread name were supposed to be >>>>>>> documented in the release notes - but as far as I can see that never >>>>>>> happened. :( >>>>>>> >>>>>>> My position on this remains that if it is desirable for the main >>>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>>> launcher needs to be setting them using the available platform APIs. >>>>>>> Unfortunately this is complicated - as evidenced by the VM code for >>>>>>> this - due to the need to verify API availability. >>>>>>> >>>>>>> Any change in behaviour in relation to Thread.setName would have >>>>>>> to go >>>>>>> through our CCC process I think. But a change in the launcher would >>>>>>> not. >>>>>>> >>>>>>> Sorry. >>>>>>> >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> --------------- >>>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 >>>>>>>> +0200 >>>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 >>>>>>>> +0900 >>>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>>> // Thread naming only supported for the current thread, doesn't >>>>>>>> work >>>>>>>> for >>>>>>>> // target threads. >>>>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>>>>> + if (Thread::current() == thr) { >>>>>>>> // we don't set the name of an attached thread to avoid >>>>>>>> stepping >>>>>>>> // on other programs >>>>>>>> const char *thread_name = >>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>> >>>>>>>> --------------- >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>> Roger, >>>>>>>>>> Thanks for your comment! >>>>>>>>>> >>>>>>>>>> David, >>>>>>>>>> >>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>> exposing >>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>>> calling >>>>>>>>>> main method), >>>>>>>>>> I could set native thread name. >>>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>>>>> set >>>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>> >>>>>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>>>>> unfortunately, takes me back to the basic premise here that we >>>>>>>>> don't >>>>>>>>> set the name of threads not created by the JVM. The fact that the >>>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>>>>>> named at >>>>>>>>> the native level. >>>>>>>>> >>>>>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>>> native threads then it is free to do so, but I would not be >>>>>>>>> exporting >>>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>>> >>>>>>>>> Sorry. >>>>>>>>> >>>>>>>>> David >>>>>>>>> ----- >>>>>>>>> >>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> Comments: >>>>>>>>>>> >>>>>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>>>>> functions: >>>>>>>>>>> >>>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>>> >>>>>>>>>>> - The first function applies to the current thread, the second >>>>>>>>>>> one a >>>>>>>>>>> specific java thread. >>>>>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>>>>> what >>>>>>>>>>> the new function does. >>>>>>>>>>> >>>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>>> instead of >>>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>> as is done on unix and mac. >>>>>>>>>>> >>>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>>>>> line 730 >>>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>>>>> same >>>>>>>>>>> line as dlsym... >>>>>>>>>>> >>>>>>>>>>> $.02, Roger >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>> check - >>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>>> then >>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>>> work >>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>> >>>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>> --------- >>>>>>>>>>>> public class Sleep{ >>>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>> } >>>>>>>>>>>> } >>>>>>>>>>>> --------- >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>> exposing >>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I exported new JVM function to set native thread name, >>>>>>>>>>>>>>>> and JLI >>>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>>>>> rather >>>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>> that case. >>>>>>>>>>>>>> >>>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>>> >>>>>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>>>>> native >>>>>>>>>>>>> name is not set. >>>>>>>>>>>>> >>>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>>> >>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>> check - >>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>>> then >>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>>> work >>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>> >>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>> exposing >>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> David >>>>>>>>>>>>> ----- >>>>>>>>>>>>> >>>>>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>>>>> thread name. >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> [1] >>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> David >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>>>>>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>>>>>>>>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>>>>>>>>>>>>>>>>>>>>>> Mar 29 >>>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>>>>>>>>>>>>>>>>>>>>>> Mar 30 >>>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>>>>>>>>>>>>>>>>>>>>>> "main"; >>>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>> thread); >>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we >>>>>>>>>>>>>>>>>>>>>>> want >>>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - >>>>>>>>>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I >>>>>>>>>>>>>>>>>>>>>>> think >>>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> From david.holmes at oracle.com Sun Apr 17 10:38:46 2016 From: david.holmes at oracle.com (David Holmes) Date: Sun, 17 Apr 2016 20:38:46 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57130544.8000601@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5712BAB9.5040400@oracle.com> <57130544.8000601@gmail.com> Message-ID: <571367B6.5020808@oracle.com> On 17/04/2016 1:38 PM, Yasumasa Suenaga wrote: > Hi David, > >> Need to hear from core-libs and/or launcher folk as this touches a >> number of pieces of code. > > I'm waiting more reviewer(s) . > > BTW, Should I make patches which are based on jdk9/dev repos? > My proposal includes hotspot changes. > So I want to know whether I can push all changes jdk9/dev/{jdk,hotspot} > after reviewing. No, jdk9/hs please. Thanks, David > I can update my webrev to adapt to jdk9/dev repos if need. > > > Thanks, > > Yasumasa > > > On 2016/04/17 7:20, David Holmes wrote: >> Hi Yasumasa, >> >> On 16/04/2016 7:29 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>> I uploaded new webrev: >>> >>> - hotspot: >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>> >>> - jdk: >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >> >> Ah sneaky! :) Using JNI to by-pass access control so we can set up a >> private method to do the name setting, yet avoid any API change that >> would require a CCC request. I think I like it. :) >> >> Need to hear from core-libs and/or launcher folk as this touches a >> number of pieces of code. >> >> Thanks, >> David >> ----- >> >>> >>>> it won't work unless you change the semantics of setName so I'm not >>>> sure what you were thinking here. To take advantage of an arg taking >>>> JVM_SetNativThreadName you would need to call it directly as no Java >>>> code will call it . ??? >>> >>> I added a flag for setting native thread name to JNI-attached thread. >>> This change can set native thread name if main thread changes to >>> JNI-attached thread. >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/16 16:11, David Holmes wrote: >>>> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> That change in behaviour may be a problem, it could be considered a >>>>>> regression that setName stops setting the native thread main, even >>>>>> though we never really intended it to work in the first place. :( >>>>>> Such >>>>>> a change needs to go through CCC. >>>>> >>>>> I understood. >>>>> Can I send CCC request? >>>>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>> >>>> Sorry you can't file a CCC request, you would need a sponsor for that. >>>> But at this stage I don't think I agree with the proposed change >>>> because of the change in behaviour - there's no way to restore the >>>> "broken" behaviour. >>>> >>>>> I want to continue to discuss about it on JDK-8154331 [1]. >>>> >>>> Okay we can do that. >>>> >>>>> >>>>>> Further, we expect the launcher to use the supported JNI interface >>>>>> (as >>>>>> other processes would), not the internal JVM interface that exists >>>>>> for >>>>>> the JDK sources to communicate with the JVM. >>>>> >>>>> I think that we do not use JVM interface if we add new method in >>>>> LauncherHelper as below: >>>>> ---------------- >>>>> diff -r f02139a1ac84 >>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>> Wed Apr 13 14:19:30 2016 +0000 >>>>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>> Sat Apr 16 11:25:53 2016 +0900 >>>>> @@ -960,4 +960,8 @@ >>>>> else >>>>> return md.toNameAndVersion() + " (" + loc + ")"; >>>>> } >>>>> + >>>>> + static void setNativeThreadName(String name) { >>>>> + Thread.currentThread().setName(name); >>>>> + } >>>> >>>> You could also make that call via JNI directly, so not sure the helper >>>> adds much here. But it won't work unless you change the semantics of >>>> setName so I'm not sure what you were thinking here. To take advantage >>>> of an arg taking JVM_SetNativThreadName you would need to call it >>>> directly as no Java code will call it . ??? >>>> >>>> David >>>> ----- >>>> >>>>> } >>>>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>>>> 2016 +0000 >>>>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>>>> 2016 +0900 >>>>> @@ -125,6 +125,7 @@ >>>>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>> static void ShowSettings(JNIEnv* env, char *optString); >>>>> static void ListModules(JNIEnv* env, char *optString); >>>>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>>> >>>>> static void SetPaths(int argc, char **argv); >>>>> >>>>> @@ -325,6 +326,7 @@ >>>>> * mainThread.isAlive() to work as expected. >>>>> */ >>>>> #define LEAVE() \ >>>>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>> do { \ >>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>> @@ -488,6 +490,9 @@ >>>>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>> >>>>> + /* Set native thread name. */ >>>>> + SetNativeThreadName(env, "main"); >>>>> + >>>>> /* Invoke main method. */ >>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>> >>>>> @@ -1686,6 +1691,22 @@ >>>>> joptString); >>>>> } >>>>> >>>>> +/** >>>>> + * Set native thread name as possible. >>>>> + */ >>>>> +static void >>>>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>> +{ >>>>> + jmethodID setNativeThreadNameID; >>>>> + jstring nameString; >>>>> + jclass cls = GetLauncherHelperClass(env); >>>>> + NULL_CHECK(cls); >>>>> + NULL_CHECK(setNativeThreadNameID = >>>>> (*env)->GetStaticMethodID(env, cls, >>>>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>>>> nameString); >>>>> +} >>>>> + >>>>> /* >>>>> * Prints default usage or the Xusage message, see >>>>> sun.launcher.LauncherHelper.java >>>>> */ >>>>> ---------------- >>>>> >>>>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>> >>>>>> However this is still a change to the exported JVM interface and so >>>>>> has to be approved. >>>>> >>>>> Do you mean that this change needs CCC? >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> [1] >>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On 2016/04/16 7:26, David Holmes wrote: >>>>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>> Hi David, >>>>>>> >>>>>>>> I think it is a bug based on the comment here: >>>>>>>> >>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>> thread and >>>>>>>> JNI attached threads >>>>>>> >>>>>>> I filed it to JBS as JDK-8154331. >>>>>>> I will send review request to hotspot-runtime-dev. >>>>>>> >>>>>>> >>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>> setName >>>>>>>> will no longer set the native name for the main thread. >>>>>>> >>>>>>> I know. >>>>>> >>>>>> That change in behaviour may be a problem, it could be considered a >>>>>> regression that setName stops setting the native thread main, even >>>>>> though we never really intended it to work in the first place. :( >>>>>> Such >>>>>> a change needs to go through CCC. >>>>>> >>>>>>> I checked changeset history. >>>>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>>>> backported JDK 8. >>>>>> >>>>>> Yes this all came in as part of the OSX port in 7u2. >>>>>> >>>>>>> However, this function seems to be called from >>>>>>> Thread#setNativeName() >>>>>>> only. >>>>>>> In addition, Thread#setNativeName() is private method. >>>>>>> >>>>>>> Thus I think that we can add an argument to >>>>>>> JVM_SetNativeThreadName() >>>>>>> for force setting. >>>>>>> (e.g. "bool forced") >>>>>>> >>>>>>> It makes a change of JVM API. >>>>>>> However, this function is NOT public, so I think we can add one more >>>>>>> argument. >>>>>>> >>>>>>> What do you think about this? >>>>>>> If it is accepted, we can set native thread name from Java launcher. >>>>>> >>>>>> The private/public aspect of the Java API is not really at issue. Yes >>>>>> we would add another arg to the JVM function to allow it to apply to >>>>>> JNI-attached threads as well (I'd prefer the arg reflect that not >>>>>> just >>>>>> "force"). However this is still a change to the exported JVM >>>>>> interface >>>>>> and so has to be approved. Further, we expect the launcher to use the >>>>>> supported JNI interface (as other processes would), not the internal >>>>>> JVM interface that exists for the JDK sources to communicate with the >>>>>> JVM. >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>> Hi Yasumasa, >>>>>>>> >>>>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>> Hi David, >>>>>>>>> >>>>>>>>>> The fact that the "main" thread is not tagged as being a >>>>>>>>>> JNI-attached >>>>>>>>>> thread seems accidental to me >>>>>>>>> >>>>>>>>> Should I file it to JBS? >>>>>>>> >>>>>>>> I think it is a bug based on the comment here: >>>>>>>> >>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>> thread and >>>>>>>> JNI attached threads >>>>>>>> >>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>> setName >>>>>>>> will no longer set the native name for the main thread. >>>>>>>> >>>>>>>>> I think that we can fix as below: >>>>>>>>> --------------- >>>>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 >>>>>>>>> +0200 >>>>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 >>>>>>>>> +0900 >>>>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>> >>>>>>>>> // Attach the main thread to this os thread >>>>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>> // must do this before set_active_handles >>>>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>> // Notify JVMTI agents that VM initialization is complete - >>>>>>>>> nop if >>>>>>>>> no agents. >>>>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>> >>>>>>>>> + // Change attach status to "attached" >>>>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>> + >>>>>>>> >>>>>>>> I think we can do this straight after the JavaThread constructor. >>>>>>>> >>>>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>>>> backend."); >>>>>>>>> } >>>>>>>>> --------------- >>>>>>>>> >>>>>>>>> >>>>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>>>> >>>>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread >>>>>>>>> name >>>>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>> However, I think that it should be changed if Java developer calls >>>>>>>>> Thread#setName() explicitly. >>>>>>>>> It is not the same of changing native thread name at >>>>>>>>> Threads::create_vm(). >>>>>>>>> >>>>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>>>> What do you think about this? >>>>>>>> >>>>>>>> The decision to not change the name of JNI-attached threads was a >>>>>>>> deliberate one** - this functionality originated with the OSX port >>>>>>>> and >>>>>>>> it was reported that the initial feedback with this feature was to >>>>>>>> ensure it didn't mess with thread names that had been set by the >>>>>>>> host >>>>>>>> process. If we do as you propose then we will just have an >>>>>>>> inconsistency for people to complain about: "why does my native >>>>>>>> thread >>>>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>>>> >>>>>>>> ** If you follow the bugs and related discussions on this, the >>>>>>>> semantics and limitations (truncation, current thread only, non-JNI >>>>>>>> threads only) of setting the native thread name were supposed to be >>>>>>>> documented in the release notes - but as far as I can see that >>>>>>>> never >>>>>>>> happened. :( >>>>>>>> >>>>>>>> My position on this remains that if it is desirable for the main >>>>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>>>> launcher needs to be setting them using the available platform >>>>>>>> APIs. >>>>>>>> Unfortunately this is complicated - as evidenced by the VM code for >>>>>>>> this - due to the need to verify API availability. >>>>>>>> >>>>>>>> Any change in behaviour in relation to Thread.setName would have >>>>>>>> to go >>>>>>>> through our CCC process I think. But a change in the launcher would >>>>>>>> not. >>>>>>>> >>>>>>>> Sorry. >>>>>>>> >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>>> --------------- >>>>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 >>>>>>>>> +0200 >>>>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 >>>>>>>>> +0900 >>>>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>>>> // Thread naming only supported for the current thread, >>>>>>>>> doesn't >>>>>>>>> work >>>>>>>>> for >>>>>>>>> // target threads. >>>>>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>>>>>> + if (Thread::current() == thr) { >>>>>>>>> // we don't set the name of an attached thread to avoid >>>>>>>>> stepping >>>>>>>>> // on other programs >>>>>>>>> const char *thread_name = >>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>> >>>>>>>>> >>>>>>>>> --------------- >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> Roger, >>>>>>>>>>> Thanks for your comment! >>>>>>>>>>> >>>>>>>>>>> David, >>>>>>>>>>> >>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>> exposing >>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>>>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>>>> calling >>>>>>>>>>> main method), >>>>>>>>>>> I could set native thread name. >>>>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we >>>>>>>>>>> can't >>>>>>>>>>> set >>>>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>> >>>>>>>>>> Right - I came to the same realization earlier this morning. >>>>>>>>>> Which, >>>>>>>>>> unfortunately, takes me back to the basic premise here that we >>>>>>>>>> don't >>>>>>>>>> set the name of threads not created by the JVM. The fact that the >>>>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>>>>>>> named at >>>>>>>>>> the native level. >>>>>>>>>> >>>>>>>>>> I'm afraid my view here is that the launcher has to be treated >>>>>>>>>> like >>>>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>>>> native threads then it is free to do so, but I would not be >>>>>>>>>> exporting >>>>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>>>> >>>>>>>>>> Sorry. >>>>>>>>>> >>>>>>>>>> David >>>>>>>>>> ----- >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> Comments: >>>>>>>>>>>> >>>>>>>>>>>> jvm.h: The function names are too similar but perform >>>>>>>>>>>> different >>>>>>>>>>>> functions: >>>>>>>>>>>> >>>>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>>>> >>>>>>>>>>>> - The first function applies to the current thread, the second >>>>>>>>>>>> one a >>>>>>>>>>>> specific java thread. >>>>>>>>>>>> It would seem useful for there to be a comment somewhere >>>>>>>>>>>> about >>>>>>>>>>>> what >>>>>>>>>>>> the new function does. >>>>>>>>>>>> >>>>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>>>> instead of >>>>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>> >>>>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>> used at >>>>>>>>>>>> line 730 >>>>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >>>>>>>>>>>> on the >>>>>>>>>>>> same >>>>>>>>>>>> line as dlsym... >>>>>>>>>>>> >>>>>>>>>>>> $.02, Roger >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>>> check - >>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>>>> then >>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>> should >>>>>>>>>>>>>> work >>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>> >>>>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed >>>>>>>>>>>>> native >>>>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>> --------- >>>>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>> } >>>>>>>>>>>>> } >>>>>>>>>>>>> --------- >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>> exposing >>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>>>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I exported new JVM function to set native thread name, >>>>>>>>>>>>>>>>> and JLI >>>>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> First the launcher belongs to another team so core-libs >>>>>>>>>>>>>>>> will >>>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>>>>>>>>>>>> Thread.setName >>>>>>>>>>>>>>>> rather >>>>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>>> that case. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>>>> >>>>>>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>>>>>> native >>>>>>>>>>>>>> name is not set. >>>>>>>>>>>>>> >>>>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>>>> >>>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>>> check - >>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>>>> then >>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>> should >>>>>>>>>>>>>> work >>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>> >>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>> exposing >>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> David >>>>>>>>>>>>>> ----- >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thus I think that we have to provide a function to set >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> thread name. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> [1] >>>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we >>>>>>>>>>>>>>>>>> do not >>>>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>>>>>>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>>>>>>>>>>>>>> set_active_handles >>>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >>>>>>>>>>>>>>>>>>>>>>>> name in >>>>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >>>>>>>>>>>>>>>>>>>>>>>> starte >>>>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>>>>>>>>>>>>>>>>>>>>>>> Mar 29 >>>>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>>>>>>>>>>>>>>>>>>>>>>> Mar 30 >>>>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>>>>>>>>>>>>>>>>>>>>>>> "main"; >>>>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>> thread); >>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and >>>>>>>>>>>>>>>>>>>>>>>> thus >>>>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. >>>>>>>>>>>>>>>>>>>>>>>> So I >>>>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we >>>>>>>>>>>>>>>>>>>>>>>> want >>>>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - >>>>>>>>>>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I >>>>>>>>>>>>>>>>>>>>>>>> think >>>>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name >>>>>>>>>>>>>>>>>>>>>>>> via >>>>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> From dbrosius at mebigfatguy.com Sun Apr 17 14:06:44 2016 From: dbrosius at mebigfatguy.com (Dave Brosius) Date: Sun, 17 Apr 2016 10:06:44 -0400 Subject: RFR(m): 8145468u1 deprecations for java.lang In-Reply-To: <57116CF2.4080108@oracle.com> References: <57116CF2.4080108@oracle.com> Message-ID: <57139874.5000809@mebigfatguy.com> Greetings, Along these lines, is there a reason not to deprecate the String(String s) constructor? Now that substring doesn't glom off the original string, i see no reason for this constructor. -dave On 04/15/2016 06:36 PM, Stuart Marks wrote: > Hi all, > > Here's a small update to the jdk repo webrev for this change. There > are no changes to any API deprecations or other specification changes. > The changes are confined to the warnings cleanup work. > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.1.jdk/ > > The files changed relative to the previous webrev are as follows. > > src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java > > - revert autoboxing per Remi, add @SuppressWarnings and comments > > src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java > src/jdk.jcmd/share/classes/sun/tools/jstat/ExpressionExecuter.java > > - cleanups as suggested by Paul > > src/java.base/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java > > src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java > src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java > > > - cleanups to windows files that I had missed previously > > There are also no changes to langtools or top repo; those webrevs are > unchanged: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > Thanks, > > s'marks > > > From joe.darcy at oracle.com Sun Apr 17 17:31:29 2016 From: joe.darcy at oracle.com (joe darcy) Date: Sun, 17 Apr 2016 10:31:29 -0700 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract Message-ID: <5713C871.1080407@oracle.com> Hello, With talk of deprecation in the air [1], I thought it would be a fine time to examine one of the bugs on my list JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract As the title of the bug implies, The Class.newInstance method knowingly violates the checking exception contract. This has long been documented in its specification: > Note that this method propagates any exception thrown by the nullary > constructor, including a checked exception. Use of this method > effectively bypasses the compile-time exception checking that would > otherwise be performed by the compiler. The Constructor.newInstance > method avoids this problem by wrapping any exception thrown by the > constructor in a (checked) InvocationTargetException. Roughly, the fix would be to turn the text of this note into the @deprecated text and to add a @Deprecated(since="9") annotation to the method. There are a few dozen uses of the method in the JDK that would have to be @SuppressWarning-ed or otherwise updated. Thoughts on the appropriateness of deprecating this method at this time? Comments on the bug have suggested that besides deprecating the method, a new method on Class could be introduced, newInstanceWithProperExceptionBehavior, that had the same signature but wrapped exceptions thrown by the constructor call in the same way Constructor.newInstance does. Thanks, -Joe [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html From scolebourne at joda.org Sun Apr 17 21:10:48 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Sun, 17 Apr 2016 22:10:48 +0100 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: <570E6C2E.4060208@Oracle.com> References: <570E5589.7080106@oracle.com> <570E6C2E.4060208@Oracle.com> Message-ID: The LDML spec indicates that the "GMT" string should be localized: http://unicode.org/repos/cldr/trunk/specs/ldml/tr35-dates.html#Using_Time_Zone_Names The text of appendLocalizedOffset() is written with the intention of the output being localized (otherwise, what is the point of the method!) I assume this was something that got missed when implementing appendLocalizedOffset(). It may require additional localized data from the LDML data files. This webrev looks fine. Stephen On 13 April 2016 at 16:56, Roger Riggs wrote: > Hi Nadeesh, > > The bugfix looks fine. > > The TODO comment on the "GMT" raises the question (as a separate issue) > about implementing the TODO or removing the TODO comment. > > I'm not sure where the localized string for "GMT" would come from but it > might be a useful improvement > unless it was judged to a compatibility issue. > > Roger > > > > > On 4/13/2016 10:19 AM, nadeesh tv wrote: > > HI all, > > Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 > > Issue - java.time.format.DateTimeFormatter can't parse localized zone-offset > > Solution - Corrected the mistake in calculating parse end position and > removed an unnecessary null check > > > webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ > > PS: TCKOffsetPrinterParser.test_print_localized() already contain some test > cases related to parsing and formatting. therefore did not repeat in the new > test cases file > > -- > Thanks and Regards, > Nadeesh TV > > From scolebourne at joda.org Sun Apr 17 21:33:22 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Sun, 17 Apr 2016 22:33:22 +0100 Subject: RFR:JDK-8031085:DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS" In-Reply-To: <570EB042.3040709@oracle.com> References: <570EB042.3040709@oracle.com> Message-ID: The updated spec at line 670 is not clear - the adjacent parsing mode only applies when in strict mode. Suggest a new sentence before the lenient mode one: "In strict mode, if the minimum and maximum widths are equal and there is no decimal point then the parser will participate in adjacent value parsing, see {@code appendValue(java.time.temporal.TemporalField, int)}. Line 2968 is missing a blank line Line 3001 does not need == true on isStrict() == true Perhaps line 3004 should return false? I'm not sure what is gained by calling super. The changes to the test cases look wrong. test_adjacent_lenient_fractionFollows_2digit() and test_adjacent_lenient_fractionFollows_0digit() should not have changed, as the nano-of-second parsing is in lenient mode, and thus should still parse from zero to nine digits. thanks Stephen On 13 April 2016 at 21:46, nadeesh tv wrote: > HI all, > > BUG ID : https://bugs.openjdk.java.net/browse/JDK-8031085 > > Webrev : http://cr.openjdk.java.net/~ntv/8031085/webrev.00/ > > Issue - Fractional parts of seconds do not participate in the protocol for > adjacent value parsing > > Solution - Changed the FractionPrinterParser to subclass of > NumberPrinterParser to make it participate in adjacent value parsing > > 2 existing test cases > TCKDateTimeFormatterBuilder.test_adjacent_lenient_fractionFollows_0digit and > test_adjacent_lenient_fractionFollows_2digit were failing. Changed them > accordingly. > > -- > Thanks and Regards, > Nadeesh TV > From scolebourne at joda.org Sun Apr 17 21:58:15 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Sun, 17 Apr 2016 22:58:15 +0100 Subject: RFR:JDK-8148947:DateTimeFormatter pattern letter 'g' In-Reply-To: <56FC16B9.3000806@oracle.com> References: <56FC16B9.3000806@oracle.com> Message-ID: Looks fine to me Stephen On 30 March 2016 at 19:11, nadeesh tv wrote: > Hi all, > > BUG ID : https://bugs.openjdk.java.net/browse/JDK-8148947 > > Webrev : http://cr.openjdk.java.net/~ntv/8148947/webrev.00/ > > Added new pattern letter 'g' for Modified Julian day. > > Apart from that made clarification to JulianFields and removed semicolons > from docs of DateTimeFormatterBuilder as suggested by Stephen > > -- > Thanks and Regards, > Nadeesh TV > From david.holmes at oracle.com Sun Apr 17 23:05:05 2016 From: david.holmes at oracle.com (David Holmes) Date: Mon, 18 Apr 2016 09:05:05 +1000 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <570EF756.2090602@oracle.com> References: <570EF756.2090602@oracle.com> Message-ID: <571416A1.5020509@oracle.com> Hi Stuart, On 14/04/2016 11:50 AM, Stuart Marks wrote: > Hi all, > > Please review this first round of deprecation changes for the java.lang > package. This changeset includes the following: > > - a set of APIs being newly deprecated > - a set of already-deprecated APIs that are "upgraded" to forRemoval=true > - addition of the "since" element to all deprecations > - cleanup of some of the warnings caused by new deprecations > > Webrevs: > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.jdk/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8145468/webrev.0.top/ > > The newly deprecated APIs include all of the constructors for the boxed > primitives. We don't intend to remove these yet, so they don't declare a > value for the forRemoval element, implying the default value of false. > The constructors being deprecated are as follows: > > Boolean(boolean) > Boolean(String) > Byte(byte) > Byte(String) > Character(char) > Double(double) > Double(String) > Float(float) > Float(double) > Float(String) > Integer(int) > Integer(String) > Long(long) > Long(String) > Short(short) > Short(String) > > The methods being deprecated with forRemoval=true are listed below. All > of these methods have already been deprecated. They are all ill-defined, > or they don't work, or they don't do anything useful. > > Runtime.getLocalizedInputStream(InputStream) > Runtime.getLocalizedOutputStream(OutputStream) > Runtime.runFinalizersOnExit(boolean) > SecurityManager.checkAwtEventQueueAccess() > SecurityManager.checkMemberAccess(Class, int) > SecurityManager.checkSystemClipboardAccess() > SecurityManager.checkTopLevelWindow(Object) > System.runFinalizersOnExit(boolean) > Thread.countStackFrames() > Thread.destroy() > Thread.stop(Throwable) Surprised Thread.suspend/resume are not marked for removal given they are effectively unusable. David ----- > Most of the files in the changeset are cleanups. Some of them are simply > the addition of the "since" element to the @Deprecated annotation, to > indicate the version in which the API became deprecated. > > The rest of the changes are cleanup of warnings that were created by the > deprecation of the boxed primitive constructors. There are a total of a > couple hundred such uses sprinkled around the JDK. I've taken care of a > portion of them, with the exception of the java.desktop module, which > alone has over 100 uses of boxed primitive constructors. I've disabled > deprecation warnings for the java.desktop module for the time being; > these uses can be cleaned up later. I've filed JDK-8154213 to cover this > cleanup task. > > For the warnings cleanups I did, I mostly did conversions of the form: > > new Double(dval) > > to > > Double.valueOf(dval) > > This is a very safe transformation. It changes the behavior only in the > cases where the code relies on getting a new instance of the box object > instead of one that might come out of a cache. I didn't see any such > code (and I should hope there's no such code in the JDK!). > > I applied autoboxing only sparingly, in the cases where it was an > obviously safe thing to do, or where nearby code already uses > autoboxing. Autoboxing actually generates a call to the appropriate > valueOf() method, so the bytecode would be the same in most cases. The > only difference is clutter in the source code. On the other hand, > there's some risk in converting to autoboxing, as the implicitly > autoboxed type might end up different from an explicit call to > valueOf(). This isn't always obvious, so that's why I mostly avoided > autoboxing. > > Thanks, > > s'marks > From sundararajan.athijegannathan at oracle.com Mon Apr 18 04:18:37 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Mon, 18 Apr 2016 09:48:37 +0530 Subject: RFR: 8151056: ASM enable original deprecated methods. (simple fix) In-Reply-To: <57115981.2070203@oracle.com> References: <57115981.2070203@oracle.com> Message-ID: <5714601D.1090207@oracle.com> Looks good -Sundar On 4/16/2016 2:43 AM, Kumar Srinivasan wrote: > Hello, > > Please review this simple fix [1] to re-instate the original deprecated > methods, as a background, there were commented out because > of an internal dependency [2], and since has been fixed. > > Thanks > Kumar > > > [1] http://cr.openjdk.java.net/~ksrini/8151056/webrev.00/ > [2] > http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-March/039256.html From gilleshabran at gmail.com Sat Apr 16 05:33:50 2016 From: gilleshabran at gmail.com (Gilles Habran) Date: Sat, 16 Apr 2016 07:33:50 +0200 Subject: Files.walk() is unusable because of AccessDeniedException Message-ID: Good morning, I am trying to use Files.walk() in a Java 8 way but it is broken. I am trying to create an app to manage files and size on all my Linux system (so I would walk from the root directory and show the 5 biggest files of each directory for example). *JDK-8039910* has been raised for this issue but it is closed (2014-11-22). Alan Bateman wrote that the method is working as intended but I don't see how this could be intended because at the moment, it is unusable in a Java 8 way and for me. When we use a terminal operations on the Stream returned by Files.walk(), we get a crash because of AccessDeniedException For example, here is the directory (rules.d) that makes everything crash : [9:51:20 - ghabran at arch:/tmp/chromium-pepper-flash]$ ll /usr/share/polkit-1 total 8.0K drwxr-xr-x 2 root root 4.0K Apr 14 09:18 actions *drwxr-x--- 2 root polkitd 4.0K Apr 14 09:18 rules.d* As you can see, as a simple user, I don't have access. It is not possible to apply a filter to check the attributes to manage the file/directory to see if we have the rights because an exception is thrown before we get to check the attributes. Here are several scenarios : 1) This doesn't crash (there seems to have no exception thrown). I get error code 0, no exception is printed on my terminal. try { Stream directoryTree = Files.walk(*Paths.get("/")*); directoryTree .filter(p -> { try { return Files.isRegularFile(p) && Files.isReadable(p); } catch (Exception e) { return false; } }); } catch (IOException ioe) { System.out.println(ioe); } 2) this raises the exception AccessDeniedException (this goes in the catch) try { Stream directoryTree = Files.walk( *Paths.get("/usr/share/polkit-1/rules.d")*); directoryTree .filter(p -> { try { return Files.isRegularFile(p) && Files.isReadable(p); } catch (Exception e) { return false; } }); *} catch (IOException ioe) {* * System.out.println(ioe);* *}* 3) this crashes with a stack trace : AccessDeniedException *(this doesn't go in the catch)* try { Stream directoryTree = Files.walk(*Paths.get("/")*); directoryTree .filter(p -> { try { return Files.isRegularFile(p) && Files.isReadable(p); } catch (Exception e) { return false; } })*.forEach(System.out::println);* } catch (IOException ioe) { System.out.println(ioe); } 4) this crashes but goes into the catch try { Stream directoryTree = Files.walk( *Paths.get("/usr/share/polkit-1/rules.d")*); directoryTree .filter(p -> { try { return Files.isRegularFile(p) && Files.isReadable(p); } catch (Exception e) { return false; } })*.forEach(System.out::println)*; *} catch (IOException ioe) {* * System.out.println(ioe);* *}* In the meantime, I will use the old way with walkFileTree and a FileVisitor. How am I supposed to walk() a directory tree in Java 8 without walk() ? I was looking forward to using Stream to do it but I can't. What should I do ? Thank you. Regards, Gilles From david.holmes at oracle.com Mon Apr 18 04:40:36 2016 From: david.holmes at oracle.com (David Holmes) Date: Mon, 18 Apr 2016 14:40:36 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571367B6.5020808@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5712BAB9.5040400@oracle.com> <57130544.8000601@gmail.com> <571367B6.5020808@oracle.com> Message-ID: <57146544.9050903@oracle.com> On 17/04/2016 8:38 PM, David Holmes wrote: > On 17/04/2016 1:38 PM, Yasumasa Suenaga wrote: >> Hi David, >> >>> Need to hear from core-libs and/or launcher folk as this touches a >>> number of pieces of code. >> >> I'm waiting more reviewer(s) . >> >> BTW, Should I make patches which are based on jdk9/dev repos? >> My proposal includes hotspot changes. >> So I want to know whether I can push all changes jdk9/dev/{jdk,hotspot} >> after reviewing. > > No, jdk9/hs please. And it will need to go via JPRT so I will sponsor it for you. Thanks, David > Thanks, > David > >> I can update my webrev to adapt to jdk9/dev repos if need. >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/17 7:20, David Holmes wrote: >>> Hi Yasumasa, >>> >>> On 16/04/2016 7:29 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>> I uploaded new webrev: >>>> >>>> - hotspot: >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>> >>>> - jdk: >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>> >>> Ah sneaky! :) Using JNI to by-pass access control so we can set up a >>> private method to do the name setting, yet avoid any API change that >>> would require a CCC request. I think I like it. :) >>> >>> Need to hear from core-libs and/or launcher folk as this touches a >>> number of pieces of code. >>> >>> Thanks, >>> David >>> ----- >>> >>>> >>>>> it won't work unless you change the semantics of setName so I'm not >>>>> sure what you were thinking here. To take advantage of an arg taking >>>>> JVM_SetNativThreadName you would need to call it directly as no Java >>>>> code will call it . ??? >>>> >>>> I added a flag for setting native thread name to JNI-attached thread. >>>> This change can set native thread name if main thread changes to >>>> JNI-attached thread. >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/16 16:11, David Holmes wrote: >>>>> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>>> That change in behaviour may be a problem, it could be considered a >>>>>>> regression that setName stops setting the native thread main, even >>>>>>> though we never really intended it to work in the first place. :( >>>>>>> Such >>>>>>> a change needs to go through CCC. >>>>>> >>>>>> I understood. >>>>>> Can I send CCC request? >>>>>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>> >>>>> Sorry you can't file a CCC request, you would need a sponsor for that. >>>>> But at this stage I don't think I agree with the proposed change >>>>> because of the change in behaviour - there's no way to restore the >>>>> "broken" behaviour. >>>>> >>>>>> I want to continue to discuss about it on JDK-8154331 [1]. >>>>> >>>>> Okay we can do that. >>>>> >>>>>> >>>>>>> Further, we expect the launcher to use the supported JNI interface >>>>>>> (as >>>>>>> other processes would), not the internal JVM interface that exists >>>>>>> for >>>>>>> the JDK sources to communicate with the JVM. >>>>>> >>>>>> I think that we do not use JVM interface if we add new method in >>>>>> LauncherHelper as below: >>>>>> ---------------- >>>>>> diff -r f02139a1ac84 >>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> Wed Apr 13 14:19:30 2016 +0000 >>>>>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> Sat Apr 16 11:25:53 2016 +0900 >>>>>> @@ -960,4 +960,8 @@ >>>>>> else >>>>>> return md.toNameAndVersion() + " (" + loc + ")"; >>>>>> } >>>>>> + >>>>>> + static void setNativeThreadName(String name) { >>>>>> + Thread.currentThread().setName(name); >>>>>> + } >>>>> >>>>> You could also make that call via JNI directly, so not sure the helper >>>>> adds much here. But it won't work unless you change the semantics of >>>>> setName so I'm not sure what you were thinking here. To take advantage >>>>> of an arg taking JVM_SetNativThreadName you would need to call it >>>>> directly as no Java code will call it . ??? >>>>> >>>>> David >>>>> ----- >>>>> >>>>>> } >>>>>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>>>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>>>>> 2016 +0000 >>>>>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>>>>> 2016 +0900 >>>>>> @@ -125,6 +125,7 @@ >>>>>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>> static void ListModules(JNIEnv* env, char *optString); >>>>>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>>>> >>>>>> static void SetPaths(int argc, char **argv); >>>>>> >>>>>> @@ -325,6 +326,7 @@ >>>>>> * mainThread.isAlive() to work as expected. >>>>>> */ >>>>>> #define LEAVE() \ >>>>>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>> do { \ >>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>> @@ -488,6 +490,9 @@ >>>>>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>> >>>>>> + /* Set native thread name. */ >>>>>> + SetNativeThreadName(env, "main"); >>>>>> + >>>>>> /* Invoke main method. */ >>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>>> >>>>>> @@ -1686,6 +1691,22 @@ >>>>>> joptString); >>>>>> } >>>>>> >>>>>> +/** >>>>>> + * Set native thread name as possible. >>>>>> + */ >>>>>> +static void >>>>>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>> +{ >>>>>> + jmethodID setNativeThreadNameID; >>>>>> + jstring nameString; >>>>>> + jclass cls = GetLauncherHelperClass(env); >>>>>> + NULL_CHECK(cls); >>>>>> + NULL_CHECK(setNativeThreadNameID = >>>>>> (*env)->GetStaticMethodID(env, cls, >>>>>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>>>>> nameString); >>>>>> +} >>>>>> + >>>>>> /* >>>>>> * Prints default usage or the Xusage message, see >>>>>> sun.launcher.LauncherHelper.java >>>>>> */ >>>>>> ---------------- >>>>>> >>>>>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>> >>>>>>> However this is still a change to the exported JVM interface and so >>>>>>> has to be approved. >>>>>> >>>>>> Do you mean that this change needs CCC? >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> [1] >>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi David, >>>>>>>> >>>>>>>>> I think it is a bug based on the comment here: >>>>>>>>> >>>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>>> thread and >>>>>>>>> JNI attached threads >>>>>>>> >>>>>>>> I filed it to JBS as JDK-8154331. >>>>>>>> I will send review request to hotspot-runtime-dev. >>>>>>>> >>>>>>>> >>>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>>> setName >>>>>>>>> will no longer set the native name for the main thread. >>>>>>>> >>>>>>>> I know. >>>>>>> >>>>>>> That change in behaviour may be a problem, it could be considered a >>>>>>> regression that setName stops setting the native thread main, even >>>>>>> though we never really intended it to work in the first place. :( >>>>>>> Such >>>>>>> a change needs to go through CCC. >>>>>>> >>>>>>>> I checked changeset history. >>>>>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>>>>> backported JDK 8. >>>>>>> >>>>>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>> >>>>>>>> However, this function seems to be called from >>>>>>>> Thread#setNativeName() >>>>>>>> only. >>>>>>>> In addition, Thread#setNativeName() is private method. >>>>>>>> >>>>>>>> Thus I think that we can add an argument to >>>>>>>> JVM_SetNativeThreadName() >>>>>>>> for force setting. >>>>>>>> (e.g. "bool forced") >>>>>>>> >>>>>>>> It makes a change of JVM API. >>>>>>>> However, this function is NOT public, so I think we can add one >>>>>>>> more >>>>>>>> argument. >>>>>>>> >>>>>>>> What do you think about this? >>>>>>>> If it is accepted, we can set native thread name from Java >>>>>>>> launcher. >>>>>>> >>>>>>> The private/public aspect of the Java API is not really at issue. >>>>>>> Yes >>>>>>> we would add another arg to the JVM function to allow it to apply to >>>>>>> JNI-attached threads as well (I'd prefer the arg reflect that not >>>>>>> just >>>>>>> "force"). However this is still a change to the exported JVM >>>>>>> interface >>>>>>> and so has to be approved. Further, we expect the launcher to use >>>>>>> the >>>>>>> supported JNI interface (as other processes would), not the internal >>>>>>> JVM interface that exists for the JDK sources to communicate with >>>>>>> the >>>>>>> JVM. >>>>>>> >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>> Hi Yasumasa, >>>>>>>>> >>>>>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi David, >>>>>>>>>> >>>>>>>>>>> The fact that the "main" thread is not tagged as being a >>>>>>>>>>> JNI-attached >>>>>>>>>>> thread seems accidental to me >>>>>>>>>> >>>>>>>>>> Should I file it to JBS? >>>>>>>>> >>>>>>>>> I think it is a bug based on the comment here: >>>>>>>>> >>>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>>> thread and >>>>>>>>> JNI attached threads >>>>>>>>> >>>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>>> setName >>>>>>>>> will no longer set the native name for the main thread. >>>>>>>>> >>>>>>>>>> I think that we can fix as below: >>>>>>>>>> --------------- >>>>>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 >>>>>>>>>> +0200 >>>>>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 >>>>>>>>>> +0900 >>>>>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>> >>>>>>>>>> // Attach the main thread to this os thread >>>>>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>> // must do this before set_active_handles >>>>>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>> // Notify JVMTI agents that VM initialization is complete - >>>>>>>>>> nop if >>>>>>>>>> no agents. >>>>>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>> >>>>>>>>>> + // Change attach status to "attached" >>>>>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>> + >>>>>>>>> >>>>>>>>> I think we can do this straight after the JavaThread constructor. >>>>>>>>> >>>>>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>>>>> backend."); >>>>>>>>>> } >>>>>>>>>> --------------- >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>>>>> >>>>>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread >>>>>>>>>> name >>>>>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>> However, I think that it should be changed if Java developer >>>>>>>>>> calls >>>>>>>>>> Thread#setName() explicitly. >>>>>>>>>> It is not the same of changing native thread name at >>>>>>>>>> Threads::create_vm(). >>>>>>>>>> >>>>>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>>>>> What do you think about this? >>>>>>>>> >>>>>>>>> The decision to not change the name of JNI-attached threads was a >>>>>>>>> deliberate one** - this functionality originated with the OSX port >>>>>>>>> and >>>>>>>>> it was reported that the initial feedback with this feature was to >>>>>>>>> ensure it didn't mess with thread names that had been set by the >>>>>>>>> host >>>>>>>>> process. If we do as you propose then we will just have an >>>>>>>>> inconsistency for people to complain about: "why does my native >>>>>>>>> thread >>>>>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>>>>> >>>>>>>>> ** If you follow the bugs and related discussions on this, the >>>>>>>>> semantics and limitations (truncation, current thread only, >>>>>>>>> non-JNI >>>>>>>>> threads only) of setting the native thread name were supposed >>>>>>>>> to be >>>>>>>>> documented in the release notes - but as far as I can see that >>>>>>>>> never >>>>>>>>> happened. :( >>>>>>>>> >>>>>>>>> My position on this remains that if it is desirable for the main >>>>>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>>>>> launcher needs to be setting them using the available platform >>>>>>>>> APIs. >>>>>>>>> Unfortunately this is complicated - as evidenced by the VM code >>>>>>>>> for >>>>>>>>> this - due to the need to verify API availability. >>>>>>>>> >>>>>>>>> Any change in behaviour in relation to Thread.setName would have >>>>>>>>> to go >>>>>>>>> through our CCC process I think. But a change in the launcher >>>>>>>>> would >>>>>>>>> not. >>>>>>>>> >>>>>>>>> Sorry. >>>>>>>>> >>>>>>>>> David >>>>>>>>> ----- >>>>>>>>> >>>>>>>>>> --------------- >>>>>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 >>>>>>>>>> +0200 >>>>>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 >>>>>>>>>> +0900 >>>>>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>>>>> // Thread naming only supported for the current thread, >>>>>>>>>> doesn't >>>>>>>>>> work >>>>>>>>>> for >>>>>>>>>> // target threads. >>>>>>>>>> - if (Thread::current() == thr && >>>>>>>>>> !thr->has_attached_via_jni()) { >>>>>>>>>> + if (Thread::current() == thr) { >>>>>>>>>> // we don't set the name of an attached thread to avoid >>>>>>>>>> stepping >>>>>>>>>> // on other programs >>>>>>>>>> const char *thread_name = >>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> --------------- >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Roger, >>>>>>>>>>>> Thanks for your comment! >>>>>>>>>>>> >>>>>>>>>>>> David, >>>>>>>>>>>> >>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>>>>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>>>>> calling >>>>>>>>>>>> main method), >>>>>>>>>>>> I could set native thread name. >>>>>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we >>>>>>>>>>>> can't >>>>>>>>>>>> set >>>>>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>> >>>>>>>>>>> Right - I came to the same realization earlier this morning. >>>>>>>>>>> Which, >>>>>>>>>>> unfortunately, takes me back to the basic premise here that we >>>>>>>>>>> don't >>>>>>>>>>> set the name of threads not created by the JVM. The fact that >>>>>>>>>>> the >>>>>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>>>>>>>> named at >>>>>>>>>>> the native level. >>>>>>>>>>> >>>>>>>>>>> I'm afraid my view here is that the launcher has to be treated >>>>>>>>>>> like >>>>>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>>>>> native threads then it is free to do so, but I would not be >>>>>>>>>>> exporting >>>>>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>>>>> >>>>>>>>>>> Sorry. >>>>>>>>>>> >>>>>>>>>>> David >>>>>>>>>>> ----- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> Comments: >>>>>>>>>>>>> >>>>>>>>>>>>> jvm.h: The function names are too similar but perform >>>>>>>>>>>>> different >>>>>>>>>>>>> functions: >>>>>>>>>>>>> >>>>>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>>>>> >>>>>>>>>>>>> - The first function applies to the current thread, the >>>>>>>>>>>>> second >>>>>>>>>>>>> one a >>>>>>>>>>>>> specific java thread. >>>>>>>>>>>>> It would seem useful for there to be a comment somewhere >>>>>>>>>>>>> about >>>>>>>>>>>>> what >>>>>>>>>>>>> the new function does. >>>>>>>>>>>>> >>>>>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>>>>> instead of >>>>>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>> >>>>>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>> used at >>>>>>>>>>>>> line 730 >>>>>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >>>>>>>>>>>>> on the >>>>>>>>>>>>> same >>>>>>>>>>>>> line as dlsym... >>>>>>>>>>>>> >>>>>>>>>>>>> $.02, Roger >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>>>> check - >>>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> then >>>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>>> should >>>>>>>>>>>>>>> work >>>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>> >>>>>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed >>>>>>>>>>>>>> native >>>>>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>>> --------- >>>>>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>>> } >>>>>>>>>>>>>> } >>>>>>>>>>>>>> --------- >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>> >>>>>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I exported new JVM function to set native thread name, >>>>>>>>>>>>>>>>>> and JLI >>>>>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> First the launcher belongs to another team so core-libs >>>>>>>>>>>>>>>>> will >>>>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>>>>>>>>>>>>> Thread.setName >>>>>>>>>>>>>>>>> rather >>>>>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>>>> that case. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> At Thread.init time the thread is not alive, which is why >>>>>>>>>>>>>>> the >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> name is not set. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>>>> check - >>>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> then >>>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>>> should >>>>>>>>>>>>>>> work >>>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> David >>>>>>>>>>>>>>> ----- >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thus I think that we have to provide a function to set >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> thread name. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> [1] >>>>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we >>>>>>>>>>>>>>>>>>> do not >>>>>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>> Thu >>>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>> Thu >>>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>>>>>>>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>>>>>>>>>>>>>>> set_active_handles >>>>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >>>>>>>>>>>>>>>>>>>>>>>>> name in >>>>>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >>>>>>>>>>>>>>>>>>>>>>>>> starte >>>>>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>>>>>>>>>>>>>>>>>>>>>>>> Mar 29 >>>>>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>>>>>>>>>>>>>>>>>>>>>>>> Mar 30 >>>>>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>>>>>>>>>>>>>>>>>>>>>>>> "main"; >>>>>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>>> thread); >>>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' >>>>>>>>>>>>>>>>>>>>>>>>> and >>>>>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and >>>>>>>>>>>>>>>>>>>>>>>>> thus >>>>>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>> So I >>>>>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we >>>>>>>>>>>>>>>>>>>>>>>>> want >>>>>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might >>>>>>>>>>>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java >>>>>>>>>>>>>>>>>>>>>>>>> Main >>>>>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - >>>>>>>>>>>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I >>>>>>>>>>>>>>>>>>>>>>>>> think >>>>>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name >>>>>>>>>>>>>>>>>>>>>>>>> via >>>>>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and >>>>>>>>>>>>>>>>>>>>>>>>> main >>>>>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review >>>>>>>>>>>>>>>>>>>>>>>>> it? >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> From chris.hegarty at oracle.com Mon Apr 18 05:53:11 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 18 Apr 2016 06:53:11 +0100 Subject: RFR [9] 8153372: Remove sun.misc.ManagedLocalsThread from jdk.httpserver Message-ID: <573D9678-69CD-4DC1-AEBA-663B1C9F0F88@oracle.com> 8056152 added a new constructor to java.lang.Thread to constructing Threads that do not inherit inheritable-thread-local initial values. Given there is now a supported API for creating such threads, other areas of the JDK should be updated to use it. This change updates the code in the jdk.httpserver to use the new Thread constructor. diff --git a/src/jdk.httpserver/share/classes/module-info.java b/src/jdk.httpserver/share/classes/module-info.java --- a/src/jdk.httpserver/share/classes/module-info.java +++ b/src/jdk.httpserver/share/classes/module-info.java @@ -25,8 +25,7 @@ module jdk.httpserver { requires java.logging; - // 8153372 - requires jdk.unsupported; + exports com.sun.net.httpserver; exports com.sun.net.httpserver.spi; uses com.sun.net.httpserver.spi.HttpServerProvider; diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java @@ -36,7 +36,6 @@ import com.sun.net.httpserver.*; import java.security.AccessController; import java.security.PrivilegedAction; -import sun.misc.ManagedLocalsThread; import sun.net.httpserver.HttpConnection.State; /** @@ -143,7 +142,7 @@ if (executor == null) { executor = new DefaultExecutor(); } - dispatcherThread = new ManagedLocalsThread(dispatcher); + dispatcherThread = new Thread(null, dispatcher, "HTTP-Dispatcher", 0, false); started = true; dispatcherThread.start(); } -Chris. From chris.hegarty at oracle.com Mon Apr 18 06:01:48 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 18 Apr 2016 07:01:48 +0100 Subject: RFR [9] 8153158: Remove sun.misc.ManagedLocalsThread from java.logging Message-ID: 8056152 added a new constructor to java.lang.Thread to constructing Threads that do not inherit inheritable-thread-local initial values. Given there is now a supported API for creating such threads, other areas of the JDK should be updated to use it. This change updates the code in java.logging to use the new Thread constructor. --- a/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -42,7 +42,6 @@ import java.util.stream.Stream; import jdk.internal.misc.JavaAWTAccess; import jdk.internal.misc.SharedSecrets; -import sun.misc.ManagedLocalsThread; import sun.util.logging.internal.LoggingProviderImpl; /** @@ -254,9 +253,10 @@ // This private class is used as a shutdown hook. // It does a "reset" to close all open handlers. - private class Cleaner extends ManagedLocalsThread { + private class Cleaner extends Thread { private Cleaner() { + super(null, null, "Logging-Cleaner", 0, false); /* Set context class loader to null in order to avoid * keeping a strong reference to an application classloader. */ diff --git a/src/java.logging/share/classes/module-info.java b/src/java.logging/share/classes/module-info.java --- a/src/java.logging/share/classes/module-info.java +++ b/src/java.logging/share/classes/module-info.java @@ -24,8 +24,6 @@ */ module java.logging { - // 8153158 - requires jdk.unsupported; exports java.util.logging; provides jdk.internal.logger.DefaultLoggerFinder with sun.util.logging.internal.LoggingProviderImpl; -Chris. From forax at univ-mlv.fr Mon Apr 18 07:45:29 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Mon, 18 Apr 2016 09:45:29 +0200 (CEST) Subject: RFR: 8151056: ASM enable original deprecated methods. (simple fix) In-Reply-To: <5714601D.1090207@oracle.com> References: <57115981.2070203@oracle.com> <5714601D.1090207@oracle.com> Message-ID: <363834556.262744.1460965529310.JavaMail.zimbra@u-pem.fr> Thumb up ! R?mi ----- Mail original ----- > De: "Sundararajan Athijegannathan" > ?: core-libs-dev at openjdk.java.net > Envoy?: Lundi 18 Avril 2016 06:18:37 > Objet: Re: RFR: 8151056: ASM enable original deprecated methods. (simple fix) > > Looks good > > -Sundar > > On 4/16/2016 2:43 AM, Kumar Srinivasan wrote: > > Hello, > > > > Please review this simple fix [1] to re-instate the original deprecated > > methods, as a background, there were commented out because > > of an internal dependency [2], and since has been fixed. > > > > Thanks > > Kumar > > > > > > [1] http://cr.openjdk.java.net/~ksrini/8151056/webrev.00/ > > [2] > > http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-March/039256.html > > From claes.redestad at oracle.com Mon Apr 18 09:35:49 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Mon, 18 Apr 2016 11:35:49 +0200 Subject: RFR [9] 8153158: Remove sun.misc.ManagedLocalsThread from java.logging In-Reply-To: References: Message-ID: <5714AA75.803@oracle.com> Looks good, Chris /Claes On 04/18/2016 08:01 AM, Chris Hegarty wrote: > 8056152 added a new constructor to java.lang.Thread to constructing Threads that > do not inherit inheritable-thread-local initial values. Given there is now a supported > API for creating such threads, other areas of the JDK should be updated to use it. > > This change updates the code in java.logging to use the new Thread constructor. > > --- a/src/java.logging/share/classes/java/util/logging/LogManager.java > +++ b/src/java.logging/share/classes/java/util/logging/LogManager.java > @@ -42,7 +42,6 @@ > import java.util.stream.Stream; > import jdk.internal.misc.JavaAWTAccess; > import jdk.internal.misc.SharedSecrets; > -import sun.misc.ManagedLocalsThread; > import sun.util.logging.internal.LoggingProviderImpl; > > /** > @@ -254,9 +253,10 @@ > > // This private class is used as a shutdown hook. > // It does a "reset" to close all open handlers. > - private class Cleaner extends ManagedLocalsThread { > + private class Cleaner extends Thread { > > private Cleaner() { > + super(null, null, "Logging-Cleaner", 0, false); > /* Set context class loader to null in order to avoid > * keeping a strong reference to an application classloader. > */ > diff --git a/src/java.logging/share/classes/module-info.java b/src/java.logging/share/classes/module-info.java > --- a/src/java.logging/share/classes/module-info.java > +++ b/src/java.logging/share/classes/module-info.java > @@ -24,8 +24,6 @@ > */ > > module java.logging { > - // 8153158 > - requires jdk.unsupported; > exports java.util.logging; > provides jdk.internal.logger.DefaultLoggerFinder with > sun.util.logging.internal.LoggingProviderImpl; > > -Chris. From yasuenag at gmail.com Mon Apr 18 10:28:15 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Mon, 18 Apr 2016 19:28:15 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57146544.9050903@oracle.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5712BAB9.5040400@oracle.com> <57130544.8000601@gmail.com> <571367B6.5020808@oracle.com> <57146544.9050903@oracle.com> Message-ID: 2016/04/18 13:41 "David Holmes" : > > On 17/04/2016 8:38 PM, David Holmes wrote: >> >> On 17/04/2016 1:38 PM, Yasumasa Suenaga wrote: >>> >>> Hi David, >>> >>>> Need to hear from core-libs and/or launcher folk as this touches a >>>> number of pieces of code. >>> >>> >>> I'm waiting more reviewer(s) . >>> >>> BTW, Should I make patches which are based on jdk9/dev repos? >>> My proposal includes hotspot changes. >>> So I want to know whether I can push all changes jdk9/dev/{jdk,hotspot} >>> after reviewing. >> >> >> No, jdk9/hs please. > > > And it will need to go via JPRT so I will sponsor it for you. Thanks! I will send changesets to you after reviewing. Yasumasa > Thanks, > David > > >> Thanks, >> David >> >>> I can update my webrev to adapt to jdk9/dev repos if need. >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/17 7:20, David Holmes wrote: >>>> >>>> Hi Yasumasa, >>>> >>>> On 16/04/2016 7:29 PM, Yasumasa Suenaga wrote: >>>>> >>>>> Hi David, >>>>> >>>>> I uploaded new webrev: >>>>> >>>>> - hotspot: >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>> >>>>> - jdk: >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>> >>>> >>>> Ah sneaky! :) Using JNI to by-pass access control so we can set up a >>>> private method to do the name setting, yet avoid any API change that >>>> would require a CCC request. I think I like it. :) >>>> >>>> Need to hear from core-libs and/or launcher folk as this touches a >>>> number of pieces of code. >>>> >>>> Thanks, >>>> David >>>> ----- >>>> >>>>> >>>>>> it won't work unless you change the semantics of setName so I'm not >>>>>> sure what you were thinking here. To take advantage of an arg taking >>>>>> JVM_SetNativThreadName you would need to call it directly as no Java >>>>>> code will call it . ??? >>>>> >>>>> >>>>> I added a flag for setting native thread name to JNI-attached thread. >>>>> This change can set native thread name if main thread changes to >>>>> JNI-attached thread. >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/16 16:11, David Holmes wrote: >>>>>> >>>>>> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>> >>>>>>> Hi David, >>>>>>> >>>>>>>> That change in behaviour may be a problem, it could be considered a >>>>>>>> regression that setName stops setting the native thread main, even >>>>>>>> though we never really intended it to work in the first place. :( >>>>>>>> Such >>>>>>>> a change needs to go through CCC. >>>>>>> >>>>>>> >>>>>>> I understood. >>>>>>> Can I send CCC request? >>>>>>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>> >>>>>> >>>>>> Sorry you can't file a CCC request, you would need a sponsor for that. >>>>>> But at this stage I don't think I agree with the proposed change >>>>>> because of the change in behaviour - there's no way to restore the >>>>>> "broken" behaviour. >>>>>> >>>>>>> I want to continue to discuss about it on JDK-8154331 [1]. >>>>>> >>>>>> >>>>>> Okay we can do that. >>>>>> >>>>>>> >>>>>>>> Further, we expect the launcher to use the supported JNI interface >>>>>>>> (as >>>>>>>> other processes would), not the internal JVM interface that exists >>>>>>>> for >>>>>>>> the JDK sources to communicate with the JVM. >>>>>>> >>>>>>> >>>>>>> I think that we do not use JVM interface if we add new method in >>>>>>> LauncherHelper as below: >>>>>>> ---------------- >>>>>>> diff -r f02139a1ac84 >>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>> @@ -960,4 +960,8 @@ >>>>>>> else >>>>>>> return md.toNameAndVersion() + " (" + loc + ")"; >>>>>>> } >>>>>>> + >>>>>>> + static void setNativeThreadName(String name) { >>>>>>> + Thread.currentThread().setName(name); >>>>>>> + } >>>>>> >>>>>> >>>>>> You could also make that call via JNI directly, so not sure the helper >>>>>> adds much here. But it won't work unless you change the semantics of >>>>>> setName so I'm not sure what you were thinking here. To take advantage >>>>>> of an arg taking JVM_SetNativThreadName you would need to call it >>>>>> directly as no Java code will call it . ??? >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>>> } >>>>>>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>>>>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>>>>>> 2016 +0000 >>>>>>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>>>>>> 2016 +0900 >>>>>>> @@ -125,6 +125,7 @@ >>>>>>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>>> static void ListModules(JNIEnv* env, char *optString); >>>>>>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>>>>> >>>>>>> static void SetPaths(int argc, char **argv); >>>>>>> >>>>>>> @@ -325,6 +326,7 @@ >>>>>>> * mainThread.isAlive() to work as expected. >>>>>>> */ >>>>>>> #define LEAVE() \ >>>>>>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>> do { \ >>>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>> @@ -488,6 +490,9 @@ >>>>>>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>> >>>>>>> + /* Set native thread name. */ >>>>>>> + SetNativeThreadName(env, "main"); >>>>>>> + >>>>>>> /* Invoke main method. */ >>>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>>>> >>>>>>> @@ -1686,6 +1691,22 @@ >>>>>>> joptString); >>>>>>> } >>>>>>> >>>>>>> +/** >>>>>>> + * Set native thread name as possible. >>>>>>> + */ >>>>>>> +static void >>>>>>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>> +{ >>>>>>> + jmethodID setNativeThreadNameID; >>>>>>> + jstring nameString; >>>>>>> + jclass cls = GetLauncherHelperClass(env); >>>>>>> + NULL_CHECK(cls); >>>>>>> + NULL_CHECK(setNativeThreadNameID = >>>>>>> (*env)->GetStaticMethodID(env, cls, >>>>>>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>>>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>>>>>> nameString); >>>>>>> +} >>>>>>> + >>>>>>> /* >>>>>>> * Prints default usage or the Xusage message, see >>>>>>> sun.launcher.LauncherHelper.java >>>>>>> */ >>>>>>> ---------------- >>>>>>> >>>>>>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>>> >>>>>>>> However this is still a change to the exported JVM interface and so >>>>>>>> has to be approved. >>>>>>> >>>>>>> >>>>>>> Do you mean that this change needs CCC? >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> [1] >>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>> >>>>>>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>> >>>>>>>>> Hi David, >>>>>>>>> >>>>>>>>>> I think it is a bug based on the comment here: >>>>>>>>>> >>>>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>>>> thread and >>>>>>>>>> JNI attached threads >>>>>>>>> >>>>>>>>> >>>>>>>>> I filed it to JBS as JDK-8154331. >>>>>>>>> I will send review request to hotspot-runtime-dev. >>>>>>>>> >>>>>>>>> >>>>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>>>> setName >>>>>>>>>> will no longer set the native name for the main thread. >>>>>>>>> >>>>>>>>> >>>>>>>>> I know. >>>>>>>> >>>>>>>> >>>>>>>> That change in behaviour may be a problem, it could be considered a >>>>>>>> regression that setName stops setting the native thread main, even >>>>>>>> though we never really intended it to work in the first place. :( >>>>>>>> Such >>>>>>>> a change needs to go through CCC. >>>>>>>> >>>>>>>>> I checked changeset history. >>>>>>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>>>>>> backported JDK 8. >>>>>>>> >>>>>>>> >>>>>>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>>> >>>>>>>>> However, this function seems to be called from >>>>>>>>> Thread#setNativeName() >>>>>>>>> only. >>>>>>>>> In addition, Thread#setNativeName() is private method. >>>>>>>>> >>>>>>>>> Thus I think that we can add an argument to >>>>>>>>> JVM_SetNativeThreadName() >>>>>>>>> for force setting. >>>>>>>>> (e.g. "bool forced") >>>>>>>>> >>>>>>>>> It makes a change of JVM API. >>>>>>>>> However, this function is NOT public, so I think we can add one >>>>>>>>> more >>>>>>>>> argument. >>>>>>>>> >>>>>>>>> What do you think about this? >>>>>>>>> If it is accepted, we can set native thread name from Java >>>>>>>>> launcher. >>>>>>>> >>>>>>>> >>>>>>>> The private/public aspect of the Java API is not really at issue. >>>>>>>> Yes >>>>>>>> we would add another arg to the JVM function to allow it to apply to >>>>>>>> JNI-attached threads as well (I'd prefer the arg reflect that not >>>>>>>> just >>>>>>>> "force"). However this is still a change to the exported JVM >>>>>>>> interface >>>>>>>> and so has to be approved. Further, we expect the launcher to use >>>>>>>> the >>>>>>>> supported JNI interface (as other processes would), not the internal >>>>>>>> JVM interface that exists for the JDK sources to communicate with >>>>>>>> the >>>>>>>> JVM. >>>>>>>> >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>> >>>>>>>>>> Hi Yasumasa, >>>>>>>>>> >>>>>>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>>>>>>>>>> Hi David, >>>>>>>>>>> >>>>>>>>>>>> The fact that the "main" thread is not tagged as being a >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> thread seems accidental to me >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Should I file it to JBS? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> I think it is a bug based on the comment here: >>>>>>>>>> >>>>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>>>> thread and >>>>>>>>>> JNI attached threads >>>>>>>>>> >>>>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>>>> setName >>>>>>>>>> will no longer set the native name for the main thread. >>>>>>>>>> >>>>>>>>>>> I think that we can fix as below: >>>>>>>>>>> --------------- >>>>>>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 >>>>>>>>>>> +0200 >>>>>>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 >>>>>>>>>>> +0900 >>>>>>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>> >>>>>>>>>>> // Attach the main thread to this os thread >>>>>>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>> // must do this before set_active_handles >>>>>>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>> // Notify JVMTI agents that VM initialization is complete - >>>>>>>>>>> nop if >>>>>>>>>>> no agents. >>>>>>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>> >>>>>>>>>>> + // Change attach status to "attached" >>>>>>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>> + >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> I think we can do this straight after the JavaThread constructor. >>>>>>>>>> >>>>>>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>>>>>> backend."); >>>>>>>>>>> } >>>>>>>>>>> --------------- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread >>>>>>>>>>> name >>>>>>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>>> However, I think that it should be changed if Java developer >>>>>>>>>>> calls >>>>>>>>>>> Thread#setName() explicitly. >>>>>>>>>>> It is not the same of changing native thread name at >>>>>>>>>>> Threads::create_vm(). >>>>>>>>>>> >>>>>>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>>>>>> What do you think about this? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> The decision to not change the name of JNI-attached threads was a >>>>>>>>>> deliberate one** - this functionality originated with the OSX port >>>>>>>>>> and >>>>>>>>>> it was reported that the initial feedback with this feature was to >>>>>>>>>> ensure it didn't mess with thread names that had been set by the >>>>>>>>>> host >>>>>>>>>> process. If we do as you propose then we will just have an >>>>>>>>>> inconsistency for people to complain about: "why does my native >>>>>>>>>> thread >>>>>>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>>>>>> >>>>>>>>>> ** If you follow the bugs and related discussions on this, the >>>>>>>>>> semantics and limitations (truncation, current thread only, >>>>>>>>>> non-JNI >>>>>>>>>> threads only) of setting the native thread name were supposed >>>>>>>>>> to be >>>>>>>>>> documented in the release notes - but as far as I can see that >>>>>>>>>> never >>>>>>>>>> happened. :( >>>>>>>>>> >>>>>>>>>> My position on this remains that if it is desirable for the main >>>>>>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>>>>>> launcher needs to be setting them using the available platform >>>>>>>>>> APIs. >>>>>>>>>> Unfortunately this is complicated - as evidenced by the VM code >>>>>>>>>> for >>>>>>>>>> this - due to the need to verify API availability. >>>>>>>>>> >>>>>>>>>> Any change in behaviour in relation to Thread.setName would have >>>>>>>>>> to go >>>>>>>>>> through our CCC process I think. But a change in the launcher >>>>>>>>>> would >>>>>>>>>> not. >>>>>>>>>> >>>>>>>>>> Sorry. >>>>>>>>>> >>>>>>>>>> David >>>>>>>>>> ----- >>>>>>>>>> >>>>>>>>>>> --------------- >>>>>>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 >>>>>>>>>>> +0200 >>>>>>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 >>>>>>>>>>> +0900 >>>>>>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>>>>>> // Thread naming only supported for the current thread, >>>>>>>>>>> doesn't >>>>>>>>>>> work >>>>>>>>>>> for >>>>>>>>>>> // target threads. >>>>>>>>>>> - if (Thread::current() == thr && >>>>>>>>>>> !thr->has_attached_via_jni()) { >>>>>>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>> // we don't set the name of an attached thread to avoid >>>>>>>>>>> stepping >>>>>>>>>>> // on other programs >>>>>>>>>>> const char *thread_name = >>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> --------------- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>>>>>>>>>>>> Roger, >>>>>>>>>>>>> Thanks for your comment! >>>>>>>>>>>>> >>>>>>>>>>>>> David, >>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>>>>>> calling >>>>>>>>>>>>> main method), >>>>>>>>>>>>> I could set native thread name. >>>>>>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we >>>>>>>>>>>>> can't >>>>>>>>>>>>> set >>>>>>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Right - I came to the same realization earlier this morning. >>>>>>>>>>>> Which, >>>>>>>>>>>> unfortunately, takes me back to the basic premise here that we >>>>>>>>>>>> don't >>>>>>>>>>>> set the name of threads not created by the JVM. The fact that >>>>>>>>>>>> the >>>>>>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>>>>>>>>> named at >>>>>>>>>>>> the native level. >>>>>>>>>>>> >>>>>>>>>>>> I'm afraid my view here is that the launcher has to be treated >>>>>>>>>>>> like >>>>>>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>>>>>> native threads then it is free to do so, but I would not be >>>>>>>>>>>> exporting >>>>>>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>>>>>> >>>>>>>>>>>> Sorry. >>>>>>>>>>>> >>>>>>>>>>>> David >>>>>>>>>>>> ----- >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Comments: >>>>>>>>>>>>>> >>>>>>>>>>>>>> jvm.h: The function names are too similar but perform >>>>>>>>>>>>>> different >>>>>>>>>>>>>> functions: >>>>>>>>>>>>>> >>>>>>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>>>>>> >>>>>>>>>>>>>> - The first function applies to the current thread, the >>>>>>>>>>>>>> second >>>>>>>>>>>>>> one a >>>>>>>>>>>>>> specific java thread. >>>>>>>>>>>>>> It would seem useful for there to be a comment somewhere >>>>>>>>>>>>>> about >>>>>>>>>>>>>> what >>>>>>>>>>>>>> the new function does. >>>>>>>>>>>>>> >>>>>>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>>>>>> instead of >>>>>>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>>> >>>>>>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>>> used at >>>>>>>>>>>>>> line 730 >>>>>>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >>>>>>>>>>>>>> on the >>>>>>>>>>>>>> same >>>>>>>>>>>>>> line as dlsym... >>>>>>>>>>>>>> >>>>>>>>>>>>>> $.02, Roger >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>>>>> check - >>>>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>> work >>>>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>>>> --------- >>>>>>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> --------- >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> I exported new JVM function to set native thread name, >>>>>>>>>>>>>>>>>>> and JLI >>>>>>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> First the launcher belongs to another team so core-libs >>>>>>>>>>>>>>>>>> will >>>>>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>>>>>>>>>>>>>> Thread.setName >>>>>>>>>>>>>>>>>> rather >>>>>>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>>>>> that case. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> At Thread.init time the thread is not alive, which is why >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> name is not set. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>>>>> check - >>>>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>> work >>>>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> ----- >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thus I think that we have to provide a function to set >>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>> thread name. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> [1] >>>>>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we >>>>>>>>>>>>>>>>>>>> do not >>>>>>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>>> Thu >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>>> Thu >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>>>>>>>>>>>>>>>> set_active_handles >>>>>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >>>>>>>>>>>>>>>>>>>>>>>>>> name in >>>>>>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >>>>>>>>>>>>>>>>>>>>>>>>>> starte >>>>>>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 29 >>>>>>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 30 >>>>>>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>>>>>>>>>>>>>>>>>>>>>>>>> "main"; >>>>>>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>>>> thread); >>>>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' >>>>>>>>>>>>>>>>>>>>>>>>>> and >>>>>>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and >>>>>>>>>>>>>>>>>>>>>>>>>> thus >>>>>>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>>> So I >>>>>>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we >>>>>>>>>>>>>>>>>>>>>>>>>> want >>>>>>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might >>>>>>>>>>>>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java >>>>>>>>>>>>>>>>>>>>>>>>>> Main >>>>>>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - >>>>>>>>>>>>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I >>>>>>>>>>>>>>>>>>>>>>>>>> think >>>>>>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name >>>>>>>>>>>>>>>>>>>>>>>>>> via >>>>>>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and >>>>>>>>>>>>>>>>>>>>>>>>>> main >>>>>>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review >>>>>>>>>>>>>>>>>>>>>>>>>> it? >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> From chris.hegarty at oracle.com Mon Apr 18 10:37:38 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 18 Apr 2016 11:37:38 +0100 Subject: RFR [9] 8147553: Remove sun.misc.ManagedLocalsThread from java.management Message-ID: <5714B8F2.1000304@oracle.com> 8056152 added a new constructor to java.lang.Thread to constructing Threads that do not inherit inheritable-thread-local initial values. Given there is now a supported API for creating such threads, other areas of the JDK should be updated to use it. This change updates the code in java.management to use the new Thread constructor. http://cr.openjdk.java.net/~chegar/8147553/ https://bugs.openjdk.java.net/browse/JDK-8147553 -Chris. From spliterator at gmail.com Mon Apr 18 11:12:58 2016 From: spliterator at gmail.com (Stefan Zobel) Date: Mon, 18 Apr 2016 13:12:58 +0200 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <1689211029.20160416190543@gmail.com> References: <1689211029.20160416190543@gmail.com> Message-ID: Hi Tagir, nice catch. I think this optimization is worthwile. I'm a bit surprised about the JMH results for limits 200 and 2000. limit = 200 is significantly faster than the unpatched code (with higher variance, though) and limit = 2000 is about the same, but with a significantly reduced variance. Maybe you'd need to increase the number of iterations / forks to get more stable results that are in line with expectations - or do I miss something here? Regards, Stefan 2016-04-16 15:05 GMT+02:00 Tagir F. Valeev : > Hello! > > Please review and sponsor the following patch: > https://bugs.openjdk.java.net/browse/JDK-8154387 > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r1/ > > The rationale is to speed-up the parallel processing for unordered > streams with low limit value. Such problems occur when you want to > perform expensive filtering and select at most x elements which pass > the filter (order does not matter). Currently unordered limit > operation buffers up to 128 elements for each parallel task before it > checks whether limit is reached. This is actually harmful when > requested limit is lower: much more elements are requested from the > upstream than necessary. Here's simple JMH test which illustrates the > problem: > > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ > It extracts the requested number of probable-primes from the list of > 10000 BigInteger numbers. The results with 9ea+111: > > Benchmark (limit) Mode Cnt Score Error Units > LimitTest.parLimit 2 avgt 30 108,971 ? 0,643 us/op > LimitTest.parLimit 20 avgt 30 934,176 ? 14,003 us/op > LimitTest.parLimit 200 avgt 30 8772,417 ? 190,609 us/op > LimitTest.parLimit 2000 avgt 30 41775,463 ? 1800,537 us/op > LimitTest.parUnorderedLimit 2 avgt 30 2557,798 ? 13,161 us/op > LimitTest.parUnorderedLimit 20 avgt 30 2578,283 ? 23,547 us/op > LimitTest.parUnorderedLimit 200 avgt 30 4577,318 ? 40,793 us/op > LimitTest.parUnorderedLimit 2000 avgt 30 12279,346 ? 523,823 us/op > LimitTest.seqLimit 2 avgt 30 34,831 ? 0,190 us/op > LimitTest.seqLimit 20 avgt 30 369,729 ? 1,427 us/op > LimitTest.seqLimit 200 avgt 30 3690,544 ? 13,907 us/op > LimitTest.seqLimit 2000 avgt 30 36681,637 ? 156,538 us/op > > When the limit is 2 or 20, parallel unordered version is slower than > parallel ordered! Even for limit = 200 it's still slower than > sequential operation. > > The idea of the patch is to tweak the CHUNK_SIZE using the given limit and > parallelism level. I used the following formula: > > this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, > (skip + limit) / ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; > > This does not affect cases when limit is big or not set at all (in > skip mode). However it greatly improves cases when limit is small: > > Benchmark (limit) Mode Cnt Score Error Units > LimitTest.parLimit 2 avgt 30 109,502 ? 0,750 us/op > LimitTest.parLimit 20 avgt 30 954,716 ? 39,276 us/op > LimitTest.parLimit 200 avgt 30 8706,226 ? 184,330 us/op > LimitTest.parLimit 2000 avgt 30 42126,346 ? 3163,444 us/op > LimitTest.parUnorderedLimit 2 avgt 30 39,303 ? 0,177 us/op !!! > LimitTest.parUnorderedLimit 20 avgt 30 266,107 ? 0,492 us/op !!! > LimitTest.parUnorderedLimit 200 avgt 30 2547,177 ? 58,538 us/op !!! > LimitTest.parUnorderedLimit 2000 avgt 30 12216,402 ? 430,574 us/op > LimitTest.seqLimit 2 avgt 30 34,993 ? 0,704 us/op > LimitTest.seqLimit 20 avgt 30 369,497 ? 1,754 us/op > LimitTest.seqLimit 200 avgt 30 3716,059 ? 61,054 us/op > LimitTest.seqLimit 2000 avgt 30 36814,356 ? 161,531 us/op > > Here you can see that unordered cases are significantly improved. Now > they are always faster than parallel ordered and faster than > sequential for limit >= 20. > > I did not think up how to test this patch as it does not change > visible behavior, only speed. However all the existing tests pass. > > What do you think? > > With best regards, > Tagir Valeev. > From amaembo at gmail.com Mon Apr 18 12:01:02 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Mon, 18 Apr 2016 18:01:02 +0600 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: References: <1689211029.20160416190543@gmail.com> Message-ID: <438268400.20160418180102@gmail.com> Hello! SZ> I'm a bit surprised about the JMH results for limits 200 and 2000. SZ> limit = 200 is significantly faster than the unpatched code (with SZ> higher variance, though) and limit = 2000 is about the same, but SZ> with a significantly reduced variance. Maybe you'd need to increase SZ> the number of iterations / forks to get more stable results that SZ> are in line with expectations - or do I miss something here? It was just a quick test not in the clean environment, so you should not draw any conclusions from the error numbers. It's quite expected that for limit = 2000 the performance is the same as I have 4 CPU machine and 2000 is greater than 128*4. On the other hand, 200 is less than 128*4, so this case is also improved (though not so drastically as less limits). With best regards, Tagir Valeev. SZ> Regards, SZ> Stefan SZ> 2016-04-16 15:05 GMT+02:00 Tagir F. Valeev : >> Hello! >> >> Please review and sponsor the following patch: >> https://bugs.openjdk.java.net/browse/JDK-8154387 >> http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r1/ >> >> The rationale is to speed-up the parallel processing for unordered >> streams with low limit value. Such problems occur when you want to >> perform expensive filtering and select at most x elements which pass >> the filter (order does not matter). Currently unordered limit >> operation buffers up to 128 elements for each parallel task before it >> checks whether limit is reached. This is actually harmful when >> requested limit is lower: much more elements are requested from the >> upstream than necessary. Here's simple JMH test which illustrates the >> problem: >> >> http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ >> It extracts the requested number of probable-primes from the list of >> 10000 BigInteger numbers. The results with 9ea+111: >> >> Benchmark (limit) Mode Cnt Score Error Units >> LimitTest.parLimit 2 avgt 30 108,971 ? 0,643 us/op >> LimitTest.parLimit 20 avgt 30 934,176 ? 14,003 us/op >> LimitTest.parLimit 200 avgt 30 8772,417 ? 190,609 us/op >> LimitTest.parLimit 2000 avgt 30 41775,463 ? 1800,537 us/op >> LimitTest.parUnorderedLimit 2 avgt 30 2557,798 ? 13,161 us/op >> LimitTest.parUnorderedLimit 20 avgt 30 2578,283 ? 23,547 us/op >> LimitTest.parUnorderedLimit 200 avgt 30 4577,318 ? 40,793 us/op >> LimitTest.parUnorderedLimit 2000 avgt 30 12279,346 ? 523,823 us/op >> LimitTest.seqLimit 2 avgt 30 34,831 ? 0,190 us/op >> LimitTest.seqLimit 20 avgt 30 369,729 ? 1,427 us/op >> LimitTest.seqLimit 200 avgt 30 3690,544 ? 13,907 us/op >> LimitTest.seqLimit 2000 avgt 30 36681,637 ? 156,538 us/op >> >> When the limit is 2 or 20, parallel unordered version is slower than >> parallel ordered! Even for limit = 200 it's still slower than >> sequential operation. >> >> The idea of the patch is to tweak the CHUNK_SIZE using the given limit and >> parallelism level. I used the following formula: >> >> this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, >> (skip + limit) / ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; >> >> This does not affect cases when limit is big or not set at all (in >> skip mode). However it greatly improves cases when limit is small: >> >> Benchmark (limit) Mode Cnt Score Error Units >> LimitTest.parLimit 2 avgt 30 109,502 ? 0,750 us/op >> LimitTest.parLimit 20 avgt 30 954,716 ? 39,276 us/op >> LimitTest.parLimit 200 avgt 30 8706,226 ? 184,330 us/op >> LimitTest.parLimit 2000 avgt 30 42126,346 ? 3163,444 us/op >> LimitTest.parUnorderedLimit 2 avgt 30 39,303 ? 0,177 us/op !!! >> LimitTest.parUnorderedLimit 20 avgt 30 266,107 ? 0,492 us/op !!! >> LimitTest.parUnorderedLimit 200 avgt 30 2547,177 ? 58,538 us/op !!! >> LimitTest.parUnorderedLimit 2000 avgt 30 12216,402 ? 430,574 us/op >> LimitTest.seqLimit 2 avgt 30 34,993 ? 0,704 us/op >> LimitTest.seqLimit 20 avgt 30 369,497 ? 1,754 us/op >> LimitTest.seqLimit 200 avgt 30 3716,059 ? 61,054 us/op >> LimitTest.seqLimit 2000 avgt 30 36814,356 ? 161,531 us/op >> >> Here you can see that unordered cases are significantly improved. Now >> they are always faster than parallel ordered and faster than >> sequential for limit >= 20. >> >> I did not think up how to test this patch as it does not change >> visible behavior, only speed. However all the existing tests pass. >> >> What do you think? >> >> With best regards, >> Tagir Valeev. >> From spliterator at gmail.com Mon Apr 18 12:07:57 2016 From: spliterator at gmail.com (Stefan Zobel) Date: Mon, 18 Apr 2016 14:07:57 +0200 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <438268400.20160418180102@gmail.com> References: <1689211029.20160416190543@gmail.com> <438268400.20160418180102@gmail.com> Message-ID: 2016-04-18 14:01 GMT+02:00 Tagir F. Valeev : > Hello! > > It was just a quick test not in the clean environment, so you should > not draw any conclusions from the error numbers. It's quite expected > that for limit = 2000 the performance is the same as I have 4 CPU > machine and 2000 is greater than 128*4. On the other hand, 200 is less > than 128*4, so this case is also improved (though not so drastically > as less limits). Thanks for the clarification Tagir. Makes sense now. I missed the "commonPoolParallelism + 1" bit ... Regards, Stefan > > With best regards, > Tagir Valeev. > From paul.sandoz at oracle.com Mon Apr 18 12:17:32 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 18 Apr 2016 14:17:32 +0200 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <1689211029.20160416190543@gmail.com> References: <1689211029.20160416190543@gmail.com> Message-ID: <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> Hi Tagir, > On 16 Apr 2016, at 15:05, Tagir F. Valeev wrote: > > Hello! > > Please review and sponsor the following patch: > https://bugs.openjdk.java.net/browse/JDK-8154387 Thanks for looking at this, it?s something i intended to get around to but never found the time. I closed JDK-8072841 as a dup of this. > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r1/ > 913 UnorderedSliceSpliterator(T_SPLITR s, long skip, long limit) { 914 this.s = s; 915 this.unlimited = limit < 0; 916 this.skipThreshold = limit >= 0 ? limit : 0; 917 this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, 918 (skip + limit) / ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; 919 this.permits = new AtomicLong(limit >= 0 ? skip + limit : skip); 920 } 921 Note the common pool parallelism can never be 0. I dunno if you added 1 for that or another reason. Did you consider: (skip + limit) / AbstractTask.LEAF_TARGET ? What if chunkSize is zero? should it be a minimum of 1? Testing wise i think our existing tests cover things ok. Performance-wise looks good. Probable primes are my favourite way of easily increasing Q (cost per op) :-) Can you run the stream tests and the perf tests with parallelism disabled: -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 ? Thanks, Paul. > The rationale is to speed-up the parallel processing for unordered > streams with low limit value. Such problems occur when you want to > perform expensive filtering and select at most x elements which pass > the filter (order does not matter). Currently unordered limit > operation buffers up to 128 elements for each parallel task before it > checks whether limit is reached. This is actually harmful when > requested limit is lower: much more elements are requested from the > upstream than necessary. Here's simple JMH test which illustrates the > problem: > > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ > It extracts the requested number of probable-primes from the list of > 10000 BigInteger numbers. The results with 9ea+111: > > Benchmark (limit) Mode Cnt Score Error Units > LimitTest.parLimit 2 avgt 30 108,971 ? 0,643 us/op > LimitTest.parLimit 20 avgt 30 934,176 ? 14,003 us/op > LimitTest.parLimit 200 avgt 30 8772,417 ? 190,609 us/op > LimitTest.parLimit 2000 avgt 30 41775,463 ? 1800,537 us/op > LimitTest.parUnorderedLimit 2 avgt 30 2557,798 ? 13,161 us/op > LimitTest.parUnorderedLimit 20 avgt 30 2578,283 ? 23,547 us/op > LimitTest.parUnorderedLimit 200 avgt 30 4577,318 ? 40,793 us/op > LimitTest.parUnorderedLimit 2000 avgt 30 12279,346 ? 523,823 us/op > LimitTest.seqLimit 2 avgt 30 34,831 ? 0,190 us/op > LimitTest.seqLimit 20 avgt 30 369,729 ? 1,427 us/op > LimitTest.seqLimit 200 avgt 30 3690,544 ? 13,907 us/op > LimitTest.seqLimit 2000 avgt 30 36681,637 ? 156,538 us/op > > When the limit is 2 or 20, parallel unordered version is slower than > parallel ordered! Even for limit = 200 it's still slower than > sequential operation. > > The idea of the patch is to tweak the CHUNK_SIZE using the given limit and > parallelism level. I used the following formula: > > this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, > (skip + limit) / ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; > > This does not affect cases when limit is big or not set at all (in > skip mode). However it greatly improves cases when limit is small: > > Benchmark (limit) Mode Cnt Score Error Units > LimitTest.parLimit 2 avgt 30 109,502 ? 0,750 us/op > LimitTest.parLimit 20 avgt 30 954,716 ? 39,276 us/op > LimitTest.parLimit 200 avgt 30 8706,226 ? 184,330 us/op > LimitTest.parLimit 2000 avgt 30 42126,346 ? 3163,444 us/op > LimitTest.parUnorderedLimit 2 avgt 30 39,303 ? 0,177 us/op !!! > LimitTest.parUnorderedLimit 20 avgt 30 266,107 ? 0,492 us/op !!! > LimitTest.parUnorderedLimit 200 avgt 30 2547,177 ? 58,538 us/op !!! > LimitTest.parUnorderedLimit 2000 avgt 30 12216,402 ? 430,574 us/op > LimitTest.seqLimit 2 avgt 30 34,993 ? 0,704 us/op > LimitTest.seqLimit 20 avgt 30 369,497 ? 1,754 us/op > LimitTest.seqLimit 200 avgt 30 3716,059 ? 61,054 us/op > LimitTest.seqLimit 2000 avgt 30 36814,356 ? 161,531 us/op > > Here you can see that unordered cases are significantly improved. Now > they are always faster than parallel ordered and faster than > sequential for limit >= 20. > > I did not think up how to test this patch as it does not change > visible behavior, only speed. However all the existing tests pass. > > What do you think? > > With best regards, > Tagir Valeev. > From amaembo at gmail.com Mon Apr 18 12:35:50 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Mon, 18 Apr 2016 18:35:50 +0600 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> Message-ID: <82218119.20160418183550@gmail.com> Hello! Thank you for review! PS> 913 UnorderedSliceSpliterator(T_SPLITR s, long skip, long limit) { PS> 914 this.s = s; PS> 915 this.unlimited = limit < 0; PS> 916 this.skipThreshold = limit >= 0 ? limit : 0; PS> 917 this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, PS> 918 (skip + limit) / PS> ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; PS> 919 this.permits = new AtomicLong(limit >= 0 ? skip + limit : skip); PS> 920 } PS> 921 PS> Note the common pool parallelism can never be 0. I dunno if you PS> added 1 for that or another reason. It's actually ((skip + limit) / ForkJoinPool.getCommonPoolParallelism()) + 1 Not (skip + limit) / (ForkJoinPool.getCommonPoolParallelism() + 1) Probably I should add explicit parentheses to make this clear. One is added exactly to make chunkSize at least 1. PS> Did you consider: PS> (skip + limit) / AbstractTask.LEAF_TARGET PS> ? It should not make drastic changes in my test, but I will try. PS> What if chunkSize is zero? should it be a minimum of 1? PS> Testing wise i think our existing tests cover things ok. PS> Performance-wise looks good. Probable primes are my favourite way PS> of easily increasing Q (cost per op) :-) PS> Can you run the stream tests and the perf tests with parallelism disabled: PS> -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 Ok. I think I should also test the performance for some high-N low-Q task to check whether it not degrades. Will perform all the tests later this week. By the way is these some special place to commit/store JMH tests (except CodeReview server), so they could be reused later? With best regards, Tagir Valeev. PS> ? PS> Thanks, PS> Paul. >> The rationale is to speed-up the parallel processing for unordered >> streams with low limit value. Such problems occur when you want to >> perform expensive filtering and select at most x elements which pass >> the filter (order does not matter). Currently unordered limit >> operation buffers up to 128 elements for each parallel task before it >> checks whether limit is reached. This is actually harmful when >> requested limit is lower: much more elements are requested from the >> upstream than necessary. Here's simple JMH test which illustrates the >> problem: >> >> http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ >> It extracts the requested number of probable-primes from the list of >> 10000 BigInteger numbers. The results with 9ea+111: >> >> Benchmark (limit) Mode Cnt Score Error Units >> LimitTest.parLimit 2 avgt 30 108,971 ? 0,643 us/op >> LimitTest.parLimit 20 avgt 30 934,176 ? 14,003 us/op >> LimitTest.parLimit 200 avgt 30 8772,417 ? 190,609 us/op >> LimitTest.parLimit 2000 avgt 30 41775,463 ? 1800,537 us/op >> LimitTest.parUnorderedLimit 2 avgt 30 2557,798 ? 13,161 us/op >> LimitTest.parUnorderedLimit 20 avgt 30 2578,283 ? 23,547 us/op >> LimitTest.parUnorderedLimit 200 avgt 30 4577,318 ? 40,793 us/op >> LimitTest.parUnorderedLimit 2000 avgt 30 12279,346 ? 523,823 us/op >> LimitTest.seqLimit 2 avgt 30 34,831 ? 0,190 us/op >> LimitTest.seqLimit 20 avgt 30 369,729 ? 1,427 us/op >> LimitTest.seqLimit 200 avgt 30 3690,544 ? 13,907 us/op >> LimitTest.seqLimit 2000 avgt 30 36681,637 ? 156,538 us/op >> >> When the limit is 2 or 20, parallel unordered version is slower than >> parallel ordered! Even for limit = 200 it's still slower than >> sequential operation. >> >> The idea of the patch is to tweak the CHUNK_SIZE using the given limit and >> parallelism level. I used the following formula: >> >> this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, >> (skip + limit) / ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; >> >> This does not affect cases when limit is big or not set at all (in >> skip mode). However it greatly improves cases when limit is small: >> >> Benchmark (limit) Mode Cnt Score Error Units >> LimitTest.parLimit 2 avgt 30 109,502 ? 0,750 us/op >> LimitTest.parLimit 20 avgt 30 954,716 ? 39,276 us/op >> LimitTest.parLimit 200 avgt 30 8706,226 ? 184,330 us/op >> LimitTest.parLimit 2000 avgt 30 42126,346 ? 3163,444 us/op >> LimitTest.parUnorderedLimit 2 avgt 30 39,303 ? 0,177 us/op !!! >> LimitTest.parUnorderedLimit 20 avgt 30 266,107 ? 0,492 us/op !!! >> LimitTest.parUnorderedLimit 200 avgt 30 2547,177 ? 58,538 us/op !!! >> LimitTest.parUnorderedLimit 2000 avgt 30 12216,402 ? 430,574 us/op >> LimitTest.seqLimit 2 avgt 30 34,993 ? 0,704 us/op >> LimitTest.seqLimit 20 avgt 30 369,497 ? 1,754 us/op >> LimitTest.seqLimit 200 avgt 30 3716,059 ? 61,054 us/op >> LimitTest.seqLimit 2000 avgt 30 36814,356 ? 161,531 us/op >> >> Here you can see that unordered cases are significantly improved. Now >> they are always faster than parallel ordered and faster than >> sequential for limit >= 20. >> >> I did not think up how to test this patch as it does not change >> visible behavior, only speed. However all the existing tests pass. >> >> What do you think? >> >> With best regards, >> Tagir Valeev. >> From paul.sandoz at oracle.com Mon Apr 18 12:54:44 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 18 Apr 2016 14:54:44 +0200 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <82218119.20160418183550@gmail.com> References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> <82218119.20160418183550@gmail.com> Message-ID: <1888A4C6-194C-4BE0-9149-F169D38D1E5A@oracle.com> > On 18 Apr 2016, at 14:35, Tagir F. Valeev wrote: > > Hello! > > Thank you for review! > > PS> 913 UnorderedSliceSpliterator(T_SPLITR s, long skip, long limit) { > PS> 914 this.s = s; > PS> 915 this.unlimited = limit < 0; > PS> 916 this.skipThreshold = limit >= 0 ? limit : 0; > PS> 917 this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE, > PS> 918 (skip + limit) / > PS> ForkJoinPool.getCommonPoolParallelism() + 1) : CHUNK_SIZE; > PS> 919 this.permits = new AtomicLong(limit >= 0 ? skip + limit : skip); > PS> 920 } > PS> 921 > > PS> Note the common pool parallelism can never be 0. I dunno if you > PS> added 1 for that or another reason. > > It's actually > ((skip + limit) / ForkJoinPool.getCommonPoolParallelism()) + 1 > Not > (skip + limit) / (ForkJoinPool.getCommonPoolParallelism() + 1) > > Probably I should add explicit parentheses to make this clear. One is > added exactly to make chunkSize at least 1. > Doh. I think i need glasses? A comment on the range might help too. > PS> Did you consider: > > PS> (skip + limit) / AbstractTask.LEAF_TARGET > > PS> ? > > It should not make drastic changes in my test, but I will try. > Ok. > PS> What if chunkSize is zero? should it be a minimum of 1? > > PS> Testing wise i think our existing tests cover things ok. > > PS> Performance-wise looks good. Probable primes are my favourite way > PS> of easily increasing Q (cost per op) :-) > > PS> Can you run the stream tests and the perf tests with parallelism disabled: > > PS> -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 > > Ok. I think I should also test the performance for some high-N low-Q > task to check whether it not degrades. Will perform all the tests > later this week. > > By the way is these some special place to commit/store JMH tests > (except CodeReview server), so they could be reused later? > Not that i am aware of. The best thing for the moment is to place ?em on cr.openjdk as you have done. Paul. From daniel.fuchs at oracle.com Mon Apr 18 13:23:26 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Mon, 18 Apr 2016 15:23:26 +0200 Subject: RFR [9] 8153158: Remove sun.misc.ManagedLocalsThread from java.logging In-Reply-To: References: Message-ID: On 18/04/16 08:01, Chris Hegarty wrote: > 8056152 added a new constructor to java.lang.Thread to constructing Threads that > do not inherit inheritable-thread-local initial values. Given there is now a supported > API for creating such threads, other areas of the JDK should be updated to use it. > > This change updates the code in java.logging to use the new Thread constructor. Hi Chris, Looks good to me. best regards -- daniel > > --- a/src/java.logging/share/classes/java/util/logging/LogManager.java > +++ b/src/java.logging/share/classes/java/util/logging/LogManager.java > @@ -42,7 +42,6 @@ > import java.util.stream.Stream; > import jdk.internal.misc.JavaAWTAccess; > import jdk.internal.misc.SharedSecrets; > -import sun.misc.ManagedLocalsThread; > import sun.util.logging.internal.LoggingProviderImpl; > > /** > @@ -254,9 +253,10 @@ > > // This private class is used as a shutdown hook. > // It does a "reset" to close all open handlers. > - private class Cleaner extends ManagedLocalsThread { > + private class Cleaner extends Thread { > > private Cleaner() { > + super(null, null, "Logging-Cleaner", 0, false); > /* Set context class loader to null in order to avoid > * keeping a strong reference to an application classloader. > */ > diff --git a/src/java.logging/share/classes/module-info.java b/src/java.logging/share/classes/module-info.java > --- a/src/java.logging/share/classes/module-info.java > +++ b/src/java.logging/share/classes/module-info.java > @@ -24,8 +24,6 @@ > */ > > module java.logging { > - // 8153158 > - requires jdk.unsupported; > exports java.util.logging; > provides jdk.internal.logger.DefaultLoggerFinder with > sun.util.logging.internal.LoggingProviderImpl; > > -Chris. > From daniel.fuchs at oracle.com Mon Apr 18 13:24:31 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Mon, 18 Apr 2016 15:24:31 +0200 Subject: RFR [9] 8147553: Remove sun.misc.ManagedLocalsThread from java.management In-Reply-To: <5714B8F2.1000304@oracle.com> References: <5714B8F2.1000304@oracle.com> Message-ID: Hi Chris, The changes look good to me. best regards, -- daniel On 18/04/16 12:37, Chris Hegarty wrote: > 8056152 added a new constructor to java.lang.Thread to constructing > Threads that do not inherit inheritable-thread-local initial values. > Given there is now a supported API for creating such threads, other > areas of the JDK should be updated to use it. > > This change updates the code in java.management to use the new Thread > constructor. > > http://cr.openjdk.java.net/~chegar/8147553/ > https://bugs.openjdk.java.net/browse/JDK-8147553 > > -Chris. > From kumar.x.srinivasan at oracle.com Mon Apr 18 14:23:54 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Mon, 18 Apr 2016 07:23:54 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57146544.9050903@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5712BAB9.5040400@oracle.com> <57130544.8000601@gmail.com> <571367B6.5020808@oracle.com> <57146544.9050903@oracle.com> Message-ID: <5714EDFA.7070803@oracle.com> Hi, Looks ok to me. Thanks Kumar > On 17/04/2016 8:38 PM, David Holmes wrote: >> On 17/04/2016 1:38 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> Need to hear from core-libs and/or launcher folk as this touches a >>>> number of pieces of code. >>> >>> I'm waiting more reviewer(s) . >>> >>> BTW, Should I make patches which are based on jdk9/dev repos? >>> My proposal includes hotspot changes. >>> So I want to know whether I can push all changes jdk9/dev/{jdk,hotspot} >>> after reviewing. >> >> No, jdk9/hs please. > > And it will need to go via JPRT so I will sponsor it for you. > > Thanks, > David > >> Thanks, >> David >> >>> I can update my webrev to adapt to jdk9/dev repos if need. >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/17 7:20, David Holmes wrote: >>>> Hi Yasumasa, >>>> >>>> On 16/04/2016 7:29 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>> I uploaded new webrev: >>>>> >>>>> - hotspot: >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>> >>>>> - jdk: >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>> >>>> Ah sneaky! :) Using JNI to by-pass access control so we can set up a >>>> private method to do the name setting, yet avoid any API change that >>>> would require a CCC request. I think I like it. :) >>>> >>>> Need to hear from core-libs and/or launcher folk as this touches a >>>> number of pieces of code. >>>> >>>> Thanks, >>>> David >>>> ----- >>>> >>>>> >>>>>> it won't work unless you change the semantics of setName so I'm not >>>>>> sure what you were thinking here. To take advantage of an arg taking >>>>>> JVM_SetNativThreadName you would need to call it directly as no Java >>>>>> code will call it . ??? >>>>> >>>>> I added a flag for setting native thread name to JNI-attached thread. >>>>> This change can set native thread name if main thread changes to >>>>> JNI-attached thread. >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/16 16:11, David Holmes wrote: >>>>>> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>> Hi David, >>>>>>> >>>>>>>> That change in behaviour may be a problem, it could be >>>>>>>> considered a >>>>>>>> regression that setName stops setting the native thread main, even >>>>>>>> though we never really intended it to work in the first place. :( >>>>>>>> Such >>>>>>>> a change needs to go through CCC. >>>>>>> >>>>>>> I understood. >>>>>>> Can I send CCC request? >>>>>>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>> >>>>>> Sorry you can't file a CCC request, you would need a sponsor for >>>>>> that. >>>>>> But at this stage I don't think I agree with the proposed change >>>>>> because of the change in behaviour - there's no way to restore the >>>>>> "broken" behaviour. >>>>>> >>>>>>> I want to continue to discuss about it on JDK-8154331 [1]. >>>>>> >>>>>> Okay we can do that. >>>>>> >>>>>>> >>>>>>>> Further, we expect the launcher to use the supported JNI interface >>>>>>>> (as >>>>>>>> other processes would), not the internal JVM interface that exists >>>>>>>> for >>>>>>>> the JDK sources to communicate with the JVM. >>>>>>> >>>>>>> I think that we do not use JVM interface if we add new method in >>>>>>> LauncherHelper as below: >>>>>>> ---------------- >>>>>>> diff -r f02139a1ac84 >>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>> @@ -960,4 +960,8 @@ >>>>>>> else >>>>>>> return md.toNameAndVersion() + " (" + loc + ")"; >>>>>>> } >>>>>>> + >>>>>>> + static void setNativeThreadName(String name) { >>>>>>> + Thread.currentThread().setName(name); >>>>>>> + } >>>>>> >>>>>> You could also make that call via JNI directly, so not sure the >>>>>> helper >>>>>> adds much here. But it won't work unless you change the semantics of >>>>>> setName so I'm not sure what you were thinking here. To take >>>>>> advantage >>>>>> of an arg taking JVM_SetNativThreadName you would need to call it >>>>>> directly as no Java code will call it . ??? >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>>> } >>>>>>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>>>>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 >>>>>>> 14:19:30 >>>>>>> 2016 +0000 >>>>>>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 >>>>>>> 11:25:53 >>>>>>> 2016 +0900 >>>>>>> @@ -125,6 +125,7 @@ >>>>>>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>>> static void ListModules(JNIEnv* env, char *optString); >>>>>>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>>>>> >>>>>>> static void SetPaths(int argc, char **argv); >>>>>>> >>>>>>> @@ -325,6 +326,7 @@ >>>>>>> * mainThread.isAlive() to work as expected. >>>>>>> */ >>>>>>> #define LEAVE() \ >>>>>>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>> do { \ >>>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>> @@ -488,6 +490,9 @@ >>>>>>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>> >>>>>>> + /* Set native thread name. */ >>>>>>> + SetNativeThreadName(env, "main"); >>>>>>> + >>>>>>> /* Invoke main method. */ >>>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>> mainArgs); >>>>>>> >>>>>>> @@ -1686,6 +1691,22 @@ >>>>>>> joptString); >>>>>>> } >>>>>>> >>>>>>> +/** >>>>>>> + * Set native thread name as possible. >>>>>>> + */ >>>>>>> +static void >>>>>>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>> +{ >>>>>>> + jmethodID setNativeThreadNameID; >>>>>>> + jstring nameString; >>>>>>> + jclass cls = GetLauncherHelperClass(env); >>>>>>> + NULL_CHECK(cls); >>>>>>> + NULL_CHECK(setNativeThreadNameID = >>>>>>> (*env)->GetStaticMethodID(env, cls, >>>>>>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>>>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>>>>>> nameString); >>>>>>> +} >>>>>>> + >>>>>>> /* >>>>>>> * Prints default usage or the Xusage message, see >>>>>>> sun.launcher.LauncherHelper.java >>>>>>> */ >>>>>>> ---------------- >>>>>>> >>>>>>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>>> >>>>>>>> However this is still a change to the exported JVM interface >>>>>>>> and so >>>>>>>> has to be approved. >>>>>>> >>>>>>> Do you mean that this change needs CCC? >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> [1] >>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>> Hi David, >>>>>>>>> >>>>>>>>>> I think it is a bug based on the comment here: >>>>>>>>>> >>>>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>>>> thread and >>>>>>>>>> JNI attached threads >>>>>>>>> >>>>>>>>> I filed it to JBS as JDK-8154331. >>>>>>>>> I will send review request to hotspot-runtime-dev. >>>>>>>>> >>>>>>>>> >>>>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>>>> setName >>>>>>>>>> will no longer set the native name for the main thread. >>>>>>>>> >>>>>>>>> I know. >>>>>>>> >>>>>>>> That change in behaviour may be a problem, it could be >>>>>>>> considered a >>>>>>>> regression that setName stops setting the native thread main, even >>>>>>>> though we never really intended it to work in the first place. :( >>>>>>>> Such >>>>>>>> a change needs to go through CCC. >>>>>>>> >>>>>>>>> I checked changeset history. >>>>>>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and >>>>>>>>> it is >>>>>>>>> backported JDK 8. >>>>>>>> >>>>>>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>>> >>>>>>>>> However, this function seems to be called from >>>>>>>>> Thread#setNativeName() >>>>>>>>> only. >>>>>>>>> In addition, Thread#setNativeName() is private method. >>>>>>>>> >>>>>>>>> Thus I think that we can add an argument to >>>>>>>>> JVM_SetNativeThreadName() >>>>>>>>> for force setting. >>>>>>>>> (e.g. "bool forced") >>>>>>>>> >>>>>>>>> It makes a change of JVM API. >>>>>>>>> However, this function is NOT public, so I think we can add one >>>>>>>>> more >>>>>>>>> argument. >>>>>>>>> >>>>>>>>> What do you think about this? >>>>>>>>> If it is accepted, we can set native thread name from Java >>>>>>>>> launcher. >>>>>>>> >>>>>>>> The private/public aspect of the Java API is not really at issue. >>>>>>>> Yes >>>>>>>> we would add another arg to the JVM function to allow it to >>>>>>>> apply to >>>>>>>> JNI-attached threads as well (I'd prefer the arg reflect that not >>>>>>>> just >>>>>>>> "force"). However this is still a change to the exported JVM >>>>>>>> interface >>>>>>>> and so has to be approved. Further, we expect the launcher to use >>>>>>>> the >>>>>>>> supported JNI interface (as other processes would), not the >>>>>>>> internal >>>>>>>> JVM interface that exists for the JDK sources to communicate with >>>>>>>> the >>>>>>>> JVM. >>>>>>>> >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>> Hi Yasumasa, >>>>>>>>>> >>>>>>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi David, >>>>>>>>>>> >>>>>>>>>>>> The fact that the "main" thread is not tagged as being a >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> thread seems accidental to me >>>>>>>>>>> >>>>>>>>>>> Should I file it to JBS? >>>>>>>>>> >>>>>>>>>> I think it is a bug based on the comment here: >>>>>>>>>> >>>>>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>>>>>>> thread and >>>>>>>>>> JNI attached threads >>>>>>>>>> >>>>>>>>>> Though that will introduce a change in behaviour by itself as >>>>>>>>>> setName >>>>>>>>>> will no longer set the native name for the main thread. >>>>>>>>>> >>>>>>>>>>> I think that we can fix as below: >>>>>>>>>>> --------------- >>>>>>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 >>>>>>>>>>> 2016 >>>>>>>>>>> +0200 >>>>>>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 >>>>>>>>>>> 2016 >>>>>>>>>>> +0900 >>>>>>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>> >>>>>>>>>>> // Attach the main thread to this os thread >>>>>>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>> // must do this before set_active_handles >>>>>>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>> // Notify JVMTI agents that VM initialization is complete - >>>>>>>>>>> nop if >>>>>>>>>>> no agents. >>>>>>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>> >>>>>>>>>>> + // Change attach status to "attached" >>>>>>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>> + >>>>>>>>>> >>>>>>>>>> I think we can do this straight after the JavaThread >>>>>>>>>> constructor. >>>>>>>>>> >>>>>>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>>>>>> backend."); >>>>>>>>>>> } >>>>>>>>>>> --------------- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> If it wants to name its native threads then it is free to >>>>>>>>>>>> do so, >>>>>>>>>>> >>>>>>>>>>> Currently, JVM_SetNativeThreadName() cannot change native >>>>>>>>>>> thread >>>>>>>>>>> name >>>>>>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>>> However, I think that it should be changed if Java developer >>>>>>>>>>> calls >>>>>>>>>>> Thread#setName() explicitly. >>>>>>>>>>> It is not the same of changing native thread name at >>>>>>>>>>> Threads::create_vm(). >>>>>>>>>>> >>>>>>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>>>>>> What do you think about this? >>>>>>>>>> >>>>>>>>>> The decision to not change the name of JNI-attached threads >>>>>>>>>> was a >>>>>>>>>> deliberate one** - this functionality originated with the OSX >>>>>>>>>> port >>>>>>>>>> and >>>>>>>>>> it was reported that the initial feedback with this feature >>>>>>>>>> was to >>>>>>>>>> ensure it didn't mess with thread names that had been set by the >>>>>>>>>> host >>>>>>>>>> process. If we do as you propose then we will just have an >>>>>>>>>> inconsistency for people to complain about: "why does my native >>>>>>>>>> thread >>>>>>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>>>>>> >>>>>>>>>> ** If you follow the bugs and related discussions on this, the >>>>>>>>>> semantics and limitations (truncation, current thread only, >>>>>>>>>> non-JNI >>>>>>>>>> threads only) of setting the native thread name were supposed >>>>>>>>>> to be >>>>>>>>>> documented in the release notes - but as far as I can see that >>>>>>>>>> never >>>>>>>>>> happened. :( >>>>>>>>>> >>>>>>>>>> My position on this remains that if it is desirable for the main >>>>>>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>>>>>> launcher needs to be setting them using the available platform >>>>>>>>>> APIs. >>>>>>>>>> Unfortunately this is complicated - as evidenced by the VM code >>>>>>>>>> for >>>>>>>>>> this - due to the need to verify API availability. >>>>>>>>>> >>>>>>>>>> Any change in behaviour in relation to Thread.setName would have >>>>>>>>>> to go >>>>>>>>>> through our CCC process I think. But a change in the launcher >>>>>>>>>> would >>>>>>>>>> not. >>>>>>>>>> >>>>>>>>>> Sorry. >>>>>>>>>> >>>>>>>>>> David >>>>>>>>>> ----- >>>>>>>>>> >>>>>>>>>>> --------------- >>>>>>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 >>>>>>>>>>> 2016 >>>>>>>>>>> +0200 >>>>>>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 >>>>>>>>>>> 2016 >>>>>>>>>>> +0900 >>>>>>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>>>>>> // Thread naming only supported for the current thread, >>>>>>>>>>> doesn't >>>>>>>>>>> work >>>>>>>>>>> for >>>>>>>>>>> // target threads. >>>>>>>>>>> - if (Thread::current() == thr && >>>>>>>>>>> !thr->has_attached_via_jni()) { >>>>>>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>> // we don't set the name of an attached thread to avoid >>>>>>>>>>> stepping >>>>>>>>>>> // on other programs >>>>>>>>>>> const char *thread_name = >>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> --------------- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Roger, >>>>>>>>>>>>> Thanks for your comment! >>>>>>>>>>>>> >>>>>>>>>>>>> David, >>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't >>>>>>>>>>>>>>>> like >>>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>>>>>>>>>>>> I tried to call Thread#setName() after initializing VM >>>>>>>>>>>>> (before >>>>>>>>>>>>> calling >>>>>>>>>>>>> main method), >>>>>>>>>>>>> I could set native thread name. >>>>>>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we >>>>>>>>>>>>> can't >>>>>>>>>>>>> set >>>>>>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>> >>>>>>>>>>>> Right - I came to the same realization earlier this morning. >>>>>>>>>>>> Which, >>>>>>>>>>>> unfortunately, takes me back to the basic premise here that we >>>>>>>>>>>> don't >>>>>>>>>>>> set the name of threads not created by the JVM. The fact that >>>>>>>>>>>> the >>>>>>>>>>>> "main" thread is not tagged as being a JNI-attached thread >>>>>>>>>>>> seems >>>>>>>>>>>> accidental to me - so JVM_SetNativeThreadName is only >>>>>>>>>>>> working by >>>>>>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>>>>>>>>> named at >>>>>>>>>>>> the native level. >>>>>>>>>>>> >>>>>>>>>>>> I'm afraid my view here is that the launcher has to be treated >>>>>>>>>>>> like >>>>>>>>>>>> any other process that might host a JVM. If it wants to >>>>>>>>>>>> name its >>>>>>>>>>>> native threads then it is free to do so, but I would not be >>>>>>>>>>>> exporting >>>>>>>>>>>> a function from the JVM to do that - it would have to use >>>>>>>>>>>> the OS >>>>>>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>>>>>> >>>>>>>>>>>> Sorry. >>>>>>>>>>>> >>>>>>>>>>>> David >>>>>>>>>>>> ----- >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Comments: >>>>>>>>>>>>>> >>>>>>>>>>>>>> jvm.h: The function names are too similar but perform >>>>>>>>>>>>>> different >>>>>>>>>>>>>> functions: >>>>>>>>>>>>>> >>>>>>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>>>>>> >>>>>>>>>>>>>> - The first function applies to the current thread, the >>>>>>>>>>>>>> second >>>>>>>>>>>>>> one a >>>>>>>>>>>>>> specific java thread. >>>>>>>>>>>>>> It would seem useful for there to be a comment somewhere >>>>>>>>>>>>>> about >>>>>>>>>>>>>> what >>>>>>>>>>>>>> the new function does. >>>>>>>>>>>>>> >>>>>>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>>>>>> instead of >>>>>>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>>> >>>>>>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>>> used at >>>>>>>>>>>>>> line 730 >>>>>>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >>>>>>>>>>>>>> on the >>>>>>>>>>>>>> same >>>>>>>>>>>>>> line as dlsym... >>>>>>>>>>>>>> >>>>>>>>>>>>>> $.02, Roger >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> That is an interesting question which I haven't had >>>>>>>>>>>>>>>> time to >>>>>>>>>>>>>>>> check - >>>>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>> work >>>>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>>>> --------- >>>>>>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> --------- >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't >>>>>>>>>>>>>>>> like >>>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> I exported new JVM function to set native thread name, >>>>>>>>>>>>>>>>>>> and JLI >>>>>>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> First the launcher belongs to another team so core-libs >>>>>>>>>>>>>>>>>> will >>>>>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>>>>> review and approve this (in particular Kumar) - now >>>>>>>>>>>>>>>>>> cc'd. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>>>>>>>>>>>>>> Thread.setName >>>>>>>>>>>>>>>>>> rather >>>>>>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot >>>>>>>>>>>>>>>>>> changes >>>>>>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>>>>> that case. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>>>>>>>>>> Thread#setName() in >>>>>>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> At Thread.init time the thread is not alive, which is why >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> name is not set. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> That is an interesting question which I haven't had >>>>>>>>>>>>>>>> time to >>>>>>>>>>>>>>>> check - >>>>>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>> work >>>>>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't >>>>>>>>>>>>>>>> like >>>>>>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> ----- >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thus I think that we have to provide a function to set >>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>> thread name. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> [1] >>>>>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we >>>>>>>>>>>>>>>>>>>> do not >>>>>>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes >>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>>> Thu >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>>>>> Thu >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>>>>>>>>>>>>>>>> set_active_handles >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >>>>>>>>>>>>>>>>>>>>>>>>>> name in >>>>>>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, >>>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >>>>>>>>>>>>>>>>>>>>>>>>>> starte >>>>>>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad >>>>>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something >>>>>>>>>>>>>>>>>>>>>>>>>> like >>>>>>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 29 >>>>>>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>>>>>>>>>>>>>>>>>>>>>>>>> Mar 30 >>>>>>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>>>>>>>>>>>>>>>>>>>>>>>>> "main"; >>>>>>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>>>> thread); >>>>>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' >>>>>>>>>>>>>>>>>>>>>>>>>> and >>>>>>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and >>>>>>>>>>>>>>>>>>>>>>>>>> thus >>>>>>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is >>>>>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>>> So I >>>>>>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, >>>>>>>>>>>>>>>>>>>>>>>>>> since we >>>>>>>>>>>>>>>>>>>>>>>>>> want >>>>>>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might >>>>>>>>>>>>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java >>>>>>>>>>>>>>>>>>>>>>>>>> Main >>>>>>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>>>>>>>>>>>>>>>>>>>>>>>>> launcher - >>>>>>>>>>>>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I >>>>>>>>>>>>>>>>>>>>>>>>>> think >>>>>>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name >>>>>>>>>>>>>>>>>>>>>>>>>> via >>>>>>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and >>>>>>>>>>>>>>>>>>>>>>>>>> main >>>>>>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should >>>>>>>>>>>>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review >>>>>>>>>>>>>>>>>>>>>>>>>> it? >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> From Alan.Bateman at oracle.com Mon Apr 18 14:57:34 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 18 Apr 2016 15:57:34 +0100 Subject: 8154159: rmic should not have a supported entry point Message-ID: <5714F5DE.80906@oracle.com> When we brought the module system into JDK 9 then it included a new entry point for the RMI compiler (rmic). This was a mistake (conflicts with the policy for root modules that we have in JEP 261) and should not have been brought into JDK 9. The following patch removes it, it has already been removed from the jake forest: http://cr.openjdk.java.net/~alanb/8154159/webrev/ Thanks, Alan From Roger.Riggs at Oracle.com Mon Apr 18 15:10:56 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 18 Apr 2016 11:10:56 -0400 Subject: 8154159: rmic should not have a supported entry point In-Reply-To: <5714F5DE.80906@oracle.com> References: <5714F5DE.80906@oracle.com> Message-ID: <5714F900.6010705@Oracle.com> Look fine. On 4/18/2016 10:57 AM, Alan Bateman wrote: > > When we brought the module system into JDK 9 then it included a new > entry point for the RMI compiler (rmic). This was a mistake (conflicts > with the policy for root modules that we have in JEP 261) and should > not have been brought into JDK 9. The following patch removes it, it > has already been removed from the jake forest: > > http://cr.openjdk.java.net/~alanb/8154159/webrev/ > > Thanks, > > Alan From chris.hegarty at oracle.com Mon Apr 18 15:15:31 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 18 Apr 2016 16:15:31 +0100 Subject: 8154159: rmic should not have a supported entry point In-Reply-To: <5714F5DE.80906@oracle.com> References: <5714F5DE.80906@oracle.com> Message-ID: <5714FA13.7000209@oracle.com> On 18/04/16 15:57, Alan Bateman wrote: > > When we brought the module system into JDK 9 then it included a new > entry point for the RMI compiler (rmic). This was a mistake (conflicts > with the policy for root modules that we have in JEP 261) and should not > have been brought into JDK 9. The following patch removes it, it has > already been removed from the jake forest: > > http://cr.openjdk.java.net/~alanb/8154159/webrev/ To satisfy myself, I checked the history of the files in the webrev, and your changes look like an accurate reversal of the mistaken changes in this area. Reviewed. -Chris. From markt at apache.org Mon Apr 18 15:58:51 2016 From: markt at apache.org (Mark Thomas) Date: Mon, 18 Apr 2016 16:58:51 +0100 Subject: Project Jigsaw, Apache Tomcat and RMI related memory leaks Message-ID: <5715043B.4090901@apache.org> Hi, The Apache Tomcat community was asked by Rory O'Donnell for feedback on JDK 9 + Project Jigsaw. Having provided that feedback we were directed here so I have reproduced that feedback below. I've started testing Tomcat trunk with JDK 9 + Project Jigsaw and it looks like we are going to hit a bunch of problems related to Tomcat's memory leak protection. The short version is there are lots of JDK calls that can result in a reference being retained to the current class loader. If that class loader is the web application class loader it often ends up being pinned in memory. This triggers a memory leak when the web application is reloaded since the web application class loader is not eligible for GC. Tomcat generally uses reflection to find these problems. It then does one of two things: - If the JRE provides an API the application developer should have used to clean up the reference, Tomcat does this for them and then logs a very loud error message telling the developer they need to fix their app. - If there is nothing the developer could have done to avoid the problem, Tomcat cleans it up. Usually this is via reflection again. Reporting this second class of issues as JRE bugs has been on my TODO list for a long time. It looks like Java 9 is going to bump this to the top of the list. The first problem we have hit is related to RMI. The memory leak is triggered by a call to: java.rmi.registry.Registry.bind() or java.rmi.registry.Registry.rebind() The problem occurs when an object of a class loaded by the web application class loader is bound to the RMI registry. There is no standard API (that I have found) that completely removes all references. In particular java.rmi.registry.Registry.unbind() doesn't help. The code Tomcat uses to clean this up is at [1]. Essentially, we need to remove any reference to the web application's class loader from the RMI caches. With JDK 9 this fails with: java.lang.reflect.InaccessibleObjectException: Unable to make member of class sun.rmi.transport.Target accessible: module java.rmi does not export sun.rmi.transport to unnamed module ... I took a look at the JDK 9 API but I could not find a way to bypass this. Possible solutions include: 1. Some way that allows us to continue to use reflection as per the current code. 2. A new method somewhere in the RMI API that clears all references associated with a given class loader from the cache. 3. Modify Registry.unbind() so it removes all references. 4. Something else... I do have a concern with 3 on its own that, while that would allow applications to clear their own references, it would mean Tomcat would have no way to check for the problem. Ideally, I'd like to see the API extended so a) applications are able to clean up after themselves and b) Tomcat can check for leaked references and generate error messages for the ones found. Any and all suggestions gratefully received. Thanks, Mark [1] http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?view=annotate#l2214 From xueming.shen at oracle.com Mon Apr 18 17:14:12 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Mon, 18 Apr 2016 10:14:12 -0700 Subject: RFR: JDK-815440: JRT filesystem loaded by JDK8 with URLClassLoader is not closable since JDK-8147460 Message-ID: <571515E4.5020808@oracle.com> Hi, Please help review the change for JDK-8154403 issue: https://bugs.openjdk.java.net/browse/JDK-8154403 webrev: http://cr.openjdk.java.net/~sherman/8154403/webrev/ The direct trigger of the failure is that the test case is passing in a null as parameter "env" to create a new jrt filesystem. The nio spec specifies that it will trigger NPE. The existing implementation does not check the "null" and passes it directly into JrtFileSystem's constructor, in which the "null" is interpreted as "a not closable jrt file system" (A implementation detail). The fix is to add the "null check" in the provider and pass in "empty map" in the test case. Alan, the original jrtfs implementation throws UOE in JrtFileSystemProvider.getTheFileSystem(), is it better to just "silently" ignore the close request for the "not-closable" jrt? I'm file with either way though. Thanks, Sherman From nadeesh.tv at oracle.com Mon Apr 18 17:28:29 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Mon, 18 Apr 2016 22:58:29 +0530 Subject: RFR:JDK-8154050:java.time.format.DateTimeFormatter can't parse localized zone-offset In-Reply-To: References: <570E5589.7080106@oracle.com> <570E6C2E.4060208@Oracle.com> Message-ID: <5715193D.3070604@oracle.com> Hi Roger/Stephen, On 4/18/2016 2:40 AM, Stephen Colebourne wrote: > The LDML spec indicates that the "GMT" string should be localized: > http://unicode.org/repos/cldr/trunk/specs/ldml/tr35-dates.html#Using_Time_Zone_Names > The text of appendLocalizedOffset() is written with the intention of > the output being localized (otherwise, what is the point of the > method!) > > I assume this was something that got missed when implementing > appendLocalizedOffset(). It may require additional localized data from > the LDML data files. If OK, I will create a new enhancement request for this in JBS Regards, Nadeesh > > This webrev looks fine. > Stephen > > > > On 13 April 2016 at 16:56, Roger Riggs wrote: >> Hi Nadeesh, >> >> The bugfix looks fine. >> >> The TODO comment on the "GMT" raises the question (as a separate issue) >> about implementing the TODO or removing the TODO comment. >> >> I'm not sure where the localized string for "GMT" would come from but it >> might be a useful improvement >> unless it was judged to a compatibility issue. >> >> Roger >> >> >> >> >> On 4/13/2016 10:19 AM, nadeesh tv wrote: >> >> HI all, >> >> Bug Id - https://bugs.openjdk.java.net/browse/JDK-8154050 >> >> Issue - java.time.format.DateTimeFormatter can't parse localized zone-offset >> >> Solution - Corrected the mistake in calculating parse end position and >> removed an unnecessary null check >> >> >> webrev - http://cr.openjdk.java.net/~ntv/8154050/webrev.00/ >> >> PS: TCKOffsetPrinterParser.test_print_localized() already contain some test >> cases related to parsing and formatting. therefore did not repeat in the new >> test cases file >> >> -- >> Thanks and Regards, >> Nadeesh TV >> >> -- Thanks and Regards, Nadeesh TV From martinrb at google.com Mon Apr 18 17:30:04 2016 From: martinrb at google.com (Martin Buchholz) Date: Mon, 18 Apr 2016 10:30:04 -0700 Subject: RFR: 8154470: defines.h confused about PROGNAME and JAVA_ARGS Message-ID: Hi Kumar and Alan, I'd like you to do a code review. http://cr.openjdk.java.net/~martin/webrevs/openjdk9/PROGNAME/ https://bugs.openjdk.java.net/browse/JDK-8154470 Sorry, I got carried away hacking on the tests. Some changes could be split out. Aside from fixing the logic error in defines.h, printing out tr.status is useless, because it just invokes Object.toString on PrintWriter - System.out.println(tr.status); + System.out.println(tr); It's complete coincidence this extends Kumar's recent test testJLDEnvWithTool. From Alan.Bateman at oracle.com Mon Apr 18 17:37:10 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 18 Apr 2016 18:37:10 +0100 Subject: RFR: JDK-815440: JRT filesystem loaded by JDK8 with URLClassLoader is not closable since JDK-8147460 In-Reply-To: <571515E4.5020808@oracle.com> References: <571515E4.5020808@oracle.com> Message-ID: <57151B46.9070203@oracle.com> On 18/04/2016 18:14, Xueming Shen wrote: > Hi, > > Please help review the change for JDK-8154403 > > issue: https://bugs.openjdk.java.net/browse/JDK-8154403 > webrev: http://cr.openjdk.java.net/~sherman/8154403/webrev/ > > The direct trigger of the failure is that the test case is passing in > a null as parameter > "env" to create a new jrt filesystem. The nio spec specifies that it > will trigger NPE. The > existing implementation does not check the "null" and passes it > directly into > JrtFileSystem's constructor, in which the "null" is interpreted as "a > not closable jrt file > system" (A implementation detail). > > The fix is to add the "null check" in the provider and pass in "empty > map" in the test case. > > Alan, the original jrtfs implementation throws UOE in > JrtFileSystemProvider.getTheFileSystem(), > is it better to just "silently" ignore the close request for the > "not-closable" jrt? I'm file with > either way though. L107 checks if env is null so that is not needed. Otherwise looks okay. If someone is attempting to close the file system returned by FileSystem.getFileSystem(URI.create("jrt:/")) then something is wrong. I may have suggested to Sundar that this throw UOE because this method is specified to throw this for the default file system. It should be okay to keep that behavior. -Alan From gerard.ziemski at oracle.com Mon Apr 18 18:14:15 2016 From: gerard.ziemski at oracle.com (Gerard Ziemski) Date: Mon, 18 Apr 2016 13:14:15 -0500 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57120600.6090005@gmail.com> References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> Message-ID: hi Yasumasa, Nice work. I have 2 questions: ======== File: java.c #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? after every single JNI call? In this example instead of NULL_CHECK, should we be using CHECK_EXCEPTION_NULL_LEAVE macro? #2 Should the comment for ?SetNativeThreadName? be ?Set native thread name if possible.? not "Set native thread name as possible.?? cheers > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga wrote: > > Hi David, > > I uploaded new webrev: > > - hotspot: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ > > - jdk: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ > > >> it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? > > I added a flag for setting native thread name to JNI-attached thread. > This change can set native thread name if main thread changes to JNI-attached thread. > > > Thanks, > > Yasumasa > > > On 2016/04/16 16:11, David Holmes wrote: >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> That change in behaviour may be a problem, it could be considered a >>>> regression that setName stops setting the native thread main, even >>>> though we never really intended it to work in the first place. :( Such >>>> a change needs to go through CCC. >>> >>> I understood. >>> Can I send CCC request? >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >> >> Sorry you can't file a CCC request, you would need a sponsor for that. But at this stage I don't think I agree with the proposed change because of the change in behaviour - there's no way to restore the "broken" behaviour. >> >>> I want to continue to discuss about it on JDK-8154331 [1]. >> >> Okay we can do that. >> >>> >>>> Further, we expect the launcher to use the supported JNI interface (as >>>> other processes would), not the internal JVM interface that exists for >>>> the JDK sources to communicate with the JVM. >>> >>> I think that we do not use JVM interface if we add new method in >>> LauncherHelper as below: >>> ---------------- >>> diff -r f02139a1ac84 >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> Wed Apr 13 14:19:30 2016 +0000 >>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> Sat Apr 16 11:25:53 2016 +0900 >>> @@ -960,4 +960,8 @@ >>> else >>> return md.toNameAndVersion() + " (" + loc + ")"; >>> } >>> + >>> + static void setNativeThreadName(String name) { >>> + Thread.currentThread().setName(name); >>> + } >> >> You could also make that call via JNI directly, so not sure the helper adds much here. But it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? >> >> David >> ----- >> >>> } >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>> 2016 +0000 >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>> 2016 +0900 >>> @@ -125,6 +125,7 @@ >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>> static void ShowSettings(JNIEnv* env, char *optString); >>> static void ListModules(JNIEnv* env, char *optString); >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>> >>> static void SetPaths(int argc, char **argv); >>> >>> @@ -325,6 +326,7 @@ >>> * mainThread.isAlive() to work as expected. >>> */ >>> #define LEAVE() \ >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>> do { \ >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>> @@ -488,6 +490,9 @@ >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>> >>> + /* Set native thread name. */ >>> + SetNativeThreadName(env, "main"); >>> + >>> /* Invoke main method. */ >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>> >>> @@ -1686,6 +1691,22 @@ >>> joptString); >>> } >>> >>> +/** >>> + * Set native thread name as possible. >>> + */ >>> +static void >>> +SetNativeThreadName(JNIEnv *env, char *name) >>> +{ >>> + jmethodID setNativeThreadNameID; >>> + jstring nameString; >>> + jclass cls = GetLauncherHelperClass(env); >>> + NULL_CHECK(cls); >>> + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>> nameString); >>> +} >>> + >>> /* >>> * Prints default usage or the Xusage message, see >>> sun.launcher.LauncherHelper.java >>> */ >>> ---------------- >>> >>> So I want to add new arg to JVM_SetNativeThreadName(). >>> >>>> However this is still a change to the exported JVM interface and so >>>> has to be approved. >>> >>> Do you mean that this change needs CCC? >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> [1] >>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>> >>> >>> >>> On 2016/04/16 7:26, David Holmes wrote: >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> I think it is a bug based on the comment here: >>>>>> >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>> JNI attached threads >>>>> >>>>> I filed it to JBS as JDK-8154331. >>>>> I will send review request to hotspot-runtime-dev. >>>>> >>>>> >>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>> will no longer set the native name for the main thread. >>>>> >>>>> I know. >>>> >>>> That change in behaviour may be a problem, it could be considered a >>>> regression that setName stops setting the native thread main, even >>>> though we never really intended it to work in the first place. :( Such >>>> a change needs to go through CCC. >>>> >>>>> I checked changeset history. >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>> backported JDK 8. >>>> >>>> Yes this all came in as part of the OSX port in 7u2. >>>> >>>>> However, this function seems to be called from Thread#setNativeName() >>>>> only. >>>>> In addition, Thread#setNativeName() is private method. >>>>> >>>>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>>>> for force setting. >>>>> (e.g. "bool forced") >>>>> >>>>> It makes a change of JVM API. >>>>> However, this function is NOT public, so I think we can add one more >>>>> argument. >>>>> >>>>> What do you think about this? >>>>> If it is accepted, we can set native thread name from Java launcher. >>>> >>>> The private/public aspect of the Java API is not really at issue. Yes >>>> we would add another arg to the JVM function to allow it to apply to >>>> JNI-attached threads as well (I'd prefer the arg reflect that not just >>>> "force"). However this is still a change to the exported JVM interface >>>> and so has to be approved. Further, we expect the launcher to use the >>>> supported JNI interface (as other processes would), not the internal >>>> JVM interface that exists for the JDK sources to communicate with the >>>> JVM. >>>> >>>> David >>>> ----- >>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>> Hi Yasumasa, >>>>>> >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>> Hi David, >>>>>>> >>>>>>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>>>>>> thread seems accidental to me >>>>>>> >>>>>>> Should I file it to JBS? >>>>>> >>>>>> I think it is a bug based on the comment here: >>>>>> >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>> JNI attached threads >>>>>> >>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>> will no longer set the native name for the main thread. >>>>>> >>>>>>> I think that we can fix as below: >>>>>>> --------------- >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>> #endif // INCLUDE_JVMCI >>>>>>> >>>>>>> // Attach the main thread to this os thread >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>> main_thread->initialize_thread_current(); >>>>>>> // must do this before set_active_handles >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>> // Notify JVMTI agents that VM initialization is complete - nop if >>>>>>> no agents. >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>> >>>>>>> + // Change attach status to "attached" >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>> + >>>>>> >>>>>> I think we can do this straight after the JavaThread constructor. >>>>>> >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>> backend."); >>>>>>> } >>>>>>> --------------- >>>>>>> >>>>>>> >>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>> >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>>>>>> when the caller thread is JNI-attached thread. >>>>>>> However, I think that it should be changed if Java developer calls >>>>>>> Thread#setName() explicitly. >>>>>>> It is not the same of changing native thread name at >>>>>>> Threads::create_vm(). >>>>>>> >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>> What do you think about this? >>>>>> >>>>>> The decision to not change the name of JNI-attached threads was a >>>>>> deliberate one** - this functionality originated with the OSX port and >>>>>> it was reported that the initial feedback with this feature was to >>>>>> ensure it didn't mess with thread names that had been set by the host >>>>>> process. If we do as you propose then we will just have an >>>>>> inconsistency for people to complain about: "why does my native thread >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>> >>>>>> ** If you follow the bugs and related discussions on this, the >>>>>> semantics and limitations (truncation, current thread only, non-JNI >>>>>> threads only) of setting the native thread name were supposed to be >>>>>> documented in the release notes - but as far as I can see that never >>>>>> happened. :( >>>>>> >>>>>> My position on this remains that if it is desirable for the main >>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>> launcher needs to be setting them using the available platform APIs. >>>>>> Unfortunately this is complicated - as evidenced by the VM code for >>>>>> this - due to the need to verify API availability. >>>>>> >>>>>> Any change in behaviour in relation to Thread.setName would have to go >>>>>> through our CCC process I think. But a change in the launcher would >>>>>> not. >>>>>> >>>>>> Sorry. >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>>> --------------- >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>> // Thread naming only supported for the current thread, doesn't >>>>>>> work >>>>>>> for >>>>>>> // target threads. >>>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>>>> + if (Thread::current() == thr) { >>>>>>> // we don't set the name of an attached thread to avoid stepping >>>>>>> // on other programs >>>>>>> const char *thread_name = >>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>> --------------- >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>> >>>>>>>> >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>> Roger, >>>>>>>>> Thanks for your comment! >>>>>>>>> >>>>>>>>> David, >>>>>>>>> >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>> exposing >>>>>>>>>>>> a new JVM function this way. >>>>>>>>> >>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>> calling >>>>>>>>> main method), >>>>>>>>> I could set native thread name. >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>>>> set >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>> >>>>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>>>> unfortunately, takes me back to the basic premise here that we don't >>>>>>>> set the name of threads not created by the JVM. The fact that the >>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>>>>>> the native level. >>>>>>>> >>>>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>> native threads then it is free to do so, but I would not be exporting >>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>> >>>>>>>> Sorry. >>>>>>>> >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> Comments: >>>>>>>>>> >>>>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>>>> functions: >>>>>>>>>> >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>> >>>>>>>>>> - The first function applies to the current thread, the second >>>>>>>>>> one a >>>>>>>>>> specific java thread. >>>>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>>>> what >>>>>>>>>> the new function does. >>>>>>>>>> >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>> instead of >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>> as is done on unix and mac. >>>>>>>>>> >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>>>> line 730 >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>>>> same >>>>>>>>>> line as dlsym... >>>>>>>>>> >>>>>>>>>> $.02, Roger >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>> check - >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>> then >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>> work >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>> >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>> --------- >>>>>>>>>>> public class Sleep{ >>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>> } >>>>>>>>>>> } >>>>>>>>>>> --------- >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>> exposing >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>> >>>>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>>>> need to >>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>>>> rather >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>> needed in >>>>>>>>>>>>>> that case. >>>>>>>>>>>>> >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>> >>>>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>>>> native >>>>>>>>>>>> name is not set. >>>>>>>>>>>> >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>> >>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>> check - >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>> then >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>> work >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>> >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>> exposing >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> David >>>>>>>>>>>> ----- >>>>>>>>>>>> >>>>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>>>> thread name. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> [1] >>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> From brian.burkhalter at oracle.com Mon Apr 18 18:37:57 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Mon, 18 Apr 2016 11:37:57 -0700 Subject: JDK 9 RFR of 8154183: (spec) {Data, }InputStream.read(byte[], int, int) - spec of offset argument confusing In-Reply-To: <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> References: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> Message-ID: <3D955157-CAAB-48ED-8AA2-742C277503B0@oracle.com> The patch has been updated in place to replace var with {@code var}, @exception with @throws, and align the text where needed only for the methods in question. Brian On Apr 15, 2016, at 3:46 PM, Brian Burkhalter wrote: > Re-posted with correct subject line. > > On Apr 15, 2016, at 3:35 PM, Brian Burkhalter wrote: > >> Please review at your convenience. >> >> Issue: https://bugs.openjdk.java.net/browse/JDK-8154183 >> Patch: http://cr.openjdk.java.net/~bpb/8154183/webrev.00/ >> >> Summary: >> 1) Reinstate the ObjectInputStream part of the fixforhttps://bugs.openjdk.java.net/browse/JDK-4150728 which was inadvertently reverted in a subsequent merge. >> 2) Apply the same clarifications and addition of missing exception/throws tags to both variants of readFully(). From Roger.Riggs at Oracle.com Mon Apr 18 19:45:27 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 18 Apr 2016 15:45:27 -0400 Subject: JDK 9 RFR of 8154183: (spec) {Data, }InputStream.read(byte[], int, int) - spec of offset argument confusing In-Reply-To: <3D955157-CAAB-48ED-8AA2-742C277503B0@oracle.com> References: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> <3D955157-CAAB-48ED-8AA2-742C277503B0@oracle.com> Message-ID: <57153957.5030300@Oracle.com> Hi Brian, Editorial cleanup. - In the new @throws NullPointerException and IndexOutOfBoundExceptions, the first word after the exception should not be capitalized. For example "if" instead of "If" makes it consistent with the existing doc DataInputStream: - "the start offset in*to* the" ; "in" preferred over "into" consistent with previous descriptions ObjectInputStream.java: line 1012+ - usually the @throws description is not a complete sentence and does not deserve a "." per-file-consistency... for example, + * @throws NullPointerException If {@code buf} is {@code null}*. *RandomAccessFile: 433+ - keep the alignment of the @param lines - @throws NPE; remvoe the training "." Roger p.s. There is a new version of webrev that generates convenient next and prev file links. On 4/18/2016 2:37 PM, Brian Burkhalter wrote: > The patch has been updated in place to replace var with {@code var}, @exception with @throws, and align the text where needed only for the methods in question. > > Brian > > On Apr 15, 2016, at 3:46 PM, Brian Burkhalter wrote: > >> Re-posted with correct subject line. >> >> On Apr 15, 2016, at 3:35 PM, Brian Burkhalter wrote: >> >>> Please review at your convenience. >>> >>> Issue: https://bugs.openjdk.java.net/browse/JDK-8154183 >>> Patch: http://cr.openjdk.java.net/~bpb/8154183/webrev.00/ >>> >>> Summary: >>> 1) Reinstate the ObjectInputStream part of the fixforhttps://bugs.openjdk.java.net/browse/JDK-4150728 which was inadvertently reverted in a subsequent merge. >>> 2) Apply the same clarifications and addition of missing exception/throws tags to both variants of readFully(). From brian.burkhalter at oracle.com Mon Apr 18 19:57:00 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Mon, 18 Apr 2016 12:57:00 -0700 Subject: JDK 9 RFR of 8154183: (spec) {Data, }InputStream.read(byte[], int, int) - spec of offset argument confusing In-Reply-To: <57153957.5030300@Oracle.com> References: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> <3D955157-CAAB-48ED-8AA2-742C277503B0@oracle.com> <57153957.5030300@Oracle.com> Message-ID: <3EBFBB48-F470-4CB1-A43F-40011EBDB02B@oracle.com> Hi Roger, On Apr 18, 2016, at 12:45 PM, Roger Riggs wrote: > Editorial cleanup. > - In the new @throws NullPointerException and IndexOutOfBoundExceptions, > the first word after the exception should not be capitalized. > For example "if" instead of "If" makes it consistent with the existing doc I noticed that but it was inconsistent throughout the files. Will Change. > DataInputStream: > - "the start offset in*to* the" ; "in" preferred over "into" consistent with previous descriptions > > ObjectInputStream.java: line 1012+ > - usually the @throws description is not a complete sentence and does not deserve a "." > per-file-consistency... > for example, > + * @throws NullPointerException If {@code buf} is {@code null}*. > > *RandomAccessFile: 433+ > > - keep the alignment of the @param lines > - @throws NPE; remvoe the training ?." Will update those also. > p.s. There is a new version of webrev that generates convenient next and prev file links. I noticed that in, I believe, Claes?s webrevs but had not updated mine yet; thanks for mentioning: it is convenient. Thanks, Brian From chris.hegarty at oracle.com Mon Apr 18 20:50:48 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Mon, 18 Apr 2016 21:50:48 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba Message-ID: This change updates the code in the cobra module to use the new Thread constructor that suppresses inheritable-thread-local initial values. http://cr.openjdk.java.net/~chegar/8148863/ https://bugs.openjdk.java.net/browse/JDK-8148863 I?m open to suggestions for better names for the Threads. -Chris. From brian.burkhalter at oracle.com Mon Apr 18 20:53:27 2016 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Mon, 18 Apr 2016 13:53:27 -0700 Subject: JDK 9 RFR of 8154183: (spec) {Data, }InputStream.read(byte[], int, int) - spec of offset argument confusing In-Reply-To: <57153957.5030300@Oracle.com> References: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> <3D955157-CAAB-48ED-8AA2-742C277503B0@oracle.com> <57153957.5030300@Oracle.com> Message-ID: A new patch generated using the latest version of webrev is here: http://cr.openjdk.java.net/~bpb/8154183/webrev.01/ I have addressed the various editorial comments except with respect to capitalizing the first word after the exception name and ending the @throws description with a period: I have made the new @throws clauses consistent with other such clauses already present in the same method. In some case this means starting with lower case, in others upper case; likewise in some cases there are periods at the end, in other cases not. Thanks, Brian On Apr 18, 2016, at 12:45 PM, Roger Riggs wrote: > - In the new @throws NullPointerException and IndexOutOfBoundExceptions, > the first word after the exception should not be capitalized. > For example "if" instead of "If" makes it consistent with the existing doc > > ObjectInputStream.java: line 1012+ > - usually the @throws description is not a complete sentence and does not deserve a "." > per-file-consistency... > for example, > + * @throws NullPointerException If {@code buf} is {@code null}*. From christoph.langer at sap.com Mon Apr 18 21:03:46 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Mon, 18 Apr 2016 21:03:46 +0000 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <570D6871.5000405@oracle.com> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> <570D6871.5000405@oracle.com> Message-ID: Hi Joe, here is the updated webrev where I incorporated your suggestions: http://cr.openjdk.java.net/~clanger/webrevs/8153781.1/ I also added a testcase. As for the message " DoctypedeclNotClosed ": I did it in several languages but there are some languages where I don't have the knowledge to create a localized string. Is there some process for this or would we just be ok with reverting to the English text for that particular message? Thanks in advance for your review :) All the best Christoph > -----Original Message----- > From: huizhe wang [mailto:huizhe.wang at oracle.com] > Sent: Dienstag, 12. April 2016 23:28 > To: Langer, Christoph > Cc: core-libs-dev at openjdk.java.net > Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: > EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping > large DOCTYPE section with CRLF at wrong place > > > On 4/12/2016 11:50 AM, Langer, Christoph wrote: > > Hi Joe, > > > > thanks as always for your suggestions and I'll try to work it in. It will probably > take me a little while as I'm currently busy with another thing. I'll update my > webrev eventually and add a testcase, too. > > Ok. > > > > But one question: I understand that the fix in skipDTD will be sufficient to fix > the issue. Nevetheless, can you explain me why the change in scanData is not > beneficial or could even cause issues? There are several places in scanData > when further loads are done. But only at this point where there's exactly one > character after CRLF at the end of the buffer the method just returns without > further load. If it wouldn't leave here it seems to me as if it would continue > correctly and load more data. That would probably also be better in the sense > of performance I guess?? > > It's there to handle the situation where a surrogate pair got split in > between buffers. > > -Joe > > > > > Thanks > > Christoph > > > >> -----Original Message----- > >> From: huizhe wang [mailto:huizhe.wang at oracle.com] > >> Sent: Dienstag, 12. April 2016 19:54 > >> To: Langer, Christoph > >> Cc: core-libs-dev at openjdk.java.net > >> Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: > >> EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when > skipping > >> large DOCTYPE section with CRLF at wrong place > >> > >> Also, EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET was a > >> wrong msg > >> id. It would be good to change that to DoctypedeclNotClosed and add a > >> message to XMLMessages.properties right before > DoctypedeclUnterminated, > >> sth. like the following: > >> > >> DoctypedeclNotClosed = The document type declaration for root element > >> type \"{0}\" must be closed with '']''. > >> > >> Thanks, > >> Joe > >> > >> On 4/11/2016 5:49 PM, huizhe wang wrote: > >>> On 4/7/2016 1:45 PM, Langer, Christoph wrote: > >>>> Hi, > >>>> > >>>> > >>>> > >>>> I've run into a peculiar issue with Xerces. > >>>> > >>>> > >>>> > >>>> The problem is happening when a DTD shall be skipped, the DTD is > >>>> larger than the buffer of the current entity and a CRLF sequence > >>>> occurs just one char before the buffer end. > >>>> > >>>> > >>>> > >>>> The reason is that method skipDTD of class XMLDTDScannerImpl (about > >>>> line 389) calls XMLEntityScanner.scanData() to scan for the next > >>>> occurrence of ']'. The scanData method might return true which > >>>> indicates that the delimiter ']' was not found yet and more data is > >>>> to scan. Other users of scanData would handle this and call this > >>>> method in a loop until it returns false or some other condition > >>>> happens. So I've fixed that place like at the other callers of scanData. > >>> This part of the change looks good. > >>>> > >>>> > >>>> Nevertheless, the scanData method would usually load more data when > >>>> it is at the end of the buffer. But in the special case when CRLF is > >>>> found at the end of buffer - 1, scanData would just return true. So I > >>>> also removed that check at line 1374 in XMLEntityScanner. Do you see > >>>> any problem with that? Is there any reason behind it which I'm > >>>> overseeing? > >>> No need to remove this after the above change. The parser needs to > >>> retain what's in the xml, e.g., not removing new lines. > >>>> Furthermore I took the chance for further little cleanups. I've added > >>>> the new copyright header to the files... is that the correct one? > >>> Yes, that's the right license header. However, > >>>> > >>>> I also aligned the calls to invokeListeners(position) in > >>>> XMLEntityScanner to always pass the actual position from which the > >>>> load is started. Do you think this is correct? > >>> Yes. > >>>> > >>>> > >>>> Here is the bug: > >>>> > >>>> https://bugs.openjdk.java.net/browse/JDK-8153781 > >>>> > >>>> > >>>> > >>>> Here is the webrev: > >>>> > >>>> http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ > >>>> > >>>> > >>>> > >>>> Please give me some comments before I finalize my change including a > >>>> jtreg testcase. > >>> It would be better if you had included the testcase so that the review > >>> can be done together with the code change. > >>> > >>> Thanks, > >>> Joe > >>> > >>>> > >>>> > >>>> Thanks & Best regards > >>>> > >>>> Christoph > >>>> > >>>> > >>>> From Roger.Riggs at Oracle.com Mon Apr 18 21:06:00 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 18 Apr 2016 17:06:00 -0400 Subject: JDK 9 RFR of 8154183: (spec) {Data, }InputStream.read(byte[], int, int) - spec of offset argument confusing In-Reply-To: References: <73583803-8861-4937-B873-A16F318F95E4@oracle.com> <563D390F-9B55-4425-B986-EAE44B947AFA@oracle.com> <3D955157-CAAB-48ED-8AA2-742C277503B0@oracle.com> <57153957.5030300@Oracle.com> Message-ID: <57154C38.7010308@Oracle.com> HI Brian, Looks good, Thanks for making them consistent, Roger On 4/18/2016 4:53 PM, Brian Burkhalter wrote: > A new patch generated using the latest version of webrev is here: > > http://cr.openjdk.java.net/~bpb/8154183/webrev.01/ > > > I have addressed the various editorial comments except with respect to > capitalizing the first word after the exception name and ending the > @throws description with a period: I have made the new @throws clauses > consistent with other such clauses already present in the same method. > In some case this means starting with lower case, in others upper > case; likewise in some cases there are periods at the end, in other > cases not. > > Thanks, > > Brian > > On Apr 18, 2016, at 12:45 PM, Roger Riggs > wrote: > >> - In the new @throws NullPointerException and IndexOutOfBoundExceptions, >> the first word after the exception should not be capitalized. >> For example "if" instead of "If" makes it consistent with the >> existing doc >> >> ObjectInputStream.java: line 1012+ >> - usually the @throws description is not a complete sentence and does >> not deserve a "." >> per-file-consistency... >> for example, >> + * @throws NullPointerException If {@code buf} is {@code null}*. > From stuart.marks at oracle.com Mon Apr 18 21:53:03 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 18 Apr 2016 14:53:03 -0700 Subject: RFR(m): 8145468 deprecations for java.lang In-Reply-To: <571416A1.5020509@oracle.com> References: <570EF756.2090602@oracle.com> <571416A1.5020509@oracle.com> Message-ID: <5715573F.3010201@oracle.com> On 4/17/16 4:05 PM, David Holmes wrote: > On 14/04/2016 11:50 AM, Stuart Marks wrote: >> The methods being deprecated with forRemoval=true are listed below. All >> of these methods have already been deprecated. They are all ill-defined, >> or they don't work, or they don't do anything useful. > > Surprised Thread.suspend/resume are not marked for removal given they are > effectively unusable. There's some rationale here. These methods (along with the no-arg Thread.stop()) have been deprecated for many years, since JDK 1.2 according to my research. Isn't it time to remove them? Well, the fact is that they do perform their intended functions: suspend() and resume() really do suspend and resume the target thread, and stop() really causes the target thread to throw ThreadDeath. No doubt using these is unsafe. Using them involves either some risk of deadlock or data corruption, or using them in such a restricted fashion that the risk is mitigated. In fact they do get a fair amount of use. It's not difficult to find a bunch of usages of them on grepcode.com. For example, Hadoop among other projects uses suspend/resume to test timeout handling code. I'm aware of frameworks that use stop() on runaway plugins in an attempt to initiate error recovery and an orderly shutdown. Clearly such usage isn't guaranteed to work, but it *might* work, and if so, it seems preferable to forcible termination of the entire JVM. That risk tradeoff is for the applications and frameworks to make. With this in mind it's not obvious to me that suspend/resume/stop ought to be deprecated for removal. This is certainly a worthwhile discussion to have. If someone has a pressing case to get rid of these, or perhaps just suspend/resume, by all means make it. I do think this should be considered separately from JDK-8145468, though. s'marks From stuart.marks at oracle.com Mon Apr 18 22:30:20 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 18 Apr 2016 15:30:20 -0700 Subject: RFR(m): 8145468u1 deprecations for java.lang In-Reply-To: <57139874.5000809@mebigfatguy.com> References: <57116CF2.4080108@oracle.com> <57139874.5000809@mebigfatguy.com> Message-ID: <57155FFC.7050907@oracle.com> On 4/17/16 7:06 AM, Dave Brosius wrote: > Along these lines, is there a reason not to deprecate the > > String(String s) > > constructor? Now that substring doesn't glom off the original string, i see no > reason for this constructor. It's a fair point. But I think that historically there's been much greater awareness of Strings' identity than that of boxed primitives. At issue is string interning. When you compile a Java program, a string literal like "foo" is unavoidably interned. This is wired deeply into the language, compiler, and JVM, and has been so since 1.0. With boxed primitives, there is autoboxing, but it's only been around since Java 5. ("Only" 11 years.) There is a cache, and although this is mandated by the JLS, it's actually maintained only by the library. The notion of identity of strings seems stronger, thus there's a greater need for new String(String) if you want to guarantee a string has a unique identity. It also seems much more likely for us to be able to turn boxed primitives into values than to turn strings into values. (One issue is that strings can be of all different sizes, whereas all instances/values of a boxed primitive are of the same size.) Thus there appears to be a greater benefit to migrating code away from the box constructors than from the String(String) constructor. This is probably something that should be revisited at some point, though. There are probably more misuses of String(String) out there than there are legitimate uses. s'marks From mark.reinhold at oracle.com Mon Apr 18 23:01:37 2016 From: mark.reinhold at oracle.com (mark.reinhold at oracle.com) Date: Mon, 18 Apr 2016 16:01:37 -0700 Subject: JDK 9 proposal: allocating ByteBuffers on heterogeneous memory In-Reply-To: <5B9F9ACA-BCA9-455A-9EA5-59ECEFBFAF7F@oracle.com> References: <484C3956-9D94-4686-BDDE-03F821D58A33@intel.com> <7809D2A6-9665-458F-B9DB-37A3FD1451EB@intel.com> <5B9F9ACA-BCA9-455A-9EA5-59ECEFBFAF7F@oracle.com> Message-ID: <20160418160137.493395728eggemoggin.niobe.net> 2016/4/8 1:41:47 -0700, paul.sandoz at oracle.com: > On 8 Apr 2016, at 00:03, Dohrmann, Steve wrote: >> Just to clarify, it is incidental that the proposed Memory interface >> has only one method. We see the value of the interface as >> nominative; a new type that can be passed around to abstract various >> sources of ByteBuffer memory. > > I suspected as much, but would prefer that we gain more experience on > what this interface should be, and how it intersects with other > efforts, rather than introducing a skeletal version now. I agree with Paul on this. It seems premature to introduce some kind of grand "Memory" abstraction. Without actual experience with a broad set of use cases we're almost certain to get it wrong. If what you want to do now can be expressed via IntFunction then that seems a good basis for further experimentation. - Mark From stevenschlansker at gmail.com Mon Apr 18 23:03:00 2016 From: stevenschlansker at gmail.com (Steven Schlansker) Date: Mon, 18 Apr 2016 16:03:00 -0700 Subject: RFR(m): 8145468u1 deprecations for java.lang In-Reply-To: <57155FFC.7050907@oracle.com> References: <57116CF2.4080108@oracle.com> <57139874.5000809@mebigfatguy.com> <57155FFC.7050907@oracle.com> Message-ID: > On Apr 18, 2016, at 3:30 PM, Stuart Marks wrote: > > On 4/17/16 7:06 AM, Dave Brosius wrote: >> Along these lines, is there a reason not to deprecate the >> >> String(String s) >> >> constructor? Now that substring doesn't glom off the original string, i see no >> reason for this constructor. > > It's a fair point. But I think that historically there's been much greater awareness of Strings' identity than that of boxed primitives. > > At issue is string interning. When you compile a Java program, a string literal like "foo" is unavoidably interned. This is wired deeply into the language, compiler, and JVM, and has been so since 1.0. > > With boxed primitives, there is autoboxing, but it's only been around since Java 5. ("Only" 11 years.) There is a cache, and although this is mandated by the JLS, it's actually maintained only by the library. > > The notion of identity of strings seems stronger, thus there's a greater need for new String(String) if you want to guarantee a string has a unique identity. > > It also seems much more likely for us to be able to turn boxed primitives into values than to turn strings into values. (One issue is that strings can be of all different sizes, whereas all instances/values of a boxed primitive are of the same size.) Thus there appears to be a greater benefit to migrating code away from the box constructors than from the String(String) constructor. > > This is probably something that should be revisited at some point, though. There are probably more misuses of String(String) out there than there are legitimate uses. As an example of a useful use of the new String(String) constructor, I once wrote (pseudo) code: WeakHashMap memoTable = new WeakHashMap<>(); public String memoTransform(String key) { String value = memoTable.get(key); if (value != null) return value; value = transform(key); // Might be identity function and return 'key' memoTable.put(key, (key == value) ? new String(value) : value); } If you aren't careful to copy your value in this sort of situation, you can end with never-collectible entries and therefore memory leaks in your weak hash table. If substring were specified to always return unique objects, that could work as well -- but in my opinion the copy constructor is clearer when object identity is important, and it looks like String sensibly avoids unnecessary copying: String.java:1933 return (beginIndex == 0) ? this : new String(value, beginIndex, subLen); From stuart.marks at oracle.com Mon Apr 18 23:05:47 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 18 Apr 2016 16:05:47 -0700 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5713C871.1080407@oracle.com> References: <5713C871.1080407@oracle.com> Message-ID: <5715684B.7020305@oracle.com> On 4/17/16 10:31 AM, joe darcy wrote: > With talk of deprecation in the air [1], I thought it would be a fine time to "In the Spring a young man's fancy lightly turns to thoughts of deprecation." -- apologies to Tennyson > examine one of the bugs on my list > > JDK-6850612: Deprecate Class.newInstance since it violates the checked > exception language contract > > As the title of the bug implies, The Class.newInstance method knowingly violates > the checking exception contract. This has long been documented in its > specification: [...] > > Comments on the bug have suggested that besides deprecating the method, a new > method on Class could be introduced, newInstanceWithProperExceptionBehavior, > that had the same signature but wrapped exceptions thrown by the constructor > call in the same way Constructor.newInstance does. Deprecating Class.newInstance() seems reasonable to me, for the reasons you've stated. It's not clear to me that a replacement method adds much value. I believe it's possible to replace a call clazz.newInstance() // 1 with the call clazz.getConstructor().newInstance() // 2 which is only a bit longer. Both snippets are declared to throw InstantiationException and IllegalAccessException. But snippet 2 also is declared to throw InvocationTargetException and NoSuchMethodException. This would seem to be an inconvenience, but *all* of these exceptions are subtypes of ReflectiveOperationException. It seems pretty likely to me that most code handles these different exception types the same way. So it's fairly low cost to replace snippet 1 with snippet 2, and to adjust the exception handling to deal with ReflectiveOperationException. Thus I don't see much value in adding a new method such as Class.newInstanceWithProperExceptionBehavior(). s'marks From kumar.x.srinivasan at oracle.com Mon Apr 18 23:14:21 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Mon, 18 Apr 2016 16:14:21 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> Message-ID: <57156A4D.5000401@oracle.com> Oops on my part, Gerard is right. We need to make SetNativeThreadName exit, if there is an error, otherwise it would enter the VM with an exception at the call site. So I think CHECK_EXCEPTION_NULL_LEAVE is the right thing to do, or we need to have a check and exit at the call site. Kumar > hi Yasumasa, > > Nice work. I have 2 questions: > > ======== > File: java.c > > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? after every single JNI call? In this example instead of NULL_CHECK, should we be using CHECK_EXCEPTION_NULL_LEAVE macro? > > #2 Should the comment for ?SetNativeThreadName? be ?Set native thread name if possible.? not "Set native thread name as possible.?? > > > cheers > >> On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga wrote: >> >> Hi David, >> >> I uploaded new webrev: >> >> - hotspot: >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >> >> - jdk: >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >> >> >>> it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? >> I added a flag for setting native thread name to JNI-attached thread. >> This change can set native thread name if main thread changes to JNI-attached thread. >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/16 16:11, David Holmes wrote: >>> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> That change in behaviour may be a problem, it could be considered a >>>>> regression that setName stops setting the native thread main, even >>>>> though we never really intended it to work in the first place. :( Such >>>>> a change needs to go through CCC. >>>> I understood. >>>> Can I send CCC request? >>>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>> Sorry you can't file a CCC request, you would need a sponsor for that. But at this stage I don't think I agree with the proposed change because of the change in behaviour - there's no way to restore the "broken" behaviour. >>> >>>> I want to continue to discuss about it on JDK-8154331 [1]. >>> Okay we can do that. >>> >>>>> Further, we expect the launcher to use the supported JNI interface (as >>>>> other processes would), not the internal JVM interface that exists for >>>>> the JDK sources to communicate with the JVM. >>>> I think that we do not use JVM interface if we add new method in >>>> LauncherHelper as below: >>>> ---------------- >>>> diff -r f02139a1ac84 >>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> Wed Apr 13 14:19:30 2016 +0000 >>>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> Sat Apr 16 11:25:53 2016 +0900 >>>> @@ -960,4 +960,8 @@ >>>> else >>>> return md.toNameAndVersion() + " (" + loc + ")"; >>>> } >>>> + >>>> + static void setNativeThreadName(String name) { >>>> + Thread.currentThread().setName(name); >>>> + } >>> You could also make that call via JNI directly, so not sure the helper adds much here. But it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? >>> >>> David >>> ----- >>> >>>> } >>>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>>> 2016 +0000 >>>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>>> 2016 +0900 >>>> @@ -125,6 +125,7 @@ >>>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>> static void ShowSettings(JNIEnv* env, char *optString); >>>> static void ListModules(JNIEnv* env, char *optString); >>>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>> >>>> static void SetPaths(int argc, char **argv); >>>> >>>> @@ -325,6 +326,7 @@ >>>> * mainThread.isAlive() to work as expected. >>>> */ >>>> #define LEAVE() \ >>>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> do { \ >>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>> @@ -488,6 +490,9 @@ >>>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>> >>>> + /* Set native thread name. */ >>>> + SetNativeThreadName(env, "main"); >>>> + >>>> /* Invoke main method. */ >>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>> >>>> @@ -1686,6 +1691,22 @@ >>>> joptString); >>>> } >>>> >>>> +/** >>>> + * Set native thread name as possible. >>>> + */ >>>> +static void >>>> +SetNativeThreadName(JNIEnv *env, char *name) >>>> +{ >>>> + jmethodID setNativeThreadNameID; >>>> + jstring nameString; >>>> + jclass cls = GetLauncherHelperClass(env); >>>> + NULL_CHECK(cls); >>>> + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, >>>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>>> nameString); >>>> +} >>>> + >>>> /* >>>> * Prints default usage or the Xusage message, see >>>> sun.launcher.LauncherHelper.java >>>> */ >>>> ---------------- >>>> >>>> So I want to add new arg to JVM_SetNativeThreadName(). >>>> >>>>> However this is still a change to the exported JVM interface and so >>>>> has to be approved. >>>> Do you mean that this change needs CCC? >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> [1] >>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>> >>>> >>>> >>>> On 2016/04/16 7:26, David Holmes wrote: >>>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>>> I think it is a bug based on the comment here: >>>>>>> >>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>>> JNI attached threads >>>>>> I filed it to JBS as JDK-8154331. >>>>>> I will send review request to hotspot-runtime-dev. >>>>>> >>>>>> >>>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>>> will no longer set the native name for the main thread. >>>>>> I know. >>>>> That change in behaviour may be a problem, it could be considered a >>>>> regression that setName stops setting the native thread main, even >>>>> though we never really intended it to work in the first place. :( Such >>>>> a change needs to go through CCC. >>>>> >>>>>> I checked changeset history. >>>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>>>>> backported JDK 8. >>>>> Yes this all came in as part of the OSX port in 7u2. >>>>> >>>>>> However, this function seems to be called from Thread#setNativeName() >>>>>> only. >>>>>> In addition, Thread#setNativeName() is private method. >>>>>> >>>>>> Thus I think that we can add an argument to JVM_SetNativeThreadName() >>>>>> for force setting. >>>>>> (e.g. "bool forced") >>>>>> >>>>>> It makes a change of JVM API. >>>>>> However, this function is NOT public, so I think we can add one more >>>>>> argument. >>>>>> >>>>>> What do you think about this? >>>>>> If it is accepted, we can set native thread name from Java launcher. >>>>> The private/public aspect of the Java API is not really at issue. Yes >>>>> we would add another arg to the JVM function to allow it to apply to >>>>> JNI-attached threads as well (I'd prefer the arg reflect that not just >>>>> "force"). However this is still a change to the exported JVM interface >>>>> and so has to be approved. Further, we expect the launcher to use the >>>>> supported JNI interface (as other processes would), not the internal >>>>> JVM interface that exists for the JDK sources to communicate with the >>>>> JVM. >>>>> >>>>> David >>>>> ----- >>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>> Hi Yasumasa, >>>>>>> >>>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi David, >>>>>>>> >>>>>>>>> The fact that the "main" thread is not tagged as being a JNI-attached >>>>>>>>> thread seems accidental to me >>>>>>>> Should I file it to JBS? >>>>>>> I think it is a bug based on the comment here: >>>>>>> >>>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and >>>>>>> JNI attached threads >>>>>>> >>>>>>> Though that will introduce a change in behaviour by itself as setName >>>>>>> will no longer set the native name for the main thread. >>>>>>> >>>>>>>> I think that we can fix as below: >>>>>>>> --------------- >>>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>> #endif // INCLUDE_JVMCI >>>>>>>> >>>>>>>> // Attach the main thread to this os thread >>>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>> main_thread->initialize_thread_current(); >>>>>>>> // must do this before set_active_handles >>>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>> // Notify JVMTI agents that VM initialization is complete - nop if >>>>>>>> no agents. >>>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>> >>>>>>>> + // Change attach status to "attached" >>>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>> + >>>>>>> I think we can do this straight after the JavaThread constructor. >>>>>>> >>>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>>>>> backend."); >>>>>>>> } >>>>>>>> --------------- >>>>>>>> >>>>>>>> >>>>>>>>> If it wants to name its native threads then it is free to do so, >>>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread name >>>>>>>> when the caller thread is JNI-attached thread. >>>>>>>> However, I think that it should be changed if Java developer calls >>>>>>>> Thread#setName() explicitly. >>>>>>>> It is not the same of changing native thread name at >>>>>>>> Threads::create_vm(). >>>>>>>> >>>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>>>>>>> What do you think about this? >>>>>>> The decision to not change the name of JNI-attached threads was a >>>>>>> deliberate one** - this functionality originated with the OSX port and >>>>>>> it was reported that the initial feedback with this feature was to >>>>>>> ensure it didn't mess with thread names that had been set by the host >>>>>>> process. If we do as you propose then we will just have an >>>>>>> inconsistency for people to complain about: "why does my native thread >>>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>>>> >>>>>>> ** If you follow the bugs and related discussions on this, the >>>>>>> semantics and limitations (truncation, current thread only, non-JNI >>>>>>> threads only) of setting the native thread name were supposed to be >>>>>>> documented in the release notes - but as far as I can see that never >>>>>>> happened. :( >>>>>>> >>>>>>> My position on this remains that if it is desirable for the main >>>>>>> thread (and DestroyJavaVM thread) to have native names then the >>>>>>> launcher needs to be setting them using the available platform APIs. >>>>>>> Unfortunately this is complicated - as evidenced by the VM code for >>>>>>> this - due to the need to verify API availability. >>>>>>> >>>>>>> Any change in behaviour in relation to Thread.setName would have to go >>>>>>> through our CCC process I think. But a change in the launcher would >>>>>>> not. >>>>>>> >>>>>>> Sorry. >>>>>>> >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> --------------- >>>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 >>>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 >>>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>>>>> // Thread naming only supported for the current thread, doesn't >>>>>>>> work >>>>>>>> for >>>>>>>> // target threads. >>>>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { >>>>>>>> + if (Thread::current() == thr) { >>>>>>>> // we don't set the name of an attached thread to avoid stepping >>>>>>>> // on other programs >>>>>>>> const char *thread_name = >>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>> --------------- >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>> >>>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>> Roger, >>>>>>>>>> Thanks for your comment! >>>>>>>>>> >>>>>>>>>> David, >>>>>>>>>> >>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>> exposing >>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>>>>>>>>> calling >>>>>>>>>> main method), >>>>>>>>>> I could set native thread name. >>>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't >>>>>>>>>> set >>>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>> Right - I came to the same realization earlier this morning. Which, >>>>>>>>> unfortunately, takes me back to the basic premise here that we don't >>>>>>>>> set the name of threads not created by the JVM. The fact that the >>>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>>>>>>>> accident for the initial attach, and can't be used for the >>>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently named at >>>>>>>>> the native level. >>>>>>>>> >>>>>>>>> I'm afraid my view here is that the launcher has to be treated like >>>>>>>>> any other process that might host a JVM. If it wants to name its >>>>>>>>> native threads then it is free to do so, but I would not be exporting >>>>>>>>> a function from the JVM to do that - it would have to use the OS >>>>>>>>> specific API's for that on a platform-by-platform basis. >>>>>>>>> >>>>>>>>> Sorry. >>>>>>>>> >>>>>>>>> David >>>>>>>>> ----- >>>>>>>>> >>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> Comments: >>>>>>>>>>> >>>>>>>>>>> jvm.h: The function names are too similar but perform different >>>>>>>>>>> functions: >>>>>>>>>>> >>>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>>>>>>>> >>>>>>>>>>> - The first function applies to the current thread, the second >>>>>>>>>>> one a >>>>>>>>>>> specific java thread. >>>>>>>>>>> It would seem useful for there to be a comment somewhere about >>>>>>>>>>> what >>>>>>>>>>> the new function does. >>>>>>>>>>> >>>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>>>>>>>>>> instead of >>>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>> as is done on unix and mac. >>>>>>>>>>> >>>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at >>>>>>>>>>> line 730 >>>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the >>>>>>>>>>> same >>>>>>>>>>> line as dlsym... >>>>>>>>>>> >>>>>>>>>>> $.02, Roger >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>> check - >>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>>> then >>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>>> work >>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native >>>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>> --------- >>>>>>>>>>>> public class Sleep{ >>>>>>>>>>>> public static void main(String[] args) throws Exception{ >>>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>> } >>>>>>>>>>>> } >>>>>>>>>>>> --------- >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>> exposing >>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI >>>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>> First the launcher belongs to another team so core-libs will >>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName >>>>>>>>>>>>>>> rather >>>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>> that case. >>>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>>> At Thread.init time the thread is not alive, which is why the >>>>>>>>>>>>> native >>>>>>>>>>>>> name is not set. >>>>>>>>>>>>> >>>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>>>>>>>>>> That is an interesting question which I haven't had time to >>>>>>>>>>>>> check - >>>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread >>>>>>>>>>>>> then >>>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should >>>>>>>>>>>>> work >>>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>> >>>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>>>>>>>>>>>> exposing >>>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> David >>>>>>>>>>>>> ----- >>>>>>>>>>>>> >>>>>>>>>>>>>> Thus I think that we have to provide a function to set native >>>>>>>>>>>>>> thread name. >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> [1] >>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> David >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not >>>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles >>>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in >>>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte >>>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 >>>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 >>>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; >>>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); >>>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus >>>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I >>>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want >>>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have >>>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. >>>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think >>>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via >>>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> From yasuenag at gmail.com Mon Apr 18 23:28:32 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Tue, 19 Apr 2016 08:28:32 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: References: <56F3F90D.9010408@gmail.com> <56F41AFF.4090002@oracle.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> Message-ID: Hi Gerard, 2016/04/19 3:14 "Gerard Ziemski" : > > hi Yasumasa, > > Nice work. I have 2 questions: > > ======== > File: java.c > > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? after every single JNI call? In this example instead of NULL_CHECK, should we be using CHECK_EXCEPTION_NULL_LEAVE macro? It is not critical if we encounter error at JNI function call because we cannot set native thread name only. So I think that we do not need to leave from launcher process. > #2 Should the comment for ?SetNativeThreadName? be ?Set native thread name if possible.? not "Set native thread name as possible.?? Sorry for my bad English :-) Thanks, Yasumasa > cheers > > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga wrote: > > > > Hi David, > > > > I uploaded new webrev: > > > > - hotspot: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ > > > > - jdk: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ > > > > > >> it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? > > > > I added a flag for setting native thread name to JNI-attached thread. > > This change can set native thread name if main thread changes to JNI-attached thread. > > > > > > Thanks, > > > > Yasumasa > > > > > > On 2016/04/16 16:11, David Holmes wrote: > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: > >>> Hi David, > >>> > >>>> That change in behaviour may be a problem, it could be considered a > >>>> regression that setName stops setting the native thread main, even > >>>> though we never really intended it to work in the first place. :( Such > >>>> a change needs to go through CCC. > >>> > >>> I understood. > >>> Can I send CCC request? > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) > >> > >> Sorry you can't file a CCC request, you would need a sponsor for that. But at this stage I don't think I agree with the proposed change because of the change in behaviour - there's no way to restore the "broken" behaviour. > >> > >>> I want to continue to discuss about it on JDK-8154331 [1]. > >> > >> Okay we can do that. > >> > >>> > >>>> Further, we expect the launcher to use the supported JNI interface (as > >>>> other processes would), not the internal JVM interface that exists for > >>>> the JDK sources to communicate with the JVM. > >>> > >>> I think that we do not use JVM interface if we add new method in > >>> LauncherHelper as below: > >>> ---------------- > >>> diff -r f02139a1ac84 > >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java > >>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java > >>> Wed Apr 13 14:19:30 2016 +0000 > >>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java > >>> Sat Apr 16 11:25:53 2016 +0900 > >>> @@ -960,4 +960,8 @@ > >>> else > >>> return md.toNameAndVersion() + " (" + loc + ")"; > >>> } > >>> + > >>> + static void setNativeThreadName(String name) { > >>> + Thread.currentThread().setName(name); > >>> + } > >> > >> You could also make that call via JNI directly, so not sure the helper adds much here. But it won't work unless you change the semantics of setName so I'm not sure what you were thinking here. To take advantage of an arg taking JVM_SetNativThreadName you would need to call it directly as no Java code will call it . ??? > >> > >> David > >> ----- > >> > >>> } > >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c > >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 > >>> 2016 +0000 > >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 > >>> 2016 +0900 > >>> @@ -125,6 +125,7 @@ > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); > >>> static void ShowSettings(JNIEnv* env, char *optString); > >>> static void ListModules(JNIEnv* env, char *optString); > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); > >>> > >>> static void SetPaths(int argc, char **argv); > >>> > >>> @@ -325,6 +326,7 @@ > >>> * mainThread.isAlive() to work as expected. > >>> */ > >>> #define LEAVE() \ > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ > >>> do { \ > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ > >>> @@ -488,6 +490,9 @@ > >>> mainArgs = CreateApplicationArgs(env, argv, argc); > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); > >>> > >>> + /* Set native thread name. */ > >>> + SetNativeThreadName(env, "main"); > >>> + > >>> /* Invoke main method. */ > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); > >>> > >>> @@ -1686,6 +1691,22 @@ > >>> joptString); > >>> } > >>> > >>> +/** > >>> + * Set native thread name as possible. > >>> + */ > >>> +static void > >>> +SetNativeThreadName(JNIEnv *env, char *name) > >>> +{ > >>> + jmethodID setNativeThreadNameID; > >>> + jstring nameString; > >>> + jclass cls = GetLauncherHelperClass(env); > >>> + NULL_CHECK(cls); > >>> + NULL_CHECK(setNativeThreadNameID = (*env)->GetStaticMethodID(env, cls, > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > >>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, > >>> nameString); > >>> +} > >>> + > >>> /* > >>> * Prints default usage or the Xusage message, see > >>> sun.launcher.LauncherHelper.java > >>> */ > >>> ---------------- > >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). > >>> > >>>> However this is still a change to the exported JVM interface and so > >>>> has to be approved. > >>> > >>> Do you mean that this change needs CCC? > >>> > >>> > >>> Thanks, > >>> > >>> Yasumasa > >>> > >>> > >>> [1] > >>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html > >>> > >>> > >>> > >>> On 2016/04/16 7:26, David Holmes wrote: > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: > >>>>> Hi David, > >>>>> > >>>>>> I think it is a bug based on the comment here: > >>>>>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and > >>>>>> JNI attached threads > >>>>> > >>>>> I filed it to JBS as JDK-8154331. > >>>>> I will send review request to hotspot-runtime-dev. > >>>>> > >>>>> > >>>>>> Though that will introduce a change in behaviour by itself as setName > >>>>>> will no longer set the native name for the main thread. > >>>>> > >>>>> I know. > >>>> > >>>> That change in behaviour may be a problem, it could be considered a > >>>> regression that setName stops setting the native thread main, even > >>>> though we never really intended it to work in the first place. :( Such > >>>> a change needs to go through CCC. > >>>> > >>>>> I checked changeset history. > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is > >>>>> backported JDK 8. > >>>> > >>>> Yes this all came in as part of the OSX port in 7u2. > >>>> > >>>>> However, this function seems to be called from Thread#setNativeName() > >>>>> only. > >>>>> In addition, Thread#setNativeName() is private method. > >>>>> > >>>>> Thus I think that we can add an argument to JVM_SetNativeThreadName() > >>>>> for force setting. > >>>>> (e.g. "bool forced") > >>>>> > >>>>> It makes a change of JVM API. > >>>>> However, this function is NOT public, so I think we can add one more > >>>>> argument. > >>>>> > >>>>> What do you think about this? > >>>>> If it is accepted, we can set native thread name from Java launcher. > >>>> > >>>> The private/public aspect of the Java API is not really at issue. Yes > >>>> we would add another arg to the JVM function to allow it to apply to > >>>> JNI-attached threads as well (I'd prefer the arg reflect that not just > >>>> "force"). However this is still a change to the exported JVM interface > >>>> and so has to be approved. Further, we expect the launcher to use the > >>>> supported JNI interface (as other processes would), not the internal > >>>> JVM interface that exists for the JDK sources to communicate with the > >>>> JVM. > >>>> > >>>> David > >>>> ----- > >>>> > >>>>> > >>>>> Thanks, > >>>>> > >>>>> Yasumasa > >>>>> > >>>>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: > >>>>>> Hi Yasumasa, > >>>>>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: > >>>>>>> Hi David, > >>>>>>> > >>>>>>>> The fact that the "main" thread is not tagged as being a JNI-attached > >>>>>>>> thread seems accidental to me > >>>>>>> > >>>>>>> Should I file it to JBS? > >>>>>> > >>>>>> I think it is a bug based on the comment here: > >>>>>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main thread and > >>>>>> JNI attached threads > >>>>>> > >>>>>> Though that will introduce a change in behaviour by itself as setName > >>>>>> will no longer set the native name for the main thread. > >>>>>> > >>>>>>> I think that we can fix as below: > >>>>>>> --------------- > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 2016 +0200 > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 2016 +0900 > >>>>>>> @@ -3592,7 +3592,7 @@ > >>>>>>> #endif // INCLUDE_JVMCI > >>>>>>> > >>>>>>> // Attach the main thread to this os thread > >>>>>>> - JavaThread* main_thread = new JavaThread(); > >>>>>>> + JavaThread* main_thread = new JavaThread(true); > >>>>>>> main_thread->set_thread_state(_thread_in_vm); > >>>>>>> main_thread->initialize_thread_current(); > >>>>>>> // must do this before set_active_handles > >>>>>>> @@ -3776,6 +3776,9 @@ > >>>>>>> // Notify JVMTI agents that VM initialization is complete - nop if > >>>>>>> no agents. > >>>>>>> JvmtiExport::post_vm_initialized(); > >>>>>>> > >>>>>>> + // Change attach status to "attached" > >>>>>>> + main_thread->set_done_attaching_via_jni(); > >>>>>>> + > >>>>>> > >>>>>> I think we can do this straight after the JavaThread constructor. > >>>>>> > >>>>>>> if (TRACE_START() != JNI_OK) { > >>>>>>> vm_exit_during_initialization("Failed to start tracing > >>>>>>> backend."); > >>>>>>> } > >>>>>>> --------------- > >>>>>>> > >>>>>>> > >>>>>>>> If it wants to name its native threads then it is free to do so, > >>>>>>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native thread name > >>>>>>> when the caller thread is JNI-attached thread. > >>>>>>> However, I think that it should be changed if Java developer calls > >>>>>>> Thread#setName() explicitly. > >>>>>>> It is not the same of changing native thread name at > >>>>>>> Threads::create_vm(). > >>>>>>> > >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. > >>>>>>> What do you think about this? > >>>>>> > >>>>>> The decision to not change the name of JNI-attached threads was a > >>>>>> deliberate one** - this functionality originated with the OSX port and > >>>>>> it was reported that the initial feedback with this feature was to > >>>>>> ensure it didn't mess with thread names that had been set by the host > >>>>>> process. If we do as you propose then we will just have an > >>>>>> inconsistency for people to complain about: "why does my native thread > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" > >>>>>> > >>>>>> ** If you follow the bugs and related discussions on this, the > >>>>>> semantics and limitations (truncation, current thread only, non-JNI > >>>>>> threads only) of setting the native thread name were supposed to be > >>>>>> documented in the release notes - but as far as I can see that never > >>>>>> happened. :( > >>>>>> > >>>>>> My position on this remains that if it is desirable for the main > >>>>>> thread (and DestroyJavaVM thread) to have native names then the > >>>>>> launcher needs to be setting them using the available platform APIs. > >>>>>> Unfortunately this is complicated - as evidenced by the VM code for > >>>>>> this - due to the need to verify API availability. > >>>>>> > >>>>>> Any change in behaviour in relation to Thread.setName would have to go > >>>>>> through our CCC process I think. But a change in the launcher would > >>>>>> not. > >>>>>> > >>>>>> Sorry. > >>>>>> > >>>>>> David > >>>>>> ----- > >>>>>> > >>>>>>> --------------- > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 2016 +0200 > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 2016 +0900 > >>>>>>> @@ -3187,7 +3187,7 @@ > >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); > >>>>>>> // Thread naming only supported for the current thread, doesn't > >>>>>>> work > >>>>>>> for > >>>>>>> // target threads. > >>>>>>> - if (Thread::current() == thr && !thr->has_attached_via_jni()) { > >>>>>>> + if (Thread::current() == thr) { > >>>>>>> // we don't set the name of an attached thread to avoid stepping > >>>>>>> // on other programs > >>>>>>> const char *thread_name = > >>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); > >>>>>>> --------------- > >>>>>>> > >>>>>>> > >>>>>>> Thanks, > >>>>>>> > >>>>>>> Yasumasa > >>>>>>> > >>>>>>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: > >>>>>>>> > >>>>>>>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: > >>>>>>>>> Roger, > >>>>>>>>> Thanks for your comment! > >>>>>>>>> > >>>>>>>>> David, > >>>>>>>>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like > >>>>>>>>>>>> exposing > >>>>>>>>>>>> a new JVM function this way. > >>>>>>>>> > >>>>>>>>> I tried to call Thread#setName() after initializing VM (before > >>>>>>>>> calling > >>>>>>>>> main method), > >>>>>>>>> I could set native thread name. > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we can't > >>>>>>>>> set > >>>>>>>>> native thread name for DestroyJavaVM. > >>>>>>>> > >>>>>>>> Right - I came to the same realization earlier this morning. Which, > >>>>>>>> unfortunately, takes me back to the basic premise here that we don't > >>>>>>>> set the name of threads not created by the JVM. The fact that the > >>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by > >>>>>>>> accident for the initial attach, and can't be used for the > >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently named at > >>>>>>>> the native level. > >>>>>>>> > >>>>>>>> I'm afraid my view here is that the launcher has to be treated like > >>>>>>>> any other process that might host a JVM. If it wants to name its > >>>>>>>> native threads then it is free to do so, but I would not be exporting > >>>>>>>> a function from the JVM to do that - it would have to use the OS > >>>>>>>> specific API's for that on a platform-by-platform basis. > >>>>>>>> > >>>>>>>> Sorry. > >>>>>>>> > >>>>>>>> David > >>>>>>>> ----- > >>>>>>>> > >>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> Thanks, > >>>>>>>>> > >>>>>>>>> Yasumasa > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: > >>>>>>>>>> Hi, > >>>>>>>>>> > >>>>>>>>>> Comments: > >>>>>>>>>> > >>>>>>>>>> jvm.h: The function names are too similar but perform different > >>>>>>>>>> functions: > >>>>>>>>>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName > >>>>>>>>>> > >>>>>>>>>> - The first function applies to the current thread, the second > >>>>>>>>>> one a > >>>>>>>>>> specific java thread. > >>>>>>>>>> It would seem useful for there to be a comment somewhere about > >>>>>>>>>> what > >>>>>>>>>> the new function does. > >>>>>>>>>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) > >>>>>>>>>> instead of > >>>>>>>>>> (SetNativeThreadName0_t) > >>>>>>>>>> as is done on unix and mac. > >>>>>>>>>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: > >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs used at > >>>>>>>>>> line 730 > >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast on the > >>>>>>>>>> same > >>>>>>>>>> line as dlsym... > >>>>>>>>>> > >>>>>>>>>> $.02, Roger > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: > >>>>>>>>>>>> That is an interesting question which I haven't had time to > >>>>>>>>>>>> check - > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread > >>>>>>>>>>>> then > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should > >>>>>>>>>>>> work > >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of > >>>>>>>>>>>> JNI-attached threads :( ) > >>>>>>>>>>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed native > >>>>>>>>>>> thread name (test) was set. > >>>>>>>>>>> --------- > >>>>>>>>>>> public class Sleep{ > >>>>>>>>>>> public static void main(String[] args) throws Exception{ > >>>>>>>>>>> Thread.currentThread().setName("test"); > >>>>>>>>>>> Thread.sleep(3600000); > >>>>>>>>>>> } > >>>>>>>>>>> } > >>>>>>>>>>> --------- > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like > >>>>>>>>>>>> exposing > >>>>>>>>>>>> a new JVM function this way. > >>>>>>>>>>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> Thanks, > >>>>>>>>>>> > >>>>>>>>>>> Yasumasa > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>> Hi, > >>>>>>>>>>>>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: > >>>>>>>>>>>>>> Hi, > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>>>> Hi David, > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> Thanks for your comment. > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> I exported new JVM function to set native thread name, and JLI > >>>>>>>>>>>>>>> uses it > >>>>>>>>>>>>>>> in new webrev. > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> First the launcher belongs to another team so core-libs will > >>>>>>>>>>>>>> need to > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. > >>>>>>>>>>>>> > >>>>>>>>>>>>> Thanks! > >>>>>>>>>>>>> I'm waiting to review :-) > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to Thread.setName > >>>>>>>>>>>>>> rather > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes > >>>>>>>>>>>>>> needed in > >>>>>>>>>>>>>> that case. > >>>>>>>>>>>>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in > >>>>>>>>>>>>> Thread#init(), > >>>>>>>>>>>>> but I could not change native thread name. > >>>>>>>>>>>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, which is why the > >>>>>>>>>>>> native > >>>>>>>>>>>> name is not set. > >>>>>>>>>>>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. > >>>>>>>>>>>> > >>>>>>>>>>>> That is an interesting question which I haven't had time to > >>>>>>>>>>>> check - > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached thread > >>>>>>>>>>>> then > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion should > >>>>>>>>>>>> work > >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of > >>>>>>>>>>>> JNI-attached threads :( ) > >>>>>>>>>>>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like > >>>>>>>>>>>> exposing > >>>>>>>>>>>> a new JVM function this way. > >>>>>>>>>>>> > >>>>>>>>>>>> Thanks, > >>>>>>>>>>>> David > >>>>>>>>>>>> ----- > >>>>>>>>>>>> > >>>>>>>>>>>>> Thus I think that we have to provide a function to set native > >>>>>>>>>>>>> thread name. > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>> > >>>>>>>>>>>>> Yasumasa > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> [1] > >>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>> David > >>>>>>>>>>>>>> > >>>>>>>>>>>>>>> Could you review again? > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> - hotspot: > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> - jdk: > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> Yasumasa > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: > >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> Hi Yasumasa, > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on > >>>>>>>>>>>>>>>> vacation). > >>>>>>>>>>>>>>>> This > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we do not > >>>>>>>>>>>>>>>> set the > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the > >>>>>>>>>>>>>>>> "main" > >>>>>>>>>>>>>>>> thread. > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> David > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>>>>>> Thanks Robbin, > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>> Yasumasa > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" : > >>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> /Robbin > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: > >>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> /Robbin > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> Hi, > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. > >>>>>>>>>>>>>>>>>>>> Could you review it? > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> Yasumasa > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: > >>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> Hi, > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" < robbin.ehn at oracle.com > >>>>>>>>>>>>>>>>>>>>>> >: > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>>>>>>> >>: > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp > >>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu > >>>>>>>>>>>>>>>>>>>>>> Mar 24 > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 > >>>>>>>>>>>>>>>>>>>>>> +0000 > >>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu > >>>>>>>>>>>>>>>>>>>>>> Mar 24 > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 > >>>>>>>>>>>>>>>>>>>>>> +0100 > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new JavaThread(); > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->set_thread_state(_thread_in_vm); > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); > >>>>>>>>>>>>>>>>>>>>>> >> > + main_thread->set_native_thread_name("main"); > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before set_active_handles > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread name in > >>>>>>>>>>>>>>>>>>>>>> Thread > >>>>>>>>>>>>>>>>>>>>>> class. > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native > >>>>>>>>>>>>>>>>>>>>>> thread > >>>>>>>>>>>>>>>>>>>>>> name > >>>>>>>>>>>>>>>>>>>>>> will be > >>>>>>>>>>>>>>>>>>>>>> set at > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already starte > >>>>>>>>>>>>>>>>>>>>>> in VM. > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name > >>>>>>>>>>>>>>>>>>>>>> should > >>>>>>>>>>>>>>>>>>>>>> be the > >>>>>>>>>>>>>>>>>>>>>> same. > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like > >>>>>>>>>>>>>>>>>>>>>> this is > >>>>>>>>>>>>>>>>>>>>>> nicer, no? > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue Mar 29 > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 > >>>>>>>>>>>>>>>>>>>>>> 2016 > >>>>>>>>>>>>>>>>>>>>>> +0200 > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed Mar 30 > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 > >>>>>>>>>>>>>>>>>>>>>> 2016 > >>>>>>>>>>>>>>>>>>>>>> +0200 > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread > >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle > >>>>>>>>>>>>>>>>>>>>>> thread_group, > >>>>>>>>>>>>>>>>>>>>>> JavaThread* > >>>>>>>>>>>>>>>>>>>>>> thread, > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { > >>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = "main"; > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = > >>>>>>>>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> true, > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = > >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), thread); > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), > >>>>>>>>>>>>>>>>>>>>>> NormPriority); > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); > >>>>>>>>>>>>>>>>>>>>>> > - > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > >>>>>>>>>>>>>>>>>>>>>> > + > >>>>>>>>>>>>>>>>>>>>>> > + > >>>>>>>>>>>>>>>>>>>>>> thread->set_native_thread_name(initial_thread_name); > >>>>>>>>>>>>>>>>>>>>>> > + > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str(initial_thread_name, > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> Thanks! > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and > >>>>>>>>>>>>>>>>>>>>>> naming > >>>>>>>>>>>>>>>>>>>>>> this > >>>>>>>>>>>>>>>>>>>>>> thread > >>>>>>>>>>>>>>>>>>>>>> just > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and thus > >>>>>>>>>>>>>>>>>>>>>> the > >>>>>>>>>>>>>>>>>>>>>> process) is > >>>>>>>>>>>>>>>>>>>>>> 'java' but > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not > >>>>>>>>>>>>>>>>>>>>>> JavaThread. > >>>>>>>>>>>>>>>>>>>>>> It is > >>>>>>>>>>>>>>>>>>>>>> waiting > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for JavaThread. So I > >>>>>>>>>>>>>>>>>>>>>> think that > >>>>>>>>>>>>>>>>>>>>>> we do > >>>>>>>>>>>>>>>>>>>>>> not > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since we want > >>>>>>>>>>>>>>>>>>>>>> java and > >>>>>>>>>>>>>>>>>>>>>> native > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might have > >>>>>>>>>>>>>>>>>>>>>> some > >>>>>>>>>>>>>>>>>>>>>> dependents. > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main > >>>>>>>>>>>>>>>>>>>>>> Thread'. > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java launcher - e.g. > >>>>>>>>>>>>>>>>>>>>>> Apache > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, I think > >>>>>>>>>>>>>>>>>>>>>> that we > >>>>>>>>>>>>>>>>>>>>>> have to > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> No > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> /Robbin > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > /Robbin > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa Suenaga wrote: > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread name via > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main > >>>>>>>>>>>>>>>>>>>>>> thread is > >>>>>>>>>>>>>>>>>>>>>> JavaThread. > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have > >>>>>>>>>>>>>>>>>>>>>> native > >>>>>>>>>>>>>>>>>>>>>> thread > >>>>>>>>>>>>>>>>>>>>>> name. > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> > From kumar.x.srinivasan at oracle.com Mon Apr 18 23:53:36 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Mon, 18 Apr 2016 16:53:36 -0700 Subject: RFR: 8154470: defines.h confused about PROGNAME and JAVA_ARGS In-Reply-To: References: Message-ID: <57157380.5000602@oracle.com> Hi Martin, Tested with jprt, seems to be ok, the changes are ok with me. Unless Alan has some reservations. Thanks Kumar > Hi Kumar and Alan, > > I'd like you to do a code review. > > http://cr.openjdk.java.net/~martin/webrevs/openjdk9/PROGNAME/ > https://bugs.openjdk.java.net/browse/JDK-8154470 > > Sorry, I got carried away hacking on the tests. Some changes could be > split out. > Aside from fixing the logic error in defines.h, > > printing out tr.status is useless, because it just invokes > Object.toString on PrintWriter > > - System.out.println(tr.status); > + System.out.println(tr); > > It's complete coincidence this extends Kumar's recent test testJLDEnvWithTool. From david.holmes at oracle.com Tue Apr 19 00:26:39 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 19 Apr 2016 10:26:39 +1000 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5715684B.7020305@oracle.com> References: <5713C871.1080407@oracle.com> <5715684B.7020305@oracle.com> Message-ID: <57157B3F.8030408@oracle.com> I agree with Stuart. David On 19/04/2016 9:05 AM, Stuart Marks wrote: > > > On 4/17/16 10:31 AM, joe darcy wrote: >> With talk of deprecation in the air [1], I thought it would be a fine >> time to > > "In the Spring a young man's fancy lightly turns to thoughts of > deprecation." > -- apologies to Tennyson > >> examine one of the bugs on my list >> >> JDK-6850612: Deprecate Class.newInstance since it violates the >> checked >> exception language contract >> >> As the title of the bug implies, The Class.newInstance method >> knowingly violates >> the checking exception contract. This has long been documented in its >> specification: [...] >> >> Comments on the bug have suggested that besides deprecating the >> method, a new >> method on Class could be introduced, >> newInstanceWithProperExceptionBehavior, >> that had the same signature but wrapped exceptions thrown by the >> constructor >> call in the same way Constructor.newInstance does. > > Deprecating Class.newInstance() seems reasonable to me, for the reasons > you've stated. > > It's not clear to me that a replacement method adds much value. I > believe it's possible to replace a call > > clazz.newInstance() // 1 > > with the call > > clazz.getConstructor().newInstance() // 2 > > which is only a bit longer. Both snippets are declared to throw > InstantiationException and IllegalAccessException. But snippet 2 also is > declared to throw InvocationTargetException and NoSuchMethodException. > > This would seem to be an inconvenience, but *all* of these exceptions > are subtypes of ReflectiveOperationException. It seems pretty likely to > me that most code handles these different exception types the same way. > So it's fairly low cost to replace snippet 1 with snippet 2, and to > adjust the exception handling to deal with ReflectiveOperationException. > Thus I don't see much value in adding a new method such as > Class.newInstanceWithProperExceptionBehavior(). > > s'marks From joe.darcy at oracle.com Tue Apr 19 00:42:37 2016 From: joe.darcy at oracle.com (Joseph D. Darcy) Date: Mon, 18 Apr 2016 17:42:37 -0700 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <57157B3F.8030408@oracle.com> References: <5713C871.1080407@oracle.com> <5715684B.7020305@oracle.com> <57157B3F.8030408@oracle.com> Message-ID: <57157EFD.9080008@oracle.com> Hello, With that feedback, I'll go ahead and prepare a changeset for the deprecation of this method and the suppression of the resulting warnings. Thanks, -Joe On 4/18/2016 5:26 PM, David Holmes wrote: > I agree with Stuart. > > David > > On 19/04/2016 9:05 AM, Stuart Marks wrote: >> >> >> On 4/17/16 10:31 AM, joe darcy wrote: >>> With talk of deprecation in the air [1], I thought it would be a fine >>> time to >> >> "In the Spring a young man's fancy lightly turns to thoughts of >> deprecation." >> -- apologies to Tennyson >> >>> examine one of the bugs on my list >>> >>> JDK-6850612: Deprecate Class.newInstance since it violates the >>> checked >>> exception language contract >>> >>> As the title of the bug implies, The Class.newInstance method >>> knowingly violates >>> the checking exception contract. This has long been documented in its >>> specification: [...] >>> >>> Comments on the bug have suggested that besides deprecating the >>> method, a new >>> method on Class could be introduced, >>> newInstanceWithProperExceptionBehavior, >>> that had the same signature but wrapped exceptions thrown by the >>> constructor >>> call in the same way Constructor.newInstance does. >> >> Deprecating Class.newInstance() seems reasonable to me, for the reasons >> you've stated. >> >> It's not clear to me that a replacement method adds much value. I >> believe it's possible to replace a call >> >> clazz.newInstance() // 1 >> >> with the call >> >> clazz.getConstructor().newInstance() // 2 >> >> which is only a bit longer. Both snippets are declared to throw >> InstantiationException and IllegalAccessException. But snippet 2 also is >> declared to throw InvocationTargetException and NoSuchMethodException. >> >> This would seem to be an inconvenience, but *all* of these exceptions >> are subtypes of ReflectiveOperationException. It seems pretty likely to >> me that most code handles these different exception types the same way. >> So it's fairly low cost to replace snippet 1 with snippet 2, and to >> adjust the exception handling to deal with ReflectiveOperationException. >> Thus I don't see much value in adding a new method such as >> Class.newInstanceWithProperExceptionBehavior(). >> >> s'marks From herve.boutemy at free.fr Tue Apr 19 01:49:45 2016 From: herve.boutemy at free.fr (=?ISO-8859-1?Q?Herv=E9?= BOUTEMY) Date: Tue, 19 Apr 2016 03:49:45 +0200 Subject: Multi-Release JAR runtime support Message-ID: <1511462.jDlVcCe28l@herve-desktop> Hi OpenJDK Core Developers, Today, to prepare a conference talk on Java 9 (DevoxxFR, on wednesday 20th), I tested once again Maven proposed layout to produce Multi-Release JARs: https://github.com/hboutemy/maven-jep238 And I added a little script (. run-demo.sh) to run the build then execute the resulting jar with JRE 7, 8 and 9. As expected, JRE 7 and 8 gave the same result, since my JRE 8 isn't patched to support MR JARs (if there is a simple way to add support, don't hesitate to give me a pointer. Or if there is any standard Java 8 build that should support it). But the unexpected part is that JRE 9, either classical or jigsaw, don't take advantage of the MR JAR: is this really expected, or did I do something wrong? Regards, Herv? Here is the interesting part of the output of the script: Archive: multirelease/target/multirelease-0.8-SNAPSHOT.jar testing: META-INF/MANIFEST.MF OK testing: base/Base.class OK testing: mr/A.class OK testing: META-INF/versions/8/mr/A.class OK testing: META-INF/versions/9/mr/A.class OK No errors detected in compressed data of multirelease/target/multirelease-0.8- SNAPSHOT.jar. [...] # Run Multi Release JAR with JRE 7 $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 1.7.0_71-b14 BASE # Run Multi Release JAR with JRE 8 $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 1.8.0_25-b17 BASE # Run Multi Release JAR with JRE 9 classic $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 9-ea+114 BASE # Run Multi Release JAR with JRE 9 Jigsaw $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 9-ea+114-2016-04-15-162029.javare.4859.nc BASE From xueming.shen at oracle.com Tue Apr 19 02:58:42 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Mon, 18 Apr 2016 19:58:42 -0700 Subject: RFR: JDK-8154498: fix to 8154403 results in failure of UserModuleTest.java on all platforms Message-ID: <57159EE2.2030809@oracle.com> Hi, Please help review the test case only change for JDK-8154498 issue: https://bugs.openjdk.java.net/browse/JDK-8154498 webrev: http://cr.openjdk.java.net/~sherman/8154498/webrev/ A "empty" map need to be passed in as the parameter for FileSystems.newFileSystem(), instead of "null". Thanks, Sherman From joe.darcy at oracle.com Tue Apr 19 03:49:53 2016 From: joe.darcy at oracle.com (joe darcy) Date: Mon, 18 Apr 2016 20:49:53 -0700 Subject: RFR: JDK-8154498: fix to 8154403 results in failure of UserModuleTest.java on all platforms In-Reply-To: <57159EE2.2030809@oracle.com> References: <57159EE2.2030809@oracle.com> Message-ID: <5715AAE1.5050108@oracle.com> Looks fine Sherman; thanks, -Joe On 4/18/2016 7:58 PM, Xueming Shen wrote: > Hi, > > Please help review the test case only change for JDK-8154498 > > issue: https://bugs.openjdk.java.net/browse/JDK-8154498 > webrev: http://cr.openjdk.java.net/~sherman/8154498/webrev/ > > A "empty" map need to be passed in as the parameter for > FileSystems.newFileSystem(), > instead of "null". > > Thanks, > Sherman From sundararajan.athijegannathan at oracle.com Tue Apr 19 04:09:29 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Tue, 19 Apr 2016 09:39:29 +0530 Subject: RFR: JDK-8154498: fix to 8154403 results in failure of UserModuleTest.java on all platforms In-Reply-To: <57159EE2.2030809@oracle.com> References: <57159EE2.2030809@oracle.com> Message-ID: <5715AF79.2090000@oracle.com> +1 -Sundar On 4/19/2016 8:28 AM, Xueming Shen wrote: > Hi, > > Please help review the test case only change for JDK-8154498 > > issue: https://bugs.openjdk.java.net/browse/JDK-8154498 > webrev: http://cr.openjdk.java.net/~sherman/8154498/webrev/ > > A "empty" map need to be passed in as the parameter for > FileSystems.newFileSystem(), > instead of "null". > > Thanks, > Sherman From david.holmes at oracle.com Tue Apr 19 05:04:37 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 19 Apr 2016 15:04:37 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: References: <56F3F90D.9010408@gmail.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> Message-ID: <5715BC65.3010302@oracle.com> Hi Yasumasa, Thanks for persevering with this to get it into the current form. Sorry I haven't been able to do a detailed review until now. On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: > Hi Gerard, > > 2016/04/19 3:14 "Gerard Ziemski" >: > > > > hi Yasumasa, > > > > Nice work. I have 2 questions: > > > > ======== > > File: java.c > > > > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? > after every single JNI call? In this example instead of NULL_CHECK, > should we be using CHECK_EXCEPTION_NULL_LEAVE macro? > > It is not critical if we encounter error at JNI function call because > we cannot set native thread name only. > So I think that we do not need to leave from launcher process. I agree we do not need to abort if an exception occurs (and in fact I don't think an exception is even possible from this code), but we should ensure any pending exception is cleared before any futher JNI calls might be made. Note that NULL_CHECK is already used extensively throughout the launcher code - so if this usage is wrong then it is all wrong! More on this code below ... Other comments: hotspot/src/share/vm/prims/jvm.cpp Please add a comment to the method now that you removed the internal comment: // Sets the native thread name for a JavaThread. If specifically // requested JNI-attached threads can also have their native name set; // otherwise we do not modify JNI-attached threads as it may interfere // with the application that created them. --- jdk/src/java.base/share/classes/java/lang/Thread.java Please add the following comments: + // Don't modify JNI-attached threads setNativeName(name, false); + // May be called directly via JNI or reflection (when permitted) to + // allow JNI-attached threads to set their native name private native void setNativeName(String name, boolean allowAttachedThread); --- jd/src/java.base/share/native/libjli/java.c 328 #define LEAVE() \ 329 SetNativeThreadName(env, "DestroyJavaVM"); \ I was going to suggest this be set later, but realized we have to be attached to do this and that happens inside DestroyJavaVM. :) + /* Set native thread name. */ + SetNativeThreadName(env, "main"); The comment is redundant given the name of the method. That aside I'm not sure why you do this so late in the process, I would have done it immediately after here: 386 if (!InitializeJVM(&vm, &env, &ifn)) { 387 JLI_ReportErrorMessage(JVM_ERROR1); 388 exit(1); 389 } + SetNativeThreadName(env, "main"); + /** + * Set native thread name as possible. + */ Other than the as->if change I'm unclear where the "possible" bit comes into play - why would it not be possible? 1705 NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); 1706 NULL_CHECK(currentThreadID = (*env)->GetStaticMethodID(env, cls, 1707 "currentThread", "()Ljava/lang/Thread;")); 1708 NULL_CHECK(currentThread = (*env)->CallStaticObjectMethod(env, cls, 1709 currentThreadID)); 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, 1711 "setNativeName", "(Ljava/lang/String;Z)V")); 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, 1714 nameString, JNI_TRUE); As above NULL_CHECK is fine here, but we should check for and clear any pending exception after CallVoidMethod. One thing I dislike about the current structure is that we have to go from char* to java.lang.String to call setNativeName which then calls JVM_SetNativeThreadName which converts the j.l.String back to a char* ! Overall I wonder about the affect on startup cost. But if there is an issue we can revisit this. Thanks, David ----- > > #2 Should the comment for ?SetNativeThreadName? be ?Set native thread > name if possible.? not "Set native thread name as possible.?? > > Sorry for my bad English :-) > > Thanks, > > Yasumasa > > > cheers > > > > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga > wrote: > > > > > > Hi David, > > > > > > I uploaded new webrev: > > > > > > - hotspot: > > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ > > > > > > - jdk: > > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ > > > > > > > > >> it won't work unless you change the semantics of setName so I'm > not sure what you were thinking here. To take advantage of an arg taking > JVM_SetNativThreadName you would need to call it directly as no Java > code will call it . ??? > > > > > > I added a flag for setting native thread name to JNI-attached thread. > > > This change can set native thread name if main thread changes to > JNI-attached thread. > > > > > > > > > Thanks, > > > > > > Yasumasa > > > > > > > > > On 2016/04/16 16:11, David Holmes wrote: > > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: > > >>> Hi David, > > >>> > > >>>> That change in behaviour may be a problem, it could be considered a > > >>>> regression that setName stops setting the native thread main, even > > >>>> though we never really intended it to work in the first place. > :( Such > > >>>> a change needs to go through CCC. > > >>> > > >>> I understood. > > >>> Can I send CCC request? > > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) > > >> > > >> Sorry you can't file a CCC request, you would need a sponsor for > that. But at this stage I don't think I agree with the proposed change > because of the change in behaviour - there's no way to restore the > "broken" behaviour. > > >> > > >>> I want to continue to discuss about it on JDK-8154331 [1]. > > >> > > >> Okay we can do that. > > >> > > >>> > > >>>> Further, we expect the launcher to use the supported JNI > interface (as > > >>>> other processes would), not the internal JVM interface that > exists for > > >>>> the JDK sources to communicate with the JVM. > > >>> > > >>> I think that we do not use JVM interface if we add new method in > > >>> LauncherHelper as below: > > >>> ---------------- > > >>> diff -r f02139a1ac84 > > >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java > > >>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java > > >>> Wed Apr 13 14:19:30 2016 +0000 > > >>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java > > >>> Sat Apr 16 11:25:53 2016 +0900 > > >>> @@ -960,4 +960,8 @@ > > >>> else > > >>> return md.toNameAndVersion() + " (" + loc + ")"; > > >>> } > > >>> + > > >>> + static void setNativeThreadName(String name) { > > >>> + Thread.currentThread().setName(name); > > >>> + } > > >> > > >> You could also make that call via JNI directly, so not sure the > helper adds much here. But it won't work unless you change the semantics > of setName so I'm not sure what you were thinking here. To take > advantage of an arg taking JVM_SetNativThreadName you would need to call > it directly as no Java code will call it . ??? > > >> > > >> David > > >> ----- > > >> > > >>> } > > >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c > > >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 > > >>> 2016 +0000 > > >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 > > >>> 2016 +0900 > > >>> @@ -125,6 +125,7 @@ > > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); > > >>> static void ShowSettings(JNIEnv* env, char *optString); > > >>> static void ListModules(JNIEnv* env, char *optString); > > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); > > >>> > > >>> static void SetPaths(int argc, char **argv); > > >>> > > >>> @@ -325,6 +326,7 @@ > > >>> * mainThread.isAlive() to work as expected. > > >>> */ > > >>> #define LEAVE() \ > > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ > > >>> do { \ > > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ > > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ > > >>> @@ -488,6 +490,9 @@ > > >>> mainArgs = CreateApplicationArgs(env, argv, argc); > > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); > > >>> > > >>> + /* Set native thread name. */ > > >>> + SetNativeThreadName(env, "main"); > > >>> + > > >>> /* Invoke main method. */ > > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); > > >>> > > >>> @@ -1686,6 +1691,22 @@ > > >>> joptString); > > >>> } > > >>> > > >>> +/** > > >>> + * Set native thread name as possible. > > >>> + */ > > >>> +static void > > >>> +SetNativeThreadName(JNIEnv *env, char *name) > > >>> +{ > > >>> + jmethodID setNativeThreadNameID; > > >>> + jstring nameString; > > >>> + jclass cls = GetLauncherHelperClass(env); > > >>> + NULL_CHECK(cls); > > >>> + NULL_CHECK(setNativeThreadNameID = > (*env)->GetStaticMethodID(env, cls, > > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); > > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > > >>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, > > >>> nameString); > > >>> +} > > >>> + > > >>> /* > > >>> * Prints default usage or the Xusage message, see > > >>> sun.launcher.LauncherHelper.java > > >>> */ > > >>> ---------------- > > >>> > > >>> So I want to add new arg to JVM_SetNativeThreadName(). > > >>> > > >>>> However this is still a change to the exported JVM interface and so > > >>>> has to be approved. > > >>> > > >>> Do you mean that this change needs CCC? > > >>> > > >>> > > >>> Thanks, > > >>> > > >>> Yasumasa > > >>> > > >>> > > >>> [1] > > >>> > http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html > > >>> > > >>> > > >>> > > >>> On 2016/04/16 7:26, David Holmes wrote: > > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: > > >>>>> Hi David, > > >>>>> > > >>>>>> I think it is a bug based on the comment here: > > >>>>>> > > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main > thread and > > >>>>>> JNI attached threads > > >>>>> > > >>>>> I filed it to JBS as JDK-8154331. > > >>>>> I will send review request to hotspot-runtime-dev. > > >>>>> > > >>>>> > > >>>>>> Though that will introduce a change in behaviour by itself as > setName > > >>>>>> will no longer set the native name for the main thread. > > >>>>> > > >>>>> I know. > > >>>> > > >>>> That change in behaviour may be a problem, it could be considered a > > >>>> regression that setName stops setting the native thread main, even > > >>>> though we never really intended it to work in the first place. > :( Such > > >>>> a change needs to go through CCC. > > >>>> > > >>>>> I checked changeset history. > > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is > > >>>>> backported JDK 8. > > >>>> > > >>>> Yes this all came in as part of the OSX port in 7u2. > > >>>> > > >>>>> However, this function seems to be called from > Thread#setNativeName() > > >>>>> only. > > >>>>> In addition, Thread#setNativeName() is private method. > > >>>>> > > >>>>> Thus I think that we can add an argument to > JVM_SetNativeThreadName() > > >>>>> for force setting. > > >>>>> (e.g. "bool forced") > > >>>>> > > >>>>> It makes a change of JVM API. > > >>>>> However, this function is NOT public, so I think we can add one > more > > >>>>> argument. > > >>>>> > > >>>>> What do you think about this? > > >>>>> If it is accepted, we can set native thread name from Java > launcher. > > >>>> > > >>>> The private/public aspect of the Java API is not really at > issue. Yes > > >>>> we would add another arg to the JVM function to allow it to apply to > > >>>> JNI-attached threads as well (I'd prefer the arg reflect that > not just > > >>>> "force"). However this is still a change to the exported JVM > interface > > >>>> and so has to be approved. Further, we expect the launcher to > use the > > >>>> supported JNI interface (as other processes would), not the internal > > >>>> JVM interface that exists for the JDK sources to communicate > with the > > >>>> JVM. > > >>>> > > >>>> David > > >>>> ----- > > >>>> > > >>>>> > > >>>>> Thanks, > > >>>>> > > >>>>> Yasumasa > > >>>>> > > >>>>> > > >>>>> On 2016/04/15 19:16, David Holmes wrote: > > >>>>>> Hi Yasumasa, > > >>>>>> > > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: > > >>>>>>> Hi David, > > >>>>>>> > > >>>>>>>> The fact that the "main" thread is not tagged as being a > JNI-attached > > >>>>>>>> thread seems accidental to me > > >>>>>>> > > >>>>>>> Should I file it to JBS? > > >>>>>> > > >>>>>> I think it is a bug based on the comment here: > > >>>>>> > > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main > thread and > > >>>>>> JNI attached threads > > >>>>>> > > >>>>>> Though that will introduce a change in behaviour by itself as > setName > > >>>>>> will no longer set the native name for the main thread. > > >>>>>> > > >>>>>>> I think that we can fix as below: > > >>>>>>> --------------- > > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp > > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 > 2016 +0200 > > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 > 2016 +0900 > > >>>>>>> @@ -3592,7 +3592,7 @@ > > >>>>>>> #endif // INCLUDE_JVMCI > > >>>>>>> > > >>>>>>> // Attach the main thread to this os thread > > >>>>>>> - JavaThread* main_thread = new JavaThread(); > > >>>>>>> + JavaThread* main_thread = new JavaThread(true); > > >>>>>>> main_thread->set_thread_state(_thread_in_vm); > > >>>>>>> main_thread->initialize_thread_current(); > > >>>>>>> // must do this before set_active_handles > > >>>>>>> @@ -3776,6 +3776,9 @@ > > >>>>>>> // Notify JVMTI agents that VM initialization is complete > - nop if > > >>>>>>> no agents. > > >>>>>>> JvmtiExport::post_vm_initialized(); > > >>>>>>> > > >>>>>>> + // Change attach status to "attached" > > >>>>>>> + main_thread->set_done_attaching_via_jni(); > > >>>>>>> + > > >>>>>> > > >>>>>> I think we can do this straight after the JavaThread constructor. > > >>>>>> > > >>>>>>> if (TRACE_START() != JNI_OK) { > > >>>>>>> vm_exit_during_initialization("Failed to start tracing > > >>>>>>> backend."); > > >>>>>>> } > > >>>>>>> --------------- > > >>>>>>> > > >>>>>>> > > >>>>>>>> If it wants to name its native threads then it is free to do so, > > >>>>>>> > > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native > thread name > > >>>>>>> when the caller thread is JNI-attached thread. > > >>>>>>> However, I think that it should be changed if Java developer > calls > > >>>>>>> Thread#setName() explicitly. > > >>>>>>> It is not the same of changing native thread name at > > >>>>>>> Threads::create_vm(). > > >>>>>>> > > >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. > > >>>>>>> What do you think about this? > > >>>>>> > > >>>>>> The decision to not change the name of JNI-attached threads was a > > >>>>>> deliberate one** - this functionality originated with the OSX > port and > > >>>>>> it was reported that the initial feedback with this feature was to > > >>>>>> ensure it didn't mess with thread names that had been set by > the host > > >>>>>> process. If we do as you propose then we will just have an > > >>>>>> inconsistency for people to complain about: "why does my > native thread > > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" > > >>>>>> > > >>>>>> ** If you follow the bugs and related discussions on this, the > > >>>>>> semantics and limitations (truncation, current thread only, > non-JNI > > >>>>>> threads only) of setting the native thread name were supposed > to be > > >>>>>> documented in the release notes - but as far as I can see that > never > > >>>>>> happened. :( > > >>>>>> > > >>>>>> My position on this remains that if it is desirable for the main > > >>>>>> thread (and DestroyJavaVM thread) to have native names then the > > >>>>>> launcher needs to be setting them using the available platform > APIs. > > >>>>>> Unfortunately this is complicated - as evidenced by the VM > code for > > >>>>>> this - due to the need to verify API availability. > > >>>>>> > > >>>>>> Any change in behaviour in relation to Thread.setName would > have to go > > >>>>>> through our CCC process I think. But a change in the launcher > would > > >>>>>> not. > > >>>>>> > > >>>>>> Sorry. > > >>>>>> > > >>>>>> David > > >>>>>> ----- > > >>>>>> > > >>>>>>> --------------- > > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 > 2016 +0200 > > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 > 2016 +0900 > > >>>>>>> @@ -3187,7 +3187,7 @@ > > >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); > > >>>>>>> // Thread naming only supported for the current thread, > doesn't > > >>>>>>> work > > >>>>>>> for > > >>>>>>> // target threads. > > >>>>>>> - if (Thread::current() == thr && > !thr->has_attached_via_jni()) { > > >>>>>>> + if (Thread::current() == thr) { > > >>>>>>> // we don't set the name of an attached thread to avoid > stepping > > >>>>>>> // on other programs > > >>>>>>> const char *thread_name = > > >>>>>>> > java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); > > >>>>>>> --------------- > > >>>>>>> > > >>>>>>> > > >>>>>>> Thanks, > > >>>>>>> > > >>>>>>> Yasumasa > > >>>>>>> > > >>>>>>> > > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: > > >>>>>>>>> Roger, > > >>>>>>>>> Thanks for your comment! > > >>>>>>>>> > > >>>>>>>>> David, > > >>>>>>>>> > > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like > > >>>>>>>>>>>> exposing > > >>>>>>>>>>>> a new JVM function this way. > > >>>>>>>>> > > >>>>>>>>> I tried to call Thread#setName() after initializing VM (before > > >>>>>>>>> calling > > >>>>>>>>> main method), > > >>>>>>>>> I could set native thread name. > > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we > can't > > >>>>>>>>> set > > >>>>>>>>> native thread name for DestroyJavaVM. > > >>>>>>>> > > >>>>>>>> Right - I came to the same realization earlier this morning. > Which, > > >>>>>>>> unfortunately, takes me back to the basic premise here that > we don't > > >>>>>>>> set the name of threads not created by the JVM. The fact > that the > > >>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems > > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by > > >>>>>>>> accident for the initial attach, and can't be used for the > > >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently > named at > > >>>>>>>> the native level. > > >>>>>>>> > > >>>>>>>> I'm afraid my view here is that the launcher has to be > treated like > > >>>>>>>> any other process that might host a JVM. If it wants to name its > > >>>>>>>> native threads then it is free to do so, but I would not be > exporting > > >>>>>>>> a function from the JVM to do that - it would have to use the OS > > >>>>>>>> specific API's for that on a platform-by-platform basis. > > >>>>>>>> > > >>>>>>>> Sorry. > > >>>>>>>> > > >>>>>>>> David > > >>>>>>>> ----- > > >>>>>>>> > > >>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> Thanks, > > >>>>>>>>> > > >>>>>>>>> Yasumasa > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: > > >>>>>>>>>> Hi, > > >>>>>>>>>> > > >>>>>>>>>> Comments: > > >>>>>>>>>> > > >>>>>>>>>> jvm.h: The function names are too similar but perform > different > > >>>>>>>>>> functions: > > >>>>>>>>>> > > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName > > >>>>>>>>>> > > >>>>>>>>>> - The first function applies to the current thread, the > second > > >>>>>>>>>> one a > > >>>>>>>>>> specific java thread. > > >>>>>>>>>> It would seem useful for there to be a comment somewhere > about > > >>>>>>>>>> what > > >>>>>>>>>> the new function does. > > >>>>>>>>>> > > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) > > >>>>>>>>>> instead of > > >>>>>>>>>> (SetNativeThreadName0_t) > > >>>>>>>>>> as is done on unix and mac. > > >>>>>>>>>> > > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: > > >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs > used at > > >>>>>>>>>> line 730 > > >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast > on the > > >>>>>>>>>> same > > >>>>>>>>>> line as dlsym... > > >>>>>>>>>> > > >>>>>>>>>> $.02, Roger > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>> That is an interesting question which I haven't had time to > > >>>>>>>>>>>> check - > > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached > thread > > >>>>>>>>>>>> then > > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion > should > > >>>>>>>>>>>> work > > >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of > > >>>>>>>>>>>> JNI-attached threads :( ) > > >>>>>>>>>>> > > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed > native > > >>>>>>>>>>> thread name (test) was set. > > >>>>>>>>>>> --------- > > >>>>>>>>>>> public class Sleep{ > > >>>>>>>>>>> public static void main(String[] args) throws Exception{ > > >>>>>>>>>>> Thread.currentThread().setName("test"); > > >>>>>>>>>>> Thread.sleep(3600000); > > >>>>>>>>>>> } > > >>>>>>>>>>> } > > >>>>>>>>>>> --------- > > >>>>>>>>>>> > > >>>>>>>>>>> > > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like > > >>>>>>>>>>>> exposing > > >>>>>>>>>>>> a new JVM function this way. > > >>>>>>>>>>> > > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. > > >>>>>>>>>>> > > >>>>>>>>>>> > > >>>>>>>>>>> Thanks, > > >>>>>>>>>>> > > >>>>>>>>>>> Yasumasa > > >>>>>>>>>>> > > >>>>>>>>>>> > > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: > > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>>> Hi, > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: > > >>>>>>>>>>>>>> Hi, > > >>>>>>>>>>>>>> > > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>>>>> Hi David, > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> Thanks for your comment. > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> I exported new JVM function to set native thread > name, and JLI > > >>>>>>>>>>>>>>> uses it > > >>>>>>>>>>>>>>> in new webrev. > > >>>>>>>>>>>>>> > > >>>>>>>>>>>>>> First the launcher belongs to another team so > core-libs will > > >>>>>>>>>>>>>> need to > > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> Thanks! > > >>>>>>>>>>>>> I'm waiting to review :-) > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>>> Personally I would have used a Java upcall to > Thread.setName > > >>>>>>>>>>>>>> rather > > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes > > >>>>>>>>>>>>>> needed in > > >>>>>>>>>>>>>> that case. > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in > > >>>>>>>>>>>>> Thread#init(), > > >>>>>>>>>>>>> but I could not change native thread name. > > >>>>>>>>>>>> > > >>>>>>>>>>>> At Thread.init time the thread is not alive, which is > why the > > >>>>>>>>>>>> native > > >>>>>>>>>>>> name is not set. > > >>>>>>>>>>>> > > >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. > > >>>>>>>>>>>> > > >>>>>>>>>>>> That is an interesting question which I haven't had time to > > >>>>>>>>>>>> check - > > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached > thread > > >>>>>>>>>>>> then > > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion > should > > >>>>>>>>>>>> work > > >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of > > >>>>>>>>>>>> JNI-attached threads :( ) > > >>>>>>>>>>>> > > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like > > >>>>>>>>>>>> exposing > > >>>>>>>>>>>> a new JVM function this way. > > >>>>>>>>>>>> > > >>>>>>>>>>>> Thanks, > > >>>>>>>>>>>> David > > >>>>>>>>>>>> ----- > > >>>>>>>>>>>> > > >>>>>>>>>>>>> Thus I think that we have to provide a function to set > native > > >>>>>>>>>>>>> thread name. > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> Thanks, > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> Yasumasa > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> [1] > > >>>>>>>>>>>>> > https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>> > > >>>>>>>>>>>>>> Thanks, > > >>>>>>>>>>>>>> David > > >>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> Could you review again? > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> - hotspot: > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> - jdk: > > >>>>>>>>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> Thanks, > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> Yasumasa > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: > > >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... > > >>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>> Hi Yasumasa, > > >>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on > > >>>>>>>>>>>>>>>> vacation). > > >>>>>>>>>>>>>>>> This > > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we > do not > > >>>>>>>>>>>>>>>> set the > > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the > > >>>>>>>>>>>>>>>> "main" > > >>>>>>>>>>>>>>>> thread. > > >>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>> David > > >>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>>>>>>> Thanks Robbin, > > >>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) > > >>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>> Yasumasa > > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >: > > >>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. > > >>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>> /Robbin > > >>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: > > >>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>> Thanks, looks good. > > >>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>> /Robbin > > >>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> Hi, > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. > > >>>>>>>>>>>>>>>>>>>> Could you review it? > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> Thanks, > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> Yasumasa > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: > > >>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> Hi, > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" > > > >>>>>>>>>>>>>>>>>>>>>> >>: > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, > > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >>>: > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 > > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp > > >>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu > > >>>>>>>>>>>>>>>>>>>>>> Mar 24 > > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 > > >>>>>>>>>>>>>>>>>>>>>> +0000 > > >>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu > > >>>>>>>>>>>>>>>>>>>>>> Mar 24 > > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 > > >>>>>>>>>>>>>>>>>>>>>> +0100 > > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ > > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new > JavaThread(); > > >>>>>>>>>>>>>>>>>>>>>> >> > > main_thread->set_thread_state(_thread_in_vm); > > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); > > >>>>>>>>>>>>>>>>>>>>>> >> > + > main_thread->set_native_thread_name("main"); > > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before > set_active_handles > > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> > main_thread->set_active_handles(JNIHandleBlock::allocate_block()); > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread > name in > > >>>>>>>>>>>>>>>>>>>>>> Thread > > >>>>>>>>>>>>>>>>>>>>>> class. > > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). > > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native > > >>>>>>>>>>>>>>>>>>>>>> thread > > >>>>>>>>>>>>>>>>>>>>>> name > > >>>>>>>>>>>>>>>>>>>>>> will be > > >>>>>>>>>>>>>>>>>>>>>> set at > > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already > starte > > >>>>>>>>>>>>>>>>>>>>>> in VM. > > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in > > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). > > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name > > >>>>>>>>>>>>>>>>>>>>>> should > > >>>>>>>>>>>>>>>>>>>>>> be the > > >>>>>>>>>>>>>>>>>>>>>> same. > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like > > >>>>>>>>>>>>>>>>>>>>>> this is > > >>>>>>>>>>>>>>>>>>>>>> nicer, no? > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue > Mar 29 > > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 > > >>>>>>>>>>>>>>>>>>>>>> 2016 > > >>>>>>>>>>>>>>>>>>>>>> +0200 > > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed > Mar 30 > > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 > > >>>>>>>>>>>>>>>>>>>>>> 2016 > > >>>>>>>>>>>>>>>>>>>>>> +0200 > > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ > > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread > > >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle > > >>>>>>>>>>>>>>>>>>>>>> thread_group, > > >>>>>>>>>>>>>>>>>>>>>> JavaThread* > > >>>>>>>>>>>>>>>>>>>>>> thread, > > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { > > >>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = > "main"; > > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = > > >>>>>>>>>>>>>>>>>>>>>> > SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> true, > > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); > > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = > > >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); > > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ > > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), > thread); > > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), > > >>>>>>>>>>>>>>>>>>>>>> NormPriority); > > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); > > >>>>>>>>>>>>>>>>>>>>>> > - > > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = > > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", > > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > > >>>>>>>>>>>>>>>>>>>>>> > + > > >>>>>>>>>>>>>>>>>>>>>> > + > > >>>>>>>>>>>>>>>>>>>>>> > thread->set_native_thread_name(initial_thread_name); > > >>>>>>>>>>>>>>>>>>>>>> > + > > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = > > >>>>>>>>>>>>>>>>>>>>>> > java_lang_String::create_from_str(initial_thread_name, > > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); > > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> Thanks! > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and > > >>>>>>>>>>>>>>>>>>>>>> naming > > >>>>>>>>>>>>>>>>>>>>>> this > > >>>>>>>>>>>>>>>>>>>>>> thread > > >>>>>>>>>>>>>>>>>>>>>> just > > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and > thus > > >>>>>>>>>>>>>>>>>>>>>> the > > >>>>>>>>>>>>>>>>>>>>>> process) is > > >>>>>>>>>>>>>>>>>>>>>> 'java' but > > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not > > >>>>>>>>>>>>>>>>>>>>>> JavaThread. > > >>>>>>>>>>>>>>>>>>>>>> It is > > >>>>>>>>>>>>>>>>>>>>>> waiting > > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with > > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). > > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for > JavaThread. So I > > >>>>>>>>>>>>>>>>>>>>>> think that > > >>>>>>>>>>>>>>>>>>>>>> we do > > >>>>>>>>>>>>>>>>>>>>>> not > > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since > we want > > >>>>>>>>>>>>>>>>>>>>>> java and > > >>>>>>>>>>>>>>>>>>>>>> native > > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might > have > > >>>>>>>>>>>>>>>>>>>>>> some > > >>>>>>>>>>>>>>>>>>>>>> dependents. > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 > > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND > > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java > > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main > > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main > > >>>>>>>>>>>>>>>>>>>>>> Thread'. > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> I do not think so. > > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java > launcher - e.g. > > >>>>>>>>>>>>>>>>>>>>>> Apache > > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, > I think > > >>>>>>>>>>>>>>>>>>>>>> that we > > >>>>>>>>>>>>>>>>>>>>>> have to > > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. > > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> No > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> Thanks again! > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> /Robbin > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> Thanks, > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> Yasumasa > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > Thanks > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > /Robbin > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> > > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin > > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa > Suenaga wrote: > > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread > name via > > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). > > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main > > >>>>>>>>>>>>>>>>>>>>>> thread is > > >>>>>>>>>>>>>>>>>>>>>> JavaThread. > > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have > > >>>>>>>>>>>>>>>>>>>>>> native > > >>>>>>>>>>>>>>>>>>>>>> thread > > >>>>>>>>>>>>>>>>>>>>>> name. > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. > > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa > > >>>>>>>>>>>>>>>>>>>>>> >> > > > > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>> > > > From Alan.Bateman at oracle.com Tue Apr 19 07:46:36 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Apr 2016 08:46:36 +0100 Subject: Multi-Release JAR runtime support In-Reply-To: <1511462.jDlVcCe28l@herve-desktop> References: <1511462.jDlVcCe28l@herve-desktop> Message-ID: <5715E25C.6080306@oracle.com> On 19/04/2016 02:49, Herv? BOUTEMY wrote: > : > > But the unexpected part is that JRE 9, either classical or jigsaw, don't take > advantage of the MR JAR: is this really expected, or did I do something wrong? Herv? - can you dump the manifest? It's not clear from your mail that it has the Multi-Release attribute. -Alan From Alan.Bateman at oracle.com Tue Apr 19 07:48:58 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Apr 2016 08:48:58 +0100 Subject: RFR: 8154470: defines.h confused about PROGNAME and JAVA_ARGS In-Reply-To: <57157380.5000602@oracle.com> References: <57157380.5000602@oracle.com> Message-ID: <5715E2EA.2040509@oracle.com> On 19/04/2016 00:53, Kumar Srinivasan wrote: > > Hi Martin, > > Tested with jprt, seems to be ok, the changes are ok with me. Unless > Alan has some reservations. > No reservations, looks okay to me too. -Alan From sean.coffey at oracle.com Tue Apr 19 08:42:26 2016 From: sean.coffey at oracle.com (=?UTF-8?Q?Se=c3=a1n_Coffey?=) Date: Tue, 19 Apr 2016 09:42:26 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba In-Reply-To: References: Message-ID: <5715EF72.4070004@oracle.com> Looks good Chris. Regards, Sean. On 18/04/2016 21:50, Chris Hegarty wrote: > This change updates the code in the cobra module to use the new > Thread constructor that suppresses inheritable-thread-local initial > values. > > http://cr.openjdk.java.net/~chegar/8148863/ > https://bugs.openjdk.java.net/browse/JDK-8148863 > > I?m open to suggestions for better names for the Threads. > > -Chris. From nadeesh.tv at oracle.com Tue Apr 19 08:42:52 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Tue, 19 Apr 2016 14:12:52 +0530 Subject: RFR:JDK-8031085:DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS" In-Reply-To: References: <570EB042.3040709@oracle.com> Message-ID: <5715EF8C.3010809@oracle.com> Hi Stephen, Thanks for the comments. Please see the updated webrev http://cr.openjdk.java.net/~ntv/8031085/webrev.01/ -- Thanks and Regards, Nadeesh TV On 4/18/2016 3:03 AM, Stephen Colebourne wrote: > The updated spec at line 670 is not clear - the adjacent parsing mode > only applies when in strict mode. Suggest a new sentence before the > lenient mode one: "In strict mode, if the minimum and maximum widths > are equal and there is no decimal point then the parser will > participate in adjacent value parsing, see {@code > appendValue(java.time.temporal.TemporalField, int)}. > > Line 2968 is missing a blank line > > Line 3001 does not need == true on isStrict() == true > > Perhaps line 3004 should return false? I'm not sure what is gained by > calling super. > > The changes to the test cases look wrong. > > test_adjacent_lenient_fractionFollows_2digit() and > test_adjacent_lenient_fractionFollows_0digit() should not have > changed, as the nano-of-second parsing is in lenient mode, and thus > should still parse from zero to nine digits. > > thanks > Stephen > > > On 13 April 2016 at 21:46, nadeesh tv wrote: >> HI all, >> >> BUG ID : https://bugs.openjdk.java.net/browse/JDK-8031085 >> >> Webrev : http://cr.openjdk.java.net/~ntv/8031085/webrev.00/ >> >> Issue - Fractional parts of seconds do not participate in the protocol for >> adjacent value parsing >> >> Solution - Changed the FractionPrinterParser to subclass of >> NumberPrinterParser to make it participate in adjacent value parsing >> >> 2 existing test cases >> TCKDateTimeFormatterBuilder.test_adjacent_lenient_fractionFollows_0digit and >> test_adjacent_lenient_fractionFollows_2digit were failing. Changed them >> accordingly. >> >> -- >> Thanks and Regards, >> Nadeesh TV >> -- Thanks and Regards, Nadeesh TV From Alan.Bateman at oracle.com Tue Apr 19 08:55:20 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Apr 2016 09:55:20 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba In-Reply-To: References: Message-ID: <5715F278.10007@oracle.com> On 18/04/2016 21:50, Chris Hegarty wrote: > This change updates the code in the cobra module to use the new > Thread constructor that suppresses inheritable-thread-local initial > values. > > http://cr.openjdk.java.net/~chegar/8148863/ > https://bugs.openjdk.java.net/browse/JDK-8148863 > > I?m open to suggestions for better names for the Threads. > Looks okay although I agree that some of the thread names might need changing. For example "SelectorThread" is very generic, you might want to put "PEPt" or "PEPt-Transport" into the thread name too. Another one is the KeepAlive thread, which I assume should have "Servant" in the name somewhere. There are several inconsistencies with Corba- in some, not in others. So yes, good to do another pass over the names. -Alan From stefan.karlsson at oracle.com Tue Apr 19 09:58:31 2016 From: stefan.karlsson at oracle.com (Stefan Karlsson) Date: Tue, 19 Apr 2016 11:58:31 +0200 Subject: RFR: 8072921: -Xincgc should be removed from output Message-ID: <57160147.3030008@oracle.com> Hi all, I hope this is the right list for this RFR. Please review this patch to remove the -Xincgc output from the java launcher. http://cr.openjdk.java.net/~stefank/8072921/webrev.01 https://bugs.openjdk.java.net/browse/JDK-8072921 The output can be seen by running 'java -X': $ ../build/linux-x86_64-normal-server-release/jdk/bin/java -X -Xmixed mixed mode execution (default) -Xint interpreted mode execution only -Xbootclasspath/a: append to end of bootstrap class path -Xdiag show additional diagnostic messages -Xdiag:resolver show resolver diagnostic messages -Xnoclassgc disable class garbage collection -Xincgc enable incremental garbage collection The -Xincgc flag was removed with JEP 214: https://bugs.openjdk.java.net/browse/JDK-8044022 JEP 214: Remove GC Combinations Deprecated in JDK 8 I've left the locale specific launcher files untouched. Should I update them as well? Thanks, StefanK From chris.hegarty at oracle.com Tue Apr 19 10:17:55 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 19 Apr 2016 11:17:55 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba In-Reply-To: <5715F278.10007@oracle.com> References: <5715F278.10007@oracle.com> Message-ID: <5CE294A8-3EB7-4044-9162-271C946B5444@oracle.com> On 19 Apr 2016, at 09:55, Alan Bateman wrote: > > On 18/04/2016 21:50, Chris Hegarty wrote: >> This change updates the code in the cobra module to use the new >> Thread constructor that suppresses inheritable-thread-local initial >> values. >> >> http://cr.openjdk.java.net/~chegar/8148863/ >> https://bugs.openjdk.java.net/browse/JDK-8148863 >> >> I?m open to suggestions for better names for the Threads. >> > Looks okay although I agree that some of the thread names might need changing. I took another pass over the names. Updated in-place http://cr.openjdk.java.net/~chegar/8148863/ -Chris. From peter.levart at gmail.com Tue Apr 19 10:41:00 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 19 Apr 2016 12:41:00 +0200 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5715684B.7020305@oracle.com> References: <5713C871.1080407@oracle.com> <5715684B.7020305@oracle.com> Message-ID: <57160B3C.3040805@gmail.com> Hi, On 04/19/2016 01:05 AM, Stuart Marks wrote: > > > On 4/17/16 10:31 AM, joe darcy wrote: >> With talk of deprecation in the air [1], I thought it would be a fine >> time to > > "In the Spring a young man's fancy lightly turns to thoughts of > deprecation." > -- apologies to Tennyson > >> examine one of the bugs on my list >> >> JDK-6850612: Deprecate Class.newInstance since it violates the >> checked >> exception language contract >> >> As the title of the bug implies, The Class.newInstance method >> knowingly violates >> the checking exception contract. This has long been documented in its >> specification: [...] >> >> Comments on the bug have suggested that besides deprecating the >> method, a new >> method on Class could be introduced, >> newInstanceWithProperExceptionBehavior, >> that had the same signature but wrapped exceptions thrown by the >> constructor >> call in the same way Constructor.newInstance does. > > Deprecating Class.newInstance() seems reasonable to me, for the > reasons you've stated. > > It's not clear to me that a replacement method adds much value. I > believe it's possible to replace a call > > clazz.newInstance() // 1 > > with the call > > clazz.getConstructor().newInstance() // 2 > > which is only a bit longer. Both snippets are declared to throw > InstantiationException and IllegalAccessException. But snippet 2 also > is declared to throw InvocationTargetException and NoSuchMethodException. > > This would seem to be an inconvenience, but *all* of these exceptions > are subtypes of ReflectiveOperationException. It seems pretty likely > to me that most code handles these different exception types the same > way. So it's fairly low cost to replace snippet 1 with snippet 2, and > to adjust the exception handling to deal with > ReflectiveOperationException. Thus I don't see much value in adding a > new method such as Class.newInstanceWithProperExceptionBehavior(). ...except for performance. The Class.newInstance() does special constructor and caller caching so that access checks don't have to be performed at every invocation. Performance sensitive user code using Class.newInstance() should then probably be modified to obtain Constructor only once and then re-use it for multiple invocations. Regards, Peter > > s'marks From Alan.Bateman at oracle.com Tue Apr 19 10:45:23 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Apr 2016 11:45:23 +0100 Subject: RFR: 8072921: -Xincgc should be removed from output In-Reply-To: <57160147.3030008@oracle.com> References: <57160147.3030008@oracle.com> Message-ID: <57160C43.7020706@oracle.com> On 19/04/2016 10:58, Stefan Karlsson wrote: > > I've left the locale specific launcher files untouched. Should I > update them as well? Dropping -Xincgc rom the -X output looks okay to me. We usually don't touch the translations as they are updated in bulk periodically, often closer to the end a release. -Alan. From Alan.Bateman at oracle.com Tue Apr 19 10:47:58 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Apr 2016 11:47:58 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba In-Reply-To: <5CE294A8-3EB7-4044-9162-271C946B5444@oracle.com> References: <5715F278.10007@oracle.com> <5CE294A8-3EB7-4044-9162-271C946B5444@oracle.com> Message-ID: <57160CDE.8030009@oracle.com> On 19/04/2016 11:17, Chris Hegarty wrote: > : > I took another pass over the names. Updated in-place > http://cr.openjdk.java.net/~chegar/8148863/ > Looks okay although there still some inconsistencies - for example "POA-Destroy-Thread" vs. other POA threads that are named "Etherealizer-Thread" and "Deactivator-Thread". It's not a big deal of course. -Alan From michael.osipov at siemens.com Tue Apr 19 10:53:33 2016 From: michael.osipov at siemens.com (Osipov, Michael) Date: Tue, 19 Apr 2016 10:53:33 +0000 Subject: [JNDI/LDAP] Intercepting LDAP URLs with initial and referral directory contexts Message-ID: <68644224DA0DE64CA5A49838ED219A0425B43E31@DEFTHW99EJ5MSX.ww902.siemens.net> Hi folks, I am looking for a clean way to intercept/alter LDAP URLs for both cases: initial and referrals (follow) before the directory context is created actually. In detail, I need to perform some AD related SRV lookups and replace the provided hostname which is actually a naming context with a real hostname. What I have achieved so far but am not really happy with: I have registered an ldapURLContextFactory with Context.URL_PKG_PREFIXES where I can swap the URL but this a really ugly solution because initial connections are not routed through this factory, only referral ones. Additionally, I have to create a complete Context which my class is not willing to do, but merely extends the private class com.sun.jndi.url.ldap.ldapURLContextFactory. My questions are: 1. How can I intercept initial contexts creations too with the same ObjectFactory? 2. How do I get rid of the dependency to that private Sun class? Thanks and regards, Michael Osipov From paul.sandoz at oracle.com Tue Apr 19 12:11:01 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 19 Apr 2016 14:11:01 +0200 Subject: Multi-Release JAR runtime support In-Reply-To: <5715E25C.6080306@oracle.com> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> Message-ID: <6DEE26DF-6723-40D2-B707-7B87C38F8F1B@oracle.com> > On 19 Apr 2016, at 09:46, Alan Bateman wrote: > > > > On 19/04/2016 02:49, Herv? BOUTEMY wrote: >> : >> >> But the unexpected part is that JRE 9, either classical or jigsaw, don't take >> advantage of the MR JAR: is this really expected, or did I do something wrong? > Herv? - can you dump the manifest? It's not clear from your mail that it has the Multi-Release attribute. > Plus what build of JDK 9 are you using? JDK 9 EA 114 has Mr.Jar integrated. https://jdk9.java.net/download/ There are no current plans to back port the runtime parts to a Java 8 update release. Paul. From paul.sandoz at oracle.com Tue Apr 19 12:14:23 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 19 Apr 2016 14:14:23 +0200 Subject: Multi-Release JAR runtime support In-Reply-To: <6DEE26DF-6723-40D2-B707-7B87C38F8F1B@oracle.com> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> <6DEE26DF-6723-40D2-B707-7B87C38F8F1B@oracle.com> Message-ID: <0C092EF4-8D61-4DBA-B283-AD4DBDE0C1BF@oracle.com> > On 19 Apr 2016, at 14:11, Paul Sandoz wrote: > > >> On 19 Apr 2016, at 09:46, Alan Bateman > wrote: >> >> >> >> On 19/04/2016 02:49, Herv? BOUTEMY wrote: >>> : >>> >>> But the unexpected part is that JRE 9, either classical or jigsaw, don't take >>> advantage of the MR JAR: is this really expected, or did I do something wrong? >> Herv? - can you dump the manifest? It's not clear from your mail that it has the Multi-Release attribute. >> > > Plus what build of JDK 9 are you using? > > JDK 9 EA 114 has Mr.Jar integrated. > > https://jdk9.java.net/download/ > Sent too soon, i see you are using b114 already: 9-ea+114-2016-04-15-162029.javare.4859.nc Cab you check if you have: Multi-Release: true in your manifest? Paul. > There are no current plans to back port the runtime parts to a Java 8 update release. > > Paul. From mark.sheppard at oracle.com Tue Apr 19 12:18:42 2016 From: mark.sheppard at oracle.com (Mark Sheppard) Date: Tue, 19 Apr 2016 13:18:42 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba In-Reply-To: <5CE294A8-3EB7-4044-9162-271C946B5444@oracle.com> References: <5715F278.10007@oracle.com> <5CE294A8-3EB7-4044-9162-271C946B5444@oracle.com> Message-ID: <57162222.3000909@oracle.com> the moniker PEPT-Transport-Thread for the SelectorImpl is a bit like the name Sue in the Johnny Cash song ... perhaps ORB-Selector-Thread would be more favourable also maybe go the "whole hog" with Async-Request-Invoker-Thread, please just like naming children very emotive :-) regards Mark On 19/04/2016 11:17, Chris Hegarty wrote: > On 19 Apr 2016, at 09:55, Alan Bateman wrote: > >> On 18/04/2016 21:50, Chris Hegarty wrote: >>> This change updates the code in the cobra module to use the new >>> Thread constructor that suppresses inheritable-thread-local initial >>> values. >>> >>> http://cr.openjdk.java.net/~chegar/8148863/ >>> https://bugs.openjdk.java.net/browse/JDK-8148863 >>> >>> I?m open to suggestions for better names for the Threads. >>> >> Looks okay although I agree that some of the thread names might need changing. > I took another pass over the names. Updated in-place > http://cr.openjdk.java.net/~chegar/8148863/ > > -Chris. From gerard.ziemski at oracle.com Tue Apr 19 12:54:58 2016 From: gerard.ziemski at oracle.com (Gerard Ziemski) Date: Tue, 19 Apr 2016 07:54:58 -0500 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5715BC65.3010302@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <57! 15BC65.3010302@oracle.com> Message-ID: <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> > On Apr 19, 2016, at 12:04 AM, David Holmes wrote: > > On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >> Hi Gerard, >> >> 2016/04/19 3:14 "Gerard Ziemski" > >: >> > >> > hi Yasumasa, >> > >> > Nice work. I have 2 questions: >> > >> > ======== >> > File: java.c >> > >> > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >> after every single JNI call? In this example instead of NULL_CHECK, >> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >> >> It is not critical if we encounter error at JNI function call because >> we cannot set native thread name only. >> So I think that we do not need to leave from launcher process. > > I agree we do not need to abort if an exception occurs (and in fact I don't think an exception is even possible from this code), but we should ensure any pending exception is cleared before any futher JNI calls might be made. Note that NULL_CHECK is already used extensively throughout the launcher code - so if this usage is wrong then it is all wrong! More on this code below ... Isn?t there a risk that: (*env)->CallVoidMethod(env, currentThread, setNativeNameID, + nameString, JNI_TRUE); will raise an exception? In the least, shouldn?t we clear any possible pending exceptions at the beginning of ?SetNativeThreadName?, as you say, but also at the very end? cheers From david.holmes at oracle.com Tue Apr 19 12:59:40 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 19 Apr 2016 22:59:40 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> Message-ID: <57162BBC.7010400@oracle.com> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: > >> On Apr 19, 2016, at 12:04 AM, David Holmes wrote: >> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>> Hi Gerard, >>> >>> 2016/04/19 3:14 "Gerard Ziemski" >> >: >>>> >>>> hi Yasumasa, >>>> >>>> Nice work. I have 2 questions: >>>> >>>> ======== >>>> File: java.c >>>> >>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>> after every single JNI call? In this example instead of NULL_CHECK, >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>> >>> It is not critical if we encounter error at JNI function call because >>> we cannot set native thread name only. >>> So I think that we do not need to leave from launcher process. >> >> I agree we do not need to abort if an exception occurs (and in fact I don't think an exception is even possible from this code), but we should ensure any pending exception is cleared before any futher JNI calls might be made. Note that NULL_CHECK is already used extensively throughout the launcher code - so if this usage is wrong then it is all wrong! More on this code below ... > > Isn?t there a risk that: > > (*env)->CallVoidMethod(env, currentThread, setNativeNameID, > + nameString, JNI_TRUE); > > will raise an exception? > > In the least, shouldn?t we clear any possible pending exceptions at the beginning of ?SetNativeThreadName?, as you say, but also at the very end? I was actually saying at the end, after the call (even though I don't think any exceptions are possible - except for "async" exceptions of course). We shouldn't be able to get to the call with any exception pending as in that case the JNI calls will be returning NULL and we will exit - again this pattern is used extensively in the launcher. David > > cheers > From pavel.rappo at oracle.com Tue Apr 19 13:10:00 2016 From: pavel.rappo at oracle.com (Pavel Rappo) Date: Tue, 19 Apr 2016 14:10:00 +0100 Subject: [JNDI/LDAP] Intercepting LDAP URLs with initial and referral directory contexts In-Reply-To: <68644224DA0DE64CA5A49838ED219A0425B43E31@DEFTHW99EJ5MSX.ww902.siemens.net> References: <68644224DA0DE64CA5A49838ED219A0425B43E31@DEFTHW99EJ5MSX.ww902.siemens.net> Message-ID: <71248695-E645-4A60-BD3D-7232AFC11CCF@oracle.com> Any chance these relates to what you are looking for? "Automatic Discovery of LDAP Servers" [1] and "Manually Following Referrals" [2]? -------------------------------------------------------------------------------- [1] http://docs.oracle.com/javase/jndi/tutorial/ldap/connect/create.html [2] http://docs.oracle.com/javase/jndi/tutorial/ldap/referral/throw.html > On 19 Apr 2016, at 11:53, Osipov, Michael wrote: > > Hi folks, > > I am looking for a clean way to intercept/alter LDAP URLs for both cases: initial and referrals (follow) > before the directory context is created actually. > In detail, I need to perform some AD related SRV lookups and replace the provided hostname which is actually > a naming context with a real hostname. > > What I have achieved so far but am not really happy with: > I have registered an ldapURLContextFactory with Context.URL_PKG_PREFIXES where I can swap the URL but > this a really ugly solution because initial connections are not routed through this factory, only referral > ones. Additionally, I have to create a complete Context which my class is not willing to do, but merely > extends the private class com.sun.jndi.url.ldap.ldapURLContextFactory. > > My questions are: > 1. How can I intercept initial contexts creations too with the same ObjectFactory? > 2. How do I get rid of the dependency to that private Sun class? > > Thanks and regards, > > Michael Osipov > > From michael.osipov at siemens.com Tue Apr 19 13:24:42 2016 From: michael.osipov at siemens.com (Osipov, Michael) Date: Tue, 19 Apr 2016 13:24:42 +0000 Subject: [JNDI/LDAP] Intercepting LDAP URLs with initial and referral directory contexts In-Reply-To: <71248695-E645-4A60-BD3D-7232AFC11CCF@oracle.com> References: <68644224DA0DE64CA5A49838ED219A0425B43E31@DEFTHW99EJ5MSX.ww902.siemens.net> <71248695-E645-4A60-BD3D-7232AFC11CCF@oracle.com> Message-ID: <68644224DA0DE64CA5A49838ED219A0425B43F36@DEFTHW99EJ5MSX.ww902.siemens.net> Hi Pavel, > Any chance these relates to what you are looking for? > > "Automatic Discovery of LDAP Servers" [1] and "Manually Following > Referrals" [2]? I know both but cannot/refuse to use them. As for [1]: It suffers from https://bugs.openjdk.java.net/browse/JDK-8149521 plus I can neither lookup for site-specific domain controllers (_ldap._tcp.SiteName._sites. DnsDomainName.) nor can I provide backups servers (String[]) if the first one fails. As for [2]: I don't want to handle referrals manually because I would need to clone all env properties, construct DirContext myself and manage the open contexts until I have my result. I would ultimately duplicate the code written by Sun which simply don't want to. I quick test revealed that the Sun code just does fine. Michael > -------------------------------------------------------------------------- > ------ > [1] http://docs.oracle.com/javase/jndi/tutorial/ldap/connect/create.html > [2] http://docs.oracle.com/javase/jndi/tutorial/ldap/referral/throw.html > > > On 19 Apr 2016, at 11:53, Osipov, Michael > wrote: > > > > Hi folks, > > > > I am looking for a clean way to intercept/alter LDAP URLs for both > cases: initial and referrals (follow) > > before the directory context is created actually. > > In detail, I need to perform some AD related SRV lookups and replace the > provided hostname which is actually > > a naming context with a real hostname. > > > > What I have achieved so far but am not really happy with: > > I have registered an ldapURLContextFactory with Context.URL_PKG_PREFIXES > where I can swap the URL but > > this a really ugly solution because initial connections are not routed > through this factory, only referral > > ones. Additionally, I have to create a complete Context which my class > is not willing to do, but merely > > extends the private class com.sun.jndi.url.ldap.ldapURLContextFactory. > > > > My questions are: > > 1. How can I intercept initial contexts creations too with the same > ObjectFactory? > > 2. How do I get rid of the dependency to that private Sun class? > > > > Thanks and regards, > > > > Michael Osipov > > > > From chris.hegarty at oracle.com Tue Apr 19 13:28:51 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 19 Apr 2016 14:28:51 +0100 Subject: RFR [9] 8148863: Remove sun.misc.ManagedLocalsThread from corba In-Reply-To: <57162222.3000909@oracle.com> References: <5715F278.10007@oracle.com> <5CE294A8-3EB7-4044-9162-271C946B5444@oracle.com> <57162222.3000909@oracle.com> Message-ID: <293BBB96-34E6-4930-9FD9-B20C1B995341@oracle.com> On 19 Apr 2016, at 13:18, Mark Sheppard wrote: > > the moniker PEPT-Transport-Thread for the SelectorImpl is a bit like the name Sue in the Johnny Cash song ... > > perhaps ORB-Selector-Thread would be more favourable Ok, that?s better. > also maybe go the "whole hog" with Async-Request-Invoker-Thread, please Ok. Thanks for reviewing. -Chris. > just like naming children very emotive :-) > > regards > Mark > > On 19/04/2016 11:17, Chris Hegarty wrote: >> On 19 Apr 2016, at 09:55, Alan Bateman wrote: >> >>> On 18/04/2016 21:50, Chris Hegarty wrote: >>>> This change updates the code in the cobra module to use the new >>>> Thread constructor that suppresses inheritable-thread-local initial >>>> values. >>>> >>>> http://cr.openjdk.java.net/~chegar/8148863/ >>>> https://bugs.openjdk.java.net/browse/JDK-8148863 >>>> >>>> I?m open to suggestions for better names for the Threads. >>>> >>> Looks okay although I agree that some of the thread names might need changing. >> I took another pass over the names. Updated in-place >> http://cr.openjdk.java.net/~chegar/8148863/ >> >> -Chris. > From christoph.langer at sap.com Tue Apr 19 13:54:55 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Tue, 19 Apr 2016 13:54:55 +0000 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> <570D6871.5000405@oracle.com> Message-ID: <754e59e7aff84b768c128072277ea177@DEWDFE13DE11.global.corp.sap> Hi again, I've updated the testcase to increase the probability of it really hitting the issue. The old version was prone to miss the issue in case something changed in the parser. http://cr.openjdk.java.net/~clanger/webrevs/8153781.2/ Best regards Christoph > -----Original Message----- > From: Langer, Christoph > Sent: Montag, 18. April 2016 23:04 > To: 'huizhe wang' > Cc: core-libs-dev at openjdk.java.net > Subject: RE: RFR: JDK-8153781 Issue in XMLScanner: > EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping > large DOCTYPE section with CRLF at wrong place > > Hi Joe, > > here is the updated webrev where I incorporated your suggestions: > > http://cr.openjdk.java.net/~clanger/webrevs/8153781.1/ > > I also added a testcase. As for the message " DoctypedeclNotClosed ": I did it in > several languages but there are some languages where I don't have the > knowledge to create a localized string. Is there some process for this or would > we just be ok with reverting to the English text for that particular message? > > Thanks in advance for your review :) > > All the best > Christoph > > > -----Original Message----- > > From: huizhe wang [mailto:huizhe.wang at oracle.com] > > Sent: Dienstag, 12. April 2016 23:28 > > To: Langer, Christoph > > Cc: core-libs-dev at openjdk.java.net > > Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: > > EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping > > large DOCTYPE section with CRLF at wrong place > > > > > > On 4/12/2016 11:50 AM, Langer, Christoph wrote: > > > Hi Joe, > > > > > > thanks as always for your suggestions and I'll try to work it in. It will > probably > > take me a little while as I'm currently busy with another thing. I'll update my > > webrev eventually and add a testcase, too. > > > > Ok. > > > > > > But one question: I understand that the fix in skipDTD will be sufficient to fix > > the issue. Nevetheless, can you explain me why the change in scanData is not > > beneficial or could even cause issues? There are several places in scanData > > when further loads are done. But only at this point where there's exactly one > > character after CRLF at the end of the buffer the method just returns without > > further load. If it wouldn't leave here it seems to me as if it would continue > > correctly and load more data. That would probably also be better in the sense > > of performance I guess?? > > > > It's there to handle the situation where a surrogate pair got split in > > between buffers. > > > > -Joe > > > > > > > > Thanks > > > Christoph > > > > > >> -----Original Message----- > > >> From: huizhe wang [mailto:huizhe.wang at oracle.com] > > >> Sent: Dienstag, 12. April 2016 19:54 > > >> To: Langer, Christoph > > >> Cc: core-libs-dev at openjdk.java.net > > >> Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: > > >> EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when > > skipping > > >> large DOCTYPE section with CRLF at wrong place > > >> > > >> Also, EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET was a > > >> wrong msg > > >> id. It would be good to change that to DoctypedeclNotClosed and add a > > >> message to XMLMessages.properties right before > > DoctypedeclUnterminated, > > >> sth. like the following: > > >> > > >> DoctypedeclNotClosed = The document type declaration for root element > > >> type \"{0}\" must be closed with '']''. > > >> > > >> Thanks, > > >> Joe > > >> > > >> On 4/11/2016 5:49 PM, huizhe wang wrote: > > >>> On 4/7/2016 1:45 PM, Langer, Christoph wrote: > > >>>> Hi, > > >>>> > > >>>> > > >>>> > > >>>> I've run into a peculiar issue with Xerces. > > >>>> > > >>>> > > >>>> > > >>>> The problem is happening when a DTD shall be skipped, the DTD is > > >>>> larger than the buffer of the current entity and a CRLF sequence > > >>>> occurs just one char before the buffer end. > > >>>> > > >>>> > > >>>> > > >>>> The reason is that method skipDTD of class XMLDTDScannerImpl (about > > >>>> line 389) calls XMLEntityScanner.scanData() to scan for the next > > >>>> occurrence of ']'. The scanData method might return true which > > >>>> indicates that the delimiter ']' was not found yet and more data is > > >>>> to scan. Other users of scanData would handle this and call this > > >>>> method in a loop until it returns false or some other condition > > >>>> happens. So I've fixed that place like at the other callers of scanData. > > >>> This part of the change looks good. > > >>>> > > >>>> > > >>>> Nevertheless, the scanData method would usually load more data when > > >>>> it is at the end of the buffer. But in the special case when CRLF is > > >>>> found at the end of buffer - 1, scanData would just return true. So I > > >>>> also removed that check at line 1374 in XMLEntityScanner. Do you see > > >>>> any problem with that? Is there any reason behind it which I'm > > >>>> overseeing? > > >>> No need to remove this after the above change. The parser needs to > > >>> retain what's in the xml, e.g., not removing new lines. > > >>>> Furthermore I took the chance for further little cleanups. I've added > > >>>> the new copyright header to the files... is that the correct one? > > >>> Yes, that's the right license header. However, > > >>>> > > >>>> I also aligned the calls to invokeListeners(position) in > > >>>> XMLEntityScanner to always pass the actual position from which the > > >>>> load is started. Do you think this is correct? > > >>> Yes. > > >>>> > > >>>> > > >>>> Here is the bug: > > >>>> > > >>>> https://bugs.openjdk.java.net/browse/JDK-8153781 > > >>>> > > >>>> > > >>>> > > >>>> Here is the webrev: > > >>>> > > >>>> http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ > > >>>> > > >>>> > > >>>> > > >>>> Please give me some comments before I finalize my change including a > > >>>> jtreg testcase. > > >>> It would be better if you had included the testcase so that the review > > >>> can be done together with the code change. > > >>> > > >>> Thanks, > > >>> Joe > > >>> > > >>>> > > >>>> > > >>>> Thanks & Best regards > > >>>> > > >>>> Christoph > > >>>> > > >>>> > > >>>> From scolebourne at joda.org Tue Apr 19 14:16:08 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Tue, 19 Apr 2016 15:16:08 +0100 Subject: RFR:JDK-8031085:DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS" In-Reply-To: <5715EF8C.3010809@oracle.com> References: <570EB042.3040709@oracle.com> <5715EF8C.3010809@oracle.com> Message-ID: Looks good. Stephen On 19 April 2016 at 09:42, nadeesh tv wrote: > Hi Stephen, > > Thanks for the comments. > Please see the updated webrev > http://cr.openjdk.java.net/~ntv/8031085/webrev.01/ > > -- > Thanks and Regards, > Nadeesh TV > > > > > On 4/18/2016 3:03 AM, Stephen Colebourne wrote: >> >> The updated spec at line 670 is not clear - the adjacent parsing mode >> only applies when in strict mode. Suggest a new sentence before the >> lenient mode one: "In strict mode, if the minimum and maximum widths >> are equal and there is no decimal point then the parser will >> participate in adjacent value parsing, see {@code >> appendValue(java.time.temporal.TemporalField, int)}. >> >> Line 2968 is missing a blank line >> >> Line 3001 does not need == true on isStrict() == true >> >> Perhaps line 3004 should return false? I'm not sure what is gained by >> calling super. >> >> The changes to the test cases look wrong. >> >> test_adjacent_lenient_fractionFollows_2digit() and >> test_adjacent_lenient_fractionFollows_0digit() should not have >> changed, as the nano-of-second parsing is in lenient mode, and thus >> should still parse from zero to nine digits. >> >> thanks >> Stephen >> >> >> On 13 April 2016 at 21:46, nadeesh tv wrote: >>> >>> HI all, >>> >>> BUG ID : https://bugs.openjdk.java.net/browse/JDK-8031085 >>> >>> Webrev : http://cr.openjdk.java.net/~ntv/8031085/webrev.00/ >>> >>> Issue - Fractional parts of seconds do not participate in the protocol >>> for >>> adjacent value parsing >>> >>> Solution - Changed the FractionPrinterParser to subclass of >>> NumberPrinterParser to make it participate in adjacent value parsing >>> >>> 2 existing test cases >>> TCKDateTimeFormatterBuilder.test_adjacent_lenient_fractionFollows_0digit >>> and >>> test_adjacent_lenient_fractionFollows_2digit were failing. Changed them >>> accordingly. >>> >>> -- >>> Thanks and Regards, >>> Nadeesh TV >>> > > -- > Thanks and Regards, > Nadeesh TV > From Roger.Riggs at Oracle.com Tue Apr 19 14:30:38 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 19 Apr 2016 07:30:38 -0700 (PDT) Subject: RFR:JDK-8148947:DateTimeFormatter pattern letter 'g' In-Reply-To: References: <56FC16B9.3000806@oracle.com> Message-ID: <5716410E.8010606@Oracle.com> Hi Nadeesh, Looks good to me also. Thanks, Roger On 4/17/2016 5:58 PM, Stephen Colebourne wrote: > Looks fine to me > Stephen > > On 30 March 2016 at 19:11, nadeesh tv wrote: >> Hi all, >> >> BUG ID : https://bugs.openjdk.java.net/browse/JDK-8148947 >> >> Webrev : http://cr.openjdk.java.net/~ntv/8148947/webrev.00/ >> >> Added new pattern letter 'g' for Modified Julian day. >> >> Apart from that made clarification to JulianFields and removed semicolons >> from docs of DateTimeFormatterBuilder as suggested by Stephen >> >> -- >> Thanks and Regards, >> Nadeesh TV >> From Roger.Riggs at Oracle.com Tue Apr 19 15:25:14 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 19 Apr 2016 08:25:14 -0700 (PDT) Subject: Project Jigsaw, Apache Tomcat and RMI related memory leaks In-Reply-To: <5715043B.4090901@apache.org> References: <5715043B.4090901@apache.org> Message-ID: <57164DDA.9070806@Oracle.com> Hi Mark, It may take a bit of time to unwind and find a good solution. On 4/18/16 11:58 AM, Mark Thomas wrote: > Hi, > > The Apache Tomcat community was asked by Rory O'Donnell for feedback on > JDK 9 + Project Jigsaw. Having provided that feedback we were directed > here so I have reproduced that feedback below. > > > I've started testing Tomcat trunk with JDK 9 + Project Jigsaw and it > looks like we are going to hit a bunch of problems related to Tomcat's > memory leak protection. > > The short version is there are lots of JDK calls that can result in a > reference being retained to the current class loader. If that class > loader is the web application class loader it often ends up being pinned > in memory. This triggers a memory leak when the web application is > reloaded since the web application class loader is not eligible for GC. > > Tomcat generally uses reflection to find these problems. It then does > one of two things: > - If the JRE provides an API the application developer should have used > to clean up the reference, Tomcat does this for them and then logs a > very loud error message telling the developer they need to fix their app. > - If there is nothing the developer could have done to avoid the > problem, Tomcat cleans it up. Usually this is via reflection again. > > Reporting this second class of issues as JRE bugs has been on my TODO > list for a long time. It looks like Java 9 is going to bump this to the > top of the list. > > The first problem we have hit is related to RMI. The memory leak is > triggered by a call to: > java.rmi.registry.Registry.bind() or > java.rmi.registry.Registry.rebind() > > The problem occurs when an object of a class loaded by the web > application class loader is bound to the RMI registry. > > There is no standard API (that I have found) that completely removes all > references. In particular > java.rmi.registry.Registry.unbind() > doesn't help. unbind just removes the mapping from name to an exported object; it does not un-export the object. Unless it was exported as permanent, the normal GC/distributed GC should clear it. I would think the normal application shutdown should both remove the binding and unexport it (perhaps forcibly). But you are working on the case where the application doesn't behave properly. If you had a way to discover the exported remote objects, the normal forcible unexport mechanism should be sufficient. Handing out references to exports objects would need some kind of security check. It might be worth investigating an official shutdown mechanism though linking it to a classloader seems a bit special purpose. $.02, Roger > The code Tomcat uses to clean this up is at [1]. Essentially, we need to > remove any reference to the web application's class loader from the RMI > caches. > > With JDK 9 this fails with: > java.lang.reflect.InaccessibleObjectException: Unable to make member of > class sun.rmi.transport.Target accessible: module java.rmi does not > export sun.rmi.transport to unnamed module ... > > I took a look at the JDK 9 API but I could not find a way to bypass > this. > > Possible solutions include: > 1. Some way that allows us to continue to use reflection as per the > current code. > > 2. A new method somewhere in the RMI API that clears all references > associated with a given class loader from the cache. > > 3. Modify Registry.unbind() so it removes all references. > > 4. Something else... > > I do have a concern with 3 on its own that, while that would allow > applications to clear their own references, it would mean Tomcat would > have no way to check for the problem. > > Ideally, I'd like to see the API extended so a) applications are able to > clean up after themselves and b) Tomcat can check for leaked references > and generate error messages for the ones found. > > Any and all suggestions gratefully received. > > Thanks, > > Mark > > [1] > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?view=annotate#l2214 From steve.drach at oracle.com Tue Apr 19 16:02:37 2016 From: steve.drach at oracle.com (Steve Drach) Date: Tue, 19 Apr 2016 09:02:37 -0700 Subject: Multi-Release JAR runtime support In-Reply-To: <5715E25C.6080306@oracle.com> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> Message-ID: <171D70D9-1AC3-4413-8419-7EAD54BC2086@oracle.com> Hi Herve, I checked the jar file created from your code and, as others have suspected, the manifest does not contain the ?Multi-Release? attribute. I added the attribute with emacs and tried it out: $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 9-ea+113 FROM BASE -> NINE Regards Steve From amaembo at gmail.com Tue Apr 19 16:28:26 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Tue, 19 Apr 2016 22:28:26 +0600 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> Message-ID: <77894944.20160419222826@gmail.com> Hello! webrev is updated in-place (just added parentheses): http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r1/ Updated benchmark source and results are available here: http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ In general I observe that for low-Q filter (x -> true) the results are also improved as well as for -Djava.util.concurrent.ForkJoinPool.common.parallelism=1. My tests were performed on 4-core machine (no hyperthreading), thus default parallelism is 4. The LEAF_TARGET version does not change the results significantly. If you feel that using LEAF_TARGET is more suitable I can update webrev correspondingly. Here's detailed summary benchmark report. HighQ test (i -> i.isProbablePrime(10)) ======================================= > Sequential seqLimit 2 avgt 30 34,106 ? 0,164 us/op seqLimit 20 avgt 30 362,209 ? 1,321 us/op seqLimit 200 avgt 30 3622,753 ? 11,087 us/op seqLimit 2000 avgt 30 36188,932 ? 302,942 us/op == parallelism=4 == > Parallel ordered parLimit 2 avgt 30 107,273 ? 0,437 us/op parLimit 20 avgt 30 924,058 ? 8,642 us/op parLimit 200 avgt 30 8692,190 ? 151,165 us/op parLimit 2000 avgt 30 41029,029 ? 2189,838 us/op > Parallel unordered -- original parUnorderedLimit 2 avgt 30 2479,964 ? 18,314 us/op parUnorderedLimit 20 avgt 30 2471,107 ? 19,684 us/op parUnorderedLimit 200 avgt 30 4512,631 ? 44,871 us/op parUnorderedLimit 2000 avgt 30 12164,026 ? 422,714 us/op > Parallel unordered -- commonPoolParallelism parUnorderedLimit 2 avgt 30 39,121 ? 0,122 us/op parUnorderedLimit 20 avgt 30 264,978 ? 0,192 us/op parUnorderedLimit 200 avgt 30 2504,541 ? 5,618 us/op parUnorderedLimit 2000 avgt 30 12167,302 ? 452,540 us/op > Parallel unordered -- LEAF_TARGET parUnorderedLimit 2 avgt 30 39,116 ? 0,184 us/op parUnorderedLimit 20 avgt 30 264,382 ? 0,773 us/op parUnorderedLimit 200 avgt 30 2528,825 ? 19,141 us/op parUnorderedLimit 2000 avgt 30 11867,199 ? 370,857 us/op == parallelism=1 == > Parallel ordered parLimit 2 avgt 30 78,868 ? 0,295 us/op parLimit 20 avgt 30 763,807 ? 5,107 us/op parLimit 200 avgt 30 7416,516 ? 39,541 us/op parLimit 2000 avgt 30 73061,036 ? 188,994 us/op > Parallel unordered -- original parUnorderedLimit 2 avgt 30 2395,410 ? 10,143 us/op parUnorderedLimit 20 avgt 30 2398,281 ? 12,045 us/op parUnorderedLimit 200 avgt 30 4536,042 ? 55,675 us/op parUnorderedLimit 2000 avgt 30 21166,422 ? 89,930 us/op > Parallel unordered -- commonPoolParallelism parUnorderedLimit 2 avgt 30 59,474 ? 0,362 us/op parUnorderedLimit 20 avgt 30 403,132 ? 2,648 us/op parUnorderedLimit 200 avgt 30 4533,470 ? 63,535 us/op parUnorderedLimit 2000 avgt 30 21085,084 ? 81,648 us/op > Parallel unordered -- LEAF_TARGET parUnorderedLimit 2 avgt 30 58,607 ? 0,342 us/op parUnorderedLimit 20 avgt 30 403,514 ? 2,774 us/op parUnorderedLimit 200 avgt 30 4586,126 ? 62,480 us/op parUnorderedLimit 2000 avgt 30 21272,978 ? 62,313 us/op LowQ test (i -> true) ===================== > Sequential seqLimit 2 avgt 30 0,133 ? 0,001 us/op seqLimit 20 avgt 30 0,375 ? 0,015 us/op seqLimit 200 avgt 30 2,941 ? 0,006 us/op seqLimit 2000 avgt 30 28,756 ? 0,066 us/op == parallelism=4 == > Parallel ordered parLimit 2 avgt 30 16,259 ? 0,249 us/op parLimit 20 avgt 30 23,623 ? 0,205 us/op parLimit 200 avgt 30 29,456 ? 0,202 us/op parLimit 2000 avgt 30 65,344 ? 0,345 us/op > Parallel unordered -- original parUnorderedLimit 2 avgt 30 8,693 ? 0,137 us/op parUnorderedLimit 20 avgt 30 8,987 ? 0,091 us/op parUnorderedLimit 200 avgt 30 15,304 ? 0,073 us/op parUnorderedLimit 2000 avgt 30 31,848 ? 0,360 us/op > Parallel unordered -- commonPoolParallelism parUnorderedLimit 2 avgt 30 3,814 ? 0,034 us/op parUnorderedLimit 20 avgt 30 4,663 ? 0,028 us/op parUnorderedLimit 200 avgt 30 12,337 ? 0,390 us/op parUnorderedLimit 2000 avgt 30 31,886 ? 0,358 us/op > Parallel unordered -- LEAF_TARGET parUnorderedLimit 2 avgt 30 3,785 ? 0,042 us/op parUnorderedLimit 20 avgt 30 4,652 ? 0,029 us/op parUnorderedLimit 200 avgt 30 12,749 ? 0,028 us/op parUnorderedLimit 2000 avgt 30 31,561 ? 0,362 us/op == parallelism=1 == > Parallel ordered parLimit 2 avgt 30 6,618 ? 0,079 us/op parLimit 20 avgt 30 9,280 ? 0,197 us/op parLimit 200 avgt 30 15,549 ? 0,864 us/op parLimit 2000 avgt 30 64,075 ? 0,358 us/op > Parallel unordered -- original parUnorderedLimit 2 avgt 30 10,946 ? 0,238 us/op parUnorderedLimit 20 avgt 30 10,875 ? 0,175 us/op parUnorderedLimit 200 avgt 30 9,304 ? 0,159 us/op parUnorderedLimit 2000 avgt 30 42,164 ? 0,883 us/op > Parallel unordered -- commonPoolParallelism parUnorderedLimit 2 avgt 30 1,482 ? 0,080 us/op parUnorderedLimit 20 avgt 30 3,515 ? 0,060 us/op parUnorderedLimit 200 avgt 30 9,174 ? 0,078 us/op parUnorderedLimit 2000 avgt 30 43,048 ? 0,997 us/op > Parallel unordered -- LEAF_TARGET parUnorderedLimit 2 avgt 30 2,281 ? 0,544 us/op parUnorderedLimit 20 avgt 30 3,412 ? 0,031 us/op parUnorderedLimit 200 avgt 30 9,109 ? 0,119 us/op parUnorderedLimit 2000 avgt 30 41,742 ? 0,878 us/op With best regards, Tagir Valeev. From forax at univ-mlv.fr Tue Apr 19 17:06:01 2016 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Tue, 19 Apr 2016 17:06:01 +0000 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <57160B3C.3040805@gmail.com> References: <5713C871.1080407@oracle.com> <5715684B.7020305@oracle.com> <57160B3C.3040805@gmail.com> Message-ID: I wanted to reply that if you have a perf sensitive code that uses newInstance you should use a MethodHandle instead to avoid to do the security checks multiple times but i remember that they was an issue with MethodHandle attached to a constructor and i don't know if it was resolved. R?mi Le 19 avril 2016 12:41:00 CEST, Peter Levart a ?crit : >Hi, > >On 04/19/2016 01:05 AM, Stuart Marks wrote: >> >> >> On 4/17/16 10:31 AM, joe darcy wrote: >>> With talk of deprecation in the air [1], I thought it would be a >fine >>> time to >> >> "In the Spring a young man's fancy lightly turns to thoughts of >> deprecation." >> -- apologies to Tennyson >> >>> examine one of the bugs on my list >>> >>> JDK-6850612: Deprecate Class.newInstance since it violates the >>> checked >>> exception language contract >>> >>> As the title of the bug implies, The Class.newInstance method >>> knowingly violates >>> the checking exception contract. This has long been documented in >its >>> specification: [...] >>> >>> Comments on the bug have suggested that besides deprecating the >>> method, a new >>> method on Class could be introduced, >>> newInstanceWithProperExceptionBehavior, >>> that had the same signature but wrapped exceptions thrown by the >>> constructor >>> call in the same way Constructor.newInstance does. >> >> Deprecating Class.newInstance() seems reasonable to me, for the >> reasons you've stated. >> >> It's not clear to me that a replacement method adds much value. I >> believe it's possible to replace a call >> >> clazz.newInstance() // 1 >> >> with the call >> >> clazz.getConstructor().newInstance() // 2 >> >> which is only a bit longer. Both snippets are declared to throw >> InstantiationException and IllegalAccessException. But snippet 2 also > >> is declared to throw InvocationTargetException and >NoSuchMethodException. >> >> This would seem to be an inconvenience, but *all* of these exceptions > >> are subtypes of ReflectiveOperationException. It seems pretty likely >> to me that most code handles these different exception types the same > >> way. So it's fairly low cost to replace snippet 1 with snippet 2, and > >> to adjust the exception handling to deal with >> ReflectiveOperationException. Thus I don't see much value in adding a > >> new method such as Class.newInstanceWithProperExceptionBehavior(). > >...except for performance. The Class.newInstance() does special >constructor and caller caching so that access checks don't have to be >performed at every invocation. > >Performance sensitive user code using Class.newInstance() should then >probably be modified to obtain Constructor only once and then re-use it > >for multiple invocations. > >Regards, Peter > >> >> s'marks From Roger.Riggs at Oracle.com Tue Apr 19 17:21:14 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 19 Apr 2016 10:21:14 -0700 (PDT) Subject: RFR:JDK-8031085:DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS" In-Reply-To: References: <570EB042.3040709@oracle.com> <5715EF8C.3010809@oracle.com> Message-ID: <5716690A.80505@Oracle.com> Hi Nadeesh, java/time/format/DateTimeFormatterBuilder.java: - line 671, the @code should be @link, especially since it says "see", to make navigation easier - line 2998: Missing first sentence of the method description. otherwise looks ok. Roger On 4/19/2016 10:16 AM, Stephen Colebourne wrote: > Looks good. > Stephen > > On 19 April 2016 at 09:42, nadeesh tv wrote: >> Hi Stephen, >> >> Thanks for the comments. >> Please see the updated webrev >> http://cr.openjdk.java.net/~ntv/8031085/webrev.01/ >> >> -- >> Thanks and Regards, >> Nadeesh TV >> >> >> >> >> On 4/18/2016 3:03 AM, Stephen Colebourne wrote: >>> The updated spec at line 670 is not clear - the adjacent parsing mode >>> only applies when in strict mode. Suggest a new sentence before the >>> lenient mode one: "In strict mode, if the minimum and maximum widths >>> are equal and there is no decimal point then the parser will >>> participate in adjacent value parsing, see {@code >>> appendValue(java.time.temporal.TemporalField, int)}. >>> >>> Line 2968 is missing a blank line >>> >>> Line 3001 does not need == true on isStrict() == true >>> >>> Perhaps line 3004 should return false? I'm not sure what is gained by >>> calling super. >>> >>> The changes to the test cases look wrong. >>> >>> test_adjacent_lenient_fractionFollows_2digit() and >>> test_adjacent_lenient_fractionFollows_0digit() should not have >>> changed, as the nano-of-second parsing is in lenient mode, and thus >>> should still parse from zero to nine digits. >>> >>> thanks >>> Stephen >>> >>> >>> On 13 April 2016 at 21:46, nadeesh tv wrote: >>>> HI all, >>>> >>>> BUG ID : https://bugs.openjdk.java.net/browse/JDK-8031085 >>>> >>>> Webrev : http://cr.openjdk.java.net/~ntv/8031085/webrev.00/ >>>> >>>> Issue - Fractional parts of seconds do not participate in the protocol >>>> for >>>> adjacent value parsing >>>> >>>> Solution - Changed the FractionPrinterParser to subclass of >>>> NumberPrinterParser to make it participate in adjacent value parsing >>>> >>>> 2 existing test cases >>>> TCKDateTimeFormatterBuilder.test_adjacent_lenient_fractionFollows_0digit >>>> and >>>> test_adjacent_lenient_fractionFollows_2digit were failing. Changed them >>>> accordingly. >>>> >>>> -- >>>> Thanks and Regards, >>>> Nadeesh TV >>>> >> -- >> Thanks and Regards, >> Nadeesh TV >> From kumar.x.srinivasan at oracle.com Tue Apr 19 17:00:27 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Tue, 19 Apr 2016 10:00:27 -0700 (PDT) Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57162BBC.7010400@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> Message-ID: <5716642B.8010207@oracle.com> Hi David, 493 /* Set native thread name. */ 494 SetNativeThreadName(env, "main"); 495 496 /* Invoke main method. */ 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); Supposing an exception is thrown in 494 (a very remote case), will we not re-enter the VM in 497 with an exception ? Kumar > On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >> >>> On Apr 19, 2016, at 12:04 AM, David Holmes >>> wrote: >>> >>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>> Hi Gerard, >>>> >>>> 2016/04/19 3:14 "Gerard Ziemski" >>> >: >>>>> >>>>> hi Yasumasa, >>>>> >>>>> Nice work. I have 2 questions: >>>>> >>>>> ======== >>>>> File: java.c >>>>> >>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>> after every single JNI call? In this example instead of NULL_CHECK, >>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>> >>>> It is not critical if we encounter error at JNI function call because >>>> we cannot set native thread name only. >>>> So I think that we do not need to leave from launcher process. >>> >>> I agree we do not need to abort if an exception occurs (and in fact >>> I don't think an exception is even possible from this code), but we >>> should ensure any pending exception is cleared before any futher JNI >>> calls might be made. Note that NULL_CHECK is already used >>> extensively throughout the launcher code - so if this usage is wrong >>> then it is all wrong! More on this code below ... >> >> Isn?t there a risk that: >> >> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >> + nameString, JNI_TRUE); >> >> will raise an exception? >> >> In the least, shouldn?t we clear any possible pending exceptions at >> the beginning of ?SetNativeThreadName?, as you say, but also at the >> very end? > > I was actually saying at the end, after the call (even though I don't > think any exceptions are possible - except for "async" exceptions of > course). We shouldn't be able to get to the call with any exception > pending as in that case the JNI calls will be returning NULL and we > will exit - again this pattern is used extensively in the launcher. > > David > >> >> cheers >> From paul.sandoz at oracle.com Tue Apr 19 16:57:36 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 19 Apr 2016 09:57:36 -0700 (PDT) Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <77894944.20160419222826@gmail.com> References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> <77894944.20160419222826@gmail.com> Message-ID: > On 19 Apr 2016, at 18:28, Tagir F. Valeev wrote: > > Hello! > > webrev is updated in-place (just added parentheses): > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r1/ > > Updated benchmark source and results are available here: > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/jmh/ > > In general I observe that for low-Q filter (x -> true) the results are > also improved as well as for > -Djava.util.concurrent.ForkJoinPool.common.parallelism=1. My tests > were performed on 4-core machine (no hyperthreading), thus default > parallelism is 4. > Thanks, this looks good. > The LEAF_TARGET version does not change the results significantly. If > you feel that using LEAF_TARGET is more suitable I can update webrev > correspondingly. > It has some appeal, since there is a symmetry to using that and the threshold at which the wrapping spliterator will no longer be split by F/J tasks. Up to you. Paul. From tadamski at redhat.com Tue Apr 19 17:58:11 2016 From: tadamski at redhat.com (Tomasz Adamski) Date: Tue, 19 Apr 2016 13:58:11 -0400 (EDT) Subject: RFR: 8152084: Introduction of ssliop protocol to corbaloc In-Reply-To: <642302691.38759819.1461087755982.JavaMail.zimbra@redhat.com> Message-ID: <321794846.38762864.1461088691787.JavaMail.zimbra@redhat.com> Hello All, I would like to propose an extension to corbaloc resolution - the ssliop protocol. IORs created from corbaloc url with ssliop protocol will contain SSL tagged component with indication that secured invocation is required. As a result, connection to the resolved object will have to be secured. I'm attaching a webrev of proposed enhancement: http://cr.openjdk.java.net/~adinn/tomaszadamski/8152084/ Regards, Tomek -- Tomasz Adamski Software Engineer JBoss by Red Hat From nadeesh.tv at oracle.com Tue Apr 19 18:04:29 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Tue, 19 Apr 2016 11:04:29 -0700 (PDT) Subject: RFR:JDK-8031085:DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS" In-Reply-To: <5716690A.80505@Oracle.com> References: <570EB042.3040709@oracle.com> <5715EF8C.3010809@oracle.com> <5716690A.80505@Oracle.com> Message-ID: <5716732D.5040803@oracle.com> Hi Roger, Please see the updated webrev http://cr.openjdk.java.net/~ntv/8031085/webrev.02/ Regards, Nadeesh TV On 4/19/2016 10:51 PM, Roger Riggs wrote: > Hi Nadeesh, > > java/time/format/DateTimeFormatterBuilder.java: > - line 671, the @code should be @link, especially since it says > "see", to make navigation easier > > - line 2998: Missing first sentence of the method description. > > otherwise looks ok. > > Roger > > > > > > On 4/19/2016 10:16 AM, Stephen Colebourne wrote: >> Looks good. >> Stephen >> >> On 19 April 2016 at 09:42, nadeesh tv wrote: >>> Hi Stephen, >>> >>> Thanks for the comments. >>> Please see the updated webrev >>> http://cr.openjdk.java.net/~ntv/8031085/webrev.01/ >>> >>> -- >>> Thanks and Regards, >>> Nadeesh TV >>> >>> >>> >>> >>> On 4/18/2016 3:03 AM, Stephen Colebourne wrote: >>>> The updated spec at line 670 is not clear - the adjacent parsing mode >>>> only applies when in strict mode. Suggest a new sentence before the >>>> lenient mode one: "In strict mode, if the minimum and maximum widths >>>> are equal and there is no decimal point then the parser will >>>> participate in adjacent value parsing, see {@code >>>> appendValue(java.time.temporal.TemporalField, int)}. >>>> >>>> Line 2968 is missing a blank line >>>> >>>> Line 3001 does not need == true on isStrict() == true >>>> >>>> Perhaps line 3004 should return false? I'm not sure what is gained by >>>> calling super. >>>> >>>> The changes to the test cases look wrong. >>>> >>>> test_adjacent_lenient_fractionFollows_2digit() and >>>> test_adjacent_lenient_fractionFollows_0digit() should not have >>>> changed, as the nano-of-second parsing is in lenient mode, and thus >>>> should still parse from zero to nine digits. >>>> >>>> thanks >>>> Stephen >>>> >>>> >>>> On 13 April 2016 at 21:46, nadeesh tv wrote: >>>>> HI all, >>>>> >>>>> BUG ID : https://bugs.openjdk.java.net/browse/JDK-8031085 >>>>> >>>>> Webrev : http://cr.openjdk.java.net/~ntv/8031085/webrev.00/ >>>>> >>>>> Issue - Fractional parts of seconds do not participate in the >>>>> protocol >>>>> for >>>>> adjacent value parsing >>>>> >>>>> Solution - Changed the FractionPrinterParser to subclass of >>>>> NumberPrinterParser to make it participate in adjacent value parsing >>>>> >>>>> 2 existing test cases >>>>> TCKDateTimeFormatterBuilder.test_adjacent_lenient_fractionFollows_0digit >>>>> >>>>> and >>>>> test_adjacent_lenient_fractionFollows_2digit were failing. Changed >>>>> them >>>>> accordingly. >>>>> >>>>> -- >>>>> Thanks and Regards, >>>>> Nadeesh TV >>>>> >>> -- >>> Thanks and Regards, >>> Nadeesh TV >>> > -- Thanks and Regards, Nadeesh TV From huizhe.wang at oracle.com Tue Apr 19 18:25:30 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Tue, 19 Apr 2016 11:25:30 -0700 (PDT) Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <754e59e7aff84b768c128072277ea177@DEWDFE13DE11.global.corp.sap> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> <570D6871.5000405@oracle.com> <754e59e7aff84b768c128072277ea177@DEWDFE13DE11.global.corp.sap> Message-ID: <57167819.6020704@oracle.com> On 4/19/2016 6:54 AM, Langer, Christoph wrote: > Hi again, > > I've updated the testcase to increase the probability of it really hitting the issue. The old version was prone to miss the issue in case something changed in the parser. > > http://cr.openjdk.java.net/~clanger/webrevs/8153781.2/ Looks good overall. Error msgs: you made an extra effort :-) normally, we don't need to do any translation. The I18n team has a revolving task that will periodically pick up these changes. License header: it is correct to update to the latest Apache License format. However, we would need to preserve the "reserved comment block" if we've not changed the code, which is the case for class such as HTTPInputSource.java. Best, Joe > > Best regards > Christoph > > > >> -----Original Message----- >> From: Langer, Christoph >> Sent: Montag, 18. April 2016 23:04 >> To: 'huizhe wang' >> Cc: core-libs-dev at openjdk.java.net >> Subject: RE: RFR: JDK-8153781 Issue in XMLScanner: >> EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping >> large DOCTYPE section with CRLF at wrong place >> >> Hi Joe, >> >> here is the updated webrev where I incorporated your suggestions: >> >> http://cr.openjdk.java.net/~clanger/webrevs/8153781.1/ >> >> I also added a testcase. As for the message " DoctypedeclNotClosed ": I did it in >> several languages but there are some languages where I don't have the >> knowledge to create a localized string. Is there some process for this or would >> we just be ok with reverting to the English text for that particular message? >> >> Thanks in advance for your review :) >> >> All the best >> Christoph >> >>> -----Original Message----- >>> From: huizhe wang [mailto:huizhe.wang at oracle.com] >>> Sent: Dienstag, 12. April 2016 23:28 >>> To: Langer, Christoph >>> Cc: core-libs-dev at openjdk.java.net >>> Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: >>> EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping >>> large DOCTYPE section with CRLF at wrong place >>> >>> >>> On 4/12/2016 11:50 AM, Langer, Christoph wrote: >>>> Hi Joe, >>>> >>>> thanks as always for your suggestions and I'll try to work it in. It will >> probably >>> take me a little while as I'm currently busy with another thing. I'll update my >>> webrev eventually and add a testcase, too. >>> >>> Ok. >>>> But one question: I understand that the fix in skipDTD will be sufficient to fix >>> the issue. Nevetheless, can you explain me why the change in scanData is not >>> beneficial or could even cause issues? There are several places in scanData >>> when further loads are done. But only at this point where there's exactly one >>> character after CRLF at the end of the buffer the method just returns without >>> further load. If it wouldn't leave here it seems to me as if it would continue >>> correctly and load more data. That would probably also be better in the sense >>> of performance I guess?? >>> >>> It's there to handle the situation where a surrogate pair got split in >>> between buffers. >>> >>> -Joe >>> >>>> Thanks >>>> Christoph >>>> >>>>> -----Original Message----- >>>>> From: huizhe wang [mailto:huizhe.wang at oracle.com] >>>>> Sent: Dienstag, 12. April 2016 19:54 >>>>> To: Langer, Christoph >>>>> Cc: core-libs-dev at openjdk.java.net >>>>> Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: >>>>> EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when >>> skipping >>>>> large DOCTYPE section with CRLF at wrong place >>>>> >>>>> Also, EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET was a >>>>> wrong msg >>>>> id. It would be good to change that to DoctypedeclNotClosed and add a >>>>> message to XMLMessages.properties right before >>> DoctypedeclUnterminated, >>>>> sth. like the following: >>>>> >>>>> DoctypedeclNotClosed = The document type declaration for root element >>>>> type \"{0}\" must be closed with '']''. >>>>> >>>>> Thanks, >>>>> Joe >>>>> >>>>> On 4/11/2016 5:49 PM, huizhe wang wrote: >>>>>> On 4/7/2016 1:45 PM, Langer, Christoph wrote: >>>>>>> Hi, >>>>>>> >>>>>>> >>>>>>> >>>>>>> I've run into a peculiar issue with Xerces. >>>>>>> >>>>>>> >>>>>>> >>>>>>> The problem is happening when a DTD shall be skipped, the DTD is >>>>>>> larger than the buffer of the current entity and a CRLF sequence >>>>>>> occurs just one char before the buffer end. >>>>>>> >>>>>>> >>>>>>> >>>>>>> The reason is that method skipDTD of class XMLDTDScannerImpl (about >>>>>>> line 389) calls XMLEntityScanner.scanData() to scan for the next >>>>>>> occurrence of ']'. The scanData method might return true which >>>>>>> indicates that the delimiter ']' was not found yet and more data is >>>>>>> to scan. Other users of scanData would handle this and call this >>>>>>> method in a loop until it returns false or some other condition >>>>>>> happens. So I've fixed that place like at the other callers of scanData. >>>>>> This part of the change looks good. >>>>>>> >>>>>>> Nevertheless, the scanData method would usually load more data when >>>>>>> it is at the end of the buffer. But in the special case when CRLF is >>>>>>> found at the end of buffer - 1, scanData would just return true. So I >>>>>>> also removed that check at line 1374 in XMLEntityScanner. Do you see >>>>>>> any problem with that? Is there any reason behind it which I'm >>>>>>> overseeing? >>>>>> No need to remove this after the above change. The parser needs to >>>>>> retain what's in the xml, e.g., not removing new lines. >>>>>>> Furthermore I took the chance for further little cleanups. I've added >>>>>>> the new copyright header to the files... is that the correct one? >>>>>> Yes, that's the right license header. However, >>>>>>> I also aligned the calls to invokeListeners(position) in >>>>>>> XMLEntityScanner to always pass the actual position from which the >>>>>>> load is started. Do you think this is correct? >>>>>> Yes. >>>>>>> >>>>>>> Here is the bug: >>>>>>> >>>>>>> https://bugs.openjdk.java.net/browse/JDK-8153781 >>>>>>> >>>>>>> >>>>>>> >>>>>>> Here is the webrev: >>>>>>> >>>>>>> http://cr.openjdk.java.net/~clanger/webrevs/8153781.0/ >>>>>>> >>>>>>> >>>>>>> >>>>>>> Please give me some comments before I finalize my change including a >>>>>>> jtreg testcase. >>>>>> It would be better if you had included the testcase so that the review >>>>>> can be done together with the code change. >>>>>> >>>>>> Thanks, >>>>>> Joe >>>>>> >>>>>>> >>>>>>> Thanks & Best regards >>>>>>> >>>>>>> Christoph >>>>>>> >>>>>>> >>>>>>> From herve.boutemy at free.fr Tue Apr 19 19:37:41 2016 From: herve.boutemy at free.fr (=?ISO-8859-1?Q?Herv=E9?= BOUTEMY) Date: Tue, 19 Apr 2016 21:37:41 +0200 Subject: Multi-Release JAR runtime support In-Reply-To: <5715E25C.6080306@oracle.com> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> Message-ID: <4040113.8uvnzoatIK@herve-desktop> that's it: I added this Multi-Release: true attribute configuration in the demo and now it works like a charm, thank you Perhaps this requirement should be described in http://openjdk.java.net/jeps/238 Is it expected to be supported with JDK 8 also? Is there any magic trick to add this feature to a normal JDK 8? Regards, Herv? FYI, here is the output now: Archive: multirelease/target/multirelease-0.8-SNAPSHOT.jar testing: META-INF/MANIFEST.MF OK testing: base/Base.class OK testing: mr/A.class OK testing: META-INF/versions/9/mr/A.class OK testing: META-INF/versions/8/mr/A.class OK No errors detected in compressed data of multirelease/target/multirelease-0.8- SNAPSHOT.jar. $ unzip -p multirelease/target/multirelease-0.8-SNAPSHOT.jar META- INF/MANIFEST.MF Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven 3.3.9 Built-By: herve Build-Jdk: 9-ea Multi-Release: true [...] # Run Multi Release JAR with JRE 7 $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 1.7.0_71-b14 BASE # Run Multi Release JAR with JRE 8 $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 1.8.0_25-b17 BASE # Run Multi Release JAR with JRE 9 classic $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 9-ea+114 FROM BASE -> NINE # Run Multi Release JAR with JRE 9 Jigsaw $ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base 9-ea+114-2016-04-15-162029.javare.4859.nc FROM BASE -> NINE Le mardi 19 avril 2016 08:46:36 Alan Bateman a ?crit : > On 19/04/2016 02:49, Herv? BOUTEMY wrote: > > But the unexpected part is that JRE 9, either classical or jigsaw, don't > > take advantage of the MR JAR: is this really expected, or did I do > > something wrong? > Herv? - can you dump the manifest? It's not clear from your mail that it > has the Multi-Release attribute. > > -Alan From david.holmes at oracle.com Tue Apr 19 20:32:19 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 19 Apr 2016 13:32:19 -0700 (PDT) Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5716642B.8010207@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> Message-ID: <571695D3.6060908@oracle.com> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: > Hi David, > > 493 /* Set native thread name. */ > 494 SetNativeThreadName(env, "main"); > 495 > 496 /* Invoke main method. */ > 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); > > Supposing an exception is thrown in 494 (a very remote case), > will we not re-enter the VM in 497 with an exception ? Yes as I said: > 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, > 1714 nameString, JNI_TRUE); > > As above NULL_CHECK is fine here, but we should check for and clear any pending exception after CallVoidMethod. Thanks, David > Kumar > >> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>> >>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>> wrote: >>>> >>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>> Hi Gerard, >>>>> >>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>> >: >>>>>> >>>>>> hi Yasumasa, >>>>>> >>>>>> Nice work. I have 2 questions: >>>>>> >>>>>> ======== >>>>>> File: java.c >>>>>> >>>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>> after every single JNI call? In this example instead of NULL_CHECK, >>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>> >>>>> It is not critical if we encounter error at JNI function call because >>>>> we cannot set native thread name only. >>>>> So I think that we do not need to leave from launcher process. >>>> >>>> I agree we do not need to abort if an exception occurs (and in fact >>>> I don't think an exception is even possible from this code), but we >>>> should ensure any pending exception is cleared before any futher JNI >>>> calls might be made. Note that NULL_CHECK is already used >>>> extensively throughout the launcher code - so if this usage is wrong >>>> then it is all wrong! More on this code below ... >>> >>> Isn?t there a risk that: >>> >>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>> + nameString, JNI_TRUE); >>> >>> will raise an exception? >>> >>> In the least, shouldn?t we clear any possible pending exceptions at >>> the beginning of ?SetNativeThreadName?, as you say, but also at the >>> very end? >> >> I was actually saying at the end, after the call (even though I don't >> think any exceptions are possible - except for "async" exceptions of >> course). We shouldn't be able to get to the call with any exception >> pending as in that case the JNI calls will be returning NULL and we >> will exit - again this pattern is used extensively in the launcher. >> >> David >> >>> >>> cheers >>> > From christoph.langer at sap.com Tue Apr 19 20:45:01 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Tue, 19 Apr 2016 20:45:01 +0000 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <57167819.6020704@oracle.com> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> <570D6871.5000405@oracle.com> <754e59e7aff84b768c128072277ea177@DEWDFE13DE11.global.corp.sap> <57167819.6020704@oracle.com> Message-ID: Hi Joe, > > I've updated the testcase to increase the probability of it really hitting the > issue. The old version was prone to miss the issue in case something changed in > the parser. > > > > http://cr.openjdk.java.net/~clanger/webrevs/8153781.2/ > > Looks good overall. OK, thanks. > Error msgs: you made an extra effort :-) normally, we don't need to do > any translation. The I18n team has a revolving task that will > periodically pick up these changes. OK - I think the message is not really useful anyway. I don't see a way to produce it by creating a malformed XML document. It would probably only pop up with the old erroneous implementation of skipDTD and SUPPORT_DTD property false. > License header: it is correct to update to the latest Apache License > format. However, we would need to preserve the "reserved comment block" > if we've not changed the code, which is the case for class such as > HTTPInputSource.java. Fixed that. Here is the new webrev: http://cr.openjdk.java.net/~clanger/webrevs/8153781.3/ If you consider it reviewed I would love if you could push it for me. :-) Thanks Christoph From kumar.x.srinivasan at oracle.com Tue Apr 19 21:33:39 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Tue, 19 Apr 2016 14:33:39 -0700 (PDT) Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571695D3.6060908@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> Message-ID: <5716A433.1070909@oracle.com> On 4/19/2016 1:32 PM, David Holmes wrote: > On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >> Hi David, >> >> 493 /* Set native thread name. */ >> 494 SetNativeThreadName(env, "main"); >> 495 >> 496 /* Invoke main method. */ >> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >> mainArgs); >> >> Supposing an exception is thrown in 494 (a very remote case), >> will we not re-enter the VM in 497 with an exception ? > > Yes as I said: > >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >> 1714 nameString, JNI_TRUE); >> >> As above NULL_CHECK is fine here, but we should check for and clear >> any pending exception after CallVoidMethod. > Agreed. Kumar > Thanks, > David > >> Kumar >> >>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>> >>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>> wrote: >>>>> >>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>> Hi Gerard, >>>>>> >>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>> >: >>>>>>> >>>>>>> hi Yasumasa, >>>>>>> >>>>>>> Nice work. I have 2 questions: >>>>>>> >>>>>>> ======== >>>>>>> File: java.c >>>>>>> >>>>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>>> after every single JNI call? In this example instead of NULL_CHECK, >>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>> >>>>>> It is not critical if we encounter error at JNI function call >>>>>> because >>>>>> we cannot set native thread name only. >>>>>> So I think that we do not need to leave from launcher process. >>>>> >>>>> I agree we do not need to abort if an exception occurs (and in fact >>>>> I don't think an exception is even possible from this code), but we >>>>> should ensure any pending exception is cleared before any futher JNI >>>>> calls might be made. Note that NULL_CHECK is already used >>>>> extensively throughout the launcher code - so if this usage is wrong >>>>> then it is all wrong! More on this code below ... >>>> >>>> Isn?t there a risk that: >>>> >>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>> + nameString, JNI_TRUE); >>>> >>>> will raise an exception? >>>> >>>> In the least, shouldn?t we clear any possible pending exceptions at >>>> the beginning of ?SetNativeThreadName?, as you say, but also at the >>>> very end? >>> >>> I was actually saying at the end, after the call (even though I don't >>> think any exceptions are possible - except for "async" exceptions of >>> course). We shouldn't be able to get to the call with any exception >>> pending as in that case the JNI calls will be returning NULL and we >>> will exit - again this pattern is used extensively in the launcher. >>> >>> David >>> >>>> >>>> cheers >>>> >> From huizhe.wang at oracle.com Tue Apr 19 21:44:24 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Tue, 19 Apr 2016 14:44:24 -0700 (PDT) Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> <570D6871.5000405@oracle.com> <754e59e7aff84b768c128072277ea177@DEWDFE13DE11.global.corp.sap> <57167819.6020704@oracle.com> Message-ID: <5716A6B8.5080805@oracle.com> On 4/19/2016 1:45 PM, Langer, Christoph wrote: > Hi Joe, > >>> I've updated the testcase to increase the probability of it really hitting the >> issue. The old version was prone to miss the issue in case something changed in >> the parser. >>> http://cr.openjdk.java.net/~clanger/webrevs/8153781.2/ >> Looks good overall. > OK, thanks. > >> Error msgs: you made an extra effort :-) normally, we don't need to do >> any translation. The I18n team has a revolving task that will >> periodically pick up these changes. > OK - I think the message is not really useful anyway. I don't see a way to produce it by creating a malformed XML document. It would probably only pop up with the old erroneous implementation of skipDTD and SUPPORT_DTD property false. > >> License header: it is correct to update to the latest Apache License >> format. However, we would need to preserve the "reserved comment block" >> if we've not changed the code, which is the case for class such as >> HTTPInputSource.java. > Fixed that. > > Here is the new webrev: http://cr.openjdk.java.net/~clanger/webrevs/8153781.3/ > > If you consider it reviewed I would love if you could push it for me. :-) Sure :-) Will do after all test runs complete. Thanks, Joe > > Thanks > Christoph > From stuart.marks at oracle.com Tue Apr 19 22:11:38 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Tue, 19 Apr 2016 15:11:38 -0700 (PDT) Subject: RFR(s): 8153330: deprecate Runtime.traceInstructions & traceMethodCalls for removal Message-ID: <5716AD1A.3040902@oracle.com> Hi all, I missed a couple bits of cruft in the previous round of java.lang deprecations: the Runtime.traceInstructions() and traceMethodCalls() methods. Their implementations are empty. That is, they do absolutely nothing. They're only mentioned a couple times in the JDK, in CORBA (!) and in some RMI tests (!), and in a few symbol files. On grepcode.com, there are a couple uses, mainly attempting to enable these in response to some debugging flag being given. Thus, I propose these be deprecated for removal. Please review diff below. Thanks, s'marks diff -r 92280897299f src/java.base/share/classes/java/lang/Runtime.java --- a/src/java.base/share/classes/java/lang/Runtime.java Mon Apr 18 14:10:14 2016 -0700 +++ b/src/java.base/share/classes/java/lang/Runtime.java Tue Apr 19 15:04:25 2016 -0700 @@ -718,41 +718,27 @@ } /** - * Enables/Disables tracing of instructions. - * If the {@code boolean} argument is {@code true}, this - * method suggests that the Java virtual machine emit debugging - * information for each instruction in the virtual machine as it - * is executed. The format of this information, and the file or other - * output stream to which it is emitted, depends on the host environment. - * The virtual machine may ignore this request if it does not support - * this feature. The destination of the trace output is system - * dependent. - *

      - * If the {@code boolean} argument is {@code false}, this - * method causes the virtual machine to stop performing the - * detailed instruction trace it is performing. - * - * @param on {@code true} to enable instruction tracing; - * {@code false} to disable this feature. + * Not implemented. + * + * @deprecated + * This method was intended to control instruction tracing. + * It has been superseded by JVM-specific tracing mechanisms. + * + * @param on ignored */ + @Deprecated(since="9", forRemoval=true) public void traceInstructions(boolean on) { } /** - * Enables/Disables tracing of method calls. - * If the {@code boolean} argument is {@code true}, this - * method suggests that the Java virtual machine emit debugging - * information for each method in the virtual machine as it is - * called. The format of this information, and the file or other output - * stream to which it is emitted, depends on the host environment. The - * virtual machine may ignore this request if it does not support - * this feature. - *

      - * Calling this method with argument false suggests that the - * virtual machine cease emitting per-call debugging information. - * - * @param on {@code true} to enable instruction tracing; - * {@code false} to disable this feature. + * Not implemented. + * + * @deprecated + * This method was intended to control method call tracing. + * It has been superseded by JVM-specific tracing mechanisms. + * + * @param on ignored */ + @Deprecated(since="9", forRemoval=true) public void traceMethodCalls(boolean on) { } /** From mark.reinhold at oracle.com Tue Apr 19 22:57:02 2016 From: mark.reinhold at oracle.com (mark.reinhold at oracle.com) Date: Tue, 19 Apr 2016 15:57:02 -0700 Subject: PING: RFR: JDK-4347142: Need method to set Password protection to Zip entries In-Reply-To: <5707E1E8.9060202@gmail.com> References: <56F9A4F4.6040108@oracle.com> <5707E1E8.9060202@gmail.com> Message-ID: <20160419155702.398317500eggemoggin.niobe.net> 2016/4/8 9:52:56 -0700, anthony.vanelverdinghe at gmail.com: > I don't mind if decryption support is added for the "Traditional > Encryption". However, I believe it would be wrong to introduce > encryption support for a known-to-be-broken encryption method in the > JDK. Using the argument of "it's good enough for our case", I could also > argue that Base64 qualifies as an encryption method, or that SSLv2 is an > appropriate choice to secure network connections. I have to agree. I don't think it makes sense to add a known-vulnerable encryption algorithm to the JDK. It might work perfectly well for one use case but it will eventually be used by someone who doesn't take the time to understand it, assumes that it provides strong encryption when it doesn't, gets burned, and then blames Java. - Mark From mark.reinhold at oracle.com Wed Apr 20 00:11:25 2016 From: mark.reinhold at oracle.com (mark.reinhold at oracle.com) Date: Tue, 19 Apr 2016 17:11:25 -0700 (PDT) Subject: Multi-Release JAR runtime support In-Reply-To: <4040113.8uvnzoatIK@herve-desktop> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> <4040113.8uvnzoatIK@herve-desktop> Message-ID: <20160419171125.134877943eggemoggin.niobe.net> 2016/4/19 12:37:41 -0700, Herv? BOUTEMY : > that's it: I added this Multi-Release: true attribute configuration in the > demo and now it works like a charm, thank you > > Perhaps this requirement should be described in > http://openjdk.java.net/jeps/238 Yes -- that was certainly non-obvious! Steve, could you please add this to the JEP? (A JEP should, in general, contain and/or refer to enough information for an experienced developer to get started using the feature.) Thanks, - Mark From steve.drach at oracle.com Wed Apr 20 02:58:48 2016 From: steve.drach at oracle.com (Steve Drach) Date: Tue, 19 Apr 2016 19:58:48 -0700 (PDT) Subject: Multi-Release JAR runtime support In-Reply-To: <20160419171125.134877943eggemoggin.niobe.net> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> <4040113.8uvnzoatIK@herve-desktop> <20160419171125.134877943eggemoggin.niobe.net> Message-ID: Yes. > On Apr 19, 2016, at 5:11 PM, mark.reinhold at oracle.com wrote: > > 2016/4/19 12:37:41 -0700, Herv? BOUTEMY : >> that's it: I added this Multi-Release: true attribute configuration in the >> demo and now it works like a charm, thank you >> >> Perhaps this requirement should be described in >> http://openjdk.java.net/jeps/238 > > Yes -- that was certainly non-obvious! > > Steve, could you please add this to the JEP? (A JEP should, in general, > contain and/or refer to enough information for an experienced developer > to get started using the feature.) > > Thanks, > - Mark From christoph.langer at sap.com Wed Apr 20 06:21:13 2016 From: christoph.langer at sap.com (Langer, Christoph) Date: Wed, 20 Apr 2016 06:21:13 +0000 Subject: RFR: JDK-8153781 Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place In-Reply-To: <5716A6B8.5080805@oracle.com> References: <69c224ec9bbb4adaac47eee7917255ca@DEWDFE13DE11.global.corp.sap> <570C4604.7060700@oracle.com> <570D361C.9060602@oracle.com> <3539a24325b14dff891860ee8525f283@DEWDFE13DE11.global.corp.sap> <570D6871.5000405@oracle.com> <754e59e7aff84b768c128072277ea177@DEWDFE13DE11.global.corp.sap> <57167819.6020704@oracle.com> <5716A6B8.5080805@oracle.com> Message-ID: <2080ec4c9ea1419382fbf1ee958cdf1b@DEWDFE13DE11.global.corp.sap> Thanks Joe :-) > -----Original Message----- > From: huizhe wang [mailto:huizhe.wang at oracle.com] > Sent: Dienstag, 19. April 2016 23:44 > To: Langer, Christoph > Cc: core-libs-dev at openjdk.java.net > Subject: Re: RFR: JDK-8153781 Issue in XMLScanner: > EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping > large DOCTYPE section with CRLF at wrong place > > > On 4/19/2016 1:45 PM, Langer, Christoph wrote: > > Hi Joe, > > > >>> I've updated the testcase to increase the probability of it really hitting the > >> issue. The old version was prone to miss the issue in case something > changed in > >> the parser. > >>> http://cr.openjdk.java.net/~clanger/webrevs/8153781.2/ > >> Looks good overall. > > OK, thanks. > > > >> Error msgs: you made an extra effort :-) normally, we don't need to do > >> any translation. The I18n team has a revolving task that will > >> periodically pick up these changes. > > OK - I think the message is not really useful anyway. I don't see a way to > produce it by creating a malformed XML document. It would probably only pop > up with the old erroneous implementation of skipDTD and SUPPORT_DTD > property false. > > > >> License header: it is correct to update to the latest Apache License > >> format. However, we would need to preserve the "reserved comment block" > >> if we've not changed the code, which is the case for class such as > >> HTTPInputSource.java. > > Fixed that. > > > > Here is the new webrev: > http://cr.openjdk.java.net/~clanger/webrevs/8153781.3/ > > > > If you consider it reviewed I would love if you could push it for me. :-) > > Sure :-) Will do after all test runs complete. > > Thanks, > Joe > > > > > Thanks > > Christoph > > From stefan.karlsson at oracle.com Wed Apr 20 07:55:18 2016 From: stefan.karlsson at oracle.com (Stefan Karlsson) Date: Wed, 20 Apr 2016 09:55:18 +0200 Subject: RFR: 8072921: -Xincgc should be removed from output In-Reply-To: <57160C43.7020706@oracle.com> References: <57160147.3030008@oracle.com> <57160C43.7020706@oracle.com> Message-ID: <571735E6.7070705@oracle.com> On 2016-04-19 12:45, Alan Bateman wrote: > > > On 19/04/2016 10:58, Stefan Karlsson wrote: >> >> I've left the locale specific launcher files untouched. Should I >> update them as well? > Dropping -Xincgc rom the -X output looks okay to me. We usually don't > touch the translations as they are updated in bulk periodically, often > closer to the end a release. OK. Thanks for the review. StefanK > > -Alan. From paul.sandoz at oracle.com Wed Apr 20 08:05:57 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 20 Apr 2016 10:05:57 +0200 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> <77894944.20160419222826@gmail.com> Message-ID: > On 19 Apr 2016, at 18:57, Paul Sandoz wrote: >> The LEAF_TARGET version does not change the results significantly. If >> you feel that using LEAF_TARGET is more suitable I can update webrev >> correspondingly. >> > > It has some appeal, since there is a symmetry to using that and the threshold at which the wrapping spliterator will no longer be split by F/J tasks. Up to you. > Thinking some more about this, i think it would be preferable. It reduces the explicit referral to ForkJoinPool.getCommonPoolParallelism(). In general the binding the the common pool is an something we want to relax, but its tricky to come up with a sane parallel policy mechanism. Paul. From michael.haupt at oracle.com Wed Apr 20 09:25:50 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 20 Apr 2016 11:25:50 +0200 Subject: RFR(S): 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type Message-ID: <3CC2ABCD-2F2F-46B7-932E-C7141C7847F8@oracle.com> Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8152667 Webrev: http://cr.openjdk.java.net/~mhaupt/8152667/webrev.00/ Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From amaembo at gmail.com Wed Apr 20 11:50:34 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Wed, 20 Apr 2016 17:50:34 +0600 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> <77894944.20160419222826@gmail.com> Message-ID: <1898175477.20160420175034@gmail.com> Hello! PS> Thinking some more about this, i think it would be preferable. It PS> reduces the explicit referral to PS> ForkJoinPool.getCommonPoolParallelism(). No problems, here's updated webrev: http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r2/ All tests pass. With best regards, Tagir Valeev. From paul.sandoz at oracle.com Wed Apr 20 11:52:01 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 20 Apr 2016 13:52:01 +0200 Subject: RFR: 8154387 - Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less In-Reply-To: <1898175477.20160420175034@gmail.com> References: <1689211029.20160416190543@gmail.com> <5B0632ED-2A42-4B65-A0D6-F3D0A727C8F9@oracle.com> <77894944.20160419222826@gmail.com> <1898175477.20160420175034@gmail.com> Message-ID: <246178C8-7FDA-445A-BA5B-21A1BD61ECB2@oracle.com> > On 20 Apr 2016, at 13:50, Tagir F. Valeev wrote: > > Hello! > > PS> Thinking some more about this, i think it would be preferable. It > PS> reduces the explicit referral to > PS> ForkJoinPool.getCommonPoolParallelism(). > > No problems, here's updated webrev: > http://cr.openjdk.java.net/~tvaleev/webrev/8154387/r2/ > All tests pass. > Thanks, in my queue, as if your other webrev. Paul. From kumar.x.srinivasan at oracle.com Wed Apr 20 12:58:34 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 20 Apr 2016 05:58:34 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5716A433.1070909@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> <5716A433.1070909@oracle.com> Message-ID: <57177CFA.9020100@oracle.com> Hello, One more thing, what about a launcher regression test ? Thanks Kumar > > On 4/19/2016 1:32 PM, David Holmes wrote: >> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >>> Hi David, >>> >>> 493 /* Set native thread name. */ >>> 494 SetNativeThreadName(env, "main"); >>> 495 >>> 496 /* Invoke main method. */ >>> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>> mainArgs); >>> >>> Supposing an exception is thrown in 494 (a very remote case), >>> will we not re-enter the VM in 497 with an exception ? >> >> Yes as I said: >> >>> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>> 1714 nameString, JNI_TRUE); >>> >>> As above NULL_CHECK is fine here, but we should check for and clear >>> any pending exception after CallVoidMethod. >> > Agreed. > > Kumar > >> Thanks, >> David >> >>> Kumar >>> >>>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>>> >>>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>>> wrote: >>>>>> >>>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>> Hi Gerard, >>>>>>> >>>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>> >: >>>>>>>> >>>>>>>> hi Yasumasa, >>>>>>>> >>>>>>>> Nice work. I have 2 questions: >>>>>>>> >>>>>>>> ======== >>>>>>>> File: java.c >>>>>>>> >>>>>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>>>> after every single JNI call? In this example instead of NULL_CHECK, >>>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>> >>>>>>> It is not critical if we encounter error at JNI function call >>>>>>> because >>>>>>> we cannot set native thread name only. >>>>>>> So I think that we do not need to leave from launcher process. >>>>>> >>>>>> I agree we do not need to abort if an exception occurs (and in fact >>>>>> I don't think an exception is even possible from this code), but we >>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>> extensively throughout the launcher code - so if this usage is wrong >>>>>> then it is all wrong! More on this code below ... >>>>> >>>>> Isn?t there a risk that: >>>>> >>>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>> + nameString, JNI_TRUE); >>>>> >>>>> will raise an exception? >>>>> >>>>> In the least, shouldn?t we clear any possible pending exceptions at >>>>> the beginning of ?SetNativeThreadName?, as you say, but also at the >>>>> very end? >>>> >>>> I was actually saying at the end, after the call (even though I don't >>>> think any exceptions are possible - except for "async" exceptions of >>>> course). We shouldn't be able to get to the call with any exception >>>> pending as in that case the JNI calls will be returning NULL and we >>>> will exit - again this pattern is used extensively in the launcher. >>>> >>>> David >>>> >>>>> >>>>> cheers >>>>> >>> > From david.holmes at oracle.com Wed Apr 20 13:06:45 2016 From: david.holmes at oracle.com (David Holmes) Date: Wed, 20 Apr 2016 23:06:45 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57177CFA.9020100@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> <5716A433.1070909@oracle.com> <57177CFA.9020100@oracle.com> Message-ID: <57177EE5.2080508@oracle.com> On 20/04/2016 10:58 PM, Kumar Srinivasan wrote: > > Hello, > > One more thing, what about a launcher regression test ? What kind of regression test? I've manually visually inspected the desired behaviour but a test for it is very problematic. AFAIK there are no tests for setting the native thread name. David > Thanks > Kumar > >> >> On 4/19/2016 1:32 PM, David Holmes wrote: >>> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >>>> Hi David, >>>> >>>> 493 /* Set native thread name. */ >>>> 494 SetNativeThreadName(env, "main"); >>>> 495 >>>> 496 /* Invoke main method. */ >>>> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>> mainArgs); >>>> >>>> Supposing an exception is thrown in 494 (a very remote case), >>>> will we not re-enter the VM in 497 with an exception ? >>> >>> Yes as I said: >>> >>>> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>> 1714 nameString, JNI_TRUE); >>>> >>>> As above NULL_CHECK is fine here, but we should check for and clear >>>> any pending exception after CallVoidMethod. >>> >> Agreed. >> >> Kumar >> >>> Thanks, >>> David >>> >>>> Kumar >>>> >>>>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>>>> >>>>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>>>> wrote: >>>>>>> >>>>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>> Hi Gerard, >>>>>>>> >>>>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>> >: >>>>>>>>> >>>>>>>>> hi Yasumasa, >>>>>>>>> >>>>>>>>> Nice work. I have 2 questions: >>>>>>>>> >>>>>>>>> ======== >>>>>>>>> File: java.c >>>>>>>>> >>>>>>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>>>>> after every single JNI call? In this example instead of NULL_CHECK, >>>>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>> >>>>>>>> It is not critical if we encounter error at JNI function call >>>>>>>> because >>>>>>>> we cannot set native thread name only. >>>>>>>> So I think that we do not need to leave from launcher process. >>>>>>> >>>>>>> I agree we do not need to abort if an exception occurs (and in fact >>>>>>> I don't think an exception is even possible from this code), but we >>>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>> extensively throughout the launcher code - so if this usage is wrong >>>>>>> then it is all wrong! More on this code below ... >>>>>> >>>>>> Isn?t there a risk that: >>>>>> >>>>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>> + nameString, JNI_TRUE); >>>>>> >>>>>> will raise an exception? >>>>>> >>>>>> In the least, shouldn?t we clear any possible pending exceptions at >>>>>> the beginning of ?SetNativeThreadName?, as you say, but also at the >>>>>> very end? >>>>> >>>>> I was actually saying at the end, after the call (even though I don't >>>>> think any exceptions are possible - except for "async" exceptions of >>>>> course). We shouldn't be able to get to the call with any exception >>>>> pending as in that case the JNI calls will be returning NULL and we >>>>> will exit - again this pattern is used extensively in the launcher. >>>>> >>>>> David >>>>> >>>>>> >>>>>> cheers >>>>>> >>>> >> > From michael.haupt at oracle.com Wed Apr 20 13:13:21 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 20 Apr 2016 15:13:21 +0200 Subject: RFR(S): 8154751: MethodHandles.countedLoop does not accept empty bodies Message-ID: <33497A66-1324-437A-B083-1FBAC0E824A4@oracle.com> Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8154751 Webrev: http://cr.openjdk.java.net/~mhaupt/8154751/webrev.00/ Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From michael.haupt at oracle.com Wed Apr 20 13:46:44 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 20 Apr 2016 15:46:44 +0200 Subject: RFR(S): 8154754: MethodHandles.countedLoop errors in deriving loop arguments, result type, and local state Message-ID: <998EC76A-C30C-4B9C-9D51-7BC958036AB1@oracle.com> Dear all, please review this change. It depends on the one about 8154751 posted earlier [1]. Bug: https://bugs.openjdk.java.net/browse/JDK-8154754 Webrev: http://cr.openjdk.java.net/~mhaupt/8154754/webrev.00/ Thanks, Michael [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040386.html -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From kumar.x.srinivasan at oracle.com Wed Apr 20 14:26:34 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 20 Apr 2016 07:26:34 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57177EE5.2080508@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> <5716A433.1070909@oracle.com> <57177CFA.9020100@oracle.com> <57177EE5.2080508@oracle.com> Message-ID: <5717919A.5090109@oracle.com> On 4/20/2016 6:06 AM, David Holmes wrote: > On 20/04/2016 10:58 PM, Kumar Srinivasan wrote: >> >> Hello, >> >> One more thing, what about a launcher regression test ? > > What kind of regression test? I've manually visually inspected the > desired behaviour but a test for it is very problematic. AFAIK there > are no tests for setting the native thread name. Isn't there a management API or something to enumerate the threads ? I am more worried about some seemingly innocuous launcher change causing a regression. Well if it is hard then the jbs must be labelled so, noreg-hard. Kumar > > David > >> Thanks >> Kumar >> >>> >>> On 4/19/2016 1:32 PM, David Holmes wrote: >>>> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >>>>> Hi David, >>>>> >>>>> 493 /* Set native thread name. */ >>>>> 494 SetNativeThreadName(env, "main"); >>>>> 495 >>>>> 496 /* Invoke main method. */ >>>>> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>> mainArgs); >>>>> >>>>> Supposing an exception is thrown in 494 (a very remote case), >>>>> will we not re-enter the VM in 497 with an exception ? >>>> >>>> Yes as I said: >>>> >>>>> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>> 1714 nameString, JNI_TRUE); >>>>> >>>>> As above NULL_CHECK is fine here, but we should check for and clear >>>>> any pending exception after CallVoidMethod. >>>> >>> Agreed. >>> >>> Kumar >>> >>>> Thanks, >>>> David >>>> >>>>> Kumar >>>>> >>>>>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>>>>> >>>>>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>>>>> >>>>>>>> wrote: >>>>>>>> >>>>>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>> Hi Gerard, >>>>>>>>> >>>>>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>> >: >>>>>>>>>> >>>>>>>>>> hi Yasumasa, >>>>>>>>>> >>>>>>>>>> Nice work. I have 2 questions: >>>>>>>>>> >>>>>>>>>> ======== >>>>>>>>>> File: java.c >>>>>>>>>> >>>>>>>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>>>>>> after every single JNI call? In this example instead of >>>>>>>>> NULL_CHECK, >>>>>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>> >>>>>>>>> It is not critical if we encounter error at JNI function call >>>>>>>>> because >>>>>>>>> we cannot set native thread name only. >>>>>>>>> So I think that we do not need to leave from launcher process. >>>>>>>> >>>>>>>> I agree we do not need to abort if an exception occurs (and in >>>>>>>> fact >>>>>>>> I don't think an exception is even possible from this code), >>>>>>>> but we >>>>>>>> should ensure any pending exception is cleared before any >>>>>>>> futher JNI >>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>> extensively throughout the launcher code - so if this usage is >>>>>>>> wrong >>>>>>>> then it is all wrong! More on this code below ... >>>>>>> >>>>>>> Isn?t there a risk that: >>>>>>> >>>>>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>>> + nameString, JNI_TRUE); >>>>>>> >>>>>>> will raise an exception? >>>>>>> >>>>>>> In the least, shouldn?t we clear any possible pending exceptions at >>>>>>> the beginning of ?SetNativeThreadName?, as you say, but also at the >>>>>>> very end? >>>>>> >>>>>> I was actually saying at the end, after the call (even though I >>>>>> don't >>>>>> think any exceptions are possible - except for "async" exceptions of >>>>>> course). We shouldn't be able to get to the call with any exception >>>>>> pending as in that case the JNI calls will be returning NULL and we >>>>>> will exit - again this pattern is used extensively in the launcher. >>>>>> >>>>>> David >>>>>> >>>>>>> >>>>>>> cheers >>>>>>> >>>>> >>> >> From claes.redestad at oracle.com Wed Apr 20 14:44:24 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Wed, 20 Apr 2016 16:44:24 +0200 Subject: RFR: 8154231: Simplify access to System properties from JDK code Message-ID: <571795C8.2010007@oracle.com> Hello, now that the sun.security.action package is encapsulated we can simplify internal code to get System properties. Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ This adds a few convenience methods to GetPropertyAction[1] and GetIntegerAction[2]. Since the code calling into this can be streamlined, this leads to a net static footprint reduction of the java.base module and a tiny startup improvement. Thanks! /Claes [1] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetPropertyAction.java.udiff.html [2] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetIntegerAction.java.udiff.html From kurtymckurt at gmail.com Wed Apr 20 13:45:12 2016 From: kurtymckurt at gmail.com (kurtymckurt) Date: Wed, 20 Apr 2016 06:45:12 -0700 (MST) Subject: Locks implementing Closable Message-ID: <1461159912648-267580.post@n7.nabble.com> Has it been considered to have the Lock interface use AutoCloseable? That way users can lock in a try and not have to worry about a finally? -- View this message in context: http://openjdk.5641.n7.nabble.com/Locks-implementing-Closable-tp267580.html Sent from the OpenJDK Core Libraries mailing list archive at Nabble.com. From weijun.wang at oracle.com Wed Apr 20 14:58:36 2016 From: weijun.wang at oracle.com (Wang Weijun) Date: Wed, 20 Apr 2016 22:58:36 +0800 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <571795C8.2010007@oracle.com> References: <571795C8.2010007@oracle.com> Message-ID: <15E99E17-D462-4578-9A34-58055F9F69D6@oracle.com> This is quite convenient. We not cover the other modules? exports sun.security.action to java.desktop, java.security.jgss, jdk.crypto.pkcs11; Thanks Max > On Apr 20, 2016, at 10:44 PM, Claes Redestad wrote: > > Hello, > > now that the sun.security.action package is encapsulated we can simplify internal code to get System properties. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 > Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ > > This adds a few convenience methods to GetPropertyAction[1] and GetIntegerAction[2]. Since the code calling into this can be streamlined, this leads to a net static footprint reduction of the java.base module and a tiny startup improvement. > > Thanks! > > /Claes > > [1] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetPropertyAction.java.udiff.html > [2] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetIntegerAction.java.udiff.html From yasuenag at gmail.com Wed Apr 20 14:59:50 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Wed, 20 Apr 2016 23:59:50 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5717919A.5090109@oracle.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> <5716A433.1070909@oracle.com> <57177CFA.9020100@oracle.com> <57177EE5.2080508@oracle.com> <5717919A.5090109@oracle.com> Message-ID: <57179966.4050504@gmail.com> Hi Kumar, > Isn't there a management API or something to enumerate the threads ? On Linux, user apps can get native thread name through pthread_getname_np(3). However, this function is not called in hotspot and jdk. So I think it is difficult to get native thread name in all platforms. > Well if it is hard then the jbs must be labelled so, noreg-hard. I agree to label noreg-hard. Thanks, Yasumasa On 2016/04/20 23:26, Kumar Srinivasan wrote: > > On 4/20/2016 6:06 AM, David Holmes wrote: >> On 20/04/2016 10:58 PM, Kumar Srinivasan wrote: >>> >>> Hello, >>> >>> One more thing, what about a launcher regression test ? >> >> What kind of regression test? I've manually visually inspected the desired behaviour but a test for it is very problematic. AFAIK there are no tests for setting the native thread name. > > Isn't there a management API or something to enumerate the threads ? > I am more worried about some seemingly innocuous launcher change > causing a regression. > > Well if it is hard then the jbs must be labelled so, noreg-hard. > > Kumar > >> >> David >> >>> Thanks >>> Kumar >>> >>>> >>>> On 4/19/2016 1:32 PM, David Holmes wrote: >>>>> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >>>>>> Hi David, >>>>>> >>>>>> 493 /* Set native thread name. */ >>>>>> 494 SetNativeThreadName(env, "main"); >>>>>> 495 >>>>>> 496 /* Invoke main method. */ >>>>>> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>> mainArgs); >>>>>> >>>>>> Supposing an exception is thrown in 494 (a very remote case), >>>>>> will we not re-enter the VM in 497 with an exception ? >>>>> >>>>> Yes as I said: >>>>> >>>>>> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>>> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>> 1714 nameString, JNI_TRUE); >>>>>> >>>>>> As above NULL_CHECK is fine here, but we should check for and clear >>>>>> any pending exception after CallVoidMethod. >>>>> >>>> Agreed. >>>> >>>> Kumar >>>> >>>>> Thanks, >>>>> David >>>>> >>>>>> Kumar >>>>>> >>>>>>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>>>>>> >>>>>>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi Gerard, >>>>>>>>>> >>>>>>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>> >: >>>>>>>>>>> >>>>>>>>>>> hi Yasumasa, >>>>>>>>>>> >>>>>>>>>>> Nice work. I have 2 questions: >>>>>>>>>>> >>>>>>>>>>> ======== >>>>>>>>>>> File: java.c >>>>>>>>>>> >>>>>>>>>>> #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>>>>>>> after every single JNI call? In this example instead of NULL_CHECK, >>>>>>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>> >>>>>>>>>> It is not critical if we encounter error at JNI function call >>>>>>>>>> because >>>>>>>>>> we cannot set native thread name only. >>>>>>>>>> So I think that we do not need to leave from launcher process. >>>>>>>>> >>>>>>>>> I agree we do not need to abort if an exception occurs (and in fact >>>>>>>>> I don't think an exception is even possible from this code), but we >>>>>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>> extensively throughout the launcher code - so if this usage is wrong >>>>>>>>> then it is all wrong! More on this code below ... >>>>>>>> >>>>>>>> Isn?t there a risk that: >>>>>>>> >>>>>>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>>>> + nameString, JNI_TRUE); >>>>>>>> >>>>>>>> will raise an exception? >>>>>>>> >>>>>>>> In the least, shouldn?t we clear any possible pending exceptions at >>>>>>>> the beginning of ?SetNativeThreadName?, as you say, but also at the >>>>>>>> very end? >>>>>>> >>>>>>> I was actually saying at the end, after the call (even though I don't >>>>>>> think any exceptions are possible - except for "async" exceptions of >>>>>>> course). We shouldn't be able to get to the call with any exception >>>>>>> pending as in that case the JNI calls will be returning NULL and we >>>>>>> will exit - again this pattern is used extensively in the launcher. >>>>>>> >>>>>>> David >>>>>>> >>>>>>>> >>>>>>>> cheers >>>>>>>> >>>>>> >>>> >>> > From claes.redestad at oracle.com Wed Apr 20 15:17:56 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Wed, 20 Apr 2016 17:17:56 +0200 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <15E99E17-D462-4578-9A34-58055F9F69D6@oracle.com> References: <571795C8.2010007@oracle.com> <15E99E17-D462-4578-9A34-58055F9F69D6@oracle.com> Message-ID: <57179DA4.4070205@oracle.com> On 2016-04-20 16:58, Wang Weijun wrote: > This is quite convenient. Glad you like it! > We not cover the other modules? > > exports sun.security.action to > java.desktop, > java.security.jgss, > jdk.crypto.pkcs11; I was worried I included too many changes in this patch as it is. :-) If this patch is accepted my intention is to file follow-up RFEs for the other modules. /Claes > > Thanks > Max > >> On Apr 20, 2016, at 10:44 PM, Claes Redestad wrote: >> >> Hello, >> >> now that the sun.security.action package is encapsulated we can simplify internal code to get System properties. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 >> Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ >> >> This adds a few convenience methods to GetPropertyAction[1] and GetIntegerAction[2]. Since the code calling into this can be streamlined, this leads to a net static footprint reduction of the java.base module and a tiny startup improvement. >> >> Thanks! >> >> /Claes >> >> [1] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetPropertyAction.java.udiff.html >> [2] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetIntegerAction.java.udiff.html From pavel.rappo at oracle.com Wed Apr 20 15:41:54 2016 From: pavel.rappo at oracle.com (Pavel Rappo) Date: Wed, 20 Apr 2016 16:41:54 +0100 Subject: Locks implementing Closable In-Reply-To: <1461159912648-267580.post@n7.nabble.com> References: <1461159912648-267580.post@n7.nabble.com> Message-ID: This question should better be asked on concurrency-interest mailing list [1]. And I'm sure it has been asked there a numerous of times before. I guess one of the reasons it hasn't been done is because of a semantics mismatch. java.util.concurrent.locks.Lock is a reusable object. It can be locked after it's been unlocked. And in general it may have a very peculiar lifecycle and rules about which method should be called when and by which thread. java.lang.AutoCloseable semantics seems to apply to objects associated with some resources that may be closed only once (kind of suggests from close's idempotence requirement). -------------------------------------------------------------------------------- [1] http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest > On 20 Apr 2016, at 14:45, kurtymckurt wrote: > > Has it been considered to have the Lock interface use AutoCloseable? That > way users can lock in a try and not have to worry about a finally? > > > > -- > View this message in context: http://openjdk.5641.n7.nabble.com/Locks-implementing-Closable-tp267580.html > Sent from the OpenJDK Core Libraries mailing list archive at Nabble.com. From pavel.rappo at oracle.com Wed Apr 20 15:52:42 2016 From: pavel.rappo at oracle.com (Pavel Rappo) Date: Wed, 20 Apr 2016 16:52:42 +0100 Subject: Locks implementing Closable In-Reply-To: <1461159912648-267580.post@n7.nabble.com> References: <1461159912648-267580.post@n7.nabble.com> Message-ID: Here's a bit of background for you to explore: http://stackoverflow.com/questions/16574353/any-risk-in-a-autocloseable-wrapper-for-java-util-concurrent-locks-lock http://cs.oswego.edu/pipermail/lambda-lib/2012-June/000447.html https://bugs.openjdk.java.net/browse/JDK-7084550 I'm sure if you google it, you'll find more. Much, much more. > On 20 Apr 2016, at 14:45, kurtymckurt wrote: > > Has it been considered to have the Lock interface use AutoCloseable? That > way users can lock in a try and not have to worry about a finally? > > > > -- > View this message in context: http://openjdk.5641.n7.nabble.com/Locks-implementing-Closable-tp267580.html > Sent from the OpenJDK Core Libraries mailing list archive at Nabble.com. From Ulf.Zibis at CoSoCo.de Wed Apr 20 15:57:07 2016 From: Ulf.Zibis at CoSoCo.de (Ulf Zibis) Date: Wed, 20 Apr 2016 17:57:07 +0200 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <571795C8.2010007@oracle.com> References: <571795C8.2010007@oracle.com> Message-ID: <5717A6D3.1060706@CoSoCo.de> Hi, here my comments: Am 20.04.2016 um 16:44 schrieb Claes Redestad: > Hello, > > now that the sun.security.action package is encapsulated we can simplify internal code to get > System properties. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 > Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ > > This adds a few convenience methods to GetPropertyAction[1] and GetIntegerAction[2]. - In the original version of ProcessBuilder.java line 472 there was a nice example using lambda expression. Wouldn't this be applicable also for these new methods here? - Isn't the "theProp" naming style something from an old usage where all members have been named myXyz? I more would like "propName" or just "property". - In Integer.getProperty the default substitution is done twice, lines: 143, 148. So maybe return to the "immediate return in if...else clause" style. -Ulf From kurtymckurt at gmail.com Wed Apr 20 14:57:35 2016 From: kurtymckurt at gmail.com (kurtymckurt) Date: Wed, 20 Apr 2016 07:57:35 -0700 (MST) Subject: Locks implementing Closable In-Reply-To: References: <1461159912648-267580.post@n7.nabble.com> Message-ID: <1461164255852-267599.post@n7.nabble.com> Thank you very much for the background. -- View this message in context: http://openjdk.5641.n7.nabble.com/Locks-implementing-Closable-tp267580p267599.html Sent from the OpenJDK Core Libraries mailing list archive at Nabble.com. From claes.redestad at oracle.com Wed Apr 20 16:12:23 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Wed, 20 Apr 2016 18:12:23 +0200 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <5717A6D3.1060706@CoSoCo.de> References: <571795C8.2010007@oracle.com> <5717A6D3.1060706@CoSoCo.de> Message-ID: <5717AA67.40908@oracle.com> Thanks for looking at this, Ulf! On 2016-04-20 17:57, Ulf Zibis wrote: > Hi, > > here my comments: > > Am 20.04.2016 um 16:44 schrieb Claes Redestad: >> Hello, >> >> now that the sun.security.action package is encapsulated we can >> simplify internal code to get System properties. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 >> Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ >> >> This adds a few convenience methods to GetPropertyAction[1] and >> GetIntegerAction[2]. > > - In the original version of ProcessBuilder.java line 472 there was a > nice example using lambda expression. Wouldn't this be applicable also > for these new methods here? While perhaps a nice example in isolation, creating a lambda when there's already a specialized convenience class available expressing the same thing doesn't add any value. > - Isn't the "theProp" naming style something from an old usage where > all members have been named myXyz? I more would like "propName" or > just "property". I chose to go with keeping names in line with existing methods. If anything is to be done about this I'd prefer changing all names in the class to be consistent and modern, and that'd be a separate RFE. > - In Integer.getProperty the default substitution is done twice, > lines: 143, 148. So maybe return to the "immediate return in if...else > clause" style. The call to Integer.getInteger on line 143 was supposed to be without the defaultVal param to avoid always boxing the defaultVal. Fixed in-place. Thanks! /Claes From Ulf.Zibis at CoSoCo.de Wed Apr 20 16:56:46 2016 From: Ulf.Zibis at CoSoCo.de (Ulf Zibis) Date: Wed, 20 Apr 2016 18:56:46 +0200 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <5717AA67.40908@oracle.com> References: <571795C8.2010007@oracle.com> <5717A6D3.1060706@CoSoCo.de> <5717AA67.40908@oracle.com> Message-ID: <5717B4CE.9040109@CoSoCo.de> Hi Claes, thanks. Am 20.04.2016 um 18:12 schrieb Claes Redestad: > Thanks for looking at this, Ulf! > >> - Isn't the "theProp" naming style something from an old usage where all members have been named >> myXyz? I more would like "propName" or just "property". > > I chose to go with keeping names in line with existing methods. If anything is to be done about > this I'd prefer changing all names in the class to be consistent and modern, and that'd be a > separate RFE. Oops, I didn't notice that. ... and semantically more precise would be: "propKey" or "propID". -Ulf From chris.hegarty at oracle.com Wed Apr 20 18:51:54 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 20 Apr 2016 19:51:54 +0100 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <571795C8.2010007@oracle.com> References: <571795C8.2010007@oracle.com> Message-ID: <0E960228-9CA6-4E6F-8331-2338540B9F59@oracle.com> On 20 Apr 2016, at 15:44, Claes Redestad wrote: > Hello, > > now that the sun.security.action package is encapsulated we can simplify internal code to get System properties. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 > Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ This looks very nice. Did you accidentally remove supportsTransparentAuth in the unix version of NTLMAuthentication.java ? It is used reflectively by sun.net.www.protocol.http.NTLMAuthenticationProxy. Otherwise, this looks fine to me. -Chris. Note to self; I need to revisit the sun.reflect properties. > This adds a few convenience methods to GetPropertyAction[1] and GetIntegerAction[2]. Since the code calling into this can be streamlined, this leads to a net static footprint reduction of the java.base module and a tiny startup improvement. > > Thanks! > > /Claes > > [1] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetPropertyAction.java.udiff.html > [2] http://cr.openjdk.java.net/~redestad/8154231/webrev.01/src/java.base/share/classes/sun/security/action/GetIntegerAction.java.udiff.html From claes.redestad at oracle.com Wed Apr 20 19:34:09 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Wed, 20 Apr 2016 21:34:09 +0200 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <0E960228-9CA6-4E6F-8331-2338540B9F59@oracle.com> References: <571795C8.2010007@oracle.com> <0E960228-9CA6-4E6F-8331-2338540B9F59@oracle.com> Message-ID: <5717D9B1.4070108@oracle.com> On 2016-04-20 20:51, Chris Hegarty wrote: > On 20 Apr 2016, at 15:44, Claes Redestad wrote: > >> Hello, >> >> now that the sun.security.action package is encapsulated we can simplify internal code to get System properties. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 >> Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ > This looks very nice. Thanks! > > Did you accidentally remove supportsTransparentAuth in the unix version > of NTLMAuthentication.java ? It is used reflectively by > sun.net.www.protocol.http.NTLMAuthenticationProxy. Otherwise, this looks > fine to me. Oops, nice catch. Updated. /Claes From Alan.Bateman at oracle.com Wed Apr 20 20:19:07 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 20 Apr 2016 21:19:07 +0100 Subject: RFR(s): 8153330: deprecate Runtime.traceInstructions & traceMethodCalls for removal In-Reply-To: <5716AD1A.3040902@oracle.com> References: <5716AD1A.3040902@oracle.com> Message-ID: <5717E43B.3070208@oracle.com> On 19/04/2016 23:11, Stuart Marks wrote: > Hi all, > > I missed a couple bits of cruft in the previous round of java.lang > deprecations: the Runtime.traceInstructions() and traceMethodCalls() > methods. This looks fine. -Alan From mandy.chung at oracle.com Wed Apr 20 20:52:34 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 20 Apr 2016 13:52:34 -0700 Subject: RFR(s): 8153330: deprecate Runtime.traceInstructions & traceMethodCalls for removal In-Reply-To: <5716AD1A.3040902@oracle.com> References: <5716AD1A.3040902@oracle.com> Message-ID: > On Apr 19, 2016, at 3:11 PM, Stuart Marks wrote: > > Hi all, > > I missed a couple bits of cruft in the previous round of java.lang deprecations: the Runtime.traceInstructions() and traceMethodCalls() methods. > > Their implementations are empty. That is, they do absolutely nothing. > > They're only mentioned a couple times in the JDK, in CORBA (!) and in some RMI tests (!), and in a few symbol files. On grepcode.com, there are a couple uses, mainly attempting to enable these in response to some debugging flag being given. > > Thus, I propose these be deprecated for removal. Please review diff below. +1 Mandy From oleg.barbashov at oracle.com Wed Apr 20 22:58:58 2016 From: oleg.barbashov at oracle.com (Oleg G. Barbashov) Date: Thu, 21 Apr 2016 01:58:58 +0300 Subject: [9] 8149571: [launcher] create a regression test to test symlinks on Windows In-Reply-To: <571666E3.30807@oracle.com> References: <57160707.4030606@oracle.com> <571666E3.30807@oracle.com> Message-ID: <571809B2.1050308@oracle.com> Hi, Please review the simple test of launcher started using a symlink. issue: https://bugs.openjdk.java.net/browse/JDK-8149571 webrev: http://cr.openjdk.java.net/~ogb/8149571/ Thanks, Oleg From amy.lu at oracle.com Thu Apr 21 06:00:35 2016 From: amy.lu at oracle.com (Amy Lu) Date: Thu, 21 Apr 2016 14:00:35 +0800 Subject: JDK 9 RFR of JDK-8152936: java/lang/Class/GetPackageTest.java needs update to work with newer testng Message-ID: <57186C83.1070707@oracle.com> To get prepared for the coming testng updating in jtreg [1], test/java/lang/Class/GetPackageTest.java needs a minor update as newer version of testng requires explicit DataProvider's name (since 6.8.10). Please review the patch. This works for both current jtreg (testng 6.8.5), and later testng 6.9.5 bug: https://bugs.openjdk.java.net/browse/JDK-8152936 webrev: http://cr.openjdk.java.net/~amlu/8152936/webrev.00/ Thanks, Amy [1]: http://mail.openjdk.java.net/pipermail/jtreg-use/2016-April/000450.html --- old/test/java/lang/Class/GetPackageTest.java 2016-04-21 13:30:41.000000000 +0800 +++ new/test/java/lang/Class/GetPackageTest.java 2016-04-21 13:30:40.000000000 +0800 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ assertEquals(fooClass.getClassLoader(), loader); } - @DataProvider(name = "testclasses") + @DataProvider(name = "testClasses") public Object[][] testClasses() { return new Object[][] { // primitive type, void, array types From Alan.Bateman at oracle.com Thu Apr 21 06:12:59 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 21 Apr 2016 07:12:59 +0100 Subject: [9] 8149571: [launcher] create a regression test to test symlinks on Windows In-Reply-To: <571809B2.1050308@oracle.com> References: <57160707.4030606@oracle.com> <571666E3.30807@oracle.com> <571809B2.1050308@oracle.com> Message-ID: <57186F6B.9070702@oracle.com> On 20/04/2016 23:58, Oleg G. Barbashov wrote: > Hi, > > Please review the simple test of launcher started using a symlink. > > issue: https://bugs.openjdk.java.net/browse/JDK-8149571 > webrev: http://cr.openjdk.java.net/~ogb/8149571/ Creating sym link on Windows requires permissions so I assume this test just pass when createSymbolicLInk fails (no guarantee that the test is run with Administrator rights for example). -Alan From Alan.Bateman at oracle.com Thu Apr 21 06:14:08 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 21 Apr 2016 07:14:08 +0100 Subject: JDK 9 RFR of JDK-8152936: java/lang/Class/GetPackageTest.java needs update to work with newer testng In-Reply-To: <57186C83.1070707@oracle.com> References: <57186C83.1070707@oracle.com> Message-ID: <57186FB0.6080608@oracle.com> On 21/04/2016 07:00, Amy Lu wrote: > To get prepared for the coming testng updating in jtreg [1], > test/java/lang/Class/GetPackageTest.java needs a minor update as newer > version of testng requires explicit DataProvider's name (since 6.8.10). > > Please review the patch. This works for both current jtreg (testng > 6.8.5), and later testng 6.9.5 > > bug: https://bugs.openjdk.java.net/browse/JDK-8152936 > webrev: http://cr.openjdk.java.net/~amlu/8152936/webrev.00/ This looks good. -Alan From david.holmes at oracle.com Thu Apr 21 07:01:39 2016 From: david.holmes at oracle.com (David Holmes) Date: Thu, 21 Apr 2016 17:01:39 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57179966.4050504@gmail.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> <5716A433.1070909@oracle.com> <57177CFA.9020100@oracle.com> <57177EE5.2080508@oracle.com> <5717919A.5090109@oracle.com> <57179966.4050504@gmail.com> Message-ID: <57187AD3.30304@oracle.com> On 21/04/2016 12:59 AM, Yasumasa Suenaga wrote: > Hi Kumar, > >> Isn't there a management API or something to enumerate the threads ? Not that shows native thread names. Existing launcher tests should of course be unaffected by this change. > On Linux, user apps can get native thread name through > pthread_getname_np(3). > However, this function is not called in hotspot and jdk. > > So I think it is difficult to get native thread name in all platforms. > > >> Well if it is hard then the jbs must be labelled so, noreg-hard. > > I agree to label noreg-hard. I concur. Thanks, David > > Thanks, > > Yasumasa > > > On 2016/04/20 23:26, Kumar Srinivasan wrote: >> >> On 4/20/2016 6:06 AM, David Holmes wrote: >>> On 20/04/2016 10:58 PM, Kumar Srinivasan wrote: >>>> >>>> Hello, >>>> >>>> One more thing, what about a launcher regression test ? >>> >>> What kind of regression test? I've manually visually inspected the >>> desired behaviour but a test for it is very problematic. AFAIK there >>> are no tests for setting the native thread name. >> >> Isn't there a management API or something to enumerate the threads ? >> I am more worried about some seemingly innocuous launcher change >> causing a regression. >> >> Well if it is hard then the jbs must be labelled so, noreg-hard. >> >> Kumar >> >>> >>> David >>> >>>> Thanks >>>> Kumar >>>> >>>>> >>>>> On 4/19/2016 1:32 PM, David Holmes wrote: >>>>>> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >>>>>>> Hi David, >>>>>>> >>>>>>> 493 /* Set native thread name. */ >>>>>>> 494 SetNativeThreadName(env, "main"); >>>>>>> 495 >>>>>>> 496 /* Invoke main method. */ >>>>>>> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>> mainArgs); >>>>>>> >>>>>>> Supposing an exception is thrown in 494 (a very remote case), >>>>>>> will we not re-enter the VM in 497 with an exception ? >>>>>> >>>>>> Yes as I said: >>>>>> >>>>>>> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>>>> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>>> 1714 nameString, JNI_TRUE); >>>>>>> >>>>>>> As above NULL_CHECK is fine here, but we should check for and clear >>>>>>> any pending exception after CallVoidMethod. >>>>>> >>>>> Agreed. >>>>> >>>>> Kumar >>>>> >>>>>> Thanks, >>>>>> David >>>>>> >>>>>>> Kumar >>>>>>> >>>>>>>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>>>>>>> >>>>>>>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>>>>>>> >>>>>>>>>> wrote: >>>>>>>>>> >>>>>>>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi Gerard, >>>>>>>>>>> >>>>>>>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>> >: >>>>>>>>>>>> >>>>>>>>>>>> hi Yasumasa, >>>>>>>>>>>> >>>>>>>>>>>> Nice work. I have 2 questions: >>>>>>>>>>>> >>>>>>>>>>>> ======== >>>>>>>>>>>> File: java.c >>>>>>>>>>>> >>>>>>>>>>>> #1 Shouldn?t we be checking for >>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>> after every single JNI call? In this example instead of >>>>>>>>>>> NULL_CHECK, >>>>>>>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>> >>>>>>>>>>> It is not critical if we encounter error at JNI function call >>>>>>>>>>> because >>>>>>>>>>> we cannot set native thread name only. >>>>>>>>>>> So I think that we do not need to leave from launcher process. >>>>>>>>>> >>>>>>>>>> I agree we do not need to abort if an exception occurs (and in >>>>>>>>>> fact >>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>> but we >>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>> futher JNI >>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>> extensively throughout the launcher code - so if this usage is >>>>>>>>>> wrong >>>>>>>>>> then it is all wrong! More on this code below ... >>>>>>>>> >>>>>>>>> Isn?t there a risk that: >>>>>>>>> >>>>>>>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>>>>> + nameString, JNI_TRUE); >>>>>>>>> >>>>>>>>> will raise an exception? >>>>>>>>> >>>>>>>>> In the least, shouldn?t we clear any possible pending >>>>>>>>> exceptions at >>>>>>>>> the beginning of ?SetNativeThreadName?, as you say, but also at >>>>>>>>> the >>>>>>>>> very end? >>>>>>>> >>>>>>>> I was actually saying at the end, after the call (even though I >>>>>>>> don't >>>>>>>> think any exceptions are possible - except for "async" >>>>>>>> exceptions of >>>>>>>> course). We shouldn't be able to get to the call with any exception >>>>>>>> pending as in that case the JNI calls will be returning NULL and we >>>>>>>> will exit - again this pattern is used extensively in the launcher. >>>>>>>> >>>>>>>> David >>>>>>>> >>>>>>>>> >>>>>>>>> cheers >>>>>>>>> >>>>>>> >>>>> >>>> >> From yasuenag at gmail.com Thu Apr 21 09:27:32 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Thu, 21 Apr 2016 18:27:32 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <57187AD3.30304@oracle.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <6F78E357-8E5E-4296-883D-134DD0114847@oracle.com> <57162BBC.7010400@oracle.com> <5716642B.8010207@oracle.com> <571695D3.6060908@oracle.com> <5716A433.1070909@oracle.com> <57177CFA.9020100@oracle.com> <57177EE5.2080508@oracle.com> <5717919A.5090109@oracle.com> <57179966.4050504@gmail.com> <57187AD3.30304@oracle.com> Message-ID: <57189D04.5070904@gmail.com> >>> Well if it is hard then the jbs must be labelled so, noreg-hard. >> >> I agree to label noreg-hard. > > I concur. I added noreg-hard to JBS. Yasumasa On 2016/04/21 16:01, David Holmes wrote: > On 21/04/2016 12:59 AM, Yasumasa Suenaga wrote: >> Hi Kumar, >> >>> Isn't there a management API or something to enumerate the threads ? > > Not that shows native thread names. > > Existing launcher tests should of course be unaffected by this change. > >> On Linux, user apps can get native thread name through >> pthread_getname_np(3). >> However, this function is not called in hotspot and jdk. >> >> So I think it is difficult to get native thread name in all platforms. >> >> >>> Well if it is hard then the jbs must be labelled so, noreg-hard. >> >> I agree to label noreg-hard. > > I concur. > > Thanks, > David > >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/20 23:26, Kumar Srinivasan wrote: >>> >>> On 4/20/2016 6:06 AM, David Holmes wrote: >>>> On 20/04/2016 10:58 PM, Kumar Srinivasan wrote: >>>>> >>>>> Hello, >>>>> >>>>> One more thing, what about a launcher regression test ? >>>> >>>> What kind of regression test? I've manually visually inspected the >>>> desired behaviour but a test for it is very problematic. AFAIK there >>>> are no tests for setting the native thread name. >>> >>> Isn't there a management API or something to enumerate the threads ? >>> I am more worried about some seemingly innocuous launcher change >>> causing a regression. >>> >>> Well if it is hard then the jbs must be labelled so, noreg-hard. >>> >>> Kumar >>> >>>> >>>> David >>>> >>>>> Thanks >>>>> Kumar >>>>> >>>>>> >>>>>> On 4/19/2016 1:32 PM, David Holmes wrote: >>>>>>> On 20/04/2016 3:00 AM, Kumar Srinivasan wrote: >>>>>>>> Hi David, >>>>>>>> >>>>>>>> 493 /* Set native thread name. */ >>>>>>>> 494 SetNativeThreadName(env, "main"); >>>>>>>> 495 >>>>>>>> 496 /* Invoke main method. */ >>>>>>>> 497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>> mainArgs); >>>>>>>> >>>>>>>> Supposing an exception is thrown in 494 (a very remote case), >>>>>>>> will we not re-enter the VM in 497 with an exception ? >>>>>>> >>>>>>> Yes as I said: >>>>>>> >>>>>>>> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>>>>> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>>>> 1714 nameString, JNI_TRUE); >>>>>>>> >>>>>>>> As above NULL_CHECK is fine here, but we should check for and clear >>>>>>>> any pending exception after CallVoidMethod. >>>>>>> >>>>>> Agreed. >>>>>> >>>>>> Kumar >>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> >>>>>>>> Kumar >>>>>>>> >>>>>>>>> On 19/04/2016 10:54 PM, Gerard Ziemski wrote: >>>>>>>>>> >>>>>>>>>>> On Apr 19, 2016, at 12:04 AM, David Holmes >>>>>>>>>>> >>>>>>>>>>> wrote: >>>>>>>>>>> >>>>>>>>>>> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Hi Gerard, >>>>>>>>>>>> >>>>>>>>>>>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>>> >: >>>>>>>>>>>>> >>>>>>>>>>>>> hi Yasumasa, >>>>>>>>>>>>> >>>>>>>>>>>>> Nice work. I have 2 questions: >>>>>>>>>>>>> >>>>>>>>>>>>> ======== >>>>>>>>>>>>> File: java.c >>>>>>>>>>>>> >>>>>>>>>>>>> #1 Shouldn?t we be checking for >>>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>>> after every single JNI call? In this example instead of >>>>>>>>>>>> NULL_CHECK, >>>>>>>>>>>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>>> >>>>>>>>>>>> It is not critical if we encounter error at JNI function call >>>>>>>>>>>> because >>>>>>>>>>>> we cannot set native thread name only. >>>>>>>>>>>> So I think that we do not need to leave from launcher process. >>>>>>>>>>> >>>>>>>>>>> I agree we do not need to abort if an exception occurs (and in >>>>>>>>>>> fact >>>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>>> but we >>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>> futher JNI >>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>> extensively throughout the launcher code - so if this usage is >>>>>>>>>>> wrong >>>>>>>>>>> then it is all wrong! More on this code below ... >>>>>>>>>> >>>>>>>>>> Isn?t there a risk that: >>>>>>>>>> >>>>>>>>>> (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>>>>>>> + nameString, JNI_TRUE); >>>>>>>>>> >>>>>>>>>> will raise an exception? >>>>>>>>>> >>>>>>>>>> In the least, shouldn?t we clear any possible pending >>>>>>>>>> exceptions at >>>>>>>>>> the beginning of ?SetNativeThreadName?, as you say, but also at >>>>>>>>>> the >>>>>>>>>> very end? >>>>>>>>> >>>>>>>>> I was actually saying at the end, after the call (even though I >>>>>>>>> don't >>>>>>>>> think any exceptions are possible - except for "async" >>>>>>>>> exceptions of >>>>>>>>> course). We shouldn't be able to get to the call with any exception >>>>>>>>> pending as in that case the JNI calls will be returning NULL and we >>>>>>>>> will exit - again this pattern is used extensively in the launcher. >>>>>>>>> >>>>>>>>> David >>>>>>>>> >>>>>>>>>> >>>>>>>>>> cheers >>>>>>>>>> >>>>>>>> >>>>>> >>>>> >>> From chris.hegarty at oracle.com Thu Apr 21 09:57:54 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 21 Apr 2016 10:57:54 +0100 Subject: RFR: 8154231: Simplify access to System properties from JDK code In-Reply-To: <5717D9B1.4070108@oracle.com> References: <571795C8.2010007@oracle.com> <0E960228-9CA6-4E6F-8331-2338540B9F59@oracle.com> <5717D9B1.4070108@oracle.com> Message-ID: <8941BC61-5F27-44EB-9C3E-FA1C0B60296E@oracle.com> On 20 Apr 2016, at 20:34, Claes Redestad wrote: > > > On 2016-04-20 20:51, Chris Hegarty wrote: >> On 20 Apr 2016, at 15:44, Claes Redestad wrote: >> >>> Hello, >>> >>> now that the sun.security.action package is encapsulated we can simplify internal code to get System properties. >>> >>> Bug: https://bugs.openjdk.java.net/browse/JDK-8154231 >>> Webrev: http://cr.openjdk.java.net/~redestad/8154231/webrev.01/ >> This looks very nice. > > Thanks! > >> >> Did you accidentally remove supportsTransparentAuth in the unix version >> of NTLMAuthentication.java ? It is used reflectively by >> sun.net.www.protocol.http.NTLMAuthenticationProxy. Otherwise, this looks >> fine to me. > > Oops, nice catch. Updated. I?m happy with this version. Thanks. -Chris. From oleg.barbashov at oracle.com Thu Apr 21 11:54:40 2016 From: oleg.barbashov at oracle.com (Oleg G. Barbashov) Date: Thu, 21 Apr 2016 14:54:40 +0300 Subject: [9] 8149571: [launcher] create a regression test to test symlinks on Windows In-Reply-To: <57186F6B.9070702@oracle.com> References: <57160707.4030606@oracle.com> <571666E3.30807@oracle.com> <571809B2.1050308@oracle.com> <57186F6B.9070702@oracle.com> Message-ID: <5718BF80.3030908@oracle.com> 21.04.2016 9:12, Alan Bateman ?????: > > > On 20/04/2016 23:58, Oleg G. Barbashov wrote: >> Hi, >> >> Please review the simple test of launcher started using a symlink. >> >> issue: https://bugs.openjdk.java.net/browse/JDK-8149571 >> webrev: http://cr.openjdk.java.net/~ogb/8149571/ > Creating sym link on Windows requires permissions so I assume this > test just pass when createSymbolicLInk fails (no guarantee that the > test is run with Administrator rights for example). > > -Alan In case of weak privilege level (UAC is on, etc.) it fails with "java.nio.file.FileSystemException: A required privilege is not held by the client" (0x80070522). We can re-throw the exception with additional comments about UAC/privileges or create the manual test with appropriate instructions about changing the security policy or disabling UAC. -Oleg From markt at apache.org Thu Apr 21 11:58:05 2016 From: markt at apache.org (Mark Thomas) Date: Thu, 21 Apr 2016 12:58:05 +0100 Subject: Project Jigsaw, Apache Tomcat and RMI related memory leaks In-Reply-To: <57164DDA.9070806@Oracle.com> References: <5715043B.4090901@apache.org> <57164DDA.9070806@Oracle.com> Message-ID: <5718C04D.1080002@apache.org> On 19/04/2016 16:25, Roger Riggs wrote: > Hi Mark, > > It may take a bit of time to unwind and find a good solution. Hi Roger, Agreed. Your response has actually been a huge help. It gave me a few more things to look at and I have been able break the problem down significantly. I need to work on this some more before I come back with a much clearer statement of the problem. I hope to be in a position to do that later today or tomorrow. I'll probably do that in a new thread. Thanks for the pointers. Mark > > On 4/18/16 11:58 AM, Mark Thomas wrote: >> Hi, >> >> The Apache Tomcat community was asked by Rory O'Donnell for feedback on >> JDK 9 + Project Jigsaw. Having provided that feedback we were directed >> here so I have reproduced that feedback below. >> >> >> I've started testing Tomcat trunk with JDK 9 + Project Jigsaw and it >> looks like we are going to hit a bunch of problems related to Tomcat's >> memory leak protection. >> >> The short version is there are lots of JDK calls that can result in a >> reference being retained to the current class loader. If that class >> loader is the web application class loader it often ends up being pinned >> in memory. This triggers a memory leak when the web application is >> reloaded since the web application class loader is not eligible for GC. >> >> Tomcat generally uses reflection to find these problems. It then does >> one of two things: >> - If the JRE provides an API the application developer should have used >> to clean up the reference, Tomcat does this for them and then logs a >> very loud error message telling the developer they need to fix their app. >> - If there is nothing the developer could have done to avoid the >> problem, Tomcat cleans it up. Usually this is via reflection again. >> >> Reporting this second class of issues as JRE bugs has been on my TODO >> list for a long time. It looks like Java 9 is going to bump this to the >> top of the list. >> >> The first problem we have hit is related to RMI. The memory leak is >> triggered by a call to: >> java.rmi.registry.Registry.bind() or >> java.rmi.registry.Registry.rebind() >> >> The problem occurs when an object of a class loaded by the web >> application class loader is bound to the RMI registry. >> >> There is no standard API (that I have found) that completely removes all >> references. In particular >> java.rmi.registry.Registry.unbind() >> doesn't help. > unbind just removes the mapping from name to an exported object; > it does not un-export the object. > Unless it was exported as permanent, the normal GC/distributed GC should > clear it. > > I would think the normal application shutdown should both remove the > binding > and unexport it (perhaps forcibly). > > But you are working on the case where the application doesn't behave > properly. > > If you had a way to discover the exported remote objects, the normal > forcible unexport mechanism > should be sufficient. Handing out references to exports objects would > need some kind of security > check. > > It might be worth investigating an official shutdown mechanism though > linking it to a classloader > seems a bit special purpose. > > $.02, Roger > >> The code Tomcat uses to clean this up is at [1]. Essentially, we need to >> remove any reference to the web application's class loader from the RMI >> caches. >> >> With JDK 9 this fails with: >> java.lang.reflect.InaccessibleObjectException: Unable to make member of >> class sun.rmi.transport.Target accessible: module java.rmi does not >> export sun.rmi.transport to unnamed module ... >> >> I took a look at the JDK 9 API but I could not find a way to bypass >> this. >> >> Possible solutions include: >> 1. Some way that allows us to continue to use reflection as per the >> current code. >> >> 2. A new method somewhere in the RMI API that clears all references >> associated with a given class loader from the cache. >> >> 3. Modify Registry.unbind() so it removes all references. >> >> 4. Something else... >> >> I do have a concern with 3 on its own that, while that would allow >> applications to clear their own references, it would mean Tomcat would >> have no way to check for the problem. >> >> Ideally, I'd like to see the API extended so a) applications are able to >> clean up after themselves and b) Tomcat can check for leaked references >> and generate error messages for the ones found. >> >> Any and all suggestions gratefully received. >> >> Thanks, >> >> Mark >> >> [1] >> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?view=annotate#l2214 >> > From paul.sandoz at oracle.com Thu Apr 21 13:24:18 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 21 Apr 2016 15:24:18 +0200 Subject: RFR 8154049: DualPivot sorting calculates incorrect runs for nearly sorted arrays Message-ID: <4BCDB485-4D6C-479E-8E92-BA790BDD75AB@oracle.com> Hi, Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154049-dual-pivot-sort-one-off-error/webrev/ https://bugs.openjdk.java.net/browse/JDK-8154049 A bug was introduced with the fix for: https://bugs.openjdk.java.net/browse/JDK-8080945 Improve the performance of primitive Arrays.sort for certain patterns of array elements Certain patterns of nearly sorted data failed to sort, and surprisingly (and embarrassingly) this was not detected by existing sorting tests. It was detected by pack200 tests, but the intermittent nature of the failure at a distance meant it took a while to track this down. If the number of elements to sort is > QUICKSORT_THRESHOLD (286), then a loop over the elements is performed to count equals, ascending and descending (transformed into ascending) runs. If the number of runs is < MAX_RUN_COUNT (67) then a merge sort of the runs is performed. When the loop finishes it is necessary to clean up some edge cases to report a final run. Modifications for JDK-8080945 failed to take into account an additional case for reporting a final run (specifically a run of equals elements, in addition to the previous case of a single last element). The fix is correctly report a final run in all cases. I tried to make the code more explicit. (It might be possible to clean up the code more, but i want to get a conservative fix in). I have also modified the nearly sorted test case: - all primitive types are correctly tested based on size thresholds, specifically short/char have a lower bound, COUNTING_SORT_THRESHOLD_FOR_SHORT_OR_CHAR (3200) above which a counting sort is performed. - added a combinatorial test, where 4 (base 3) digits, each taking values of -1, 0 or 1, bound at either side a sequence of zeros of sufficient length to ensure the array size is above the quick sort threshold. This should exercise all run counting code paths In addition we have run the pack200 ?test from hell? (thanks Kumar!) and this now passes without failure. Paul. From markt at apache.org Thu Apr 21 13:53:47 2016 From: markt at apache.org (Mark Thomas) Date: Thu, 21 Apr 2016 14:53:47 +0100 Subject: TCCL memory leak in RMI registry creation In-Reply-To: <5718C04D.1080002@apache.org> References: <5715043B.4090901@apache.org> <57164DDA.9070806@Oracle.com> <5718C04D.1080002@apache.org> Message-ID: <5718DB6B.6000103@apache.org> Continuing the previous thread but with a more precise subject. Calling LocateRegistry.createRegistry(Registry.REGISTRY_PORT); is sufficient to pin the Thread Context Class Loader (TCCL) in memory with no public API available (that I can find) to remove the reference. This is a problem for modular environments like Java EE containers that can frequently load and unload modules since it will trigger a memory leak. I have made a simple Java class that demonstrates this issue available on GitHub. [1] Up to and including Java 8, it is possible to use reflection tricks [2] to a) identify these leaks and b) fix them. As of Java 9, these reflection tricks will be blocked. Being able to identify and fix these memory leaks has been extremely useful in resolving issues with memory leaks with multiple deployments in Java EE environments. I believe that equivalent functionality needs to be available in Java 9 onwards. I have no strong views on what that functionality should look like as long as it enables the leaks to be identified and, ideally, resolved. Looking at the source code for sun.rmi.transport.Target, the ccl field was added for good reason and needs to be retained. That suggests that the solution is likely to involve destroying a currently existing registry. While Registry.destroy() (or similar) would be sufficient for application developers to do the 'right thing' it would not be sufficient for container developers to identify that an application running on the container had done the 'wrong thing' and needed to be fixed. For that something along these lines would be required: LocateRegsitry.listRegistries() Registry.getThreadContextClassLoader() Registry.destroy() Assuming my analysis is correct, thoughts on the above solution or any alternative solution welcome. For example, a way to hack around the Java 9 restrictions would be sufficient. Thanks, Mark [1] https://github.com/markt-asf/memory-leaks/blob/master/src/org/apache/markt/leaks/rmi/RegistryLeak.java [2] http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?view=annotate#l2214 From paul.sandoz at oracle.com Thu Apr 21 14:34:35 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 21 Apr 2016 16:34:35 +0200 Subject: RFR 8154556: Use java.nio.ByteOrder instead of boolean value Message-ID: <8B011630-3BA4-4F97-8EE7-E5B27ACC6B12@oracle.com> Hi Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154556-vh-nio-byteorder/webrev/ This is a small tweak to the VarHandle API. The array and ByteBuffer related factory methods on MethodhHandles now accept a java.no.ByteOrder rather than a boolean value. Use of java.no.ByteOrder is considered more readable in code that a boolean value, for express big, little or native endianness. Paul. From Alan.Bateman at oracle.com Thu Apr 21 14:43:54 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 21 Apr 2016 15:43:54 +0100 Subject: RFR 8154556: Use java.nio.ByteOrder instead of boolean value In-Reply-To: <8B011630-3BA4-4F97-8EE7-E5B27ACC6B12@oracle.com> References: <8B011630-3BA4-4F97-8EE7-E5B27ACC6B12@oracle.com> Message-ID: <5718E72A.9000902@oracle.com> On 21/04/2016 15:34, Paul Sandoz wrote: > Hi > > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154556-vh-nio-byteorder/webrev/ > > This is a small tweak to the VarHandle API. The array and ByteBuffer related factory methods on MethodhHandles now accept a java.no.ByteOrder rather than a boolean value. > > Use of java.no.ByteOrder is considered more readable in code that a boolean value, for express big, little or native endianness. > The switch the ByteOrder looks okay, just wondering if have to check for null and then adjust @throws NPE in the javadoc too. BTW: Is there a reason for "throws IllegalArgumentException"? This an unchecked so I assume not needed there (the @throws in the javadoc should be sufficient). -Alan. From claes.redestad at oracle.com Thu Apr 21 14:53:26 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Thu, 21 Apr 2016 16:53:26 +0200 Subject: RFR: 8154853: java/util/TimeZone/OldIDMappingTest.sh fails after JDK-8154231 Message-ID: <5718E966.1010801@oracle.com> Hi, initializing USE_OLDMAPPING after using it - deep inside load(dis) - seems like a very bad idea in hindsight. webrev: http://cr.openjdk.java.net/~redestad/8154853/webrev.01/ bug: https://bugs.openjdk.java.net/browse/JDK-8154853 Thanks! /Claes From chris.hegarty at oracle.com Thu Apr 21 14:58:03 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 21 Apr 2016 15:58:03 +0100 Subject: RFR: 8154853: java/util/TimeZone/OldIDMappingTest.sh fails after JDK-8154231 In-Reply-To: <5718E966.1010801@oracle.com> References: <5718E966.1010801@oracle.com> Message-ID: On 21 Apr 2016, at 15:53, Claes Redestad wrote: > Hi, > > initializing USE_OLDMAPPING after using it - deep inside load(dis) - seems like a very bad idea in hindsight. > > webrev: http://cr.openjdk.java.net/~redestad/8154853/webrev.01/ > bug: https://bugs.openjdk.java.net/browse/JDK-8154853 Look ok to me Claes. -Chris. From kumar.x.srinivasan at oracle.com Thu Apr 21 15:12:27 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Thu, 21 Apr 2016 08:12:27 -0700 Subject: [9] 8149571: [launcher] create a regression test to test symlinks on Windows In-Reply-To: <5718BF80.3030908@oracle.com> References: <57160707.4030606@oracle.com> <571666E3.30807@oracle.com> <571809B2.1050308@oracle.com> <57186F6B.9070702@oracle.com> <5718BF80.3030908@oracle.com> Message-ID: <5718EDDB.1070200@oracle.com> As Alan says, we can't run this test in an automated fashion, we have to make this a manual test. Kumar > 21.04.2016 9:12, Alan Bateman ?????: >> >> >> On 20/04/2016 23:58, Oleg G. Barbashov wrote: >>> Hi, >>> >>> Please review the simple test of launcher started using a symlink. >>> >>> issue: https://bugs.openjdk.java.net/browse/JDK-8149571 >>> webrev: http://cr.openjdk.java.net/~ogb/8149571/ >> Creating sym link on Windows requires permissions so I assume this >> test just pass when createSymbolicLInk fails (no guarantee that the >> test is run with Administrator rights for example). >> >> -Alan > > In case of weak privilege level (UAC is on, etc.) it fails with > "java.nio.file.FileSystemException: A required privilege is not held > by the client" (0x80070522). > We can re-throw the exception with additional comments about > UAC/privileges or create the manual test with appropriate instructions > about changing the security policy or disabling UAC. > > -Oleg From claes.redestad at oracle.com Thu Apr 21 15:26:00 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Thu, 21 Apr 2016 17:26:00 +0200 Subject: RFR: 8154853: java/util/TimeZone/OldIDMappingTest.sh fails after JDK-8154231 In-Reply-To: References: <5718E966.1010801@oracle.com> Message-ID: <5718F108.7080306@oracle.com> On 2016-04-21 16:58, Chris Hegarty wrote: > On 21 Apr 2016, at 15:53, Claes Redestad wrote: > >> Hi, >> >> initializing USE_OLDMAPPING after using it - deep inside load(dis) - seems like a very bad idea in hindsight. >> >> webrev: http://cr.openjdk.java.net/~redestad/8154853/webrev.01/ >> bug: https://bugs.openjdk.java.net/browse/JDK-8154853 > Look ok to me Claes. > Thanks Chris, I've run some local+remote sanity tests and pushed. /Claes From mandy.chung at oracle.com Thu Apr 21 15:53:09 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 21 Apr 2016 08:53:09 -0700 Subject: JDK 9 RFR of JDK-8152936: java/lang/Class/GetPackageTest.java needs update to work with newer testng In-Reply-To: <57186C83.1070707@oracle.com> References: <57186C83.1070707@oracle.com> Message-ID: > On Apr 20, 2016, at 11:00 PM, Amy Lu wrote: > > To get prepared for the coming testng updating in jtreg [1], test/java/lang/Class/GetPackageTest.java needs a minor update as newer version of testng requires explicit DataProvider's name (since 6.8.10). > > Please review the patch. This works for both current jtreg (testng 6.8.5), and later testng 6.9.5 > > bug: https://bugs.openjdk.java.net/browse/JDK-8152936 > webrev: http://cr.openjdk.java.net/~amlu/8152936/webrev.00/ +1 Mandy From Alan.Bateman at oracle.com Thu Apr 21 15:57:43 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 21 Apr 2016 16:57:43 +0100 Subject: [9] 8149571: [launcher] create a regression test to test symlinks on Windows In-Reply-To: <5718EDDB.1070200@oracle.com> References: <57160707.4030606@oracle.com> <571666E3.30807@oracle.com> <571809B2.1050308@oracle.com> <57186F6B.9070702@oracle.com> <5718BF80.3030908@oracle.com> <5718EDDB.1070200@oracle.com> Message-ID: <5718F877.8050807@oracle.com> On 21/04/2016 16:12, Kumar Srinivasan wrote: > > As Alan says, we can't run this test in an automated fashion, > we have to make this a manual test. I would expect that the tests are run with admin privileges on some systems so the test could just silently pass when it can't create the sym link. That might be preferable to a manual tests that is run rarely. -Alan From paul.sandoz at oracle.com Thu Apr 21 16:01:20 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 21 Apr 2016 18:01:20 +0200 Subject: RFR 8154556: Use java.nio.ByteOrder instead of boolean value In-Reply-To: <5718E72A.9000902@oracle.com> References: <8B011630-3BA4-4F97-8EE7-E5B27ACC6B12@oracle.com> <5718E72A.9000902@oracle.com> Message-ID: > On 21 Apr 2016, at 16:43, Alan Bateman wrote: > > > > On 21/04/2016 15:34, Paul Sandoz wrote: >> Hi >> >> Please review: >> >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154556-vh-nio-byteorder/webrev/ >> >> This is a small tweak to the VarHandle API. The array and ByteBuffer related factory methods on MethodhHandles now accept a java.no.ByteOrder rather than a boolean value. >> >> Use of java.no.ByteOrder is considered more readable in code that a boolean value, for express big, little or native endianness. >> > The switch the ByteOrder looks okay, just wondering if have to check for null and then adjust @throws NPE in the javadoc too. > I blindly copied the same behaviour from ByteBuffer.order: /** * Modifies this buffer's byte order. * * @param bo * The new byte order, * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} * * @return This buffer */ public final ByteBuffer order(ByteOrder bo) { bigEndian = (bo == ByteOrder.BIG_ENDIAN); nativeByteOrder = (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN)); return this; } Was that behaviour intentional or an oversight? I am assuming the latter as it?s ambiguous what should happen if a third value, null, is passed. I updated the webrev in place to throw an NPE. > BTW: Is there a reason for "throws IllegalArgumentException"? This an unchecked so I assume not needed there (the @throws in the javadoc should be sufficient). > I retained consistency with existing MH factory methods. Thanks Paul. From peter.levart at gmail.com Thu Apr 21 16:07:59 2016 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 21 Apr 2016 18:07:59 +0200 Subject: java.lang.reflect.Module.WeakSet is not thread-safe Message-ID: <5718FADF.5000601@gmail.com> Hi, While browsing code in java.lang.reflect.Module (I sometimes do that just to see how thinks work ;-) I stumbled on the following nested class: private static class WeakSet { private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final Lock readLock = lock.readLock(); private final Lock writeLock = lock.writeLock(); private final WeakHashMap map = new WeakHashMap<>(); /** * Adds the specified element to the set. */ void add(E e) { writeLock.lock(); try { map.put(e, Boolean.TRUE); } finally { writeLock.unlock(); } } /** * Returns {@code true} if this set contains the specified element. */ boolean contains(E e) { readLock.lock(); try { return map.containsKey(e); } finally { readLock.unlock(); } } } ...while this seems OK from 1st look, it is not. WeakHashMap is not thread-safe even for seemingly read-only operations. All its operations can mutate internal state in a non-thread-safe way. The simplest way to fix this is to use a writeLock for containsKey operation too. But such structure does not scale well to multiple threads for frequent lookups. WeakSet is used in Module to keep track of transient read edges, exports and uses of services added dynamically to the module. Modification operations are not so performance critical, but lookup operations are. I propose to add a thread-safe WeakPairMap data structure which associates a pair of weakly-reachable keys with a strongly-reachable value based on ConcurrentHashMap. Such data structure is footprint-friendly, since only a single instance exists for a particular purpose, totaling 3 instances for the transient structures serving all Modules in the system: http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.01/ So, what do you think? Regards, Peter From paul.sandoz at oracle.com Thu Apr 21 16:21:51 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 21 Apr 2016 18:21:51 +0200 Subject: RFR 8154755: Add a VarHandle weakCompareAndSet with volatile semantics Message-ID: <07EE4695-9AF3-4F50-ACAE-831BD508B657@oracle.com> Hi, Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154755-weak-cas-volatile/webrev/ This webrev adds a new VarHandle access mode method, weakCompareAndSetVolatile [*]. (I also fixed some doc errors regarding AccessMode enum names that i forgot to update in a previous issue). Aleksey noticed a discrepancy with the current set of weak CAS methods when comparing with C++ atomics. On hardware that supports LL/SC (e.g. ARM) the weak volatile variant may be more performant than the strong volatile variant (compareAndSet) when the CAS is performed in a loop. See the thread on the jmm-dev list for more details: http://mail.openjdk.java.net/pipermail/jmm-dev/2016-April/000239.html Implementations currently defer to the strong volatile Unsafe CAS. We will follow up with changes to Unsafe, hotspot, and updating the VH implementations as separate issues. Thanks, Paul. [*] /** * Possibly atomically sets the value of a variable to the {@code newValue} * with the memory semantics of {@link #setVolatile} if the variable's * current value, referred to as the witness value, {@code ==} the * {@code expectedValue}, as accessed with the memory semantics of * {@link #getVolatile}. * *

      This operation may fail spuriously (typically, due to memory * contention) even if the witness value does match the expected value. * ... */ public final native @MethodHandle.PolymorphicSignature @HotSpotIntrinsicCandidate boolean weakCompareAndSetVolatile(Object... args); Paul. From joe.darcy at oracle.com Thu Apr 21 16:25:27 2016 From: joe.darcy at oracle.com (joe darcy) Date: Thu, 21 Apr 2016 09:25:27 -0700 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5713C871.1080407@oracle.com> References: <5713C871.1080407@oracle.com> Message-ID: <5718FEF7.1020807@oracle.com> Hello, After a generally positive reception, please review the webrev to implement the deprecation of Class.newInstance and the suppression of the resulting warnings: http://cr.openjdk.java.net/~darcy/6850612.0/ There are also some changes in the langtools repo; I'll send a separate review request for those changes to compiler-dev. I'll also forward this review request to other areas with affected code. Thanks, -Joe On 4/17/2016 10:31 AM, joe darcy wrote: > Hello, > > With talk of deprecation in the air [1], I thought it would be a fine > time to examine one of the bugs on my list > > JDK-6850612: Deprecate Class.newInstance since it violates the > checked exception language contract > > As the title of the bug implies, The Class.newInstance method > knowingly violates the checking exception contract. This has long been > documented in its specification: > >> Note that this method propagates any exception thrown by the nullary >> constructor, including a checked exception. Use of this method >> effectively bypasses the compile-time exception checking that would >> otherwise be performed by the compiler. The Constructor.newInstance >> method avoids this problem by wrapping any exception thrown by the >> constructor in a (checked) InvocationTargetException. > > Roughly, the fix would be to turn the text of this note into the > @deprecated text and to add a @Deprecated(since="9") annotation to the > method. There are a few dozen uses of the method in the JDK that would > have to be @SuppressWarning-ed or otherwise updated. > > Thoughts on the appropriateness of deprecating this method at this time? > > Comments on the bug have suggested that besides deprecating the > method, a new method on Class could be introduced, > newInstanceWithProperExceptionBehavior, that had the same signature > but wrapped exceptions thrown by the constructor call in the same way > Constructor.newInstance does. > > Thanks, > > -Joe > > [1] > http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html From pbenedict at apache.org Thu Apr 21 16:51:58 2016 From: pbenedict at apache.org (Paul Benedict) Date: Thu, 21 Apr 2016 11:51:58 -0500 Subject: @Deprecated(since) and Javadoc Message-ID: Is there a requirement that the new "since" attribute on @j.l.Deprecated lead to an automatic JavaDoc @deprecated in the doc generation? It's a bona fide replacement, right? I'm just curious because I think, if that's true, @j.l.Deprecated should mention this tool coordination in its own JavaDoc header. Cheers, Paul From kumar.x.srinivasan at oracle.com Thu Apr 21 17:01:32 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Thu, 21 Apr 2016 10:01:32 -0700 Subject: [9] 8149571: [launcher] create a regression test to test symlinks on Windows In-Reply-To: <5718F877.8050807@oracle.com> References: <57160707.4030606@oracle.com> <571666E3.30807@oracle.com> <571809B2.1050308@oracle.com> <57186F6B.9070702@oracle.com> <5718BF80.3030908@oracle.com> <5718EDDB.1070200@oracle.com> <5718F877.8050807@oracle.com> Message-ID: <5719076C.6010902@oracle.com> > > On 21/04/2016 16:12, Kumar Srinivasan wrote: >> >> As Alan says, we can't run this test in an automated fashion, >> we have to make this a manual test. > I would expect that the tests are run with admin privileges on some > systems so the test could just silently pass when it can't create the > sym link. That might be preferable to a manual tests that is run rarely. I think we should have two flavors. A manual one which is stringent, forcing to tester to run with elevated privileges if necessary, and the other which passes if link cannot be created. Amy did something similar with a pack200 test. Kumar > > -Alan From Alan.Bateman at oracle.com Thu Apr 21 18:46:58 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 21 Apr 2016 19:46:58 +0100 Subject: RFR 8154556: Use java.nio.ByteOrder instead of boolean value In-Reply-To: References: <8B011630-3BA4-4F97-8EE7-E5B27ACC6B12@oracle.com> <5718E72A.9000902@oracle.com> Message-ID: <57192022.7000306@oracle.com> On 21/04/2016 17:01, Paul Sandoz wrote: > : > I blindly copied the same behaviour from ByteBuffer.order: > > /** > * Modifies this buffer's byte order. > * > * @param bo > * The new byte order, > * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} > * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} > * > * @return This buffer > */ > public final ByteBuffer order(ByteOrder bo) { > bigEndian = (bo == ByteOrder.BIG_ENDIAN); > nativeByteOrder = > (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN)); > return this; > } > > Was that behaviour intentional or an oversight? I am assuming the latter as it?s ambiguous what should happen if a third value, null, is passed. I would assume so too. > > I updated the webrev in place to throw an NPE. Okay. > > >> BTW: Is there a reason for "throws IllegalArgumentException"? This an unchecked so I assume not needed there (the @throws in the javadoc should be sufficient). >> > I retained consistency with existing MH factory methods. > Okay although I assume it could be dropped elsewhere. -Alan. From peter.levart at gmail.com Thu Apr 21 18:56:31 2016 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 21 Apr 2016 20:56:31 +0200 Subject: java.lang.reflect.Module.WeakSet is not thread-safe In-Reply-To: <5718FADF.5000601@gmail.com> References: <5718FADF.5000601@gmail.com> Message-ID: <5719225F.1050608@gmail.com> On 04/21/2016 06:07 PM, Peter Levart wrote: > I propose to add a thread-safe WeakPairMap data structure which > associates a pair of weakly-reachable keys with a strongly-reachable > value based on ConcurrentHashMap. Such data structure is > footprint-friendly, since only a single instance exists for a > particular purpose, totaling 3 instances for the transient structures > serving all Modules in the system: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.01/ > Oops... It looks like I replaced one thread-unsafe construction with another one: 389 // additional exports added at run-time 390 // source module (1st key), target module (2nd key), exported packages (value) 391 private static final WeakPairMap> transientExports = 392 new WeakPairMap<>(); ...that would've been OK if I hadn't used normal HashSet for holding the set of packages: 623 // add package name to transientExports if absent 624 transientExports 625 .computeIfAbsent(this, other, (_this, _other) -> new HashSet<>()) 626 .add(pn); Luckily this can be easily fixed by using a ConcurrentHashMap instead of HashSet which is even more space-friendly (HashSet is just a wrapper around HashMap and HashMap is basically the same structure as ConcurrentHashMap): http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.02/ Regards, Peter From stuart.marks at oracle.com Thu Apr 21 21:54:43 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 21 Apr 2016 14:54:43 -0700 Subject: @Deprecated(since) and Javadoc In-Reply-To: References: Message-ID: <57194C23.5010202@oracle.com> On 4/21/16 9:51 AM, Paul Benedict wrote: > Is there a requirement that the new "since" attribute on @j.l.Deprecated > lead to an automatic JavaDoc @deprecated in the doc generation? It's a bona > fide replacement, right? > > I'm just curious because I think, if that's true, @j.l.Deprecated should > mention this tool coordination in its own JavaDoc header. I'm not sure what you mean by "since" in the annotation leading to an "automatic" javadoc tag. But to clarify, the @Deprecated annotation and the @deprecated javadoc tag are complementary; neither is a replacement for the other. The annotation contains "since" and "forRemoval" information and ends up in memory at runtime, since it has runtime retention. The javadoc tag should have descriptive text that explains the rationale for deprecation, risks of using, preferred alternatives, etc. It should be considered an error to have the annotation without the javadoc tag and vice-versa. Javac does some checking in this regard, but it only does the check in one direction! The tools should check both. See https://bugs.openjdk.java.net/browse/JDK-8141234 Aside from that, if you think something needs to be clarified in the doc for the @Deprecated annotation, please suggest it. Now's the time. s'marks From mandy.chung at oracle.com Thu Apr 21 22:03:17 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 21 Apr 2016 15:03:17 -0700 Subject: Review request 8154837: Class::getPackage with exploded modules when classes in modules defined to the boot loader Message-ID: Webrev: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154837/webrev.00/ The module location from an exploded image is file URL rather than file path. This issue can be reproduced with jdk/test/java/lang/Package/GetPackages.java on windows. Mandy From stuart.marks at oracle.com Thu Apr 21 22:32:05 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 21 Apr 2016 15:32:05 -0700 Subject: TCCL memory leak in RMI registry creation In-Reply-To: <5718DB6B.6000103@apache.org> References: <5715043B.4090901@apache.org> <57164DDA.9070806@Oracle.com> <5718C04D.1080002@apache.org> <5718DB6B.6000103@apache.org> Message-ID: <571954E5.50004@oracle.com> Hi Mark, Is it possible to save the reference to the registry that was created by the call to LocateRegistry.createRegistry()? If so, then it's possible to shut down that registry by exporting it: UnicastRemoteObject.unexportObject(registry, true); Adding this to the "RegistryLeak" test program you posted changes its behavior to print "no leak". (I haven't looked at this too closely, though, so I may be misinterpreting what's going on.) It's probably necessary to unexport and maybe also unbind everything from this registry as well, as Roger had suggested previously. s'marks On 4/21/16 6:53 AM, Mark Thomas wrote: > Continuing the previous thread but with a more precise subject. > > Calling > > LocateRegistry.createRegistry(Registry.REGISTRY_PORT); > > is sufficient to pin the Thread Context Class Loader (TCCL) in memory > with no public API available (that I can find) to remove the reference. > > This is a problem for modular environments like Java EE containers that > can frequently load and unload modules since it will trigger a memory > leak. I have made a simple Java class that demonstrates this issue > available on GitHub. [1] > > Up to and including Java 8, it is possible to use reflection tricks [2] > to a) identify these leaks and b) fix them. As of Java 9, these > reflection tricks will be blocked. > > Being able to identify and fix these memory leaks has been extremely > useful in resolving issues with memory leaks with multiple deployments > in Java EE environments. > > I believe that equivalent functionality needs to be available in Java 9 > onwards. I have no strong views on what that functionality should look > like as long as it enables the leaks to be identified and, ideally, > resolved. > > Looking at the source code for sun.rmi.transport.Target, the ccl field > was added for good reason and needs to be retained. That suggests that > the solution is likely to involve destroying a currently existing > registry. While Registry.destroy() (or similar) would be sufficient for > application developers to do the 'right thing' it would not be > sufficient for container developers to identify that an application > running on the container had done the 'wrong thing' and needed to be > fixed. For that something along these lines would be required: > > LocateRegsitry.listRegistries() > Registry.getThreadContextClassLoader() > Registry.destroy() > > Assuming my analysis is correct, thoughts on the above solution or any > alternative solution welcome. For example, a way to hack around the Java > 9 restrictions would be sufficient. > > Thanks, > > Mark > > > [1] > https://github.com/markt-asf/memory-leaks/blob/master/src/org/apache/markt/leaks/rmi/RegistryLeak.java > > [2] > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?view=annotate#l2214 > From pbenedict at apache.org Thu Apr 21 23:51:32 2016 From: pbenedict at apache.org (Paul Benedict) Date: Thu, 21 Apr 2016 18:51:32 -0500 Subject: @Deprecated(since) and Javadoc In-Reply-To: <57194C23.5010202@oracle.com> References: <57194C23.5010202@oracle.com> Message-ID: Well, my point was that it becomes redundant coding to specify both the annotation and the Javadoc tag. It would just seem better, in my opinion, if doing a @j.l.Deprecated(since="9") triggered whatever output is necessary during doc generation. It doesn't make sense to me to require both. The language annotation, with the new attribute, is now expressive enough for generation needs. Asking the developer to do both is wasteful effort, I think. On Apr 21, 2016 4:54 PM, "Stuart Marks" wrote: > On 4/21/16 9:51 AM, Paul Benedict wrote: > >> Is there a requirement that the new "since" attribute on @j.l.Deprecated >> lead to an automatic JavaDoc @deprecated in the doc generation? It's a >> bona >> fide replacement, right? >> >> I'm just curious because I think, if that's true, @j.l.Deprecated should >> mention this tool coordination in its own JavaDoc header. >> > > I'm not sure what you mean by "since" in the annotation leading to an > "automatic" javadoc tag. > > But to clarify, the @Deprecated annotation and the @deprecated javadoc tag > are complementary; neither is a replacement for the other. The annotation > contains "since" and "forRemoval" information and ends up in memory at > runtime, since it has runtime retention. The javadoc tag should have > descriptive text that explains the rationale for deprecation, risks of > using, preferred alternatives, etc. > > It should be considered an error to have the annotation without the > javadoc tag and vice-versa. Javac does some checking in this regard, but it > only does the check in one direction! The tools should check both. See > > https://bugs.openjdk.java.net/browse/JDK-8141234 > > Aside from that, if you think something needs to be clarified in the doc > for the @Deprecated annotation, please suggest it. Now's the time. > > s'marks > From stuart.marks at oracle.com Fri Apr 22 02:02:21 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 21 Apr 2016 19:02:21 -0700 Subject: @Deprecated(since) and Javadoc In-Reply-To: References: <57194C23.5010202@oracle.com> Message-ID: <5719862D.9000600@oracle.com> On 4/21/16 4:51 PM, Paul Benedict wrote: > Well, my point was that it becomes redundant coding to specify both the > annotation and the Javadoc tag. It would just seem better, in my opinion, if > doing a @j.l.Deprecated(since="9") triggered whatever output is necessary > during doc generation. It doesn't make sense to me to require both. The > language annotation, with the new attribute, is now expressive enough for > generation needs. Asking the developer to do both is wasteful effort, I think. If you want to deprecate something and not provide any documentation about why it was deprecated or what it should be replaced with, then the @Deprecated annotation will be sufficient. Javadoc will place a boldface heading *Deprecated.* into the javadoc output. (This has been true in JDK 8 and earlier, and it has nothing to do with the new "since" element in the @Deprecated annotation.) If you want documentation about the deprecation (rationale and replacement) then you do need to add a @deprecated javadoc tag, as redundant as that may seem. There's no place to put such documentation in the @Deprecated annotation. s'marks From stuart.marks at oracle.com Fri Apr 22 02:17:12 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 21 Apr 2016 19:17:12 -0700 Subject: RFR(s): 8154801 deprecate java.util.Observable/Observer Message-ID: <571989A8.3010901@oracle.com> Hi all, Here's a small proposal to deprecate the java.util.Observable and Observer. This deprecation will not be for removal. See https://bugs.openjdk.java.net/browse/JDK-8154801 for some background. Essentially, these classes are a very thin implementation of the Observer pattern. These classes provide little beyond maintaining a list of callbacks plus the ability calling them upon request. A 1999 comment from Josh Bloch in a related bug report said that they are no longer under active development and have been superseded by the 1.1 Beans/AWT event model. Their only use in the JDK is in the Hotspot Serviceability Agent, which doesn't even use Observable, and which uses Observer as a callback interface. SA's use of Observer could easily be replaced with lambdas and Consumer. There is some use of these classes "in the wild" but only for conventional callback purposes. Deprecation will generate warnings if that code is recompiled with deprecation warnings enabled. Diffs follow. Thanks, s'marks diff -r 92280897299f -r e16d8d56da15 src/java.base/share/classes/java/util/Observable.java --- a/src/java.base/share/classes/java/util/Observable.java Mon Apr 18 14:10:14 2016 -0700 +++ b/src/java.base/share/classes/java/util/Observable.java Thu Apr 21 15:48:23 2016 -0700 @@ -58,7 +58,19 @@ * @see java.util.Observer * @see java.util.Observer#update(java.util.Observable, java.lang.Object) * @since 1.0 + * + * @deprecated + * This class and the {@link Observer} interface have been deprecated. + * The event model supported by {@code Observer} and {@code Observable} + * is quite limited, the order of notifications delivered by + * {@code Observable} is unspecified, and state changes are not in + * one-for-one correspondence with notifications. + * For a richer event model, consider using the + * {@link java.beans} package. For reliable and ordered + * messaging among threads, consider using one of the concurrent data + * structures in the {@link java.util.concurrent} package. */ + at Deprecated(since="9") public class Observable { private boolean changed = false; private Vector obs; diff -r 92280897299f -r e16d8d56da15 src/java.base/share/classes/java/util/Observer.java --- a/src/java.base/share/classes/java/util/Observer.java Mon Apr 18 14:10:14 2016 -0700 +++ b/src/java.base/share/classes/java/util/Observer.java Thu Apr 21 15:48:23 2016 -0700 @@ -31,7 +31,12 @@ * @author Chris Warth * @see java.util.Observable * @since 1.0 + * + * @deprecated + * This interface has been deprecated. See the {@link Observable} + * class for further information. */ + at Deprecated(since="9") public interface Observer { /** * This method is called whenever the observed object is changed. An From joe.darcy at oracle.com Fri Apr 22 03:11:53 2016 From: joe.darcy at oracle.com (joe darcy) Date: Thu, 21 Apr 2016 20:11:53 -0700 Subject: RFR(s): 8154801 deprecate java.util.Observable/Observer In-Reply-To: <571989A8.3010901@oracle.com> References: <571989A8.3010901@oracle.com> Message-ID: <57199679.7030305@oracle.com> Looks good Stuart; thanks, -Joe On 4/21/2016 7:17 PM, Stuart Marks wrote: > Hi all, > > Here's a small proposal to deprecate the java.util.Observable and > Observer. This deprecation will not be for removal. > > See https://bugs.openjdk.java.net/browse/JDK-8154801 for some background. > > Essentially, these classes are a very thin implementation of the > Observer pattern. These classes provide little beyond maintaining a > list of callbacks plus the ability calling them upon request. A 1999 > comment from Josh Bloch in a related bug report said that they are no > longer under active development and have been superseded by the 1.1 > Beans/AWT event model. > > Their only use in the JDK is in the Hotspot Serviceability Agent, > which doesn't even use Observable, and which uses Observer as a > callback interface. SA's use of Observer could easily be replaced with > lambdas and Consumer. > > There is some use of these classes "in the wild" but only for > conventional callback purposes. Deprecation will generate warnings if > that code is recompiled with deprecation warnings enabled. > > Diffs follow. > > Thanks, > > s'marks > > > > diff -r 92280897299f -r e16d8d56da15 > src/java.base/share/classes/java/util/Observable.java > --- a/src/java.base/share/classes/java/util/Observable.java Mon Apr > 18 14:10:14 2016 -0700 > +++ b/src/java.base/share/classes/java/util/Observable.java Thu Apr > 21 15:48:23 2016 -0700 > @@ -58,7 +58,19 @@ > * @see java.util.Observer > * @see java.util.Observer#update(java.util.Observable, > java.lang.Object) > * @since 1.0 > + * > + * @deprecated > + * This class and the {@link Observer} interface have been deprecated. > + * The event model supported by {@code Observer} and {@code Observable} > + * is quite limited, the order of notifications delivered by > + * {@code Observable} is unspecified, and state changes are not in > + * one-for-one correspondence with notifications. > + * For a richer event model, consider using the > + * {@link java.beans} package. For reliable and ordered > + * messaging among threads, consider using one of the concurrent data > + * structures in the {@link java.util.concurrent} package. > */ > + at Deprecated(since="9") > public class Observable { > private boolean changed = false; > private Vector obs; > diff -r 92280897299f -r e16d8d56da15 > src/java.base/share/classes/java/util/Observer.java > --- a/src/java.base/share/classes/java/util/Observer.java Mon Apr > 18 14:10:14 2016 -0700 > +++ b/src/java.base/share/classes/java/util/Observer.java Thu Apr > 21 15:48:23 2016 -0700 > @@ -31,7 +31,12 @@ > * @author Chris Warth > * @see java.util.Observable > * @since 1.0 > + * > + * @deprecated > + * This interface has been deprecated. See the {@link Observable} > + * class for further information. > */ > + at Deprecated(since="9") > public interface Observer { > /** > * This method is called whenever the observed object is changed. An > > From joe.darcy at oracle.com Fri Apr 22 03:16:57 2016 From: joe.darcy at oracle.com (joe darcy) Date: Thu, 21 Apr 2016 20:16:57 -0700 Subject: @Deprecated(since) and Javadoc In-Reply-To: <5719862D.9000600@oracle.com> References: <57194C23.5010202@oracle.com> <5719862D.9000600@oracle.com> Message-ID: <571997A9.8050006@oracle.com> On 4/21/2016 7:02 PM, Stuart Marks wrote: > On 4/21/16 4:51 PM, Paul Benedict wrote: >> Well, my point was that it becomes redundant coding to specify both >> the annotation and the Javadoc tag. It would just seem better, in my >> opinion, if doing a @j.l.Deprecated(since="9") triggered whatever >> output is necessary during doc generation. It doesn't make sense to >> me to require both. The language annotation, with the new attribute, >> is now expressive enough for generation needs. Asking the developer >> to do both is wasteful effort, I think. > If you want to deprecate something and not provide any documentation > about why it was deprecated or what it should be replaced with, then > the @Deprecated annotation will be sufficient. Javadoc will place a > boldface heading > > *Deprecated.* > > into the javadoc output. (This has been true in JDK 8 and earlier, and > it has nothing to do with the new "since" element in the @Deprecated > annotation.) > > If you want documentation about the deprecation (rationale and > replacement) then you do need to add a @deprecated javadoc tag, as > redundant as that may seem. There's no place to put such documentation > in the @Deprecated annotation. > The distinct java.lang.Deprecated annotation type separate from the @deprecated javadoc tag was a deliberate design decision made back in JDK 5. Just as @throws tags and the method throws clauses are complementary, so are the annotation and javadoc tag associated with deprecation. It would be awkward to perform javadoc processing on a string in an annotation. Cheers, -Joe From yasuenag at gmail.com Fri Apr 22 03:36:51 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Fri, 22 Apr 2016 12:36:51 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571635E6.40601@gmail.com> References: <56F3F90D.9010408@gmail.com> <56FB99AD.30207@oracle.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> Message-ID: Hi all, I have uploaded webrev.04 as below. Could you review again? > - hotspot: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ > > - jdk: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ Thanks, Yasumasa 2016/04/19 22:43 "Yasumasa Suenaga" : > > Hi David, > > Thank you for your comment. > I uploaded new webrev. Could you review again? > > - hotspot: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ > > - jdk: > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ > > >> That aside I'm not sure why you do this so late in the process, I would have done it immediately after here: > > > I think that native thread name ("main") should be set just before > main method call. > However, main thread is already started, so I moved it as you suggested. > > >> One thing I dislike about the current structure is that we have to go from char* to java.lang.String to call setNativeName which then calls JVM_SetNativeThreadName which converts the j.l.String back to a char* ! > > > SoI proposed to export new JVM function to set native thread name with > const char *. > > > Thanks, > > Yasumasa > > > > On 2016/04/19 14:04, David Holmes wrote: >> >> Hi Yasumasa, >> >> Thanks for persevering with this to get it into the current form. Sorry I haven't been able to do a detailed review until now. >> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>> >>> Hi Gerard, >>> >>> 2016/04/19 3:14 "Gerard Ziemski" >> >: >>> > >>> > hi Yasumasa, >>> > >>> > Nice work. I have 2 questions: >>> > >>> > ======== >>> > File: java.c >>> > >>> > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>> after every single JNI call? In this example instead of NULL_CHECK, >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>> >>> It is not critical if we encounter error at JNI function call because >>> we cannot set native thread name only. >>> So I think that we do not need to leave from launcher process. >> >> >> I agree we do not need to abort if an exception occurs (and in fact I don't think an exception is even possible from this code), but we should ensure any pending exception is cleared before any futher JNI calls might be made. Note that NULL_CHECK is already used extensively throughout the launcher code - so if this usage is wrong then it is all wrong! More on this code below ... >> >> Other comments: >> >> hotspot/src/share/vm/prims/jvm.cpp >> >> Please add a comment to the method now that you removed the internal comment: >> >> // Sets the native thread name for a JavaThread. If specifically >> // requested JNI-attached threads can also have their native name set; >> // otherwise we do not modify JNI-attached threads as it may interfere >> // with the application that created them. >> >> --- >> >> jdk/src/java.base/share/classes/java/lang/Thread.java >> >> Please add the following comments: >> >> + // Don't modify JNI-attached threads >> setNativeName(name, false); >> >> + // May be called directly via JNI or reflection (when permitted) to >> + // allow JNI-attached threads to set their native name >> private native void setNativeName(String name, boolean allowAttachedThread); >> >> --- >> >> jd/src/java.base/share/native/libjli/java.c >> >> 328 #define LEAVE() \ >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >> >> I was going to suggest this be set later, but realized we have to be attached to do this and that happens inside DestroyJavaVM. :) >> >> + /* Set native thread name. */ >> + SetNativeThreadName(env, "main"); >> >> The comment is redundant given the name of the method. That aside I'm not sure why you do this so late in the process, I would have done it immediately after here: >> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >> 388 exit(1); >> 389 } >> + SetNativeThreadName(env, "main"); >> >> >> + /** >> + * Set native thread name as possible. >> + */ >> >> Other than the as->if change I'm unclear where the "possible" bit comes into play - why would it not be possible? >> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >> 1706 NULL_CHECK(currentThreadID = (*env)->GetStaticMethodID(env, cls, >> 1707 "currentThread", "()Ljava/lang/Thread;")); >> 1708 NULL_CHECK(currentThread = (*env)->CallStaticObjectMethod(env, cls, >> 1709 currentThreadID)); >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, >> 1711 "setNativeName", "(Ljava/lang/String;Z)V")); >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >> 1714 nameString, JNI_TRUE); >> >> As above NULL_CHECK is fine here, but we should check for and clear any pending exception after CallVoidMethod. >> >> One thing I dislike about the current structure is that we have to go from char* to java.lang.String to call setNativeName which then calls JVM_SetNativeThreadName which converts the j.l.String back to a char* ! Overall I wonder about the affect on startup cost. But if there is an issue we can revisit this. >> >> Thanks, >> David >> ----- >> >> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native thread >>> name if possible.? not "Set native thread name as possible.?? >>> >>> Sorry for my bad English :-) >>> >>> Thanks, >>> >>> Yasumasa >>> >>> > cheers >>> > >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >> > wrote: >>> > > >>> > > Hi David, >>> > > >>> > > I uploaded new webrev: >>> > > >>> > > - hotspot: >>> > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>> > > >>> > > - jdk: >>> > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>> > > >>> > > >>> > >> it won't work unless you change the semantics of setName so I'm >>> not sure what you were thinking here. To take advantage of an arg taking >>> JVM_SetNativThreadName you would need to call it directly as no Java >>> code will call it . ??? >>> > > >>> > > I added a flag for setting native thread name to JNI-attached thread. >>> > > This change can set native thread name if main thread changes to >>> JNI-attached thread. >>> > > >>> > > >>> > > Thanks, >>> > > >>> > > Yasumasa >>> > > >>> > > >>> > > On 2016/04/16 16:11, David Holmes wrote: >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>> > >>> Hi David, >>> > >>> >>> > >>>> That change in behaviour may be a problem, it could be considered a >>> > >>>> regression that setName stops setting the native thread main, even >>> > >>>> though we never really intended it to work in the first place. >>> :( Such >>> > >>>> a change needs to go through CCC. >>> > >>> >>> > >>> I understood. >>> > >>> Can I send CCC request? >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>> > >> >>> > >> Sorry you can't file a CCC request, you would need a sponsor for >>> that. But at this stage I don't think I agree with the proposed change >>> because of the change in behaviour - there's no way to restore the >>> "broken" behaviour. >>> > >> >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. >>> > >> >>> > >> Okay we can do that. >>> > >> >>> > >>> >>> > >>>> Further, we expect the launcher to use the supported JNI >>> interface (as >>> > >>>> other processes would), not the internal JVM interface that >>> exists for >>> > >>>> the JDK sources to communicate with the JVM. >>> > >>> >>> > >>> I think that we do not use JVM interface if we add new method in >>> > >>> LauncherHelper as below: >>> > >>> ---------------- >>> > >>> diff -r f02139a1ac84 >>> > >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> > >>> --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>> > >>> +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>> > >>> @@ -960,4 +960,8 @@ >>> > >>> else >>> > >>> return md.toNameAndVersion() + " (" + loc + ")"; >>> > >>> } >>> > >>> + >>> > >>> + static void setNativeThreadName(String name) { >>> > >>> + Thread.currentThread().setName(name); >>> > >>> + } >>> > >> >>> > >> You could also make that call via JNI directly, so not sure the >>> helper adds much here. But it won't work unless you change the semantics >>> of setName so I'm not sure what you were thinking here. To take >>> advantage of an arg taking JVM_SetNativThreadName you would need to call >>> it directly as no Java code will call it . ??? >>> > >> >>> > >> David >>> > >> ----- >>> > >> >>> > >>> } >>> > >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 14:19:30 >>> > >>> 2016 +0000 >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 11:25:53 >>> > >>> 2016 +0900 >>> > >>> @@ -125,6 +125,7 @@ >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>> > >>> >>> > >>> static void SetPaths(int argc, char **argv); >>> > >>> >>> > >>> @@ -325,6 +326,7 @@ >>> > >>> * mainThread.isAlive() to work as expected. >>> > >>> */ >>> > >>> #define LEAVE() \ >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>> > >>> do { \ >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>> > >>> @@ -488,6 +490,9 @@ >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>> > >>> >>> > >>> + /* Set native thread name. */ >>> > >>> + SetNativeThreadName(env, "main"); >>> > >>> + >>> > >>> /* Invoke main method. */ >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>> > >>> >>> > >>> @@ -1686,6 +1691,22 @@ >>> > >>> joptString); >>> > >>> } >>> > >>> >>> > >>> +/** >>> > >>> + * Set native thread name as possible. >>> > >>> + */ >>> > >>> +static void >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>> > >>> +{ >>> > >>> + jmethodID setNativeThreadNameID; >>> > >>> + jstring nameString; >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>> > >>> + NULL_CHECK(cls); >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>> (*env)->GetStaticMethodID(env, cls, >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, setNativeThreadNameID, >>> > >>> nameString); >>> > >>> +} >>> > >>> + >>> > >>> /* >>> > >>> * Prints default usage or the Xusage message, see >>> > >>> sun.launcher.LauncherHelper.java >>> > >>> */ >>> > >>> ---------------- >>> > >>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>> > >>> >>> > >>>> However this is still a change to the exported JVM interface and so >>> > >>>> has to be approved. >>> > >>> >>> > >>> Do you mean that this change needs CCC? >>> > >>> >>> > >>> >>> > >>> Thanks, >>> > >>> >>> > >>> Yasumasa >>> > >>> >>> > >>> >>> > >>> [1] >>> > >>> >>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>> > >>> >>> > >>> >>> > >>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>> > >>>>> Hi David, >>> > >>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>> > >>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>> thread and >>> > >>>>>> JNI attached threads >>> > >>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>> > >>>>> I will send review request to hotspot-runtime-dev. >>> > >>>>> >>> > >>>>> >>> > >>>>>> Though that will introduce a change in behaviour by itself as >>> setName >>> > >>>>>> will no longer set the native name for the main thread. >>> > >>>>> >>> > >>>>> I know. >>> > >>>> >>> > >>>> That change in behaviour may be a problem, it could be considered a >>> > >>>> regression that setName stops setting the native thread main, even >>> > >>>> though we never really intended it to work in the first place. >>> :( Such >>> > >>>> a change needs to go through CCC. >>> > >>>> >>> > >>>>> I checked changeset history. >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, and it is >>> > >>>>> backported JDK 8. >>> > >>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>> > >>>> >>> > >>>>> However, this function seems to be called from >>> Thread#setNativeName() >>> > >>>>> only. >>> > >>>>> In addition, Thread#setNativeName() is private method. >>> > >>>>> >>> > >>>>> Thus I think that we can add an argument to >>> JVM_SetNativeThreadName() >>> > >>>>> for force setting. >>> > >>>>> (e.g. "bool forced") >>> > >>>>> >>> > >>>>> It makes a change of JVM API. >>> > >>>>> However, this function is NOT public, so I think we can add one >>> more >>> > >>>>> argument. >>> > >>>>> >>> > >>>>> What do you think about this? >>> > >>>>> If it is accepted, we can set native thread name from Java >>> launcher. >>> > >>>> >>> > >>>> The private/public aspect of the Java API is not really at >>> issue. Yes >>> > >>>> we would add another arg to the JVM function to allow it to apply to >>> > >>>> JNI-attached threads as well (I'd prefer the arg reflect that >>> not just >>> > >>>> "force"). However this is still a change to the exported JVM >>> interface >>> > >>>> and so has to be approved. Further, we expect the launcher to >>> use the >>> > >>>> supported JNI interface (as other processes would), not the internal >>> > >>>> JVM interface that exists for the JDK sources to communicate >>> with the >>> > >>>> JVM. >>> > >>>> >>> > >>>> David >>> > >>>> ----- >>> > >>>> >>> > >>>>> >>> > >>>>> Thanks, >>> > >>>>> >>> > >>>>> Yasumasa >>> > >>>>> >>> > >>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>> > >>>>>> Hi Yasumasa, >>> > >>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>> > >>>>>>> Hi David, >>> > >>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as being a >>> JNI-attached >>> > >>>>>>>> thread seems accidental to me >>> > >>>>>>> >>> > >>>>>>> Should I file it to JBS? >>> > >>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>> > >>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>> thread and >>> > >>>>>> JNI attached threads >>> > >>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by itself as >>> setName >>> > >>>>>> will no longer set the native name for the main thread. >>> > >>>>>> >>> > >>>>>>> I think that we can fix as below: >>> > >>>>>>> --------------- >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 >>> 2016 +0200 >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 >>> 2016 +0900 >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>> > >>>>>>> #endif // INCLUDE_JVMCI >>> > >>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>> > >>>>>>> main_thread->initialize_thread_current(); >>> > >>>>>>> // must do this before set_active_handles >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>> > >>>>>>> // Notify JVMTI agents that VM initialization is complete >>> - nop if >>> > >>>>>>> no agents. >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>> > >>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>> > >>>>>>> + >>> > >>>>>> >>> > >>>>>> I think we can do this straight after the JavaThread constructor. >>> > >>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing >>> > >>>>>>> backend."); >>> > >>>>>>> } >>> > >>>>>>> --------------- >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>>> If it wants to name its native threads then it is free to do so, >>> > >>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native >>> thread name >>> > >>>>>>> when the caller thread is JNI-attached thread. >>> > >>>>>>> However, I think that it should be changed if Java developer >>> calls >>> > >>>>>>> Thread#setName() explicitly. >>> > >>>>>>> It is not the same of changing native thread name at >>> > >>>>>>> Threads::create_vm(). >>> > >>>>>>> >>> > >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as below. >>> > >>>>>>> What do you think about this? >>> > >>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached threads was a >>> > >>>>>> deliberate one** - this functionality originated with the OSX >>> port and >>> > >>>>>> it was reported that the initial feedback with this feature was to >>> > >>>>>> ensure it didn't mess with thread names that had been set by >>> the host >>> > >>>>>> process. If we do as you propose then we will just have an >>> > >>>>>> inconsistency for people to complain about: "why does my >>> native thread >>> > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>> > >>>>>> >>> > >>>>>> ** If you follow the bugs and related discussions on this, the >>> > >>>>>> semantics and limitations (truncation, current thread only, >>> non-JNI >>> > >>>>>> threads only) of setting the native thread name were supposed >>> to be >>> > >>>>>> documented in the release notes - but as far as I can see that >>> never >>> > >>>>>> happened. :( >>> > >>>>>> >>> > >>>>>> My position on this remains that if it is desirable for the main >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names then the >>> > >>>>>> launcher needs to be setting them using the available platform >>> APIs. >>> > >>>>>> Unfortunately this is complicated - as evidenced by the VM >>> code for >>> > >>>>>> this - due to the need to verify API availability. >>> > >>>>>> >>> > >>>>>> Any change in behaviour in relation to Thread.setName would >>> have to go >>> > >>>>>> through our CCC process I think. But a change in the launcher >>> would >>> > >>>>>> not. >>> > >>>>>> >>> > >>>>>> Sorry. >>> > >>>>>> >>> > >>>>>> David >>> > >>>>>> ----- >>> > >>>>>> >>> > >>>>>>> --------------- >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 >>> 2016 +0200 >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 >>> 2016 +0900 >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>> > >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>> > >>>>>>> // Thread naming only supported for the current thread, >>> doesn't >>> > >>>>>>> work >>> > >>>>>>> for >>> > >>>>>>> // target threads. >>> > >>>>>>> - if (Thread::current() == thr && >>> !thr->has_attached_via_jni()) { >>> > >>>>>>> + if (Thread::current() == thr) { >>> > >>>>>>> // we don't set the name of an attached thread to avoid >>> stepping >>> > >>>>>>> // on other programs >>> > >>>>>>> const char *thread_name = >>> > >>>>>>> >>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>> > >>>>>>> --------------- >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> Thanks, >>> > >>>>>>> >>> > >>>>>>> Yasumasa >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>> > >>>>>>>> >>> > >>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>> > >>>>>>>>> Roger, >>> > >>>>>>>>> Thanks for your comment! >>> > >>>>>>>>> >>> > >>>>>>>>> David, >>> > >>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>> > >>>>>>>>>>>> exposing >>> > >>>>>>>>>>>> a new JVM function this way. >>> > >>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after initializing VM (before >>> > >>>>>>>>> calling >>> > >>>>>>>>> main method), >>> > >>>>>>>>> I could set native thread name. >>> > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). So we >>> can't >>> > >>>>>>>>> set >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>> > >>>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier this morning. >>> Which, >>> > >>>>>>>> unfortunately, takes me back to the basic premise here that >>> we don't >>> > >>>>>>>> set the name of threads not created by the JVM. The fact >>> that the >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached thread seems >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only working by >>> > >>>>>>>> accident for the initial attach, and can't be used for the >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>> named at >>> > >>>>>>>> the native level. >>> > >>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has to be >>> treated like >>> > >>>>>>>> any other process that might host a JVM. If it wants to name its >>> > >>>>>>>> native threads then it is free to do so, but I would not be >>> exporting >>> > >>>>>>>> a function from the JVM to do that - it would have to use the OS >>> > >>>>>>>> specific API's for that on a platform-by-platform basis. >>> > >>>>>>>> >>> > >>>>>>>> Sorry. >>> > >>>>>>>> >>> > >>>>>>>> David >>> > >>>>>>>> ----- >>> > >>>>>>>> >>> > >>>>>>>> >>> > >>>>>>>>> >>> > >>>>>>>>> >>> > >>>>>>>>> Thanks, >>> > >>>>>>>>> >>> > >>>>>>>>> Yasumasa >>> > >>>>>>>>> >>> > >>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>> > >>>>>>>>>> Hi, >>> > >>>>>>>>>> >>> > >>>>>>>>>> Comments: >>> > >>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but perform >>> different >>> > >>>>>>>>>> functions: >>> > >>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>> > >>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the current thread, the >>> second >>> > >>>>>>>>>> one a >>> > >>>>>>>>>> specific java thread. >>> > >>>>>>>>>> It would seem useful for there to be a comment somewhere >>> about >>> > >>>>>>>>>> what >>> > >>>>>>>>>> the new function does. >>> > >>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to (void*) >>> > >>>>>>>>>> instead of >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>> > >>>>>>>>>> as is done on unix and mac. >>> > >>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>> > >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >>> used at >>> > >>>>>>>>>> line 730 >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >>> on the >>> > >>>>>>>>>> same >>> > >>>>>>>>>> line as dlsym... >>> > >>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>> > >>>>>>>>>> >>> > >>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>> That is an interesting question which I haven't had time to >>> > >>>>>>>>>>>> check - >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>> thread >>> > >>>>>>>>>>>> then >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>> should >>> > >>>>>>>>>>>> work >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I confirmed >>> native >>> > >>>>>>>>>>> thread name (test) was set. >>> > >>>>>>>>>>> --------- >>> > >>>>>>>>>>> public class Sleep{ >>> > >>>>>>>>>>> public static void main(String[] args) throws Exception{ >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>> > >>>>>>>>>>> Thread.sleep(3600000); >>> > >>>>>>>>>>> } >>> > >>>>>>>>>>> } >>> > >>>>>>>>>>> --------- >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>> > >>>>>>>>>>>> exposing >>> > >>>>>>>>>>>> a new JVM function this way. >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>>> Hi, >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>> > >>>>>>>>>>>>>> Hi, >>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>>>>> Hi David, >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native thread >>> name, and JLI >>> > >>>>>>>>>>>>>>> uses it >>> > >>>>>>>>>>>>>>> in new webrev. >>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>> core-libs will >>> > >>>>>>>>>>>>>> need to >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - now cc'd. >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>> Thread.setName >>> > >>>>>>>>>>>>>> rather >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No hotspot changes >>> > >>>>>>>>>>>>>> needed in >>> > >>>>>>>>>>>>>> that case. >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use Thread#setName() in >>> > >>>>>>>>>>>>> Thread#init(), >>> > >>>>>>>>>>>>> but I could not change native thread name. >>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, which is >>> why the >>> > >>>>>>>>>>>> native >>> > >>>>>>>>>>>> name is not set. >>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't had time to >>> > >>>>>>>>>>>> check - >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>> thread >>> > >>>>>>>>>>>> then >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>> should >>> > >>>>>>>>>>>> work >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our treatment of >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I don't like >>> > >>>>>>>>>>>> exposing >>> > >>>>>>>>>>>> a new JVM function this way. >>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>> > >>>>>>>>>>>> David >>> > >>>>>>>>>>>> ----- >>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a function to set >>> native >>> > >>>>>>>>>>>>> thread name. >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>> > >>>>>>>>>>>>> >>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>> > >>>>>>>>>>>>>> David >>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>> > >>>>>>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have been on >>> > >>>>>>>>>>>>>>>> vacation). >>> > >>>>>>>>>>>>>>>> This >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct as we >>> do not >>> > >>>>>>>>>>>>>>>> set the >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which includes the >>> > >>>>>>>>>>>>>>>> "main" >>> > >>>>>>>>>>>>>>>> thread. >>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>> > >>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>> > >>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >> >: >>> > >>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>> > >>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>> > >>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>> > >>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>> > >>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>> > >>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>> > >>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>: >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa Suenaga wrote: >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>: >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- a/src/share/vm/runtime/thread.cpp Thu >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ b/src/share/vm/runtime/thread.cpp Thu >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>> JavaThread(); >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> main_thread->set_thread_state(_thread_in_vm); >>> > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->initialize_thread_current(); >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>> main_thread->set_native_thread_name("main"); >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>> set_active_handles >>> > >>>>>>>>>>>>>>>>>>>>>> >> > main_thread->record_stack_base_and_size(); >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >>> name in >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or setName(). >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, native >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>> > >>>>>>>>>>>>>>>>>>>>>> name >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >>> starte >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting thrrad name >>> > >>>>>>>>>>>>>>>>>>>>>> should >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then something like >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp Tue >>> Mar 29 >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp Wed >>> Mar 30 >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* initial_thread_name = >>> "main"; >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>> > >>>>>>>>>>>>>>>>>>>>>> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>> > >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>> > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>> thread); >>> > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_priority(thread_oop(), >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>> > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>> > >>>>>>>>>>>>>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>> > >>>>>>>>>>>>>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, thread_oop, >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself 'java' and >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>> > >>>>>>>>>>>>>>>>>>>>>> this >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>> > >>>>>>>>>>>>>>>>>>>>>> just >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process (and >>> thus >>> > >>>>>>>>>>>>>>>>>>>>>> the >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process is not >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>> JavaThread. So I >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>> > >>>>>>>>>>>>>>>>>>>>>> not >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since >>> we want >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>> > >>>>>>>>>>>>>>>>>>>>>> native >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name might >>> have >>> > >>>>>>>>>>>>>>>>>>>>>> some >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like 'Java Main >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>> launcher - e.g. >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread name, >>> I think >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >>> Suenaga wrote: >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread >>> name via >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not have it. >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, and main >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread should have >>> > >>>>>>>>>>>>>>>>>>>>>> native >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you review it? >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>> > >>> From amy.lu at oracle.com Fri Apr 22 04:26:07 2016 From: amy.lu at oracle.com (Amy Lu) Date: Fri, 22 Apr 2016 12:26:07 +0800 Subject: JDK 9 RFR of JDK-8153933: Remove intermittent key from TimeZone/Bug6772689.java and move back to tier1 Message-ID: <5719A7DF.4070105@oracle.com> java/util/TimeZone/Bug6772689.java This test was failing intermittently (JDK-8149898, JDK-8150804). Mentioned issues have been resolved and no open bug (no failure reported) till now. This patch is to remove @key intermittent from the test and move it back to tier1. bug: https://bugs.openjdk.java.net/browse/JDK-8153933 webrev: http://cr.openjdk.java.net/~amlu/8153933/webrev.00/ Thanks, Amy --- old/test/TEST.groups 2016-04-21 15:32:52.000000000 +0800 +++ new/test/TEST.groups 2016-04-21 15:32:52.000000000 +0800 @@ -32,7 +32,6 @@ -java/util/WeakHashMap/GCDuringIteration.java \ -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ - -java/util/TimeZone/Bug6772689.java \ sun/nio/cs/ISO8859x.java \ java/nio/Buffer \ com/sun/crypto/provider/Cipher \ @@ -43,7 +42,6 @@ java/util/WeakHashMap/GCDuringIteration.java \ java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ - java/util/TimeZone/Bug6772689.java \ :jdk_io \ :jdk_nio \ -sun/nio/cs/ISO8859x.java \ --- old/test/java/util/TimeZone/Bug6772689.java 2016-04-21 15:32:53.000000000 +0800 +++ new/test/java/util/TimeZone/Bug6772689.java 2016-04-21 15:32:53.000000000 +0800 @@ -24,7 +24,6 @@ /* * @test * @bug 6772689 - * @key intermittent * @summary Test for standard-to-daylight transitions at midnight: * date stays on the given day. */ From joe.darcy at oracle.com Fri Apr 22 04:57:42 2016 From: joe.darcy at oracle.com (joe darcy) Date: Thu, 21 Apr 2016 21:57:42 -0700 Subject: JDK 9 RFR of JDK-8153933: Remove intermittent key from TimeZone/Bug6772689.java and move back to tier1 In-Reply-To: <5719A7DF.4070105@oracle.com> References: <5719A7DF.4070105@oracle.com> Message-ID: <5719AF46.2020802@oracle.com> Looks fine Amy; thanks, -Joe On 4/21/2016 9:26 PM, Amy Lu wrote: > java/util/TimeZone/Bug6772689.java > > This test was failing intermittently (JDK-8149898, JDK-8150804). > Mentioned issues have been resolved and no open bug (no failure > reported) till now. > > This patch is to remove @key intermittent from the test and move it > back to tier1. > > bug: https://bugs.openjdk.java.net/browse/JDK-8153933 > webrev: http://cr.openjdk.java.net/~amlu/8153933/webrev.00/ > > Thanks, > Amy > > > --- old/test/TEST.groups 2016-04-21 15:32:52.000000000 +0800 > +++ new/test/TEST.groups 2016-04-21 15:32:52.000000000 +0800 > @@ -32,7 +32,6 @@ > -java/util/WeakHashMap/GCDuringIteration.java \ > -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ > -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ > - -java/util/TimeZone/Bug6772689.java \ > sun/nio/cs/ISO8859x.java \ > java/nio/Buffer \ > com/sun/crypto/provider/Cipher \ > @@ -43,7 +42,6 @@ > java/util/WeakHashMap/GCDuringIteration.java \ > java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ > java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ > - java/util/TimeZone/Bug6772689.java \ > :jdk_io \ > :jdk_nio \ > -sun/nio/cs/ISO8859x.java \ > --- old/test/java/util/TimeZone/Bug6772689.java 2016-04-21 > 15:32:53.000000000 +0800 > +++ new/test/java/util/TimeZone/Bug6772689.java 2016-04-21 > 15:32:53.000000000 +0800 > @@ -24,7 +24,6 @@ > /* > * @test > * @bug 6772689 > - * @key intermittent > * @summary Test for standard-to-daylight transitions at midnight: > * date stays on the given day. > */ > > From chris.hegarty at oracle.com Fri Apr 22 05:41:57 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 22 Apr 2016 06:41:57 +0100 Subject: Review request 8154837: Class::getPackage with exploded modules when classes in modules defined to the boot loader In-Reply-To: References: Message-ID: <1BDEB9CB-B383-43C9-990B-EF30475FAB0A@oracle.com> On 21 Apr 2016, at 23:03, Mandy Chung wrote: > Webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154837/webrev.00/ This looks good to me Mandy. -Chris. > The module location from an exploded image is file URL rather than file path. This issue can be reproduced with jdk/test/java/lang/Package/GetPackages.java on windows. > > Mandy > From Alan.Bateman at oracle.com Fri Apr 22 06:31:14 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 22 Apr 2016 07:31:14 +0100 Subject: Review request 8154837: Class::getPackage with exploded modules when classes in modules defined to the boot loader In-Reply-To: References: Message-ID: <5719C532.80800@oracle.com> On 21/04/2016 23:03, Mandy Chung wrote: > Webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154837/webrev.00/ > > The module location from an exploded image is file URL rather than file path. This issue can be reproduced with jdk/test/java/lang/Package/GetPackages.java on windows. This looks okay, maybe slightly better if it starts for "file:/". At some point then I think we need to re-examine the underlying JVM function to see if we can get it to return a file URL for -Xbootclasspath/a case too. That is, it's a bit strange for the function to return a String that is sometimes a URL, sometimes a file path. -Alan From david.holmes at oracle.com Fri Apr 22 06:33:44 2016 From: david.holmes at oracle.com (David Holmes) Date: Fri, 22 Apr 2016 16:33:44 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: References: <56F3F90D.9010408@gmail.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> Message-ID: <5719C5C8.3020705@oracle.com> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: > Hi all, > > I have uploaded webrev.04 as below. > Could you review again? > > > - hotspot: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ Looks fine. > > > > - jdk: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ As per private email (but repeated here on the record) in java.c: 715 if ((*env)->ExceptionOccurred(env)) { 1716 JLI_ReportExceptionDescription(env); 1717 } I don't think we need to report the exception, but can just ignore it. Either way we have to clear the exception before continuing. Thanks, David > Thanks, > > Yasumasa > > 2016/04/19 22:43 "Yasumasa Suenaga" >: > > > > Hi David, > > > > Thank you for your comment. > > I uploaded new webrev. Could you review again? > > > > - hotspot: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ > > > > - jdk: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ > > > > > >> That aside I'm not sure why you do this so late in the process, I > would have done it immediately after here: > > > > > > I think that native thread name ("main") should be set just before > > main method call. > > However, main thread is already started, so I moved it as you suggested. > > > > > >> One thing I dislike about the current structure is that we have to > go from char* to java.lang.String to call setNativeName which then calls > JVM_SetNativeThreadName which converts the j.l.String back to a char* ! > > > > > > SoI proposed to export new JVM function to set native thread name with > > const char *. > > > > > > Thanks, > > > > Yasumasa > > > > > > > > On 2016/04/19 14:04, David Holmes wrote: > >> > >> Hi Yasumasa, > >> > >> Thanks for persevering with this to get it into the current form. > Sorry I haven't been able to do a detailed review until now. > >> > >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: > >>> > >>> Hi Gerard, > >>> > >>> 2016/04/19 3:14 "Gerard Ziemski" > >>> >>: > >>> > > >>> > hi Yasumasa, > >>> > > >>> > Nice work. I have 2 questions: > >>> > > >>> > ======== > >>> > File: java.c > >>> > > >>> > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? > >>> after every single JNI call? In this example instead of NULL_CHECK, > >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? > >>> > >>> It is not critical if we encounter error at JNI function call because > >>> we cannot set native thread name only. > >>> So I think that we do not need to leave from launcher process. > >> > >> > >> I agree we do not need to abort if an exception occurs (and in fact > I don't think an exception is even possible from this code), but we > should ensure any pending exception is cleared before any futher JNI > calls might be made. Note that NULL_CHECK is already used extensively > throughout the launcher code - so if this usage is wrong then it is all > wrong! More on this code below ... > >> > >> Other comments: > >> > >> hotspot/src/share/vm/prims/jvm.cpp > >> > >> Please add a comment to the method now that you removed the internal > comment: > >> > >> // Sets the native thread name for a JavaThread. If specifically > >> // requested JNI-attached threads can also have their native name set; > >> // otherwise we do not modify JNI-attached threads as it may interfere > >> // with the application that created them. > >> > >> --- > >> > >> jdk/src/java.base/share/classes/java/lang/Thread.java > >> > >> Please add the following comments: > >> > >> + // Don't modify JNI-attached threads > >> setNativeName(name, false); > >> > >> + // May be called directly via JNI or reflection (when permitted) to > >> + // allow JNI-attached threads to set their native name > >> private native void setNativeName(String name, boolean > allowAttachedThread); > >> > >> --- > >> > >> jd/src/java.base/share/native/libjli/java.c > >> > >> 328 #define LEAVE() \ > >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ > >> > >> I was going to suggest this be set later, but realized we have to be > attached to do this and that happens inside DestroyJavaVM. :) > >> > >> + /* Set native thread name. */ > >> + SetNativeThreadName(env, "main"); > >> > >> The comment is redundant given the name of the method. That aside > I'm not sure why you do this so late in the process, I would have done > it immediately after here: > >> > >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { > >> 387 JLI_ReportErrorMessage(JVM_ERROR1); > >> 388 exit(1); > >> 389 } > >> + SetNativeThreadName(env, "main"); > >> > >> > >> + /** > >> + * Set native thread name as possible. > >> + */ > >> > >> Other than the as->if change I'm unclear where the "possible" bit > comes into play - why would it not be possible? > >> > >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); > >> 1706 NULL_CHECK(currentThreadID = (*env)->GetStaticMethodID(env, > cls, > >> 1707 "currentThread", > "()Ljava/lang/Thread;")); > >> 1708 NULL_CHECK(currentThread = > (*env)->CallStaticObjectMethod(env, cls, > >> 1709 currentThreadID)); > >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, > >> 1711 "setNativeName", > "(Ljava/lang/String;Z)V")); > >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > >> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, > >> 1714 nameString, JNI_TRUE); > >> > >> As above NULL_CHECK is fine here, but we should check for and clear > any pending exception after CallVoidMethod. > >> > >> One thing I dislike about the current structure is that we have to > go from char* to java.lang.String to call setNativeName which then calls > JVM_SetNativeThreadName which converts the j.l.String back to a char* ! > Overall I wonder about the affect on startup cost. But if there is an > issue we can revisit this. > >> > >> Thanks, > >> David > >> ----- > >> > >> > >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native > thread > >>> name if possible.? not "Set native thread name as possible.?? > >>> > >>> Sorry for my bad English :-) > >>> > >>> Thanks, > >>> > >>> Yasumasa > >>> > >>> > cheers > >>> > > >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga > > >>> >> wrote: > >>> > > > >>> > > Hi David, > >>> > > > >>> > > I uploaded new webrev: > >>> > > > >>> > > - hotspot: > >>> > > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ > >>> > > > >>> > > - jdk: > >>> > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ > >>> > > > >>> > > > >>> > >> it won't work unless you change the semantics of setName so I'm > >>> not sure what you were thinking here. To take advantage of an arg > taking > >>> JVM_SetNativThreadName you would need to call it directly as no Java > >>> code will call it . ??? > >>> > > > >>> > > I added a flag for setting native thread name to JNI-attached > thread. > >>> > > This change can set native thread name if main thread changes to > >>> JNI-attached thread. > >>> > > > >>> > > > >>> > > Thanks, > >>> > > > >>> > > Yasumasa > >>> > > > >>> > > > >>> > > On 2016/04/16 16:11, David Holmes wrote: > >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: > >>> > >>> Hi David, > >>> > >>> > >>> > >>>> That change in behaviour may be a problem, it could be > considered a > >>> > >>>> regression that setName stops setting the native thread > main, even > >>> > >>>> though we never really intended it to work in the first place. > >>> :( Such > >>> > >>>> a change needs to go through CCC. > >>> > >>> > >>> > >>> I understood. > >>> > >>> Can I send CCC request? > >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) > >>> > >> > >>> > >> Sorry you can't file a CCC request, you would need a sponsor for > >>> that. But at this stage I don't think I agree with the proposed change > >>> because of the change in behaviour - there's no way to restore the > >>> "broken" behaviour. > >>> > >> > >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. > >>> > >> > >>> > >> Okay we can do that. > >>> > >> > >>> > >>> > >>> > >>>> Further, we expect the launcher to use the supported JNI > >>> interface (as > >>> > >>>> other processes would), not the internal JVM interface that > >>> exists for > >>> > >>>> the JDK sources to communicate with the JVM. > >>> > >>> > >>> > >>> I think that we do not use JVM interface if we add new method in > >>> > >>> LauncherHelper as below: > >>> > >>> ---------------- > >>> > >>> diff -r f02139a1ac84 > >>> > >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java > >>> > >>> --- > a/src/java.base/share/classes/sun/launcher/LauncherHelper.java > >>> > >>> Wed Apr 13 14:19:30 2016 +0000 > >>> > >>> +++ > b/src/java.base/share/classes/sun/launcher/LauncherHelper.java > >>> > >>> Sat Apr 16 11:25:53 2016 +0900 > >>> > >>> @@ -960,4 +960,8 @@ > >>> > >>> else > >>> > >>> return md.toNameAndVersion() + " (" + loc + ")"; > >>> > >>> } > >>> > >>> + > >>> > >>> + static void setNativeThreadName(String name) { > >>> > >>> + Thread.currentThread().setName(name); > >>> > >>> + } > >>> > >> > >>> > >> You could also make that call via JNI directly, so not sure the > >>> helper adds much here. But it won't work unless you change the > semantics > >>> of setName so I'm not sure what you were thinking here. To take > >>> advantage of an arg taking JVM_SetNativThreadName you would need to > call > >>> it directly as no Java code will call it . ??? > >>> > >> > >>> > >> David > >>> > >> ----- > >>> > >> > >>> > >>> } > >>> > >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c > >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 > 14:19:30 > >>> > >>> 2016 +0000 > >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 > 11:25:53 > >>> > >>> 2016 +0900 > >>> > >>> @@ -125,6 +125,7 @@ > >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); > >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); > >>> > >>> static void ListModules(JNIEnv* env, char *optString); > >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); > >>> > >>> > >>> > >>> static void SetPaths(int argc, char **argv); > >>> > >>> > >>> > >>> @@ -325,6 +326,7 @@ > >>> > >>> * mainThread.isAlive() to work as expected. > >>> > >>> */ > >>> > >>> #define LEAVE() \ > >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ > >>> > >>> do { \ > >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ > >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ > >>> > >>> @@ -488,6 +490,9 @@ > >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); > >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); > >>> > >>> > >>> > >>> + /* Set native thread name. */ > >>> > >>> + SetNativeThreadName(env, "main"); > >>> > >>> + > >>> > >>> /* Invoke main method. */ > >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, > mainArgs); > >>> > >>> > >>> > >>> @@ -1686,6 +1691,22 @@ > >>> > >>> joptString); > >>> > >>> } > >>> > >>> > >>> > >>> +/** > >>> > >>> + * Set native thread name as possible. > >>> > >>> + */ > >>> > >>> +static void > >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) > >>> > >>> +{ > >>> > >>> + jmethodID setNativeThreadNameID; > >>> > >>> + jstring nameString; > >>> > >>> + jclass cls = GetLauncherHelperClass(env); > >>> > >>> + NULL_CHECK(cls); > >>> > >>> + NULL_CHECK(setNativeThreadNameID = > >>> (*env)->GetStaticMethodID(env, cls, > >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); > >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); > >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, > setNativeThreadNameID, > >>> > >>> nameString); > >>> > >>> +} > >>> > >>> + > >>> > >>> /* > >>> > >>> * Prints default usage or the Xusage message, see > >>> > >>> sun.launcher.LauncherHelper.java > >>> > >>> */ > >>> > >>> ---------------- > >>> > >>> > >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). > >>> > >>> > >>> > >>>> However this is still a change to the exported JVM > interface and so > >>> > >>>> has to be approved. > >>> > >>> > >>> > >>> Do you mean that this change needs CCC? > >>> > >>> > >>> > >>> > >>> > >>> Thanks, > >>> > >>> > >>> > >>> Yasumasa > >>> > >>> > >>> > >>> > >>> > >>> [1] > >>> > >>> > >>> > http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> On 2016/04/16 7:26, David Holmes wrote: > >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: > >>> > >>>>> Hi David, > >>> > >>>>> > >>> > >>>>>> I think it is a bug based on the comment here: > >>> > >>>>>> > >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main > >>> thread and > >>> > >>>>>> JNI attached threads > >>> > >>>>> > >>> > >>>>> I filed it to JBS as JDK-8154331. > >>> > >>>>> I will send review request to hotspot-runtime-dev. > >>> > >>>>> > >>> > >>>>> > >>> > >>>>>> Though that will introduce a change in behaviour by itself as > >>> setName > >>> > >>>>>> will no longer set the native name for the main thread. > >>> > >>>>> > >>> > >>>>> I know. > >>> > >>>> > >>> > >>>> That change in behaviour may be a problem, it could be > considered a > >>> > >>>> regression that setName stops setting the native thread > main, even > >>> > >>>> though we never really intended it to work in the first place. > >>> :( Such > >>> > >>>> a change needs to go through CCC. > >>> > >>>> > >>> > >>>>> I checked changeset history. > >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, > and it is > >>> > >>>>> backported JDK 8. > >>> > >>>> > >>> > >>>> Yes this all came in as part of the OSX port in 7u2. > >>> > >>>> > >>> > >>>>> However, this function seems to be called from > >>> Thread#setNativeName() > >>> > >>>>> only. > >>> > >>>>> In addition, Thread#setNativeName() is private method. > >>> > >>>>> > >>> > >>>>> Thus I think that we can add an argument to > >>> JVM_SetNativeThreadName() > >>> > >>>>> for force setting. > >>> > >>>>> (e.g. "bool forced") > >>> > >>>>> > >>> > >>>>> It makes a change of JVM API. > >>> > >>>>> However, this function is NOT public, so I think we can > add one > >>> more > >>> > >>>>> argument. > >>> > >>>>> > >>> > >>>>> What do you think about this? > >>> > >>>>> If it is accepted, we can set native thread name from Java > >>> launcher. > >>> > >>>> > >>> > >>>> The private/public aspect of the Java API is not really at > >>> issue. Yes > >>> > >>>> we would add another arg to the JVM function to allow it to > apply to > >>> > >>>> JNI-attached threads as well (I'd prefer the arg reflect that > >>> not just > >>> > >>>> "force"). However this is still a change to the exported JVM > >>> interface > >>> > >>>> and so has to be approved. Further, we expect the launcher to > >>> use the > >>> > >>>> supported JNI interface (as other processes would), not the > internal > >>> > >>>> JVM interface that exists for the JDK sources to communicate > >>> with the > >>> > >>>> JVM. > >>> > >>>> > >>> > >>>> David > >>> > >>>> ----- > >>> > >>>> > >>> > >>>>> > >>> > >>>>> Thanks, > >>> > >>>>> > >>> > >>>>> Yasumasa > >>> > >>>>> > >>> > >>>>> > >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: > >>> > >>>>>> Hi Yasumasa, > >>> > >>>>>> > >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: > >>> > >>>>>>> Hi David, > >>> > >>>>>>> > >>> > >>>>>>>> The fact that the "main" thread is not tagged as being a > >>> JNI-attached > >>> > >>>>>>>> thread seems accidental to me > >>> > >>>>>>> > >>> > >>>>>>> Should I file it to JBS? > >>> > >>>>>> > >>> > >>>>>> I think it is a bug based on the comment here: > >>> > >>>>>> > >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main > >>> thread and > >>> > >>>>>> JNI attached threads > >>> > >>>>>> > >>> > >>>>>> Though that will introduce a change in behaviour by itself as > >>> setName > >>> > >>>>>> will no longer set the native name for the main thread. > >>> > >>>>>> > >>> > >>>>>>> I think that we can fix as below: > >>> > >>>>>>> --------------- > >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp > >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 > >>> 2016 +0200 > >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 > >>> 2016 +0900 > >>> > >>>>>>> @@ -3592,7 +3592,7 @@ > >>> > >>>>>>> #endif // INCLUDE_JVMCI > >>> > >>>>>>> > >>> > >>>>>>> // Attach the main thread to this os thread > >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); > >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); > >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); > >>> > >>>>>>> main_thread->initialize_thread_current(); > >>> > >>>>>>> // must do this before set_active_handles > >>> > >>>>>>> @@ -3776,6 +3776,9 @@ > >>> > >>>>>>> // Notify JVMTI agents that VM initialization is complete > >>> - nop if > >>> > >>>>>>> no agents. > >>> > >>>>>>> JvmtiExport::post_vm_initialized(); > >>> > >>>>>>> > >>> > >>>>>>> + // Change attach status to "attached" > >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); > >>> > >>>>>>> + > >>> > >>>>>> > >>> > >>>>>> I think we can do this straight after the JavaThread > constructor. > >>> > >>>>>> > >>> > >>>>>>> if (TRACE_START() != JNI_OK) { > >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing > >>> > >>>>>>> backend."); > >>> > >>>>>>> } > >>> > >>>>>>> --------------- > >>> > >>>>>>> > >>> > >>>>>>> > >>> > >>>>>>>> If it wants to name its native threads then it is free > to do so, > >>> > >>>>>>> > >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native > >>> thread name > >>> > >>>>>>> when the caller thread is JNI-attached thread. > >>> > >>>>>>> However, I think that it should be changed if Java developer > >>> calls > >>> > >>>>>>> Thread#setName() explicitly. > >>> > >>>>>>> It is not the same of changing native thread name at > >>> > >>>>>>> Threads::create_vm(). > >>> > >>>>>>> > >>> > >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as > below. > >>> > >>>>>>> What do you think about this? > >>> > >>>>>> > >>> > >>>>>> The decision to not change the name of JNI-attached > threads was a > >>> > >>>>>> deliberate one** - this functionality originated with the OSX > >>> port and > >>> > >>>>>> it was reported that the initial feedback with this > feature was to > >>> > >>>>>> ensure it didn't mess with thread names that had been set by > >>> the host > >>> > >>>>>> process. If we do as you propose then we will just have an > >>> > >>>>>> inconsistency for people to complain about: "why does my > >>> native thread > >>> > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" > >>> > >>>>>> > >>> > >>>>>> ** If you follow the bugs and related discussions on > this, the > >>> > >>>>>> semantics and limitations (truncation, current thread only, > >>> non-JNI > >>> > >>>>>> threads only) of setting the native thread name were supposed > >>> to be > >>> > >>>>>> documented in the release notes - but as far as I can see > that > >>> never > >>> > >>>>>> happened. :( > >>> > >>>>>> > >>> > >>>>>> My position on this remains that if it is desirable for > the main > >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names > then the > >>> > >>>>>> launcher needs to be setting them using the available > platform > >>> APIs. > >>> > >>>>>> Unfortunately this is complicated - as evidenced by the VM > >>> code for > >>> > >>>>>> this - due to the need to verify API availability. > >>> > >>>>>> > >>> > >>>>>> Any change in behaviour in relation to Thread.setName would > >>> have to go > >>> > >>>>>> through our CCC process I think. But a change in the launcher > >>> would > >>> > >>>>>> not. > >>> > >>>>>> > >>> > >>>>>> Sorry. > >>> > >>>>>> > >>> > >>>>>> David > >>> > >>>>>> ----- > >>> > >>>>>> > >>> > >>>>>>> --------------- > >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 > >>> 2016 +0200 > >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 > >>> 2016 +0900 > >>> > >>>>>>> @@ -3187,7 +3187,7 @@ > >>> > >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); > >>> > >>>>>>> // Thread naming only supported for the current thread, > >>> doesn't > >>> > >>>>>>> work > >>> > >>>>>>> for > >>> > >>>>>>> // target threads. > >>> > >>>>>>> - if (Thread::current() == thr && > >>> !thr->has_attached_via_jni()) { > >>> > >>>>>>> + if (Thread::current() == thr) { > >>> > >>>>>>> // we don't set the name of an attached thread to avoid > >>> stepping > >>> > >>>>>>> // on other programs > >>> > >>>>>>> const char *thread_name = > >>> > >>>>>>> > >>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); > >>> > >>>>>>> --------------- > >>> > >>>>>>> > >>> > >>>>>>> > >>> > >>>>>>> Thanks, > >>> > >>>>>>> > >>> > >>>>>>> Yasumasa > >>> > >>>>>>> > >>> > >>>>>>> > >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: > >>> > >>>>>>>> > >>> > >>>>>>>> > >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: > >>> > >>>>>>>>> Roger, > >>> > >>>>>>>>> Thanks for your comment! > >>> > >>>>>>>>> > >>> > >>>>>>>>> David, > >>> > >>>>>>>>> > >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I > don't like > >>> > >>>>>>>>>>>> exposing > >>> > >>>>>>>>>>>> a new JVM function this way. > >>> > >>>>>>>>> > >>> > >>>>>>>>> I tried to call Thread#setName() after initializing VM > (before > >>> > >>>>>>>>> calling > >>> > >>>>>>>>> main method), > >>> > >>>>>>>>> I could set native thread name. > >>> > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). > So we > >>> can't > >>> > >>>>>>>>> set > >>> > >>>>>>>>> native thread name for DestroyJavaVM. > >>> > >>>>>>>> > >>> > >>>>>>>> Right - I came to the same realization earlier this > morning. > >>> Which, > >>> > >>>>>>>> unfortunately, takes me back to the basic premise here that > >>> we don't > >>> > >>>>>>>> set the name of threads not created by the JVM. The fact > >>> that the > >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached > thread seems > >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only > working by > >>> > >>>>>>>> accident for the initial attach, and can't be used for the > >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently > >>> named at > >>> > >>>>>>>> the native level. > >>> > >>>>>>>> > >>> > >>>>>>>> I'm afraid my view here is that the launcher has to be > >>> treated like > >>> > >>>>>>>> any other process that might host a JVM. If it wants to > name its > >>> > >>>>>>>> native threads then it is free to do so, but I would not be > >>> exporting > >>> > >>>>>>>> a function from the JVM to do that - it would have to > use the OS > >>> > >>>>>>>> specific API's for that on a platform-by-platform basis. > >>> > >>>>>>>> > >>> > >>>>>>>> Sorry. > >>> > >>>>>>>> > >>> > >>>>>>>> David > >>> > >>>>>>>> ----- > >>> > >>>>>>>> > >>> > >>>>>>>> > >>> > >>>>>>>>> > >>> > >>>>>>>>> > >>> > >>>>>>>>> Thanks, > >>> > >>>>>>>>> > >>> > >>>>>>>>> Yasumasa > >>> > >>>>>>>>> > >>> > >>>>>>>>> > >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: > >>> > >>>>>>>>>> Hi, > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> Comments: > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> jvm.h: The function names are too similar but perform > >>> different > >>> > >>>>>>>>>> functions: > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> - The first function applies to the current thread, the > >>> second > >>> > >>>>>>>>>> one a > >>> > >>>>>>>>>> specific java thread. > >>> > >>>>>>>>>> It would seem useful for there to be a comment somewhere > >>> about > >>> > >>>>>>>>>> what > >>> > >>>>>>>>>> the new function does. > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to > (void*) > >>> > >>>>>>>>>> instead of > >>> > >>>>>>>>>> (SetNativeThreadName0_t) > >>> > >>>>>>>>>> as is done on unix and mac. > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: > >>> > >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs > >>> used at > >>> > >>>>>>>>>> line 730 > >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast > >>> on the > >>> > >>>>>>>>>> same > >>> > >>>>>>>>>> line as dlsym... > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> $.02, Roger > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> > >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: > >>> > >>>>>>>>>>>> That is an interesting question which I haven't had > time to > >>> > >>>>>>>>>>>> check - > >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached > >>> thread > >>> > >>>>>>>>>>>> then > >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion > >>> should > >>> > >>>>>>>>>>>> work > >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our > treatment of > >>> > >>>>>>>>>>>> JNI-attached threads :( ) > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I > confirmed > >>> native > >>> > >>>>>>>>>>> thread name (test) was set. > >>> > >>>>>>>>>>> --------- > >>> > >>>>>>>>>>> public class Sleep{ > >>> > >>>>>>>>>>> public static void main(String[] args) throws > Exception{ > >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); > >>> > >>>>>>>>>>> Thread.sleep(3600000); > >>> > >>>>>>>>>>> } > >>> > >>>>>>>>>>> } > >>> > >>>>>>>>>>> --------- > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I > don't like > >>> > >>>>>>>>>>>> exposing > >>> > >>>>>>>>>>>> a new JVM function this way. > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> Yasumasa > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> > >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: > >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: > >>> > >>>>>>>>>>>>> Hi, > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: > >>> > >>>>>>>>>>>>>> Hi, > >>> > >>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: > >>> > >>>>>>>>>>>>>>> Hi David, > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> Thanks for your comment. > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native thread > >>> name, and JLI > >>> > >>>>>>>>>>>>>>> uses it > >>> > >>>>>>>>>>>>>>> in new webrev. > >>> > >>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so > >>> core-libs will > >>> > >>>>>>>>>>>>>> need to > >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - > now cc'd. > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> Thanks! > >>> > >>>>>>>>>>>>> I'm waiting to review :-) > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to > >>> Thread.setName > >>> > >>>>>>>>>>>>>> rather > >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No > hotspot changes > >>> > >>>>>>>>>>>>>> needed in > >>> > >>>>>>>>>>>>>> that case. > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use > Thread#setName() in > >>> > >>>>>>>>>>>>> Thread#init(), > >>> > >>>>>>>>>>>>> but I could not change native thread name. > >>> > >>>>>>>>>>>> > >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, which is > >>> why the > >>> > >>>>>>>>>>>> native > >>> > >>>>>>>>>>>> name is not set. > >>> > >>>>>>>>>>>> > >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. > >>> > >>>>>>>>>>>> > >>> > >>>>>>>>>>>> That is an interesting question which I haven't had > time to > >>> > >>>>>>>>>>>> check - > >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached > >>> thread > >>> > >>>>>>>>>>>> then > >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion > >>> should > >>> > >>>>>>>>>>>> work > >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our > treatment of > >>> > >>>>>>>>>>>> JNI-attached threads :( ) > >>> > >>>>>>>>>>>> > >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I > don't like > >>> > >>>>>>>>>>>> exposing > >>> > >>>>>>>>>>>> a new JVM function this way. > >>> > >>>>>>>>>>>> > >>> > >>>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>>> David > >>> > >>>>>>>>>>>> ----- > >>> > >>>>>>>>>>>> > >>> > >>>>>>>>>>>>> Thus I think that we have to provide a function to set > >>> native > >>> > >>>>>>>>>>>>> thread name. > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> Yasumasa > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> [1] > >>> > >>>>>>>>>>>>> > >>> > https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>>>>> David > >>> > >>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> Could you review again? > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> - hotspot: > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> - jdk: > >>> > >>>>>>>>>>>>>>> > >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> Yasumasa > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: > >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... > >>> > >>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, > >>> > >>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have > been on > >>> > >>>>>>>>>>>>>>>> vacation). > >>> > >>>>>>>>>>>>>>>> This > >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct > as we > >>> do not > >>> > >>>>>>>>>>>>>>>> set the > >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which > includes the > >>> > >>>>>>>>>>>>>>>> "main" > >>> > >>>>>>>>>>>>>>>> thread. > >>> > >>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>> David > >>> > >>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: > >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, > >>> > >>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) > >>> > >>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>> Yasumasa > >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" > > >>> >>: > >>> > >>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. > >>> > >>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>> /Robbin > >>> > >>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: > >>> > >>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. > >>> > >>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>> /Robbin > >>> > >>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: > >>> > >>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> Hi, > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. > >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> > >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: > >>> > >>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> Hi, > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga > wrote: > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" > >>> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>>: > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa > Suenaga wrote: > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, > >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>>>: > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 > >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- > a/src/share/vm/runtime/thread.cpp Thu > >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 > >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 > >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ > b/src/share/vm/runtime/thread.cpp Thu > >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 > >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 > >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new > >>> JavaThread(); > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> main_thread->set_thread_state(_thread_in_vm); > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > main_thread->initialize_thread_current(); > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + > >>> main_thread->set_native_thread_name("main"); > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before > >>> set_active_handles > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > main_thread->record_stack_base_and_size(); > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread > >>> name in > >>> > >>>>>>>>>>>>>>>>>>>>>> Thread > >>> > >>>>>>>>>>>>>>>>>>>>>> class. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or > setName(). > >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, > native > >>> > >>>>>>>>>>>>>>>>>>>>>> thread > >>> > >>>>>>>>>>>>>>>>>>>>>> name > >>> > >>>>>>>>>>>>>>>>>>>>>> will be > >>> > >>>>>>>>>>>>>>>>>>>>>> set at > >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already > >>> starte > >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in > >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). > >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting > thrrad name > >>> > >>>>>>>>>>>>>>>>>>>>>> should > >>> > >>>>>>>>>>>>>>>>>>>>>> be the > >>> > >>>>>>>>>>>>>>>>>>>>>> same. > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then > something like > >>> > >>>>>>>>>>>>>>>>>>>>>> this is > >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp > Tue > >>> Mar 29 > >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 > >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 > >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 > >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp > Wed > >>> Mar 30 > >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 > >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 > >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 > >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ > >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread > >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle > >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, > >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* > >>> > >>>>>>>>>>>>>>>>>>>>>> thread, > >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { > >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* > initial_thread_name = > >>> "main"; > >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> true, > >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); > >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = > >>> > >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); > >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ > >>> > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), > >>> thread); > >>> > >>>>>>>>>>>>>>>>>>>>>> > > java_lang_Thread::set_priority(thread_oop(), > >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); > >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); > >>> > >>>>>>>>>>>>>>>>>>>>>> > - > >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = > >>> > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", > >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > >>> > >>>>>>>>>>>>>>>>>>>>>> > + > >>> > >>>>>>>>>>>>>>>>>>>>>> > + > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> thread->set_native_thread_name(initial_thread_name); > >>> > >>>>>>>>>>>>>>>>>>>>>> > + > >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> java_lang_String::create_from_str(initial_thread_name, > >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); > >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, > thread_oop, > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself > 'java' and > >>> > >>>>>>>>>>>>>>>>>>>>>> naming > >>> > >>>>>>>>>>>>>>>>>>>>>> this > >>> > >>>>>>>>>>>>>>>>>>>>>> thread > >>> > >>>>>>>>>>>>>>>>>>>>>> just > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process > (and > >>> thus > >>> > >>>>>>>>>>>>>>>>>>>>>> the > >>> > >>>>>>>>>>>>>>>>>>>>>> process) is > >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process > is not > >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. > >>> > >>>>>>>>>>>>>>>>>>>>>> It is > >>> > >>>>>>>>>>>>>>>>>>>>>> waiting > >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with > >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). > >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for > >>> JavaThread. So I > >>> > >>>>>>>>>>>>>>>>>>>>>> think that > >>> > >>>>>>>>>>>>>>>>>>>>>> we do > >>> > >>>>>>>>>>>>>>>>>>>>>> not > >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since > >>> we want > >>> > >>>>>>>>>>>>>>>>>>>>>> java and > >>> > >>>>>>>>>>>>>>>>>>>>>> native > >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name > might > >>> have > >>> > >>>>>>>>>>>>>>>>>>>>>> some > >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 > >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND > >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java > >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main > >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like > 'Java Main > >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. > >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java > >>> launcher - e.g. > >>> > >>>>>>>>>>>>>>>>>>>>>> Apache > >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread > name, > >>> I think > >>> > >>>>>>>>>>>>>>>>>>>>>> that we > >>> > >>>>>>>>>>>>>>>>>>>>>> have to > >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. > >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> No > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa > >>> Suenaga wrote: > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread > >>> name via > >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not > have it. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, > and main > >>> > >>>>>>>>>>>>>>>>>>>>>> thread is > >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread > should have > >>> > >>>>>>>>>>>>>>>>>>>>>> native > >>> > >>>>>>>>>>>>>>>>>>>>>> thread > >>> > >>>>>>>>>>>>>>>>>>>>>> name. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you > review it? > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > > >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> > >>>>>>>>>> > >>> > > >>> > From amy.lu at oracle.com Fri Apr 22 08:06:52 2016 From: amy.lu at oracle.com (Amy Lu) Date: Fri, 22 Apr 2016 16:06:52 +0800 Subject: JDK 9 RFR of JDK-8154277: JavaDoc warnings in VirtualMachineManager.java and Pool.java Message-ID: <5719DB9C.5040504@oracle.com> Please review this tiny fix for typos in the the documentation of: jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java bug: https://bugs.openjdk.java.net/browse/JDK-8154277 webrev: http://cr.openjdk.java.net/~amlu/8154277/webrev.00/ Thanks, Amy --- old/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java 2016-04-22 15:53:09.000000000 +0800 +++ new/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java 2016-04-22 15:53:09.000000000 +0800 @@ -257,11 +257,11 @@ * delegate to the {@link com.sun.jdi.connect.spi.TransportService#description() * description()} method of the underlying transport service. Both * the AttachingConnector and the ListeningConnector will have two - * Connector {@link com.sun.jdi.connect.Connector$Argument Arguments}. - * A {@link com.sun.jdi.connect.Connector$StringArgument StringArgument} + * Connector {@link com.sun.jdi.connect.Connector.Argument Arguments}. + * A {@link com.sun.jdi.connect.Connector.StringArgument StringArgument} * named {@code address} is the connector argument to specify the * address to attach too, or to listen on. A - * {@link com.sun.jdi.connect.Connector$IntegerArgument IntegerArgument} + * {@link com.sun.jdi.connect.Connector.IntegerArgument IntegerArgument} * named {@code timeout} is the connector argument to specify the * timeout when attaching, or accepting. The timeout connector may be * ignored depending on if the transport service supports an attach --- old/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java 2016-04-22 15:53:10.000000000 +0800 +++ new/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java 2016-04-22 15:53:10.000000000 +0800 @@ -226,7 +226,7 @@ *

    • For jimage content: /{module name}/{package1}/.../{packageN}/{file * name}
    • *
    • For other files (shared lib, launchers, config, ...):/{module name}/ - * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}
    • + * {@literal bin|conf|native}/{dir1}/.../{dirN}/{file name} * */ public static class ModuleData { From Alan.Bateman at oracle.com Fri Apr 22 08:09:42 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 22 Apr 2016 09:09:42 +0100 Subject: JDK 9 RFR of JDK-8154277: JavaDoc warnings in VirtualMachineManager.java and Pool.java In-Reply-To: <5719DB9C.5040504@oracle.com> References: <5719DB9C.5040504@oracle.com> Message-ID: <5719DC46.9000505@oracle.com> On 22/04/2016 09:06, Amy Lu wrote: > Please review this tiny fix for typos in the the documentation of: > > jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java > jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java > > > bug: https://bugs.openjdk.java.net/browse/JDK-8154277 > webrev: http://cr.openjdk.java.net/~amlu/8154277/webrev.00/ > > Thanks, > Amy Looks good. In the case of the jlink API then the javadoc was clean at one point but it seems to have regressed. -Alan From chris.hegarty at oracle.com Fri Apr 22 08:47:54 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 22 Apr 2016 09:47:54 +0100 Subject: RFR [9] 8154919: Remove superfluous jdk.unsupported from tools/launcher/modules/limitmods/LimitModsTest.java Message-ID: <5A9D852C-D3DA-474D-9BC3-5AB8E50638D7@oracle.com> The jdk.unsupported module was added to the LimitModsTest.java test temporally, until the problematic dependency from the java.logging module on the jdk.unsupported module could be resolved. This is now resolved, see 8153158 [1]. It was an oversight of the changes for 8153158 that this test was not updated to remove the, now superfluous, dependency the jdk.unsupported module. diff --git a/test/tools/launcher/modules/limitmods/LimitModsTest.java b/test/tools/launcher/modules/limitmods/LimitModsTest.java --- a/test/tools/launcher/modules/limitmods/LimitModsTest.java +++ b/test/tools/launcher/modules/limitmods/LimitModsTest.java @@ -103,10 +103,10 @@ public void testWithAddMods() throws Exception { int exitValue; - // java -limitmods java.base -addmods java.logging,jdk.unsupported -listmods + // java -limitmods java.base -addmods java.logging -listmods exitValue = executeTestJava("-limitmods", "java.base", "-addmods", - "java.logging,jdk.unsupported", // TODO: add bug No. + "java.logging", "-listmods") .outputTo(System.out) .errorTo(System.out) -Chris. [1] https://bugs.openjdk.java.net/browse/JDK-8153158 From Alan.Bateman at oracle.com Fri Apr 22 09:07:24 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 22 Apr 2016 10:07:24 +0100 Subject: RFR [9] 8154919: Remove superfluous jdk.unsupported from tools/launcher/modules/limitmods/LimitModsTest.java In-Reply-To: <5A9D852C-D3DA-474D-9BC3-5AB8E50638D7@oracle.com> References: <5A9D852C-D3DA-474D-9BC3-5AB8E50638D7@oracle.com> Message-ID: <5719E9CC.8050804@oracle.com> On 22/04/2016 09:47, Chris Hegarty wrote: > The jdk.unsupported module was added to the LimitModsTest.java test > temporally, until the problematic dependency from the java.logging > module on the jdk.unsupported module could be resolved. This is > now resolved, see 8153158 [1]. > > It was an oversight of the changes for 8153158 that this test was not > updated to remove the, now superfluous, dependency the > jdk.unsupported module. > > diff --git a/test/tools/launcher/modules/limitmods/LimitModsTest.java b/test/tools/launcher/modules/limitmods/LimitModsTest.java > --- a/test/tools/launcher/modules/limitmods/LimitModsTest.java > +++ b/test/tools/launcher/modules/limitmods/LimitModsTest.java > @@ -103,10 +103,10 @@ > public void testWithAddMods() throws Exception { > int exitValue; > > - // java -limitmods java.base -addmods java.logging,jdk.unsupported -listmods > + // java -limitmods java.base -addmods java.logging -listmods > exitValue = executeTestJava("-limitmods", "java.base", > "-addmods", > - "java.logging,jdk.unsupported", // TODO: add bug No. > + "java.logging", > This looks okay but would you mind changing it to "-addmods", "java.logging" which I think it how we had it originally. In these tests then there are a list of options + values and it's just a bit easier to read this way. -Alan From markt at apache.org Fri Apr 22 10:03:21 2016 From: markt at apache.org (Mark Thomas) Date: Fri, 22 Apr 2016 11:03:21 +0100 Subject: TCCL memory leak in RMI registry creation In-Reply-To: <571954E5.50004@oracle.com> References: <5715043B.4090901@apache.org> <57164DDA.9070806@Oracle.com> <5718C04D.1080002@apache.org> <5718DB6B.6000103@apache.org> <571954E5.50004@oracle.com> Message-ID: <5719F6E9.9040203@apache.org> On 21/04/2016 23:32, Stuart Marks wrote: > Hi Mark, > > Is it possible to save the reference to the registry that was created by > the call to LocateRegistry.createRegistry()? If so, then it's possible > to shut down that registry by exporting it: > > UnicastRemoteObject.unexportObject(registry, true); > > Adding this to the "RegistryLeak" test program you posted changes its > behavior to print "no leak". (I haven't looked at this too closely, > though, so I may be misinterpreting what's going on.) Excellent. Thank you very much for that. It does indeed work. > It's probably necessary to unexport and maybe also unbind everything > from this registry as well, as Roger had suggested previously. For the record, if the module/application creates the registry, unexporting the registry is sufficient. However, an additional GC cycle is required to clean up the references if unexport and unbind are not called. The good news is that, with the information above, this leak is something that modules/applications can and should do something about. This moves the problem to how to detect when modules/applications fail to clean up an RMI Registry they created. I'd like to be able to provide nice loud error messages when this happens. Open questions are: - How to get a list of RMI registries? - How to determine the TCCL for a registry (held in the ccl field of the associated sun.rmi.transport.Target object) so I can figure out if a module/application created it? The additional GC cycle required if objects in the registry are not unexported has proven problematic in the past. Ideally, I'd like to avoid that. The raises an other question. Given a Registry where you haven't retained a reference to the exported objects, is there any way to unexport those objects? Thanks for all the great pointers provided so far in this thread. I've updated and expanded the demonstration code in the GitHub repo based on the new information. Many thanks, Mark > > s'marks > > On 4/21/16 6:53 AM, Mark Thomas wrote: >> Continuing the previous thread but with a more precise subject. >> >> Calling >> >> LocateRegistry.createRegistry(Registry.REGISTRY_PORT); >> >> is sufficient to pin the Thread Context Class Loader (TCCL) in memory >> with no public API available (that I can find) to remove the reference. >> >> This is a problem for modular environments like Java EE containers that >> can frequently load and unload modules since it will trigger a memory >> leak. I have made a simple Java class that demonstrates this issue >> available on GitHub. [1] >> >> Up to and including Java 8, it is possible to use reflection tricks [2] >> to a) identify these leaks and b) fix them. As of Java 9, these >> reflection tricks will be blocked. >> >> Being able to identify and fix these memory leaks has been extremely >> useful in resolving issues with memory leaks with multiple deployments >> in Java EE environments. >> >> I believe that equivalent functionality needs to be available in Java 9 >> onwards. I have no strong views on what that functionality should look >> like as long as it enables the leaks to be identified and, ideally, >> resolved. >> >> Looking at the source code for sun.rmi.transport.Target, the ccl field >> was added for good reason and needs to be retained. That suggests that >> the solution is likely to involve destroying a currently existing >> registry. While Registry.destroy() (or similar) would be sufficient for >> application developers to do the 'right thing' it would not be >> sufficient for container developers to identify that an application >> running on the container had done the 'wrong thing' and needed to be >> fixed. For that something along these lines would be required: >> >> LocateRegsitry.listRegistries() >> Registry.getThreadContextClassLoader() >> Registry.destroy() >> >> Assuming my analysis is correct, thoughts on the above solution or any >> alternative solution welcome. For example, a way to hack around the Java >> 9 restrictions would be sufficient. >> >> Thanks, >> >> Mark >> >> >> [1] >> https://github.com/markt-asf/memory-leaks/blob/master/src/org/apache/markt/leaks/rmi/RegistryLeak.java >> >> >> [2] >> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?view=annotate#l2214 >> >> From claes.redestad at oracle.com Fri Apr 22 10:09:42 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 22 Apr 2016 12:09:42 +0200 Subject: RFR(S): 8154751: MethodHandles.countedLoop does not accept empty bodies In-Reply-To: <33497A66-1324-437A-B083-1FBAC0E824A4@oracle.com> References: <33497A66-1324-437A-B083-1FBAC0E824A4@oracle.com> Message-ID: <5719F866.1070001@oracle.com> Hi Michael, voidReturn ? zero(void.class) : identity(init.type().returnType()) is used twice, breaking it out to variable would improve readability, possibly performance. Same goes for the subexpression init.type().returnType() which is used three times currently. Otherwise it looks fine to me. Thanks! /Claes On 2016-04-20 15:13, Michael Haupt wrote: > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8154751 > Webrev: http://cr.openjdk.java.net/~mhaupt/8154751/webrev.00/ > > Thanks, > > Michael > From claes.redestad at oracle.com Fri Apr 22 10:13:48 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 22 Apr 2016 12:13:48 +0200 Subject: RFR(S): 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type In-Reply-To: <3CC2ABCD-2F2F-46B7-932E-C7141C7847F8@oracle.com> References: <3CC2ABCD-2F2F-46B7-932E-C7141C7847F8@oracle.com> Message-ID: <5719F95C.2090100@oracle.com> Hi, change looks good. There's a small pre-existing inefficiency in that initit is created unconditionally but only used if iterator == null, thus could be refactored into an if (iterator == null) ... else construct Thanks! /Claes On 2016-04-20 11:25, Michael Haupt wrote: > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8152667 > Webrev: http://cr.openjdk.java.net/~mhaupt/8152667/webrev.00/ > > Thanks, > > Michael > From claes.redestad at oracle.com Fri Apr 22 10:18:35 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 22 Apr 2016 12:18:35 +0200 Subject: RFR(S): 8154754: MethodHandles.countedLoop errors in deriving loop arguments, result type, and local state In-Reply-To: <998EC76A-C30C-4B9C-9D51-7BC958036AB1@oracle.com> References: <998EC76A-C30C-4B9C-9D51-7BC958036AB1@oracle.com> Message-ID: <5719FA7B.5050109@oracle.com> Hi, looks good to me. resultType == void.class ? zero(void.class) : identity(resultType) appears twice and unconditionally used at least once, thus could be profitably extracted to a variable for readability/imaginary performance gain. Thanks! /Claes On 2016-04-20 15:46, Michael Haupt wrote: > Dear all, > > please review this change. It depends on the one about 8154751 posted earlier [1]. > Bug: https://bugs.openjdk.java.net/browse/JDK-8154754 > Webrev: http://cr.openjdk.java.net/~mhaupt/8154754/webrev.00/ > > Thanks, > > Michael > > [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040386.html > From chris.hegarty at oracle.com Fri Apr 22 10:24:39 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 22 Apr 2016 11:24:39 +0100 Subject: RFR [9] 8154919: Remove superfluous jdk.unsupported from tools/launcher/modules/limitmods/LimitModsTest.java In-Reply-To: <5719E9CC.8050804@oracle.com> References: <5A9D852C-D3DA-474D-9BC3-5AB8E50638D7@oracle.com> <5719E9CC.8050804@oracle.com> Message-ID: <585E6C20-E486-4128-8558-BDF9625E0433@oracle.com> n 22 Apr 2016, at 10:07, Alan Bateman wrote: > On 22/04/2016 09:47, Chris Hegarty wrote: >> The jdk.unsupported module was added to the LimitModsTest.java test >> temporally, until the problematic dependency from the java.logging >> module on the jdk.unsupported module could be resolved. This is >> now resolved, see 8153158 [1]. >> >> It was an oversight of the changes for 8153158 that this test was not >> updated to remove the, now superfluous, dependency the >> jdk.unsupported module. >> >> diff --git a/test/tools/launcher/modules/limitmods/LimitModsTest.java b/test/tools/launcher/modules/limitmods/LimitModsTest.java >> --- a/test/tools/launcher/modules/limitmods/LimitModsTest.java >> +++ b/test/tools/launcher/modules/limitmods/LimitModsTest.java >> @@ -103,10 +103,10 @@ >> public void testWithAddMods() throws Exception { >> int exitValue; >> - // java -limitmods java.base -addmods java.logging,jdk.unsupported -listmods >> + // java -limitmods java.base -addmods java.logging -listmods >> exitValue = executeTestJava("-limitmods", "java.base", >> "-addmods", >> - "java.logging,jdk.unsupported", // TODO: add bug No. >> + "java.logging", >> > This looks okay but would you mind changing it to > "-addmods", "java.logging" > > which I think it how we had it originally. In these tests then there are a list of options + values and it's just a bit easier to read this way. Yes, of course. My intention was to restore the file to its original state. I?ll do this before pushing. Thanks. -Chris. From michael.haupt at oracle.com Fri Apr 22 11:37:21 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 22 Apr 2016 13:37:21 +0200 Subject: RFR(S): 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type In-Reply-To: <5719F95C.2090100@oracle.com> References: <3CC2ABCD-2F2F-46B7-932E-C7141C7847F8@oracle.com> <5719F95C.2090100@oracle.com> Message-ID: Hi Claes, thank you - I've applied this simple change and pushed. Best, Michael > Am 22.04.2016 um 12:13 schrieb Claes Redestad : > > Hi, > > change looks good. > > There's a small pre-existing inefficiency in that initit is created unconditionally but only used if iterator == null, thus could be refactored into an if (iterator == null) ... else construct > > Thanks! > > /Claes > > On 2016-04-20 11:25, Michael Haupt wrote: >> Dear all, >> >> please review this change. >> Bug: https://bugs.openjdk.java.net/browse/JDK-8152667 >> Webrev: http://cr.openjdk.java.net/~mhaupt/8152667/webrev.00/ >> >> Thanks, >> >> Michael >> > -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From yasuenag at gmail.com Fri Apr 22 12:11:25 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Fri, 22 Apr 2016 21:11:25 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <5719C5C8.3020705@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FBA618.2020809@oracle.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> Message-ID: <571A14ED.10901@gmail.com> Hi David, > I don't think we need to report the exception, but can just ignore it. Either way we have to clear the exception before continuing. I've fixed it in new webrev: http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ Thanks, Yasumasa On 2016/04/22 15:33, David Holmes wrote: > On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >> Hi all, >> >> I have uploaded webrev.04 as below. >> Could you review again? >> >> > - hotspot: >> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ > > Looks fine. > >> > >> > - jdk: >> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ > > As per private email (but repeated here on the record) in java.c: > > 715 if ((*env)->ExceptionOccurred(env)) { > 1716 JLI_ReportExceptionDescription(env); > 1717 } > > I don't think we need to report the exception, but can just ignore it. Either way we have to clear the exception before continuing. > > Thanks, > David > >> Thanks, >> >> Yasumasa >> >> 2016/04/19 22:43 "Yasumasa Suenaga" > >: >> > >> > Hi David, >> > >> > Thank you for your comment. >> > I uploaded new webrev. Could you review again? >> > >> > - hotspot: >> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >> > >> > - jdk: >> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >> > >> > >> >> That aside I'm not sure why you do this so late in the process, I >> would have done it immediately after here: >> > >> > >> > I think that native thread name ("main") should be set just before >> > main method call. >> > However, main thread is already started, so I moved it as you suggested. >> > >> > >> >> One thing I dislike about the current structure is that we have to >> go from char* to java.lang.String to call setNativeName which then calls >> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >> > >> > >> > SoI proposed to export new JVM function to set native thread name with >> > const char *. >> > >> > >> > Thanks, >> > >> > Yasumasa >> > >> > >> > >> > On 2016/04/19 14:04, David Holmes wrote: >> >> >> >> Hi Yasumasa, >> >> >> >> Thanks for persevering with this to get it into the current form. >> Sorry I haven't been able to do a detailed review until now. >> >> >> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >> >>> >> >>> Hi Gerard, >> >>> >> >>> 2016/04/19 3:14 "Gerard Ziemski" > >> >>> >>: >> >>> > >> >>> > hi Yasumasa, >> >>> > >> >>> > Nice work. I have 2 questions: >> >>> > >> >>> > ======== >> >>> > File: java.c >> >>> > >> >>> > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >> >>> after every single JNI call? In this example instead of NULL_CHECK, >> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >> >>> >> >>> It is not critical if we encounter error at JNI function call because >> >>> we cannot set native thread name only. >> >>> So I think that we do not need to leave from launcher process. >> >> >> >> >> >> I agree we do not need to abort if an exception occurs (and in fact >> I don't think an exception is even possible from this code), but we >> should ensure any pending exception is cleared before any futher JNI >> calls might be made. Note that NULL_CHECK is already used extensively >> throughout the launcher code - so if this usage is wrong then it is all >> wrong! More on this code below ... >> >> >> >> Other comments: >> >> >> >> hotspot/src/share/vm/prims/jvm.cpp >> >> >> >> Please add a comment to the method now that you removed the internal >> comment: >> >> >> >> // Sets the native thread name for a JavaThread. If specifically >> >> // requested JNI-attached threads can also have their native name set; >> >> // otherwise we do not modify JNI-attached threads as it may interfere >> >> // with the application that created them. >> >> >> >> --- >> >> >> >> jdk/src/java.base/share/classes/java/lang/Thread.java >> >> >> >> Please add the following comments: >> >> >> >> + // Don't modify JNI-attached threads >> >> setNativeName(name, false); >> >> >> >> + // May be called directly via JNI or reflection (when permitted) to >> >> + // allow JNI-attached threads to set their native name >> >> private native void setNativeName(String name, boolean >> allowAttachedThread); >> >> >> >> --- >> >> >> >> jd/src/java.base/share/native/libjli/java.c >> >> >> >> 328 #define LEAVE() \ >> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >> >> >> >> I was going to suggest this be set later, but realized we have to be >> attached to do this and that happens inside DestroyJavaVM. :) >> >> >> >> + /* Set native thread name. */ >> >> + SetNativeThreadName(env, "main"); >> >> >> >> The comment is redundant given the name of the method. That aside >> I'm not sure why you do this so late in the process, I would have done >> it immediately after here: >> >> >> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >> >> 388 exit(1); >> >> 389 } >> >> + SetNativeThreadName(env, "main"); >> >> >> >> >> >> + /** >> >> + * Set native thread name as possible. >> >> + */ >> >> >> >> Other than the as->if change I'm unclear where the "possible" bit >> comes into play - why would it not be possible? >> >> >> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >> >> 1706 NULL_CHECK(currentThreadID = (*env)->GetStaticMethodID(env, >> cls, >> >> 1707 "currentThread", >> "()Ljava/lang/Thread;")); >> >> 1708 NULL_CHECK(currentThread = >> (*env)->CallStaticObjectMethod(env, cls, >> >> 1709 currentThreadID)); >> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, >> >> 1711 "setNativeName", >> "(Ljava/lang/String;Z)V")); >> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >> >> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >> >> 1714 nameString, JNI_TRUE); >> >> >> >> As above NULL_CHECK is fine here, but we should check for and clear >> any pending exception after CallVoidMethod. >> >> >> >> One thing I dislike about the current structure is that we have to >> go from char* to java.lang.String to call setNativeName which then calls >> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >> Overall I wonder about the affect on startup cost. But if there is an >> issue we can revisit this. >> >> >> >> Thanks, >> >> David >> >> ----- >> >> >> >> >> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native >> thread >> >>> name if possible.? not "Set native thread name as possible.?? >> >>> >> >>> Sorry for my bad English :-) >> >>> >> >>> Thanks, >> >>> >> >>> Yasumasa >> >>> >> >>> > cheers >> >>> > >> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >> >> >>> >> wrote: >> >>> > > >> >>> > > Hi David, >> >>> > > >> >>> > > I uploaded new webrev: >> >>> > > >> >>> > > - hotspot: >> >>> > > >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >> >>> > > >> >>> > > - jdk: >> >>> > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >> >>> > > >> >>> > > >> >>> > >> it won't work unless you change the semantics of setName so I'm >> >>> not sure what you were thinking here. To take advantage of an arg >> taking >> >>> JVM_SetNativThreadName you would need to call it directly as no Java >> >>> code will call it . ??? >> >>> > > >> >>> > > I added a flag for setting native thread name to JNI-attached >> thread. >> >>> > > This change can set native thread name if main thread changes to >> >>> JNI-attached thread. >> >>> > > >> >>> > > >> >>> > > Thanks, >> >>> > > >> >>> > > Yasumasa >> >>> > > >> >>> > > >> >>> > > On 2016/04/16 16:11, David Holmes wrote: >> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >> >>> > >>> Hi David, >> >>> > >>> >> >>> > >>>> That change in behaviour may be a problem, it could be >> considered a >> >>> > >>>> regression that setName stops setting the native thread >> main, even >> >>> > >>>> though we never really intended it to work in the first place. >> >>> :( Such >> >>> > >>>> a change needs to go through CCC. >> >>> > >>> >> >>> > >>> I understood. >> >>> > >>> Can I send CCC request? >> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >> >>> > >> >> >>> > >> Sorry you can't file a CCC request, you would need a sponsor for >> >>> that. But at this stage I don't think I agree with the proposed change >> >>> because of the change in behaviour - there's no way to restore the >> >>> "broken" behaviour. >> >>> > >> >> >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. >> >>> > >> >> >>> > >> Okay we can do that. >> >>> > >> >> >>> > >>> >> >>> > >>>> Further, we expect the launcher to use the supported JNI >> >>> interface (as >> >>> > >>>> other processes would), not the internal JVM interface that >> >>> exists for >> >>> > >>>> the JDK sources to communicate with the JVM. >> >>> > >>> >> >>> > >>> I think that we do not use JVM interface if we add new method in >> >>> > >>> LauncherHelper as below: >> >>> > >>> ---------------- >> >>> > >>> diff -r f02139a1ac84 >> >>> > >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >> >>> > >>> --- >> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >> >>> > >>> +++ >> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >> >>> > >>> @@ -960,4 +960,8 @@ >> >>> > >>> else >> >>> > >>> return md.toNameAndVersion() + " (" + loc + ")"; >> >>> > >>> } >> >>> > >>> + >> >>> > >>> + static void setNativeThreadName(String name) { >> >>> > >>> + Thread.currentThread().setName(name); >> >>> > >>> + } >> >>> > >> >> >>> > >> You could also make that call via JNI directly, so not sure the >> >>> helper adds much here. But it won't work unless you change the >> semantics >> >>> of setName so I'm not sure what you were thinking here. To take >> >>> advantage of an arg taking JVM_SetNativThreadName you would need to >> call >> >>> it directly as no Java code will call it . ??? >> >>> > >> >> >>> > >> David >> >>> > >> ----- >> >>> > >> >> >>> > >>> } >> >>> > >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 >> 14:19:30 >> >>> > >>> 2016 +0000 >> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 >> 11:25:53 >> >>> > >>> 2016 +0900 >> >>> > >>> @@ -125,6 +125,7 @@ >> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >> >>> > >>> >> >>> > >>> static void SetPaths(int argc, char **argv); >> >>> > >>> >> >>> > >>> @@ -325,6 +326,7 @@ >> >>> > >>> * mainThread.isAlive() to work as expected. >> >>> > >>> */ >> >>> > >>> #define LEAVE() \ >> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >> >>> > >>> do { \ >> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >> >>> > >>> @@ -488,6 +490,9 @@ >> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >> >>> > >>> >> >>> > >>> + /* Set native thread name. */ >> >>> > >>> + SetNativeThreadName(env, "main"); >> >>> > >>> + >> >>> > >>> /* Invoke main method. */ >> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >> mainArgs); >> >>> > >>> >> >>> > >>> @@ -1686,6 +1691,22 @@ >> >>> > >>> joptString); >> >>> > >>> } >> >>> > >>> >> >>> > >>> +/** >> >>> > >>> + * Set native thread name as possible. >> >>> > >>> + */ >> >>> > >>> +static void >> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >> >>> > >>> +{ >> >>> > >>> + jmethodID setNativeThreadNameID; >> >>> > >>> + jstring nameString; >> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >> >>> > >>> + NULL_CHECK(cls); >> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >> >>> (*env)->GetStaticMethodID(env, cls, >> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >> setNativeThreadNameID, >> >>> > >>> nameString); >> >>> > >>> +} >> >>> > >>> + >> >>> > >>> /* >> >>> > >>> * Prints default usage or the Xusage message, see >> >>> > >>> sun.launcher.LauncherHelper.java >> >>> > >>> */ >> >>> > >>> ---------------- >> >>> > >>> >> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >> >>> > >>> >> >>> > >>>> However this is still a change to the exported JVM >> interface and so >> >>> > >>>> has to be approved. >> >>> > >>> >> >>> > >>> Do you mean that this change needs CCC? >> >>> > >>> >> >>> > >>> >> >>> > >>> Thanks, >> >>> > >>> >> >>> > >>> Yasumasa >> >>> > >>> >> >>> > >>> >> >>> > >>> [1] >> >>> > >>> >> >>> >> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >> >>> > >>>>> Hi David, >> >>> > >>>>> >> >>> > >>>>>> I think it is a bug based on the comment here: >> >>> > >>>>>> >> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >> >>> thread and >> >>> > >>>>>> JNI attached threads >> >>> > >>>>> >> >>> > >>>>> I filed it to JBS as JDK-8154331. >> >>> > >>>>> I will send review request to hotspot-runtime-dev. >> >>> > >>>>> >> >>> > >>>>> >> >>> > >>>>>> Though that will introduce a change in behaviour by itself as >> >>> setName >> >>> > >>>>>> will no longer set the native name for the main thread. >> >>> > >>>>> >> >>> > >>>>> I know. >> >>> > >>>> >> >>> > >>>> That change in behaviour may be a problem, it could be >> considered a >> >>> > >>>> regression that setName stops setting the native thread >> main, even >> >>> > >>>> though we never really intended it to work in the first place. >> >>> :( Such >> >>> > >>>> a change needs to go through CCC. >> >>> > >>>> >> >>> > >>>>> I checked changeset history. >> >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, >> and it is >> >>> > >>>>> backported JDK 8. >> >>> > >>>> >> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >> >>> > >>>> >> >>> > >>>>> However, this function seems to be called from >> >>> Thread#setNativeName() >> >>> > >>>>> only. >> >>> > >>>>> In addition, Thread#setNativeName() is private method. >> >>> > >>>>> >> >>> > >>>>> Thus I think that we can add an argument to >> >>> JVM_SetNativeThreadName() >> >>> > >>>>> for force setting. >> >>> > >>>>> (e.g. "bool forced") >> >>> > >>>>> >> >>> > >>>>> It makes a change of JVM API. >> >>> > >>>>> However, this function is NOT public, so I think we can >> add one >> >>> more >> >>> > >>>>> argument. >> >>> > >>>>> >> >>> > >>>>> What do you think about this? >> >>> > >>>>> If it is accepted, we can set native thread name from Java >> >>> launcher. >> >>> > >>>> >> >>> > >>>> The private/public aspect of the Java API is not really at >> >>> issue. Yes >> >>> > >>>> we would add another arg to the JVM function to allow it to >> apply to >> >>> > >>>> JNI-attached threads as well (I'd prefer the arg reflect that >> >>> not just >> >>> > >>>> "force"). However this is still a change to the exported JVM >> >>> interface >> >>> > >>>> and so has to be approved. Further, we expect the launcher to >> >>> use the >> >>> > >>>> supported JNI interface (as other processes would), not the >> internal >> >>> > >>>> JVM interface that exists for the JDK sources to communicate >> >>> with the >> >>> > >>>> JVM. >> >>> > >>>> >> >>> > >>>> David >> >>> > >>>> ----- >> >>> > >>>> >> >>> > >>>>> >> >>> > >>>>> Thanks, >> >>> > >>>>> >> >>> > >>>>> Yasumasa >> >>> > >>>>> >> >>> > >>>>> >> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >> >>> > >>>>>> Hi Yasumasa, >> >>> > >>>>>> >> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >> >>> > >>>>>>> Hi David, >> >>> > >>>>>>> >> >>> > >>>>>>>> The fact that the "main" thread is not tagged as being a >> >>> JNI-attached >> >>> > >>>>>>>> thread seems accidental to me >> >>> > >>>>>>> >> >>> > >>>>>>> Should I file it to JBS? >> >>> > >>>>>> >> >>> > >>>>>> I think it is a bug based on the comment here: >> >>> > >>>>>> >> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >> >>> thread and >> >>> > >>>>>> JNI attached threads >> >>> > >>>>>> >> >>> > >>>>>> Though that will introduce a change in behaviour by itself as >> >>> setName >> >>> > >>>>>> will no longer set the native name for the main thread. >> >>> > >>>>>> >> >>> > >>>>>>> I think that we can fix as below: >> >>> > >>>>>>> --------------- >> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 >> >>> 2016 +0200 >> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 >> >>> 2016 +0900 >> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >> >>> > >>>>>>> #endif // INCLUDE_JVMCI >> >>> > >>>>>>> >> >>> > >>>>>>> // Attach the main thread to this os thread >> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >> >>> > >>>>>>> main_thread->initialize_thread_current(); >> >>> > >>>>>>> // must do this before set_active_handles >> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >> >>> > >>>>>>> // Notify JVMTI agents that VM initialization is complete >> >>> - nop if >> >>> > >>>>>>> no agents. >> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >> >>> > >>>>>>> >> >>> > >>>>>>> + // Change attach status to "attached" >> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >> >>> > >>>>>>> + >> >>> > >>>>>> >> >>> > >>>>>> I think we can do this straight after the JavaThread >> constructor. >> >>> > >>>>>> >> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >> >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing >> >>> > >>>>>>> backend."); >> >>> > >>>>>>> } >> >>> > >>>>>>> --------------- >> >>> > >>>>>>> >> >>> > >>>>>>> >> >>> > >>>>>>>> If it wants to name its native threads then it is free >> to do so, >> >>> > >>>>>>> >> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native >> >>> thread name >> >>> > >>>>>>> when the caller thread is JNI-attached thread. >> >>> > >>>>>>> However, I think that it should be changed if Java developer >> >>> calls >> >>> > >>>>>>> Thread#setName() explicitly. >> >>> > >>>>>>> It is not the same of changing native thread name at >> >>> > >>>>>>> Threads::create_vm(). >> >>> > >>>>>>> >> >>> > >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as >> below. >> >>> > >>>>>>> What do you think about this? >> >>> > >>>>>> >> >>> > >>>>>> The decision to not change the name of JNI-attached >> threads was a >> >>> > >>>>>> deliberate one** - this functionality originated with the OSX >> >>> port and >> >>> > >>>>>> it was reported that the initial feedback with this >> feature was to >> >>> > >>>>>> ensure it didn't mess with thread names that had been set by >> >>> the host >> >>> > >>>>>> process. If we do as you propose then we will just have an >> >>> > >>>>>> inconsistency for people to complain about: "why does my >> >>> native thread >> >>> > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >> >>> > >>>>>> >> >>> > >>>>>> ** If you follow the bugs and related discussions on >> this, the >> >>> > >>>>>> semantics and limitations (truncation, current thread only, >> >>> non-JNI >> >>> > >>>>>> threads only) of setting the native thread name were supposed >> >>> to be >> >>> > >>>>>> documented in the release notes - but as far as I can see >> that >> >>> never >> >>> > >>>>>> happened. :( >> >>> > >>>>>> >> >>> > >>>>>> My position on this remains that if it is desirable for >> the main >> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names >> then the >> >>> > >>>>>> launcher needs to be setting them using the available >> platform >> >>> APIs. >> >>> > >>>>>> Unfortunately this is complicated - as evidenced by the VM >> >>> code for >> >>> > >>>>>> this - due to the need to verify API availability. >> >>> > >>>>>> >> >>> > >>>>>> Any change in behaviour in relation to Thread.setName would >> >>> have to go >> >>> > >>>>>> through our CCC process I think. But a change in the launcher >> >>> would >> >>> > >>>>>> not. >> >>> > >>>>>> >> >>> > >>>>>> Sorry. >> >>> > >>>>>> >> >>> > >>>>>> David >> >>> > >>>>>> ----- >> >>> > >>>>>> >> >>> > >>>>>>> --------------- >> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 >> >>> 2016 +0200 >> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 >> >>> 2016 +0900 >> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >> >>> > >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >> >>> > >>>>>>> // Thread naming only supported for the current thread, >> >>> doesn't >> >>> > >>>>>>> work >> >>> > >>>>>>> for >> >>> > >>>>>>> // target threads. >> >>> > >>>>>>> - if (Thread::current() == thr && >> >>> !thr->has_attached_via_jni()) { >> >>> > >>>>>>> + if (Thread::current() == thr) { >> >>> > >>>>>>> // we don't set the name of an attached thread to avoid >> >>> stepping >> >>> > >>>>>>> // on other programs >> >>> > >>>>>>> const char *thread_name = >> >>> > >>>>>>> >> >>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >> >>> > >>>>>>> --------------- >> >>> > >>>>>>> >> >>> > >>>>>>> >> >>> > >>>>>>> Thanks, >> >>> > >>>>>>> >> >>> > >>>>>>> Yasumasa >> >>> > >>>>>>> >> >>> > >>>>>>> >> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >> >>> > >>>>>>>> >> >>> > >>>>>>>> >> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >> >>> > >>>>>>>>> Roger, >> >>> > >>>>>>>>> Thanks for your comment! >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> David, >> >>> > >>>>>>>>> >> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >> don't like >> >>> > >>>>>>>>>>>> exposing >> >>> > >>>>>>>>>>>> a new JVM function this way. >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> I tried to call Thread#setName() after initializing VM >> (before >> >>> > >>>>>>>>> calling >> >>> > >>>>>>>>> main method), >> >>> > >>>>>>>>> I could set native thread name. >> >>> > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). >> So we >> >>> can't >> >>> > >>>>>>>>> set >> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >> >>> > >>>>>>>> >> >>> > >>>>>>>> Right - I came to the same realization earlier this >> morning. >> >>> Which, >> >>> > >>>>>>>> unfortunately, takes me back to the basic premise here that >> >>> we don't >> >>> > >>>>>>>> set the name of threads not created by the JVM. The fact >> >>> that the >> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >> thread seems >> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only >> working by >> >>> > >>>>>>>> accident for the initial attach, and can't be used for the >> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >> >>> named at >> >>> > >>>>>>>> the native level. >> >>> > >>>>>>>> >> >>> > >>>>>>>> I'm afraid my view here is that the launcher has to be >> >>> treated like >> >>> > >>>>>>>> any other process that might host a JVM. If it wants to >> name its >> >>> > >>>>>>>> native threads then it is free to do so, but I would not be >> >>> exporting >> >>> > >>>>>>>> a function from the JVM to do that - it would have to >> use the OS >> >>> > >>>>>>>> specific API's for that on a platform-by-platform basis. >> >>> > >>>>>>>> >> >>> > >>>>>>>> Sorry. >> >>> > >>>>>>>> >> >>> > >>>>>>>> David >> >>> > >>>>>>>> ----- >> >>> > >>>>>>>> >> >>> > >>>>>>>> >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> Thanks, >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> Yasumasa >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> >> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >> >>> > >>>>>>>>>> Hi, >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> Comments: >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> jvm.h: The function names are too similar but perform >> >>> different >> >>> > >>>>>>>>>> functions: >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> - The first function applies to the current thread, the >> >>> second >> >>> > >>>>>>>>>> one a >> >>> > >>>>>>>>>> specific java thread. >> >>> > >>>>>>>>>> It would seem useful for there to be a comment somewhere >> >>> about >> >>> > >>>>>>>>>> what >> >>> > >>>>>>>>>> the new function does. >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to >> (void*) >> >>> > >>>>>>>>>> instead of >> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >> >>> > >>>>>>>>>> as is done on unix and mac. >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >> >>> > >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >> >>> used at >> >>> > >>>>>>>>>> line 730 >> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >> >>> on the >> >>> > >>>>>>>>>> same >> >>> > >>>>>>>>>> line as dlsym... >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> $.02, Roger >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> >> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >> >>> > >>>>>>>>>>>> That is an interesting question which I haven't had >> time to >> >>> > >>>>>>>>>>>> check - >> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >> >>> thread >> >>> > >>>>>>>>>>>> then >> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >> >>> should >> >>> > >>>>>>>>>>>> work >> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >> treatment of >> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >> confirmed >> >>> native >> >>> > >>>>>>>>>>> thread name (test) was set. >> >>> > >>>>>>>>>>> --------- >> >>> > >>>>>>>>>>> public class Sleep{ >> >>> > >>>>>>>>>>> public static void main(String[] args) throws >> Exception{ >> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >> >>> > >>>>>>>>>>> Thread.sleep(3600000); >> >>> > >>>>>>>>>>> } >> >>> > >>>>>>>>>>> } >> >>> > >>>>>>>>>>> --------- >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >> don't like >> >>> > >>>>>>>>>>>> exposing >> >>> > >>>>>>>>>>>> a new JVM function this way. >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> Yasumasa >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> >> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >> >>> > >>>>>>>>>>>>> Hi, >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >> >>> > >>>>>>>>>>>>>> Hi, >> >>> > >>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >> >>> > >>>>>>>>>>>>>>> Hi David, >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native thread >> >>> name, and JLI >> >>> > >>>>>>>>>>>>>>> uses it >> >>> > >>>>>>>>>>>>>>> in new webrev. >> >>> > >>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >> >>> core-libs will >> >>> > >>>>>>>>>>>>>> need to >> >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - >> now cc'd. >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> Thanks! >> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >> >>> Thread.setName >> >>> > >>>>>>>>>>>>>> rather >> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >> hotspot changes >> >>> > >>>>>>>>>>>>>> needed in >> >>> > >>>>>>>>>>>>>> that case. >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >> Thread#setName() in >> >>> > >>>>>>>>>>>>> Thread#init(), >> >>> > >>>>>>>>>>>>> but I could not change native thread name. >> >>> > >>>>>>>>>>>> >> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, which is >> >>> why the >> >>> > >>>>>>>>>>>> native >> >>> > >>>>>>>>>>>> name is not set. >> >>> > >>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >> >>> > >>>>>>>>>>>> >> >>> > >>>>>>>>>>>> That is an interesting question which I haven't had >> time to >> >>> > >>>>>>>>>>>> check - >> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >> >>> thread >> >>> > >>>>>>>>>>>> then >> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >> >>> should >> >>> > >>>>>>>>>>>> work >> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >> treatment of >> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >> >>> > >>>>>>>>>>>> >> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >> don't like >> >>> > >>>>>>>>>>>> exposing >> >>> > >>>>>>>>>>>> a new JVM function this way. >> >>> > >>>>>>>>>>>> >> >>> > >>>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>>> David >> >>> > >>>>>>>>>>>> ----- >> >>> > >>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a function to set >> >>> native >> >>> > >>>>>>>>>>>>> thread name. >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> Yasumasa >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> [1] >> >>> > >>>>>>>>>>>>> >> >>> >> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>>>>> David >> >>> > >>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> Could you review again? >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> - hotspot: >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> - jdk: >> >>> > >>>>>>>>>>>>>>> >> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> Yasumasa >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >> >>> > >>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >> >>> > >>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have >> been on >> >>> > >>>>>>>>>>>>>>>> vacation). >> >>> > >>>>>>>>>>>>>>>> This >> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct >> as we >> >>> do not >> >>> > >>>>>>>>>>>>>>>> set the >> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >> includes the >> >>> > >>>>>>>>>>>>>>>> "main" >> >>> > >>>>>>>>>>>>>>>> thread. >> >>> > >>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>> David >> >>> > >>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >> >>> > >>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >> >>> > >>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>> Yasumasa >> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >> >> >>> >>: >> >>> > >>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >> >>> > >>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>> /Robbin >> >>> > >>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >> >>> > >>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >> >>> > >>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >> >>> > >>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >> >>> > >>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >> >>> > >>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga >> wrote: >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >> >>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> >>>: >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >> Suenaga wrote: >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> >>>>: >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >> a/src/share/vm/runtime/thread.cpp Thu >> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >> b/src/share/vm/runtime/thread.cpp Thu >> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >> >>> JavaThread(); >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> main_thread->set_thread_state(_thread_in_vm); >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> main_thread->initialize_thread_current(); >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >> >>> main_thread->set_native_thread_name("main"); >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >> >>> set_active_handles >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> main_thread->record_stack_base_and_size(); >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >> >>> name in >> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >> setName(). >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, >> native >> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >> >>> > >>>>>>>>>>>>>>>>>>>>>> name >> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >> >>> starte >> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >> thrrad name >> >>> > >>>>>>>>>>>>>>>>>>>>>> should >> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >> something like >> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp >> Tue >> >>> Mar 29 >> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp >> Wed >> >>> Mar 30 >> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >> initial_thread_name = >> >>> "main"; >> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >> >>> > >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >> >>> > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >> >>> thread); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> java_lang_Thread::set_priority(thread_oop(), >> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >> >>> > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> thread->set_native_thread_name(initial_thread_name); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> java_lang_String::create_from_str(initial_thread_name, >> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >> thread_oop, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself >> 'java' and >> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >> >>> > >>>>>>>>>>>>>>>>>>>>>> this >> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >> >>> > >>>>>>>>>>>>>>>>>>>>>> just >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process >> (and >> >>> thus >> >>> > >>>>>>>>>>>>>>>>>>>>>> the >> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process >> is not >> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >> >>> JavaThread. So I >> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >> >>> > >>>>>>>>>>>>>>>>>>>>>> not >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since >> >>> we want >> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >> >>> > >>>>>>>>>>>>>>>>>>>>>> native >> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name >> might >> >>> have >> >>> > >>>>>>>>>>>>>>>>>>>>>> some >> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like >> 'Java Main >> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >> >>> launcher - e.g. >> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread >> name, >> >>> I think >> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> No >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >> >>> Suenaga wrote: >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread >> >>> name via >> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >> have it. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, >> and main >> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >> should have >> >>> > >>>>>>>>>>>>>>>>>>>>>> native >> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you >> review it? >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> > >>>>>>>>>> >> >>> > >> >>> >> From paul.sandoz at oracle.com Fri Apr 22 12:39:26 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 22 Apr 2016 14:39:26 +0200 Subject: Multi-Release JAR runtime support In-Reply-To: <20160419171125.134877943eggemoggin.niobe.net> References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> <4040113.8uvnzoatIK@herve-desktop> <20160419171125.134877943eggemoggin.niobe.net> Message-ID: > On 20 Apr 2016, at 02:11, mark.reinhold at oracle.com wrote: > > 2016/4/19 12:37:41 -0700, Herv? BOUTEMY : >> that's it: I added this Multi-Release: true attribute configuration in the >> demo and now it works like a charm, thank you >> >> Perhaps this requirement should be described in >> http://openjdk.java.net/jeps/238 > > Yes -- that was certainly non-obvious! > > Steve, could you please add this to the JEP? (A JEP should, in general, > contain and/or refer to enough information for an experienced developer > to get started using the feature.) > The description is updated: https://bugs.openjdk.java.net/browse/JDK-8047305 including two new sections on compatibility and resource URLs. Paul. From michael.haupt at oracle.com Fri Apr 22 12:40:26 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 22 Apr 2016 14:40:26 +0200 Subject: RFR(S): 8154751: MethodHandles.countedLoop does not accept empty bodies In-Reply-To: <5719F866.1070001@oracle.com> References: <33497A66-1324-437A-B083-1FBAC0E824A4@oracle.com> <5719F866.1070001@oracle.com> Message-ID: <45D7DE1D-B684-419A-BC81-1CC41362949C@oracle.com> Hi Claes, thank you. I've applied the refactoring - see http://cr.openjdk.java.net/~mhaupt/8154751/webrev.01/ for an update. Best, Michael > Am 22.04.2016 um 12:09 schrieb Claes Redestad : > > Hi Michael, > > voidReturn ? zero(void.class) : identity(init.type().returnType()) is used twice, breaking it out to variable would improve readability, possibly performance. Same goes for the subexpression init.type().returnType() which is used three times currently. > > Otherwise it looks fine to me. > > Thanks! > > /Claes > > On 2016-04-20 15:13, Michael Haupt wrote: >> Dear all, >> >> please review this change. >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154751 >> Webrev: http://cr.openjdk.java.net/~mhaupt/8154751/webrev.00/ >> >> Thanks, >> >> Michael >> > -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From michael.haupt at oracle.com Fri Apr 22 12:41:14 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Fri, 22 Apr 2016 14:41:14 +0200 Subject: RFR(S): 8154754: MethodHandles.countedLoop errors in deriving loop arguments, result type, and local state In-Reply-To: <5719FA7B.5050109@oracle.com> References: <998EC76A-C30C-4B9C-9D51-7BC958036AB1@oracle.com> <5719FA7B.5050109@oracle.com> Message-ID: <191ED063-D1A6-434F-B64A-C94ED24CA173@oracle.com> Hi Claes, thanks for this one as well; see http://cr.openjdk.java.net/~mhaupt/8154754/webrev.01/ for an updated webrev. This patch still depends on the one for 8154751. Best, Michael > Am 22.04.2016 um 12:18 schrieb Claes Redestad : > > Hi, > > looks good to me. resultType == void.class ? zero(void.class) : identity(resultType) appears twice and unconditionally used at least once, thus could be profitably extracted to a variable for readability/imaginary performance gain. Thanks! /Claes > > On 2016-04-20 15:46, Michael Haupt wrote: >> Dear all, >> >> please review this change. It depends on the one about 8154751 posted earlier [1]. >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154754 >> Webrev: http://cr.openjdk.java.net/~mhaupt/8154754/webrev.00/ >> >> Thanks, >> >> Michael >> >> [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040386.html >> > -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From claes.redestad at oracle.com Fri Apr 22 13:05:07 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 22 Apr 2016 15:05:07 +0200 Subject: RFR(S): 8154754: MethodHandles.countedLoop errors in deriving loop arguments, result type, and local state In-Reply-To: <191ED063-D1A6-434F-B64A-C94ED24CA173@oracle.com> References: <998EC76A-C30C-4B9C-9D51-7BC958036AB1@oracle.com> <5719FA7B.5050109@oracle.com> <191ED063-D1A6-434F-B64A-C94ED24CA173@oracle.com> Message-ID: <571A2183.6000005@oracle.com> Hi Michael, thanks for simplifying and cleaning things up. With both patches applied the code looks good to me. /Claes On 2016-04-22 14:41, Michael Haupt wrote: > Hi Claes, > > thanks for this one as well; see http://cr.openjdk.java.net/~mhaupt/8154754/webrev.01/ for an updated webrev. This patch still depends on the one for 8154751. > > Best, > > Michael > >> Am 22.04.2016 um 12:18 schrieb Claes Redestad : >> >> Hi, >> >> looks good to me. resultType == void.class ? zero(void.class) : identity(resultType) appears twice and unconditionally used at least once, thus could be profitably extracted to a variable for readability/imaginary performance gain. Thanks! /Claes >> >> On 2016-04-20 15:46, Michael Haupt wrote: >>> Dear all, >>> >>> please review this change. It depends on the one about 8154751 posted earlier [1]. >>> Bug: https://bugs.openjdk.java.net/browse/JDK-8154754 >>> Webrev: http://cr.openjdk.java.net/~mhaupt/8154754/webrev.00/ >>> >>> Thanks, >>> >>> Michael >>> >>> [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040386.html >>> From kumar.x.srinivasan at oracle.com Fri Apr 22 14:41:34 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Fri, 22 Apr 2016 07:41:34 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571A14ED.10901@gmail.com> References: <56F3F90D.9010408@gmail.com> <56FBD8F7.3020909@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> Message-ID: <571A381E.9050605@oracle.com> Hi, This is in the wrong place: 1715 if ((*env)->ExceptionOccurred(env)) { 1716 /* 1717 * We can clear pending exception because exception at this point 1718 * is not critical. 1719 */ 1720 (*env)->ExceptionClear(env); 1721 } This above needs to be after 391 SetNativeThreadName(env, "main"); 392 Here is why, supposing 1704 through 1711, returns a NULL, but have also encountered an exception. In which case the method SetNativeThreadName will return to the caller, as if nothing has happened, because NULL_CHECK simply checks for NULL and returns to the caller. This will cause the caller to enter the VM with exceptions. Kumar On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: > Hi David, > >> I don't think we need to report the exception, but can just ignore >> it. Either way we have to clear the exception before continuing. > > I've fixed it in new webrev: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ > > > Thanks, > > Yasumasa > > > On 2016/04/22 15:33, David Holmes wrote: >> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>> Hi all, >>> >>> I have uploaded webrev.04 as below. >>> Could you review again? >>> >>> > - hotspot: >>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >> >> Looks fine. >> >>> > >>> > - jdk: >>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >> >> As per private email (but repeated here on the record) in java.c: >> >> 715 if ((*env)->ExceptionOccurred(env)) { >> 1716 JLI_ReportExceptionDescription(env); >> 1717 } >> >> I don't think we need to report the exception, but can just ignore >> it. Either way we have to clear the exception before continuing. >> >> Thanks, >> David >> >>> Thanks, >>> >>> Yasumasa >>> >>> 2016/04/19 22:43 "Yasumasa Suenaga" >> >: >>> > >>> > Hi David, >>> > >>> > Thank you for your comment. >>> > I uploaded new webrev. Could you review again? >>> > >>> > - hotspot: >>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>> > >>> > - jdk: >>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>> > >>> > >>> >> That aside I'm not sure why you do this so late in the process, I >>> would have done it immediately after here: >>> > >>> > >>> > I think that native thread name ("main") should be set just before >>> > main method call. >>> > However, main thread is already started, so I moved it as you >>> suggested. >>> > >>> > >>> >> One thing I dislike about the current structure is that we have to >>> go from char* to java.lang.String to call setNativeName which then >>> calls >>> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >>> > >>> > >>> > SoI proposed to export new JVM function to set native thread name >>> with >>> > const char *. >>> > >>> > >>> > Thanks, >>> > >>> > Yasumasa >>> > >>> > >>> > >>> > On 2016/04/19 14:04, David Holmes wrote: >>> >> >>> >> Hi Yasumasa, >>> >> >>> >> Thanks for persevering with this to get it into the current form. >>> Sorry I haven't been able to do a detailed review until now. >>> >> >>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>> >>> >>> >>> Hi Gerard, >>> >>> >>> >>> 2016/04/19 3:14 "Gerard Ziemski" >> >>> >>> >> >>: >>> >>> > >>> >>> > hi Yasumasa, >>> >>> > >>> >>> > Nice work. I have 2 questions: >>> >>> > >>> >>> > ======== >>> >>> > File: java.c >>> >>> > >>> >>> > #1 Shouldn?t we be checking for >>> ?(*env)->ExceptionOccurred(env)? >>> >>> after every single JNI call? In this example instead of >>> NULL_CHECK, >>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>> >>> >>> >>> It is not critical if we encounter error at JNI function call >>> because >>> >>> we cannot set native thread name only. >>> >>> So I think that we do not need to leave from launcher process. >>> >> >>> >> >>> >> I agree we do not need to abort if an exception occurs (and in fact >>> I don't think an exception is even possible from this code), but we >>> should ensure any pending exception is cleared before any futher JNI >>> calls might be made. Note that NULL_CHECK is already used extensively >>> throughout the launcher code - so if this usage is wrong then it is all >>> wrong! More on this code below ... >>> >> >>> >> Other comments: >>> >> >>> >> hotspot/src/share/vm/prims/jvm.cpp >>> >> >>> >> Please add a comment to the method now that you removed the >>> internal >>> comment: >>> >> >>> >> // Sets the native thread name for a JavaThread. If specifically >>> >> // requested JNI-attached threads can also have their native >>> name set; >>> >> // otherwise we do not modify JNI-attached threads as it may >>> interfere >>> >> // with the application that created them. >>> >> >>> >> --- >>> >> >>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>> >> >>> >> Please add the following comments: >>> >> >>> >> + // Don't modify JNI-attached threads >>> >> setNativeName(name, false); >>> >> >>> >> + // May be called directly via JNI or reflection (when >>> permitted) to >>> >> + // allow JNI-attached threads to set their native name >>> >> private native void setNativeName(String name, boolean >>> allowAttachedThread); >>> >> >>> >> --- >>> >> >>> >> jd/src/java.base/share/native/libjli/java.c >>> >> >>> >> 328 #define LEAVE() \ >>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>> >> >>> >> I was going to suggest this be set later, but realized we have >>> to be >>> attached to do this and that happens inside DestroyJavaVM. :) >>> >> >>> >> + /* Set native thread name. */ >>> >> + SetNativeThreadName(env, "main"); >>> >> >>> >> The comment is redundant given the name of the method. That aside >>> I'm not sure why you do this so late in the process, I would have done >>> it immediately after here: >>> >> >>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>> >> 388 exit(1); >>> >> 389 } >>> >> + SetNativeThreadName(env, "main"); >>> >> >>> >> >>> >> + /** >>> >> + * Set native thread name as possible. >>> >> + */ >>> >> >>> >> Other than the as->if change I'm unclear where the "possible" bit >>> comes into play - why would it not be possible? >>> >> >>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>> "java/lang/Thread")); >>> >> 1706 NULL_CHECK(currentThreadID = >>> (*env)->GetStaticMethodID(env, >>> cls, >>> >> 1707 "currentThread", >>> "()Ljava/lang/Thread;")); >>> >> 1708 NULL_CHECK(currentThread = >>> (*env)->CallStaticObjectMethod(env, cls, >>> >> 1709 currentThreadID)); >>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, >>> >> 1711 "setNativeName", >>> "(Ljava/lang/String;Z)V")); >>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>> setNativeNameID, >>> >> 1714 nameString, JNI_TRUE); >>> >> >>> >> As above NULL_CHECK is fine here, but we should check for and clear >>> any pending exception after CallVoidMethod. >>> >> >>> >> One thing I dislike about the current structure is that we have to >>> go from char* to java.lang.String to call setNativeName which then >>> calls >>> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >>> Overall I wonder about the affect on startup cost. But if there is an >>> issue we can revisit this. >>> >> >>> >> Thanks, >>> >> David >>> >> ----- >>> >> >>> >> >>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native >>> thread >>> >>> name if possible.? not "Set native thread name as possible.?? >>> >>> >>> >>> Sorry for my bad English :-) >>> >>> >>> >>> Thanks, >>> >>> >>> >>> Yasumasa >>> >>> >>> >>> > cheers >>> >>> > >>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>> >>> >>> >> wrote: >>> >>> > > >>> >>> > > Hi David, >>> >>> > > >>> >>> > > I uploaded new webrev: >>> >>> > > >>> >>> > > - hotspot: >>> >>> > > >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>> >>> > > >>> >>> > > - jdk: >>> >>> > > >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>> >>> > > >>> >>> > > >>> >>> > >> it won't work unless you change the semantics of setName >>> so I'm >>> >>> not sure what you were thinking here. To take advantage of an arg >>> taking >>> >>> JVM_SetNativThreadName you would need to call it directly as no >>> Java >>> >>> code will call it . ??? >>> >>> > > >>> >>> > > I added a flag for setting native thread name to JNI-attached >>> thread. >>> >>> > > This change can set native thread name if main thread >>> changes to >>> >>> JNI-attached thread. >>> >>> > > >>> >>> > > >>> >>> > > Thanks, >>> >>> > > >>> >>> > > Yasumasa >>> >>> > > >>> >>> > > >>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>> >>> > >>> Hi David, >>> >>> > >>> >>> >>> > >>>> That change in behaviour may be a problem, it could be >>> considered a >>> >>> > >>>> regression that setName stops setting the native thread >>> main, even >>> >>> > >>>> though we never really intended it to work in the first >>> place. >>> >>> :( Such >>> >>> > >>>> a change needs to go through CCC. >>> >>> > >>> >>> >>> > >>> I understood. >>> >>> > >>> Can I send CCC request? >>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>> >>> > >> >>> >>> > >> Sorry you can't file a CCC request, you would need a >>> sponsor for >>> >>> that. But at this stage I don't think I agree with the proposed >>> change >>> >>> because of the change in behaviour - there's no way to restore the >>> >>> "broken" behaviour. >>> >>> > >> >>> >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. >>> >>> > >> >>> >>> > >> Okay we can do that. >>> >>> > >> >>> >>> > >>> >>> >>> > >>>> Further, we expect the launcher to use the supported JNI >>> >>> interface (as >>> >>> > >>>> other processes would), not the internal JVM interface >>> that >>> >>> exists for >>> >>> > >>>> the JDK sources to communicate with the JVM. >>> >>> > >>> >>> >>> > >>> I think that we do not use JVM interface if we add new >>> method in >>> >>> > >>> LauncherHelper as below: >>> >>> > >>> ---------------- >>> >>> > >>> diff -r f02139a1ac84 >>> >>> > >>> >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> >>> > >>> --- >>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>> >>> > >>> +++ >>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>> >>> > >>> @@ -960,4 +960,8 @@ >>> >>> > >>> else >>> >>> > >>> return md.toNameAndVersion() + " (" + loc + >>> ")"; >>> >>> > >>> } >>> >>> > >>> + >>> >>> > >>> + static void setNativeThreadName(String name) { >>> >>> > >>> + Thread.currentThread().setName(name); >>> >>> > >>> + } >>> >>> > >> >>> >>> > >> You could also make that call via JNI directly, so not >>> sure the >>> >>> helper adds much here. But it won't work unless you change the >>> semantics >>> >>> of setName so I'm not sure what you were thinking here. To take >>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>> need to >>> call >>> >>> it directly as no Java code will call it . ??? >>> >>> > >> >>> >>> > >> David >>> >>> > >> ----- >>> >>> > >> >>> >>> > >>> } >>> >>> > >>> diff -r f02139a1ac84 >>> src/java.base/share/native/libjli/java.c >>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>> Apr 13 >>> 14:19:30 >>> >>> > >>> 2016 +0000 >>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>> Apr 16 >>> 11:25:53 >>> >>> > >>> 2016 +0900 >>> >>> > >>> @@ -125,6 +125,7 @@ >>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>> >>> > >>> >>> >>> > >>> static void SetPaths(int argc, char **argv); >>> >>> > >>> >>> >>> > >>> @@ -325,6 +326,7 @@ >>> >>> > >>> * mainThread.isAlive() to work as expected. >>> >>> > >>> */ >>> >>> > >>> #define LEAVE() \ >>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>> >>> > >>> do { \ >>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>> >>> > >>> @@ -488,6 +490,9 @@ >>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>> >>> > >>> >>> >>> > >>> + /* Set native thread name. */ >>> >>> > >>> + SetNativeThreadName(env, "main"); >>> >>> > >>> + >>> >>> > >>> /* Invoke main method. */ >>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>> mainArgs); >>> >>> > >>> >>> >>> > >>> @@ -1686,6 +1691,22 @@ >>> >>> > >>> joptString); >>> >>> > >>> } >>> >>> > >>> >>> >>> > >>> +/** >>> >>> > >>> + * Set native thread name as possible. >>> >>> > >>> + */ >>> >>> > >>> +static void >>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>> >>> > >>> +{ >>> >>> > >>> + jmethodID setNativeThreadNameID; >>> >>> > >>> + jstring nameString; >>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>> >>> > >>> + NULL_CHECK(cls); >>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>> >>> (*env)->GetStaticMethodID(env, cls, >>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>> name)); >>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>> setNativeThreadNameID, >>> >>> > >>> nameString); >>> >>> > >>> +} >>> >>> > >>> + >>> >>> > >>> /* >>> >>> > >>> * Prints default usage or the Xusage message, see >>> >>> > >>> sun.launcher.LauncherHelper.java >>> >>> > >>> */ >>> >>> > >>> ---------------- >>> >>> > >>> >>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>> >>> > >>> >>> >>> > >>>> However this is still a change to the exported JVM >>> interface and so >>> >>> > >>>> has to be approved. >>> >>> > >>> >>> >>> > >>> Do you mean that this change needs CCC? >>> >>> > >>> >>> >>> > >>> >>> >>> > >>> Thanks, >>> >>> > >>> >>> >>> > >>> Yasumasa >>> >>> > >>> >>> >>> > >>> >>> >>> > >>> [1] >>> >>> > >>> >>> >>> >>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>> >>> >>> > >>> >>> >>> > >>> >>> >>> > >>> >>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>> >>> > >>>>> Hi David, >>> >>> > >>>>> >>> >>> > >>>>>> I think it is a bug based on the comment here: >>> >>> > >>>>>> >>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for >>> main >>> >>> thread and >>> >>> > >>>>>> JNI attached threads >>> >>> > >>>>> >>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>> >>> > >>>>> >>> >>> > >>>>> >>> >>> > >>>>>> Though that will introduce a change in behaviour by >>> itself as >>> >>> setName >>> >>> > >>>>>> will no longer set the native name for the main thread. >>> >>> > >>>>> >>> >>> > >>>>> I know. >>> >>> > >>>> >>> >>> > >>>> That change in behaviour may be a problem, it could be >>> considered a >>> >>> > >>>> regression that setName stops setting the native thread >>> main, even >>> >>> > >>>> though we never really intended it to work in the first >>> place. >>> >>> :( Such >>> >>> > >>>> a change needs to go through CCC. >>> >>> > >>>> >>> >>> > >>>>> I checked changeset history. >>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, >>> and it is >>> >>> > >>>>> backported JDK 8. >>> >>> > >>>> >>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>> >>> > >>>> >>> >>> > >>>>> However, this function seems to be called from >>> >>> Thread#setNativeName() >>> >>> > >>>>> only. >>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>> >>> > >>>>> >>> >>> > >>>>> Thus I think that we can add an argument to >>> >>> JVM_SetNativeThreadName() >>> >>> > >>>>> for force setting. >>> >>> > >>>>> (e.g. "bool forced") >>> >>> > >>>>> >>> >>> > >>>>> It makes a change of JVM API. >>> >>> > >>>>> However, this function is NOT public, so I think we can >>> add one >>> >>> more >>> >>> > >>>>> argument. >>> >>> > >>>>> >>> >>> > >>>>> What do you think about this? >>> >>> > >>>>> If it is accepted, we can set native thread name from >>> Java >>> >>> launcher. >>> >>> > >>>> >>> >>> > >>>> The private/public aspect of the Java API is not really at >>> >>> issue. Yes >>> >>> > >>>> we would add another arg to the JVM function to allow >>> it to >>> apply to >>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>> reflect that >>> >>> not just >>> >>> > >>>> "force"). However this is still a change to the >>> exported JVM >>> >>> interface >>> >>> > >>>> and so has to be approved. Further, we expect the >>> launcher to >>> >>> use the >>> >>> > >>>> supported JNI interface (as other processes would), not >>> the >>> internal >>> >>> > >>>> JVM interface that exists for the JDK sources to >>> communicate >>> >>> with the >>> >>> > >>>> JVM. >>> >>> > >>>> >>> >>> > >>>> David >>> >>> > >>>> ----- >>> >>> > >>>> >>> >>> > >>>>> >>> >>> > >>>>> Thanks, >>> >>> > >>>>> >>> >>> > >>>>> Yasumasa >>> >>> > >>>>> >>> >>> > >>>>> >>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>> >>> > >>>>>> Hi Yasumasa, >>> >>> > >>>>>> >>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>> >>> > >>>>>>> Hi David, >>> >>> > >>>>>>> >>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>> being a >>> >>> JNI-attached >>> >>> > >>>>>>>> thread seems accidental to me >>> >>> > >>>>>>> >>> >>> > >>>>>>> Should I file it to JBS? >>> >>> > >>>>>> >>> >>> > >>>>>> I think it is a bug based on the comment here: >>> >>> > >>>>>> >>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for >>> main >>> >>> thread and >>> >>> > >>>>>> JNI attached threads >>> >>> > >>>>>> >>> >>> > >>>>>> Though that will introduce a change in behaviour by >>> itself as >>> >>> setName >>> >>> > >>>>>> will no longer set the native name for the main thread. >>> >>> > >>>>>> >>> >>> > >>>>>>> I think that we can fix as below: >>> >>> > >>>>>>> --------------- >>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>> 13:31:11 >>> >>> 2016 +0200 >>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>> 17:50:10 >>> >>> 2016 +0900 >>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>> >>> > >>>>>>> >>> >>> > >>>>>>> // Attach the main thread to this os thread >>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>> >>> > >>>>>>> // must do this before set_active_handles >>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization is >>> complete >>> >>> - nop if >>> >>> > >>>>>>> no agents. >>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>> >>> > >>>>>>> >>> >>> > >>>>>>> + // Change attach status to "attached" >>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>> >>> > >>>>>>> + >>> >>> > >>>>>> >>> >>> > >>>>>> I think we can do this straight after the JavaThread >>> constructor. >>> >>> > >>>>>> >>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing >>> >>> > >>>>>>> backend."); >>> >>> > >>>>>>> } >>> >>> > >>>>>>> --------------- >>> >>> > >>>>>>> >>> >>> > >>>>>>> >>> >>> > >>>>>>>> If it wants to name its native threads then it is free >>> to do so, >>> >>> > >>>>>>> >>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>> native >>> >>> thread name >>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>> >>> > >>>>>>> However, I think that it should be changed if Java >>> developer >>> >>> calls >>> >>> > >>>>>>> Thread#setName() explicitly. >>> >>> > >>>>>>> It is not the same of changing native thread name at >>> >>> > >>>>>>> Threads::create_vm(). >>> >>> > >>>>>>> >>> >>> > >>>>>>> If it is allowed, I want to fix >>> SetNativeThreadName() as >>> below. >>> >>> > >>>>>>> What do you think about this? >>> >>> > >>>>>> >>> >>> > >>>>>> The decision to not change the name of JNI-attached >>> threads was a >>> >>> > >>>>>> deliberate one** - this functionality originated with >>> the OSX >>> >>> port and >>> >>> > >>>>>> it was reported that the initial feedback with this >>> feature was to >>> >>> > >>>>>> ensure it didn't mess with thread names that had been >>> set by >>> >>> the host >>> >>> > >>>>>> process. If we do as you propose then we will just >>> have an >>> >>> > >>>>>> inconsistency for people to complain about: "why does my >>> >>> native thread >>> >>> > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>> >>> > >>>>>> >>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>> this, the >>> >>> > >>>>>> semantics and limitations (truncation, current thread >>> only, >>> >>> non-JNI >>> >>> > >>>>>> threads only) of setting the native thread name were >>> supposed >>> >>> to be >>> >>> > >>>>>> documented in the release notes - but as far as I can >>> see >>> that >>> >>> never >>> >>> > >>>>>> happened. :( >>> >>> > >>>>>> >>> >>> > >>>>>> My position on this remains that if it is desirable for >>> the main >>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names >>> then the >>> >>> > >>>>>> launcher needs to be setting them using the available >>> platform >>> >>> APIs. >>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>> the VM >>> >>> code for >>> >>> > >>>>>> this - due to the need to verify API availability. >>> >>> > >>>>>> >>> >>> > >>>>>> Any change in behaviour in relation to Thread.setName >>> would >>> >>> have to go >>> >>> > >>>>>> through our CCC process I think. But a change in the >>> launcher >>> >>> would >>> >>> > >>>>>> not. >>> >>> > >>>>>> >>> >>> > >>>>>> Sorry. >>> >>> > >>>>>> >>> >>> > >>>>>> David >>> >>> > >>>>>> ----- >>> >>> > >>>>>> >>> >>> > >>>>>>> --------------- >>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>> 13:31:11 >>> >>> 2016 +0200 >>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>> 17:50:10 >>> >>> 2016 +0900 >>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>> >>> > >>>>>>> JavaThread* thr = >>> java_lang_Thread::thread(java_thread); >>> >>> > >>>>>>> // Thread naming only supported for the current >>> thread, >>> >>> doesn't >>> >>> > >>>>>>> work >>> >>> > >>>>>>> for >>> >>> > >>>>>>> // target threads. >>> >>> > >>>>>>> - if (Thread::current() == thr && >>> >>> !thr->has_attached_via_jni()) { >>> >>> > >>>>>>> + if (Thread::current() == thr) { >>> >>> > >>>>>>> // we don't set the name of an attached thread >>> to avoid >>> >>> stepping >>> >>> > >>>>>>> // on other programs >>> >>> > >>>>>>> const char *thread_name = >>> >>> > >>>>>>> >>> >>> >>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>> >>> > >>>>>>> --------------- >>> >>> > >>>>>>> >>> >>> > >>>>>>> >>> >>> > >>>>>>> Thanks, >>> >>> > >>>>>>> >>> >>> > >>>>>>> Yasumasa >>> >>> > >>>>>>> >>> >>> > >>>>>>> >>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>> >>> > >>>>>>>>> Roger, >>> >>> > >>>>>>>>> Thanks for your comment! >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> David, >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>> don't like >>> >>> > >>>>>>>>>>>> exposing >>> >>> > >>>>>>>>>>>> a new JVM function this way. >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>> initializing VM >>> (before >>> >>> > >>>>>>>>> calling >>> >>> > >>>>>>>>> main method), >>> >>> > >>>>>>>>> I could set native thread name. >>> >>> > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). >>> So we >>> >>> can't >>> >>> > >>>>>>>>> set >>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>> morning. >>> >>> Which, >>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>> here that >>> >>> we don't >>> >>> > >>>>>>>> set the name of threads not created by the JVM. The >>> fact >>> >>> that the >>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>> thread seems >>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only >>> working by >>> >>> > >>>>>>>> accident for the initial attach, and can't be used >>> for the >>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>> inconsistently >>> >>> named at >>> >>> > >>>>>>>> the native level. >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has to be >>> >>> treated like >>> >>> > >>>>>>>> any other process that might host a JVM. If it >>> wants to >>> name its >>> >>> > >>>>>>>> native threads then it is free to do so, but I >>> would not be >>> >>> exporting >>> >>> > >>>>>>>> a function from the JVM to do that - it would have to >>> use the OS >>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>> basis. >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> Sorry. >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> David >>> >>> > >>>>>>>> ----- >>> >>> > >>>>>>>> >>> >>> > >>>>>>>> >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> Thanks, >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> Yasumasa >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> >>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>> >>> > >>>>>>>>>> Hi, >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> Comments: >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>> perform >>> >>> different >>> >>> > >>>>>>>>>> functions: >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> - The first function applies to the current >>> thread, the >>> >>> second >>> >>> > >>>>>>>>>> one a >>> >>> > >>>>>>>>>> specific java thread. >>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>> somewhere >>> >>> about >>> >>> > >>>>>>>>>> what >>> >>> > >>>>>>>>>> the new function does. >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to >>> (void*) >>> >>> > >>>>>>>>>> instead of >>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>> >>> > >>>>>>>>>> as is done on unix and mac. >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>> >>> > >>>>>>>>>> - 737: looks wrong to >>> overwriteifn->GetCreatedJavaVMs >>> >>> used at >>> >>> > >>>>>>>>>> line 730 >>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>> the cast >>> >>> on the >>> >>> > >>>>>>>>>> same >>> >>> > >>>>>>>>>> line as dlsym... >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> $.02, Roger >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> >>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't >>> had >>> time to >>> >>> > >>>>>>>>>>>> check - >>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>> JNI-attached >>> >>> thread >>> >>> > >>>>>>>>>>>> then >>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>> suggestion >>> >>> should >>> >>> > >>>>>>>>>>>> work >>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>> treatment of >>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>> confirmed >>> >>> native >>> >>> > >>>>>>>>>>> thread name (test) was set. >>> >>> > >>>>>>>>>>> --------- >>> >>> > >>>>>>>>>>> public class Sleep{ >>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>> Exception{ >>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>> >>> > >>>>>>>>>>> } >>> >>> > >>>>>>>>>>> } >>> >>> > >>>>>>>>>>> --------- >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>> don't like >>> >>> > >>>>>>>>>>>> exposing >>> >>> > >>>>>>>>>>>> a new JVM function this way. >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> Yasumasa >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> >>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>> >>> > >>>>>>>>>>>>> Hi, >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>> >>> > >>>>>>>>>>>>>> Hi, >>> >>> > >>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>> >>> > >>>>>>>>>>>>>>> Hi David, >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>> thread >>> >>> name, and JLI >>> >>> > >>>>>>>>>>>>>>> uses it >>> >>> > >>>>>>>>>>>>>>> in new webrev. >>> >>> > >>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>> >>> core-libs will >>> >>> > >>>>>>>>>>>>>> need to >>> >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - >>> now cc'd. >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> Thanks! >>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>> >>> Thread.setName >>> >>> > >>>>>>>>>>>>>> rather >>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>> hotspot changes >>> >>> > >>>>>>>>>>>>>> needed in >>> >>> > >>>>>>>>>>>>>> that case. >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>> Thread#setName() in >>> >>> > >>>>>>>>>>>>> Thread#init(), >>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>> >>> > >>>>>>>>>>>> >>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>> which is >>> >>> why the >>> >>> > >>>>>>>>>>>> native >>> >>> > >>>>>>>>>>>> name is not set. >>> >>> > >>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached >>> thread. >>> >>> > >>>>>>>>>>>> >>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't >>> had >>> time to >>> >>> > >>>>>>>>>>>> check - >>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>> JNI-attached >>> >>> thread >>> >>> > >>>>>>>>>>>> then >>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>> suggestion >>> >>> should >>> >>> > >>>>>>>>>>>> work >>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>> treatment of >>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>> >>> > >>>>>>>>>>>> >>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>> don't like >>> >>> > >>>>>>>>>>>> exposing >>> >>> > >>>>>>>>>>>> a new JVM function this way. >>> >>> > >>>>>>>>>>>> >>> >>> > >>>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>>> David >>> >>> > >>>>>>>>>>>> ----- >>> >>> > >>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>> function to set >>> >>> native >>> >>> > >>>>>>>>>>>>> thread name. >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> Yasumasa >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> [1] >>> >>> > >>>>>>>>>>>>> >>> >>> >>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>>>>> David >>> >>> > >>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> Could you review again? >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> - hotspot: >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> - jdk: >>> >>> > >>>>>>>>>>>>>>> >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> Yasumasa >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as well >>> ... >>> >>> > >>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>> >>> > >>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have >>> been on >>> >>> > >>>>>>>>>>>>>>>> vacation). >>> >>> > >>>>>>>>>>>>>>>> This >>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct >>> as we >>> >>> do not >>> >>> > >>>>>>>>>>>>>>>> set the >>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>> includes the >>> >>> > >>>>>>>>>>>>>>>> "main" >>> >>> > >>>>>>>>>>>>>>>> thread. >>> >>> > >>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>> David >>> >>> > >>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>> >>> > >>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>> >>> > >>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>> >>> >>> >>: >>> >>> > >>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>> >>> > >>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>> >>> > >>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>> >>> > >>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>> >>> > >>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>> >>> > >>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga >>> wrote: >>> >>> > >>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>> >>> > >>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga >>> wrote: >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>> >>> >>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> >>>: >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>> Suenaga wrote: >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >> >>> >>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> >>>>: >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>> a/src/share/vm/runtime/thread.cpp Thu >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>> b/src/share/vm/runtime/thread.cpp Thu >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>> >>> JavaThread(); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> main_thread->set_thread_state(_thread_in_vm); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> main_thread->initialize_thread_current(); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>> >>> main_thread->set_native_thread_name("main"); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>> >>> set_active_handles >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> main_thread->record_stack_base_and_size(); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>> something? >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to >>> thread >>> >>> name in >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>> setName(). >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, >>> native >>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>> already >>> >>> starte >>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>> thrrad name >>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>> something like >>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp >>> Tue >>> >>> Mar 29 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp >>> Wed >>> >>> Mar 30 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>> create_initial_thread(Handle >>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>> initial_thread_name = >>> >>> "main"; >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>> (THREAD, k); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> klass->allocate_instance_handle(CHECK_NULL); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> java_lang_Thread::set_thread(thread_oop(), >>> >>> thread); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> java_lang_Thread::set_priority(thread_oop(), >>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> java_lang_String::create_from_str("main", >>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> thread->set_native_thread_name(initial_thread_name); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> java_lang_String::create_from_str(initial_thread_name, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>> thread_oop, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself >>> 'java' and >>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process >>> (and >>> >>> thus >>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process >>> is not >>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>> >>> JavaThread. So I >>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>> thread. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>> anyhow, since >>> >>> we want >>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name >>> might >>> >>> have >>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | >>> head -4 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like >>> 'Java Main >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>> >>> launcher - e.g. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread >>> name, >>> >>> I think >>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >>> >>> Suenaga wrote: >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>> thread >>> >>> name via >>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>> have it. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, >>> and main >>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>> should have >>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you >>> review it? >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>> > >>>>>>>>>> >>> >>> > >>> >>> >>> From mandy.chung at oracle.com Fri Apr 22 14:45:55 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 22 Apr 2016 07:45:55 -0700 Subject: Review request 8154837: Class::getPackage with exploded modules when classes in modules defined to the boot loader In-Reply-To: <5719C532.80800@oracle.com> References: <5719C532.80800@oracle.com> Message-ID: <3E058B8D-FF27-4E57-9AD8-399014BC29BE@oracle.com> > On Apr 21, 2016, at 11:31 PM, Alan Bateman wrote: > > On 21/04/2016 23:03, Mandy Chung wrote: >> Webrev: >> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154837/webrev.00/ >> >> The module location from an exploded image is file URL rather than file path. This issue can be reproduced with jdk/test/java/lang/Package/GetPackages.java on windows. > This looks okay, maybe slightly better if it starts for "file:/?. Will patch before the push. > At some point then I think we need to re-examine the underlying JVM function to see if we can get it to return a file URL for -Xbootclasspath/a case too. That is, it's a bit strange for the function to return a String that is sometimes a URL, sometimes a file path. I agree and it?d be better to be consistent. I will file an issue to track this. Mandy From mark.reinhold at oracle.com Fri Apr 22 15:02:18 2016 From: mark.reinhold at oracle.com (mark.reinhold at oracle.com) Date: Fri, 22 Apr 2016 08:02:18 -0700 Subject: Multi-Release JAR runtime support In-Reply-To: References: <1511462.jDlVcCe28l@herve-desktop> <5715E25C.6080306@oracle.com> <4040113.8uvnzoatIK@herve-desktop> <20160419171125.134877943eggemoggin.niobe.net> Message-ID: <20160422080218.400678151eggemoggin.niobe.net> 2016/4/22 5:39:26 -0700, paul.sandoz at oracle.com: > On 20 Apr 2016, at 02:11, mark.reinhold at oracle.com wrote: >> 2016/4/19 12:37:41 -0700, Herv? BOUTEMY : >>> Perhaps this requirement should be described in >>> http://openjdk.java.net/jeps/238 >> >> Yes -- that was certainly non-obvious! >> >> Steve, could you please add this to the JEP? (A JEP should, in general, >> contain and/or refer to enough information for an experienced developer >> to get started using the feature.) > > The description is updated: > > https://bugs.openjdk.java.net/browse/JDK-8047305 > > including two new sections on compatibility and resource URLs. Excellent, thanks! (FYI, http://openjdk.java.net/jeps/* is now updated every 15 minutes from JBS rather than irregularly, as before.) - Mark From Roger.Riggs at Oracle.com Fri Apr 22 15:33:13 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 22 Apr 2016 11:33:13 -0400 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5718FEF7.1020807@oracle.com> References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> Message-ID: <571A4439.6090001@Oracle.com> Hi Joe, Wouldn't it be less make work to introduce the new method, replace the current one where appropriate and then deprecate the existing method? As it is, you/someone is going to make a second pass over all the same files. Roger On 4/21/2016 12:25 PM, joe darcy wrote: > Hello, > > After a generally positive reception, please review the webrev to > implement the deprecation of Class.newInstance and the suppression of > the resulting warnings: > > http://cr.openjdk.java.net/~darcy/6850612.0/ > > There are also some changes in the langtools repo; I'll send a > separate review request for those changes to compiler-dev. > > I'll also forward this review request to other areas with affected code. > > Thanks, > > -Joe > > On 4/17/2016 10:31 AM, joe darcy wrote: >> Hello, >> >> With talk of deprecation in the air [1], I thought it would be a fine >> time to examine one of the bugs on my list >> >> JDK-6850612: Deprecate Class.newInstance since it violates the >> checked exception language contract >> >> As the title of the bug implies, The Class.newInstance method >> knowingly violates the checking exception contract. This has long >> been documented in its specification: >> >>> Note that this method propagates any exception thrown by the nullary >>> constructor, including a checked exception. Use of this method >>> effectively bypasses the compile-time exception checking that would >>> otherwise be performed by the compiler. The Constructor.newInstance >>> method avoids this problem by wrapping any exception thrown by the >>> constructor in a (checked) InvocationTargetException. >> >> Roughly, the fix would be to turn the text of this note into the >> @deprecated text and to add a @Deprecated(since="9") annotation to >> the method. There are a few dozen uses of the method in the JDK that >> would have to be @SuppressWarning-ed or otherwise updated. >> >> Thoughts on the appropriateness of deprecating this method at this time? >> >> Comments on the bug have suggested that besides deprecating the >> method, a new method on Class could be introduced, >> newInstanceWithProperExceptionBehavior, that had the same signature >> but wrapped exceptions thrown by the constructor call in the same way >> Constructor.newInstance does. >> >> Thanks, >> >> -Joe >> >> [1] >> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html > From chris.hegarty at oracle.com Fri Apr 22 15:38:21 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 22 Apr 2016 16:38:21 +0100 Subject: RFR [9] 8147543: Remove sun.misc.ManagedLocalsThread Message-ID: <2F7550B7-2A5C-4104-8D18-48FD56999464@oracle.com> Another remaining JEP 260 task that can now be resolved ( remove a non-Critical API from sun.misc ). With all the subtasks of 8147543 [1] complete, i.e. all the dependencies on ManagedLocalsThread have been removed, it is time to remove the type itself ( its functionality has been superseded by the new Thread constructor [2] ). The changes are trivial: $ hr rm src/jdk.unsupported/share/classes/sun/misc/ManagedLocalsThread.java -Chris. [1] https://bugs.openjdk.java.net/browse/JDK-8147543 [2] https://bugs.openjdk.java.net/browse/JDK-8056152 From Roger.Riggs at Oracle.com Fri Apr 22 15:42:27 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 22 Apr 2016 11:42:27 -0400 Subject: RFR [9] 8147543: Remove sun.misc.ManagedLocalsThread In-Reply-To: <2F7550B7-2A5C-4104-8D18-48FD56999464@oracle.com> References: <2F7550B7-2A5C-4104-8D18-48FD56999464@oracle.com> Message-ID: <571A4663.60607@Oracle.com> Well done. Roger On 4/22/2016 11:38 AM, Chris Hegarty wrote: > Another remaining JEP 260 task that can now be resolved ( remove a > non-Critical API from sun.misc ). > > With all the subtasks of 8147543 [1] complete, i.e. all the dependencies on > ManagedLocalsThread have been removed, it is time to remove the type > itself ( its functionality has been superseded by the new Thread constructor > [2] ). > > The changes are trivial: > > $ hr rm src/jdk.unsupported/share/classes/sun/misc/ManagedLocalsThread.java > > -Chris. > > [1] https://bugs.openjdk.java.net/browse/JDK-8147543 > [2] https://bugs.openjdk.java.net/browse/JDK-8056152 From kumar.x.srinivasan at oracle.com Fri Apr 22 16:14:32 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Fri, 22 Apr 2016 09:14:32 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571A381E.9050605@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> Message-ID: <571A4DE8.8060508@oracle.com> Also a couple of minor suggestions: - * Set native thread name as possible. + * Set native thread name if possible. + /* - * We can clear pending exception because exception at this point - * is not critical. + */ + /* + * Clear non critical pending exceptions at this point. + */ Thanks Kumar > Hi, > > This is in the wrong place: > > 1715 if ((*env)->ExceptionOccurred(env)) { > 1716 /* > 1717 * We can clear pending exception because exception at this > point > 1718 * is not critical. > 1719 */ > 1720 (*env)->ExceptionClear(env); > 1721 } > > This above needs to be after > 391 SetNativeThreadName(env, "main"); > 392 > > Here is why, supposing 1704 through 1711, returns a NULL, > but have also encountered an exception. In which case > the method SetNativeThreadName will return to the caller, as > if nothing has happened, because NULL_CHECK simply checks for NULL > and returns to the caller. This will cause the caller to enter > the VM with exceptions. > > Kumar > > > On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >> Hi David, >> >>> I don't think we need to report the exception, but can just ignore >>> it. Either way we have to clear the exception before continuing. >> >> I've fixed it in new webrev: >> >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/22 15:33, David Holmes wrote: >>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>> Hi all, >>>> >>>> I have uploaded webrev.04 as below. >>>> Could you review again? >>>> >>>> > - hotspot: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>> >>> Looks fine. >>> >>>> > >>>> > - jdk: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>> >>> As per private email (but repeated here on the record) in java.c: >>> >>> 715 if ((*env)->ExceptionOccurred(env)) { >>> 1716 JLI_ReportExceptionDescription(env); >>> 1717 } >>> >>> I don't think we need to report the exception, but can just ignore >>> it. Either way we have to clear the exception before continuing. >>> >>> Thanks, >>> David >>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>> >: >>>> > >>>> > Hi David, >>>> > >>>> > Thank you for your comment. >>>> > I uploaded new webrev. Could you review again? >>>> > >>>> > - hotspot: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>> > >>>> > - jdk: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>> > >>>> > >>>> >> That aside I'm not sure why you do this so late in the process, I >>>> would have done it immediately after here: >>>> > >>>> > >>>> > I think that native thread name ("main") should be set just before >>>> > main method call. >>>> > However, main thread is already started, so I moved it as you >>>> suggested. >>>> > >>>> > >>>> >> One thing I dislike about the current structure is that we have to >>>> go from char* to java.lang.String to call setNativeName which then >>>> calls >>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>> char* ! >>>> > >>>> > >>>> > SoI proposed to export new JVM function to set native thread >>>> name with >>>> > const char *. >>>> > >>>> > >>>> > Thanks, >>>> > >>>> > Yasumasa >>>> > >>>> > >>>> > >>>> > On 2016/04/19 14:04, David Holmes wrote: >>>> >> >>>> >> Hi Yasumasa, >>>> >> >>>> >> Thanks for persevering with this to get it into the current form. >>>> Sorry I haven't been able to do a detailed review until now. >>>> >> >>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>> >>> >>>> >>> Hi Gerard, >>>> >>> >>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>> >>>> >>> >>> >>: >>>> >>> > >>>> >>> > hi Yasumasa, >>>> >>> > >>>> >>> > Nice work. I have 2 questions: >>>> >>> > >>>> >>> > ======== >>>> >>> > File: java.c >>>> >>> > >>>> >>> > #1 Shouldn?t we be checking for >>>> ?(*env)->ExceptionOccurred(env)? >>>> >>> after every single JNI call? In this example instead of >>>> NULL_CHECK, >>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>> >>> >>>> >>> It is not critical if we encounter error at JNI function call >>>> because >>>> >>> we cannot set native thread name only. >>>> >>> So I think that we do not need to leave from launcher process. >>>> >> >>>> >> >>>> >> I agree we do not need to abort if an exception occurs (and in >>>> fact >>>> I don't think an exception is even possible from this code), but we >>>> should ensure any pending exception is cleared before any futher JNI >>>> calls might be made. Note that NULL_CHECK is already used extensively >>>> throughout the launcher code - so if this usage is wrong then it is >>>> all >>>> wrong! More on this code below ... >>>> >> >>>> >> Other comments: >>>> >> >>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>> >> >>>> >> Please add a comment to the method now that you removed the >>>> internal >>>> comment: >>>> >> >>>> >> // Sets the native thread name for a JavaThread. If specifically >>>> >> // requested JNI-attached threads can also have their native >>>> name set; >>>> >> // otherwise we do not modify JNI-attached threads as it may >>>> interfere >>>> >> // with the application that created them. >>>> >> >>>> >> --- >>>> >> >>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>> >> >>>> >> Please add the following comments: >>>> >> >>>> >> + // Don't modify JNI-attached threads >>>> >> setNativeName(name, false); >>>> >> >>>> >> + // May be called directly via JNI or reflection (when >>>> permitted) to >>>> >> + // allow JNI-attached threads to set their native name >>>> >> private native void setNativeName(String name, boolean >>>> allowAttachedThread); >>>> >> >>>> >> --- >>>> >> >>>> >> jd/src/java.base/share/native/libjli/java.c >>>> >> >>>> >> 328 #define LEAVE() \ >>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> >> >>>> >> I was going to suggest this be set later, but realized we have >>>> to be >>>> attached to do this and that happens inside DestroyJavaVM. :) >>>> >> >>>> >> + /* Set native thread name. */ >>>> >> + SetNativeThreadName(env, "main"); >>>> >> >>>> >> The comment is redundant given the name of the method. That aside >>>> I'm not sure why you do this so late in the process, I would have done >>>> it immediately after here: >>>> >> >>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>> >> 388 exit(1); >>>> >> 389 } >>>> >> + SetNativeThreadName(env, "main"); >>>> >> >>>> >> >>>> >> + /** >>>> >> + * Set native thread name as possible. >>>> >> + */ >>>> >> >>>> >> Other than the as->if change I'm unclear where the "possible" bit >>>> comes into play - why would it not be possible? >>>> >> >>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>> "java/lang/Thread")); >>>> >> 1706 NULL_CHECK(currentThreadID = >>>> (*env)->GetStaticMethodID(env, >>>> cls, >>>> >> 1707 "currentThread", >>>> "()Ljava/lang/Thread;")); >>>> >> 1708 NULL_CHECK(currentThread = >>>> (*env)->CallStaticObjectMethod(env, cls, >>>> >> 1709 currentThreadID)); >>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, >>>> cls, >>>> >> 1711 "setNativeName", >>>> "(Ljava/lang/String;Z)V")); >>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>> setNativeNameID, >>>> >> 1714 nameString, JNI_TRUE); >>>> >> >>>> >> As above NULL_CHECK is fine here, but we should check for and >>>> clear >>>> any pending exception after CallVoidMethod. >>>> >> >>>> >> One thing I dislike about the current structure is that we have to >>>> go from char* to java.lang.String to call setNativeName which then >>>> calls >>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>> char* ! >>>> Overall I wonder about the affect on startup cost. But if there is an >>>> issue we can revisit this. >>>> >> >>>> >> Thanks, >>>> >> David >>>> >> ----- >>>> >> >>>> >> >>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native >>>> thread >>>> >>> name if possible.? not "Set native thread name as possible.?? >>>> >>> >>>> >>> Sorry for my bad English :-) >>>> >>> >>>> >>> Thanks, >>>> >>> >>>> >>> Yasumasa >>>> >>> >>>> >>> > cheers >>>> >>> > >>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>> >>>> >>> >> wrote: >>>> >>> > > >>>> >>> > > Hi David, >>>> >>> > > >>>> >>> > > I uploaded new webrev: >>>> >>> > > >>>> >>> > > - hotspot: >>>> >>> > > >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>> >>> > > >>>> >>> > > - jdk: >>>> >>> > > >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>> >>> > > >>>> >>> > > >>>> >>> > >> it won't work unless you change the semantics of setName >>>> so I'm >>>> >>> not sure what you were thinking here. To take advantage of an arg >>>> taking >>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>> no Java >>>> >>> code will call it . ??? >>>> >>> > > >>>> >>> > > I added a flag for setting native thread name to >>>> JNI-attached >>>> thread. >>>> >>> > > This change can set native thread name if main thread >>>> changes to >>>> >>> JNI-attached thread. >>>> >>> > > >>>> >>> > > >>>> >>> > > Thanks, >>>> >>> > > >>>> >>> > > Yasumasa >>>> >>> > > >>>> >>> > > >>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>> >>> > >>> Hi David, >>>> >>> > >>> >>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>> considered a >>>> >>> > >>>> regression that setName stops setting the native thread >>>> main, even >>>> >>> > >>>> though we never really intended it to work in the >>>> first place. >>>> >>> :( Such >>>> >>> > >>>> a change needs to go through CCC. >>>> >>> > >>> >>>> >>> > >>> I understood. >>>> >>> > >>> Can I send CCC request? >>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>> >>> > >> >>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>> sponsor for >>>> >>> that. But at this stage I don't think I agree with the >>>> proposed change >>>> >>> because of the change in behaviour - there's no way to restore >>>> the >>>> >>> "broken" behaviour. >>>> >>> > >> >>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. >>>> >>> > >> >>>> >>> > >> Okay we can do that. >>>> >>> > >> >>>> >>> > >>> >>>> >>> > >>>> Further, we expect the launcher to use the supported JNI >>>> >>> interface (as >>>> >>> > >>>> other processes would), not the internal JVM interface >>>> that >>>> >>> exists for >>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>> >>> > >>> >>>> >>> > >>> I think that we do not use JVM interface if we add new >>>> method in >>>> >>> > >>> LauncherHelper as below: >>>> >>> > >>> ---------------- >>>> >>> > >>> diff -r f02139a1ac84 >>>> >>> > >>> >>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> >>> > >>> --- >>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>> >>> > >>> +++ >>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>> >>> > >>> @@ -960,4 +960,8 @@ >>>> >>> > >>> else >>>> >>> > >>> return md.toNameAndVersion() + " (" + loc >>>> + ")"; >>>> >>> > >>> } >>>> >>> > >>> + >>>> >>> > >>> + static void setNativeThreadName(String name) { >>>> >>> > >>> + Thread.currentThread().setName(name); >>>> >>> > >>> + } >>>> >>> > >> >>>> >>> > >> You could also make that call via JNI directly, so not >>>> sure the >>>> >>> helper adds much here. But it won't work unless you change the >>>> semantics >>>> >>> of setName so I'm not sure what you were thinking here. To take >>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>> need to >>>> call >>>> >>> it directly as no Java code will call it . ??? >>>> >>> > >> >>>> >>> > >> David >>>> >>> > >> ----- >>>> >>> > >> >>>> >>> > >>> } >>>> >>> > >>> diff -r f02139a1ac84 >>>> src/java.base/share/native/libjli/java.c >>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>> Apr 13 >>>> 14:19:30 >>>> >>> > >>> 2016 +0000 >>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>> Apr 16 >>>> 11:25:53 >>>> >>> > >>> 2016 +0900 >>>> >>> > >>> @@ -125,6 +125,7 @@ >>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>> >>> > >>> >>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>> >>> > >>> >>>> >>> > >>> @@ -325,6 +326,7 @@ >>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>> >>> > >>> */ >>>> >>> > >>> #define LEAVE() \ >>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> >>> > >>> do { \ >>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>> >>> > >>> @@ -488,6 +490,9 @@ >>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>> >>> > >>> >>>> >>> > >>> + /* Set native thread name. */ >>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>> >>> > >>> + >>>> >>> > >>> /* Invoke main method. */ >>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>> mainArgs); >>>> >>> > >>> >>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>> >>> > >>> joptString); >>>> >>> > >>> } >>>> >>> > >>> >>>> >>> > >>> +/** >>>> >>> > >>> + * Set native thread name as possible. >>>> >>> > >>> + */ >>>> >>> > >>> +static void >>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>> >>> > >>> +{ >>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>> >>> > >>> + jstring nameString; >>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>> >>> > >>> + NULL_CHECK(cls); >>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>> >>> (*env)->GetStaticMethodID(env, cls, >>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>> name)); >>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>> setNativeThreadNameID, >>>> >>> > >>> nameString); >>>> >>> > >>> +} >>>> >>> > >>> + >>>> >>> > >>> /* >>>> >>> > >>> * Prints default usage or the Xusage message, see >>>> >>> > >>> sun.launcher.LauncherHelper.java >>>> >>> > >>> */ >>>> >>> > >>> ---------------- >>>> >>> > >>> >>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>> >>> > >>> >>>> >>> > >>>> However this is still a change to the exported JVM >>>> interface and so >>>> >>> > >>>> has to be approved. >>>> >>> > >>> >>>> >>> > >>> Do you mean that this change needs CCC? >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> Thanks, >>>> >>> > >>> >>>> >>> > >>> Yasumasa >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> [1] >>>> >>> > >>> >>>> >>> >>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>> >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>> >>> > >>>>> Hi David, >>>> >>> > >>>>> >>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>> >>> > >>>>>> >>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>> for main >>>> >>> thread and >>>> >>> > >>>>>> JNI attached threads >>>> >>> > >>>>> >>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>> >>> > >>>>> >>>> >>> > >>>>> >>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>> itself as >>>> >>> setName >>>> >>> > >>>>>> will no longer set the native name for the main thread. >>>> >>> > >>>>> >>>> >>> > >>>>> I know. >>>> >>> > >>>> >>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>> considered a >>>> >>> > >>>> regression that setName stops setting the native thread >>>> main, even >>>> >>> > >>>> though we never really intended it to work in the >>>> first place. >>>> >>> :( Such >>>> >>> > >>>> a change needs to go through CCC. >>>> >>> > >>>> >>>> >>> > >>>>> I checked changeset history. >>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, >>>> and it is >>>> >>> > >>>>> backported JDK 8. >>>> >>> > >>>> >>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>> >>> > >>>> >>>> >>> > >>>>> However, this function seems to be called from >>>> >>> Thread#setNativeName() >>>> >>> > >>>>> only. >>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>> >>> > >>>>> >>>> >>> > >>>>> Thus I think that we can add an argument to >>>> >>> JVM_SetNativeThreadName() >>>> >>> > >>>>> for force setting. >>>> >>> > >>>>> (e.g. "bool forced") >>>> >>> > >>>>> >>>> >>> > >>>>> It makes a change of JVM API. >>>> >>> > >>>>> However, this function is NOT public, so I think we can >>>> add one >>>> >>> more >>>> >>> > >>>>> argument. >>>> >>> > >>>>> >>>> >>> > >>>>> What do you think about this? >>>> >>> > >>>>> If it is accepted, we can set native thread name from >>>> Java >>>> >>> launcher. >>>> >>> > >>>> >>>> >>> > >>>> The private/public aspect of the Java API is not >>>> really at >>>> >>> issue. Yes >>>> >>> > >>>> we would add another arg to the JVM function to allow >>>> it to >>>> apply to >>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>> reflect that >>>> >>> not just >>>> >>> > >>>> "force"). However this is still a change to the >>>> exported JVM >>>> >>> interface >>>> >>> > >>>> and so has to be approved. Further, we expect the >>>> launcher to >>>> >>> use the >>>> >>> > >>>> supported JNI interface (as other processes would), >>>> not the >>>> internal >>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>> communicate >>>> >>> with the >>>> >>> > >>>> JVM. >>>> >>> > >>>> >>>> >>> > >>>> David >>>> >>> > >>>> ----- >>>> >>> > >>>> >>>> >>> > >>>>> >>>> >>> > >>>>> Thanks, >>>> >>> > >>>>> >>>> >>> > >>>>> Yasumasa >>>> >>> > >>>>> >>>> >>> > >>>>> >>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>> >>> > >>>>>> Hi Yasumasa, >>>> >>> > >>>>>> >>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>> Hi David, >>>> >>> > >>>>>>> >>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>> being a >>>> >>> JNI-attached >>>> >>> > >>>>>>>> thread seems accidental to me >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Should I file it to JBS? >>>> >>> > >>>>>> >>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>> >>> > >>>>>> >>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>> for main >>>> >>> thread and >>>> >>> > >>>>>> JNI attached threads >>>> >>> > >>>>>> >>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>> itself as >>>> >>> setName >>>> >>> > >>>>>> will no longer set the native name for the main thread. >>>> >>> > >>>>>> >>>> >>> > >>>>>>> I think that we can fix as below: >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>> 13:31:11 >>>> >>> 2016 +0200 >>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>> 17:50:10 >>>> >>> 2016 +0900 >>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>> >>> > >>>>>>> // must do this before set_active_handles >>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization is >>>> complete >>>> >>> - nop if >>>> >>> > >>>>>>> no agents. >>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> + // Change attach status to "attached" >>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>> >>> > >>>>>>> + >>>> >>> > >>>>>> >>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>> constructor. >>>> >>> > >>>>>> >>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing >>>> >>> > >>>>>>> backend."); >>>> >>> > >>>>>>> } >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> >>>> >>> > >>>>>>>> If it wants to name its native threads then it is >>>> free >>>> to do so, >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>> native >>>> >>> thread name >>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>> developer >>>> >>> calls >>>> >>> > >>>>>>> Thread#setName() explicitly. >>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>> >>> > >>>>>>> Threads::create_vm(). >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> If it is allowed, I want to fix >>>> SetNativeThreadName() as >>>> below. >>>> >>> > >>>>>>> What do you think about this? >>>> >>> > >>>>>> >>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>> threads was a >>>> >>> > >>>>>> deliberate one** - this functionality originated >>>> with the OSX >>>> >>> port and >>>> >>> > >>>>>> it was reported that the initial feedback with this >>>> feature was to >>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>> been set by >>>> >>> the host >>>> >>> > >>>>>> process. If we do as you propose then we will just >>>> have an >>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>> does my >>>> >>> native thread >>>> >>> > >>>>>> only have a name if I call >>>> cur.setName(cur.getName()) ?" >>>> >>> > >>>>>> >>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>> this, the >>>> >>> > >>>>>> semantics and limitations (truncation, current >>>> thread only, >>>> >>> non-JNI >>>> >>> > >>>>>> threads only) of setting the native thread name were >>>> supposed >>>> >>> to be >>>> >>> > >>>>>> documented in the release notes - but as far as I >>>> can see >>>> that >>>> >>> never >>>> >>> > >>>>>> happened. :( >>>> >>> > >>>>>> >>>> >>> > >>>>>> My position on this remains that if it is desirable for >>>> the main >>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names >>>> then the >>>> >>> > >>>>>> launcher needs to be setting them using the available >>>> platform >>>> >>> APIs. >>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>> the VM >>>> >>> code for >>>> >>> > >>>>>> this - due to the need to verify API availability. >>>> >>> > >>>>>> >>>> >>> > >>>>>> Any change in behaviour in relation to >>>> Thread.setName would >>>> >>> have to go >>>> >>> > >>>>>> through our CCC process I think. But a change in the >>>> launcher >>>> >>> would >>>> >>> > >>>>>> not. >>>> >>> > >>>>>> >>>> >>> > >>>>>> Sorry. >>>> >>> > >>>>>> >>>> >>> > >>>>>> David >>>> >>> > >>>>>> ----- >>>> >>> > >>>>>> >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>> 13:31:11 >>>> >>> 2016 +0200 >>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>> 17:50:10 >>>> >>> 2016 +0900 >>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>> >>> > >>>>>>> JavaThread* thr = >>>> java_lang_Thread::thread(java_thread); >>>> >>> > >>>>>>> // Thread naming only supported for the current >>>> thread, >>>> >>> doesn't >>>> >>> > >>>>>>> work >>>> >>> > >>>>>>> for >>>> >>> > >>>>>>> // target threads. >>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>> >>> !thr->has_attached_via_jni()) { >>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>> >>> > >>>>>>> // we don't set the name of an attached thread >>>> to avoid >>>> >>> stepping >>>> >>> > >>>>>>> // on other programs >>>> >>> > >>>>>>> const char *thread_name = >>>> >>> > >>>>>>> >>>> >>> >>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Thanks, >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Yasumasa >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>> Roger, >>>> >>> > >>>>>>>>> Thanks for your comment! >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> David, >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>> don't like >>>> >>> > >>>>>>>>>>>> exposing >>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>> initializing VM >>>> (before >>>> >>> > >>>>>>>>> calling >>>> >>> > >>>>>>>>> main method), >>>> >>> > >>>>>>>>> I could set native thread name. >>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>> AttachCurrentThread(). >>>> So we >>>> >>> can't >>>> >>> > >>>>>>>>> set >>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>> morning. >>>> >>> Which, >>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>> here that >>>> >>> we don't >>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>> The fact >>>> >>> that the >>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>> thread seems >>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only >>>> working by >>>> >>> > >>>>>>>> accident for the initial attach, and can't be used >>>> for the >>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>> inconsistently >>>> >>> named at >>>> >>> > >>>>>>>> the native level. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>> to be >>>> >>> treated like >>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>> wants to >>>> name its >>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>> would not be >>>> >>> exporting >>>> >>> > >>>>>>>> a function from the JVM to do that - it would have to >>>> use the OS >>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>> basis. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> Sorry. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> David >>>> >>> > >>>>>>>> ----- >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> Thanks, >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>> >>> > >>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> Comments: >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>> perform >>>> >>> different >>>> >>> > >>>>>>>>>> functions: >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>> JVM_SetNativeThreadName >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> - The first function applies to the current >>>> thread, the >>>> >>> second >>>> >>> > >>>>>>>>>> one a >>>> >>> > >>>>>>>>>> specific java thread. >>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>> somewhere >>>> >>> about >>>> >>> > >>>>>>>>>> what >>>> >>> > >>>>>>>>>> the new function does. >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to >>>> (void*) >>>> >>> > >>>>>>>>>> instead of >>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>> overwriteifn->GetCreatedJavaVMs >>>> >>> used at >>>> >>> > >>>>>>>>>> line 730 >>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>> the cast >>>> >>> on the >>>> >>> > >>>>>>>>>> same >>>> >>> > >>>>>>>>>> line as dlsym... >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> $.02, Roger >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>> haven't had >>>> time to >>>> >>> > >>>>>>>>>>>> check - >>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>> JNI-attached >>>> >>> thread >>>> >>> > >>>>>>>>>>>> then >>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>> suggestion >>>> >>> should >>>> >>> > >>>>>>>>>>>> work >>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>> treatment of >>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>> confirmed >>>> >>> native >>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>> >>> > >>>>>>>>>>> --------- >>>> >>> > >>>>>>>>>>> public class Sleep{ >>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>> Exception{ >>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>> >>> > >>>>>>>>>>> } >>>> >>> > >>>>>>>>>>> } >>>> >>> > >>>>>>>>>>> --------- >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>> don't like >>>> >>> > >>>>>>>>>>>> exposing >>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>> comment. >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>> >>> > >>>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>> thread >>>> >>> name, and JLI >>>> >>> > >>>>>>>>>>>>>>> uses it >>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>> >>> > >>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>> >>> core-libs will >>>> >>> > >>>>>>>>>>>>>> need to >>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - >>>> now cc'd. >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Thanks! >>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>> >>> Thread.setName >>>> >>> > >>>>>>>>>>>>>> rather >>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>> hotspot changes >>>> >>> > >>>>>>>>>>>>>> needed in >>>> >>> > >>>>>>>>>>>>>> that case. >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>> Thread#setName() in >>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>> which is >>>> >>> why the >>>> >>> > >>>>>>>>>>>> native >>>> >>> > >>>>>>>>>>>> name is not set. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached >>>> thread. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>> haven't had >>>> time to >>>> >>> > >>>>>>>>>>>> check - >>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>> JNI-attached >>>> >>> thread >>>> >>> > >>>>>>>>>>>> then >>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>> suggestion >>>> >>> should >>>> >>> > >>>>>>>>>>>> work >>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>> treatment of >>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>> don't like >>>> >>> > >>>>>>>>>>>> exposing >>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>> David >>>> >>> > >>>>>>>>>>>> ----- >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>> function to set >>>> >>> native >>>> >>> > >>>>>>>>>>>>> thread name. >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> [1] >>>> >>> > >>>>>>>>>>>>> >>>> >>> >>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>> David >>>> >>> > >>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>> well ... >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have >>>> been on >>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>> >>> > >>>>>>>>>>>>>>>> This >>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>> correct >>>> as we >>>> >>> do not >>>> >>> > >>>>>>>>>>>>>>>> set the >>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>> includes the >>>> >>> > >>>>>>>>>>>>>>>> "main" >>>> >>> > >>>>>>>>>>>>>>>> thread. >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> David >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>> wrote: >>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>> >>> > >>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>> >>> > >>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>> >>>> >>> >>: >>>> >>> > >>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>> >>> > >>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>> >>> > >>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>> >>> > >>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>> Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga >>>> wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>> >>> >>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> >>>: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>> Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>>> >>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> >>>>: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set >>>> it: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>> a/src/share/vm/runtime/thread.cpp Thu >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>> b/src/share/vm/runtime/thread.cpp Thu >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>> >>> JavaThread(); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> main_thread->initialize_thread_current(); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>> >>> main_thread->set_native_thread_name("main"); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>> >>> set_active_handles >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> main_thread->record_stack_base_and_size(); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> >>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>> something? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to >>>> thread >>>> >>> name in >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>> setName(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java >>>> app, >>>> native >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>> already >>>> >>> starte >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>> thrrad name >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>> something like >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp >>>> Tue >>>> >>> Mar 29 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp >>>> Wed >>>> >>> Mar 30 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>> create_initial_thread(Handle >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>> initial_thread_name = >>>> >>> "main"; >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>> (THREAD, k); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> klass->allocate_instance_handle(CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> java_lang_Thread::set_thread(thread_oop(), >>>> >>> thread); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> java_lang_Thread::set_priority(thread_oop(), >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> java_lang_String::create_from_str("main", >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> thread->set_native_thread_name(initial_thread_name); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>> thread_oop, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself >>>> 'java' and >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>> process >>>> (and >>>> >>> thus >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>> process >>>> is not >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>> >>> JavaThread. So I >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>> thread. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>> anyhow, since >>>> >>> we want >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread >>>> name >>>> might >>>> >>> have >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | >>>> head -4 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like >>>> 'Java Main >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>>> >>> launcher - e.g. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>> thread >>>> name, >>>> >>> I think >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >>>> >>> Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>> thread >>>> >>> name via >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>> have it. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>> name, >>>> and main >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>> should have >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you >>>> review it? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>> >>>> >>> > >>>> >>> >>>> > From Roger.Riggs at Oracle.com Fri Apr 22 17:32:27 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 22 Apr 2016 13:32:27 -0400 Subject: error reporting path fix in java.util.prefs.FileSytemPreferences.lockFile0() In-Reply-To: <571A5703.1000201@azulsystems.com> References: <571A5703.1000201@azulsystems.com> Message-ID: <571A602B.70406@Oracle.com> Hi Harry, Great to see a new contributor. If you haven't read up on the OpenJDK processes, there are a few things you can read about how to contribute [1] and the developers guide [2] Typically, changes are applied to the current developers release (JDK 9) and then backported as needed. Please provide a description of the problem we can see if there is already a bugid for it or create one. Send the email to core-libs-dev at openjdk.java.net If the patch is not too big you can include it in an email to core-libs-dev at openjdk.java.net and folks will review it and someone will volunteer to sponsor it for you. Changes typically require a test case so it can be shown that the test fails without the change and works with the change. Regards, Roger [1] http://openjdk.java.net/contribute/ [2] http://openjdk.java.net/guide/ On 4/22/2016 12:53 PM, harry muttart wrote: > Greetings, > > I would like to submit a jdk runtime fix on behalf of my employer, > Azul Systems. > > The issue is a long-standing error reporting corner case in the > openjdk source > base. The same error exists in jdk6, jdk7, jdk8, and jdk9 sources. > The same > change easily applies to all of these source bases. A recent check of > the latest > openjdk source base shows this as still an issue. > > As I am a complete openjdk process newbie. Can someone please recommend > the simplest way to make this happen? > > Thanks to all for your patience. > > Harry Muttart > Azul Systems > > > > The issue... > ============ > > From the runtime code below, you can see there is a path through > java.util.prefs.FileSytemPreferences.lockFile0() which can result in an > error return with an unset errno field. On the path where the incoming > argument, shared, is JNI_TRUE, any errno set by an open failure is not > saved (in result[1]). Then, when the return code from the open is > checked, > the code zeroes result[0] but the errno slot remains unset. Because > return[] is stack allocated, return[1] may contain ANY value, and the > reported errno returned is completely unhelpful. > > There is an easy fix. Capture the errno value after ALL fopen() calls. > > An Azul customer tripped this issue. > > > The source file containing the "fix opportunity" is... > jdk6, jdk7, jdk8) > jdk/src/solaris/native/java/util/FileSystemPreferences.c > jdk9) jdk/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c > > > The problem code (from openjdk6 source base) is: > > Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, > jclass thisclass, jstring java_fname, jint permission, > jboolean shared) { > const char *fname = JNU_GetStringPlatformChars(env, > java_fname, JNI_FALSE); > int fd, rc; > int result[2]; > jintArray javaResult; > int old_umask; > FLOCK fl; > > fl.l_whence = SEEK_SET; > fl.l_len = 0; > fl.l_start = 0; > if (shared == JNI_TRUE) { > fl.l_type = F_RDLCK; > } else { > fl.l_type = F_WRLCK; > } > > if (shared == JNI_TRUE) { > fd = open(fname, O_RDONLY, 0); > // NEED FIX HERE: "result[1] = errno;" > } else { > old_umask = umask(0); > fd = open(fname, O_WRONLY|O_CREAT, permission); > result[1] = errno; > umask(old_umask); > } > > if (fd < 0) { > result[0] = 0; > } else { > rc = fcntl(fd, F_SETLK64, &fl); > result[1] = errno; > if (rc < 0) { > result[0]= 0; > close(fd); > } else { > result[0] = fd; > } > } > JNU_ReleaseStringPlatformChars(env, java_fname, fname); > javaResult = (*env)->NewIntArray(env,2); > (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); > return javaResult; > } > From joe.darcy at oracle.com Fri Apr 22 17:47:07 2016 From: joe.darcy at oracle.com (joe darcy) Date: Fri, 22 Apr 2016 10:47:07 -0700 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <571A4439.6090001@Oracle.com> References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> <571A4439.6090001@Oracle.com> Message-ID: <571A639B.1000606@oracle.com> Hi Roger, Per other discussion in the thread, no new method will be introduced. The area owners will need to cleanup this usage of this method since it may involve restructuring of catch blocks, etc., since the recommended approach has different exception behavior. Thanks, -Joe On 4/22/2016 8:33 AM, Roger Riggs wrote: > Hi Joe, > > Wouldn't it be less make work to introduce the new method, replace the > current one where appropriate > and then deprecate the existing method? As it is, you/someone is > going to make a second pass > over all the same files. > > Roger > > > On 4/21/2016 12:25 PM, joe darcy wrote: >> Hello, >> >> After a generally positive reception, please review the webrev to >> implement the deprecation of Class.newInstance and the suppression of >> the resulting warnings: >> >> http://cr.openjdk.java.net/~darcy/6850612.0/ >> >> There are also some changes in the langtools repo; I'll send a >> separate review request for those changes to compiler-dev. >> >> I'll also forward this review request to other areas with affected code. >> >> Thanks, >> >> -Joe >> >> On 4/17/2016 10:31 AM, joe darcy wrote: >>> Hello, >>> >>> With talk of deprecation in the air [1], I thought it would be a >>> fine time to examine one of the bugs on my list >>> >>> JDK-6850612: Deprecate Class.newInstance since it violates the >>> checked exception language contract >>> >>> As the title of the bug implies, The Class.newInstance method >>> knowingly violates the checking exception contract. This has long >>> been documented in its specification: >>> >>>> Note that this method propagates any exception thrown by the >>>> nullary constructor, including a checked exception. Use of this >>>> method effectively bypasses the compile-time exception checking >>>> that would otherwise be performed by the compiler. The >>>> Constructor.newInstance method avoids this problem by wrapping any >>>> exception thrown by the constructor in a (checked) >>>> InvocationTargetException. >>> >>> Roughly, the fix would be to turn the text of this note into the >>> @deprecated text and to add a @Deprecated(since="9") annotation to >>> the method. There are a few dozen uses of the method in the JDK that >>> would have to be @SuppressWarning-ed or otherwise updated. >>> >>> Thoughts on the appropriateness of deprecating this method at this >>> time? >>> >>> Comments on the bug have suggested that besides deprecating the >>> method, a new method on Class could be introduced, >>> newInstanceWithProperExceptionBehavior, that had the same signature >>> but wrapped exceptions thrown by the constructor call in the same >>> way Constructor.newInstance does. >>> >>> Thanks, >>> >>> -Joe >>> >>> [1] >>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html >> > From joe.darcy at oracle.com Fri Apr 22 22:18:15 2016 From: joe.darcy at oracle.com (joe darcy) Date: Fri, 22 Apr 2016 15:18:15 -0700 Subject: JDK 9 RFR of JDK-8154277: JavaDoc warnings in VirtualMachineManager.java and Pool.java In-Reply-To: <5719DC46.9000505@oracle.com> References: <5719DB9C.5040504@oracle.com> <5719DC46.9000505@oracle.com> Message-ID: <571AA327.7000208@oracle.com> On 4/22/2016 1:09 AM, Alan Bateman wrote: > > On 22/04/2016 09:06, Amy Lu wrote: >> Please review this tiny fix for typos in the the documentation of: >> >> jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java >> jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java >> >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8154277 >> webrev: http://cr.openjdk.java.net/~amlu/8154277/webrev.00/ >> >> Thanks, >> Amy > Looks good. In the case of the jlink API then the javadoc was clean at > one point but it seems to have regressed. > I took a quick look at the makefile and didn't see a specialized entry for jdk.jlink. In any case, I recommend the build options for jdk.jlink, wherever they are, to be modified to make lint and doclint warnings fatal. Cheers, -Joe From blackdrag at gmx.org Sat Apr 23 07:25:30 2016 From: blackdrag at gmx.org (Jochen Theodorou) Date: Sat, 23 Apr 2016 09:25:30 +0200 Subject: Annotation with array of Annotation Message-ID: <571B236A.8090609@gmx.org> Hi all, I know the following does not compile and does right so by the JLS: public @interface SomeCollector { Annotation[] value(); } I know also that it would be easy to support with the existing infrastructure. What I am looking for, is the reasoning as of why this is not allowed besides what is directly in the JLS. I am trying to understand the background a bit more. Has someone a pointer? bye Jochen From yasuenag at gmail.com Sat Apr 23 13:24:38 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Sat, 23 Apr 2016 22:24:38 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571A4DE8.8060508@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> Message-ID: <571B7796.8030905@gmail.com> Hi Kumar, Thank you for your comment! I've fixed them and uploaded new webrev. Could you review again? http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ Thanks, Yasumasa On 2016/04/23 1:14, Kumar Srinivasan wrote: > > Also a couple of minor suggestions: > > - * Set native thread name as possible. > + * Set native thread name if possible. > > > + /* > - * We can clear pending exception because exception at this point > - * is not critical. > + */ > > + /* > + * Clear non critical pending exceptions at this point. > + */ > > Thanks > Kumar > >> Hi, >> >> This is in the wrong place: >> >> 1715 if ((*env)->ExceptionOccurred(env)) { >> 1716 /* >> 1717 * We can clear pending exception because exception at this point >> 1718 * is not critical. >> 1719 */ >> 1720 (*env)->ExceptionClear(env); >> 1721 } >> >> This above needs to be after >> 391 SetNativeThreadName(env, "main"); >> 392 >> >> Here is why, supposing 1704 through 1711, returns a NULL, >> but have also encountered an exception. In which case >> the method SetNativeThreadName will return to the caller, as >> if nothing has happened, because NULL_CHECK simply checks for NULL >> and returns to the caller. This will cause the caller to enter >> the VM with exceptions. >> >> Kumar >> >> >> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> I don't think we need to report the exception, but can just ignore it. Either way we have to clear the exception before continuing. >>> >>> I've fixed it in new webrev: >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/22 15:33, David Holmes wrote: >>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>> Hi all, >>>>> >>>>> I have uploaded webrev.04 as below. >>>>> Could you review again? >>>>> >>>>> > - hotspot: >>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>> >>>> Looks fine. >>>> >>>>> > >>>>> > - jdk: >>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>> >>>> As per private email (but repeated here on the record) in java.c: >>>> >>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>> 1716 JLI_ReportExceptionDescription(env); >>>> 1717 } >>>> >>>> I don't think we need to report the exception, but can just ignore it. Either way we have to clear the exception before continuing. >>>> >>>> Thanks, >>>> David >>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>> >: >>>>> > >>>>> > Hi David, >>>>> > >>>>> > Thank you for your comment. >>>>> > I uploaded new webrev. Could you review again? >>>>> > >>>>> > - hotspot: >>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>> > >>>>> > - jdk: >>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>> > >>>>> > >>>>> >> That aside I'm not sure why you do this so late in the process, I >>>>> would have done it immediately after here: >>>>> > >>>>> > >>>>> > I think that native thread name ("main") should be set just before >>>>> > main method call. >>>>> > However, main thread is already started, so I moved it as you suggested. >>>>> > >>>>> > >>>>> >> One thing I dislike about the current structure is that we have to >>>>> go from char* to java.lang.String to call setNativeName which then calls >>>>> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >>>>> > >>>>> > >>>>> > SoI proposed to export new JVM function to set native thread name with >>>>> > const char *. >>>>> > >>>>> > >>>>> > Thanks, >>>>> > >>>>> > Yasumasa >>>>> > >>>>> > >>>>> > >>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>> >> >>>>> >> Hi Yasumasa, >>>>> >> >>>>> >> Thanks for persevering with this to get it into the current form. >>>>> Sorry I haven't been able to do a detailed review until now. >>>>> >> >>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>> >>> >>>>> >>> Hi Gerard, >>>>> >>> >>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>> >>>>> >>> >>: >>>>> >>> > >>>>> >>> > hi Yasumasa, >>>>> >>> > >>>>> >>> > Nice work. I have 2 questions: >>>>> >>> > >>>>> >>> > ======== >>>>> >>> > File: java.c >>>>> >>> > >>>>> >>> > #1 Shouldn?t we be checking for ?(*env)->ExceptionOccurred(env)? >>>>> >>> after every single JNI call? In this example instead of NULL_CHECK, >>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>> >>> >>>>> >>> It is not critical if we encounter error at JNI function call because >>>>> >>> we cannot set native thread name only. >>>>> >>> So I think that we do not need to leave from launcher process. >>>>> >> >>>>> >> >>>>> >> I agree we do not need to abort if an exception occurs (and in fact >>>>> I don't think an exception is even possible from this code), but we >>>>> should ensure any pending exception is cleared before any futher JNI >>>>> calls might be made. Note that NULL_CHECK is already used extensively >>>>> throughout the launcher code - so if this usage is wrong then it is all >>>>> wrong! More on this code below ... >>>>> >> >>>>> >> Other comments: >>>>> >> >>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>> >> >>>>> >> Please add a comment to the method now that you removed the internal >>>>> comment: >>>>> >> >>>>> >> // Sets the native thread name for a JavaThread. If specifically >>>>> >> // requested JNI-attached threads can also have their native name set; >>>>> >> // otherwise we do not modify JNI-attached threads as it may interfere >>>>> >> // with the application that created them. >>>>> >> >>>>> >> --- >>>>> >> >>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>> >> >>>>> >> Please add the following comments: >>>>> >> >>>>> >> + // Don't modify JNI-attached threads >>>>> >> setNativeName(name, false); >>>>> >> >>>>> >> + // May be called directly via JNI or reflection (when permitted) to >>>>> >> + // allow JNI-attached threads to set their native name >>>>> >> private native void setNativeName(String name, boolean >>>>> allowAttachedThread); >>>>> >> >>>>> >> --- >>>>> >> >>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>> >> >>>>> >> 328 #define LEAVE() \ >>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>> >> >>>>> >> I was going to suggest this be set later, but realized we have to be >>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>> >> >>>>> >> + /* Set native thread name. */ >>>>> >> + SetNativeThreadName(env, "main"); >>>>> >> >>>>> >> The comment is redundant given the name of the method. That aside >>>>> I'm not sure why you do this so late in the process, I would have done >>>>> it immediately after here: >>>>> >> >>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>> >> 388 exit(1); >>>>> >> 389 } >>>>> >> + SetNativeThreadName(env, "main"); >>>>> >> >>>>> >> >>>>> >> + /** >>>>> >> + * Set native thread name as possible. >>>>> >> + */ >>>>> >> >>>>> >> Other than the as->if change I'm unclear where the "possible" bit >>>>> comes into play - why would it not be possible? >>>>> >> >>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>>> >> 1706 NULL_CHECK(currentThreadID = (*env)->GetStaticMethodID(env, >>>>> cls, >>>>> >> 1707 "currentThread", >>>>> "()Ljava/lang/Thread;")); >>>>> >> 1708 NULL_CHECK(currentThread = >>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>> >> 1709 currentThreadID)); >>>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, >>>>> >> 1711 "setNativeName", >>>>> "(Ljava/lang/String;Z)V")); >>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, setNativeNameID, >>>>> >> 1714 nameString, JNI_TRUE); >>>>> >> >>>>> >> As above NULL_CHECK is fine here, but we should check for and clear >>>>> any pending exception after CallVoidMethod. >>>>> >> >>>>> >> One thing I dislike about the current structure is that we have to >>>>> go from char* to java.lang.String to call setNativeName which then calls >>>>> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >>>>> Overall I wonder about the affect on startup cost. But if there is an >>>>> issue we can revisit this. >>>>> >> >>>>> >> Thanks, >>>>> >> David >>>>> >> ----- >>>>> >> >>>>> >> >>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native >>>>> thread >>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>> >>> >>>>> >>> Sorry for my bad English :-) >>>>> >>> >>>>> >>> Thanks, >>>>> >>> >>>>> >>> Yasumasa >>>>> >>> >>>>> >>> > cheers >>>>> >>> > >>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>> >>>>> >>> >> wrote: >>>>> >>> > > >>>>> >>> > > Hi David, >>>>> >>> > > >>>>> >>> > > I uploaded new webrev: >>>>> >>> > > >>>>> >>> > > - hotspot: >>>>> >>> > > >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>> >>> > > >>>>> >>> > > - jdk: >>>>> >>> > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>> >>> > > >>>>> >>> > > >>>>> >>> > >> it won't work unless you change the semantics of setName so I'm >>>>> >>> not sure what you were thinking here. To take advantage of an arg >>>>> taking >>>>> >>> JVM_SetNativThreadName you would need to call it directly as no Java >>>>> >>> code will call it . ??? >>>>> >>> > > >>>>> >>> > > I added a flag for setting native thread name to JNI-attached >>>>> thread. >>>>> >>> > > This change can set native thread name if main thread changes to >>>>> >>> JNI-attached thread. >>>>> >>> > > >>>>> >>> > > >>>>> >>> > > Thanks, >>>>> >>> > > >>>>> >>> > > Yasumasa >>>>> >>> > > >>>>> >>> > > >>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>> >>> > >>> Hi David, >>>>> >>> > >>> >>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>> considered a >>>>> >>> > >>>> regression that setName stops setting the native thread >>>>> main, even >>>>> >>> > >>>> though we never really intended it to work in the first place. >>>>> >>> :( Such >>>>> >>> > >>>> a change needs to go through CCC. >>>>> >>> > >>> >>>>> >>> > >>> I understood. >>>>> >>> > >>> Can I send CCC request? >>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>> >>> > >> >>>>> >>> > >> Sorry you can't file a CCC request, you would need a sponsor for >>>>> >>> that. But at this stage I don't think I agree with the proposed change >>>>> >>> because of the change in behaviour - there's no way to restore the >>>>> >>> "broken" behaviour. >>>>> >>> > >> >>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. >>>>> >>> > >> >>>>> >>> > >> Okay we can do that. >>>>> >>> > >> >>>>> >>> > >>> >>>>> >>> > >>>> Further, we expect the launcher to use the supported JNI >>>>> >>> interface (as >>>>> >>> > >>>> other processes would), not the internal JVM interface that >>>>> >>> exists for >>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>> >>> > >>> >>>>> >>> > >>> I think that we do not use JVM interface if we add new method in >>>>> >>> > >>> LauncherHelper as below: >>>>> >>> > >>> ---------------- >>>>> >>> > >>> diff -r f02139a1ac84 >>>>> >>> > >>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>> >>> > >>> --- >>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>> >>> > >>> +++ >>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>> >>> > >>> else >>>>> >>> > >>> return md.toNameAndVersion() + " (" + loc + ")"; >>>>> >>> > >>> } >>>>> >>> > >>> + >>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>> >>> > >>> + } >>>>> >>> > >> >>>>> >>> > >> You could also make that call via JNI directly, so not sure the >>>>> >>> helper adds much here. But it won't work unless you change the >>>>> semantics >>>>> >>> of setName so I'm not sure what you were thinking here. To take >>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would need to >>>>> call >>>>> >>> it directly as no Java code will call it . ??? >>>>> >>> > >> >>>>> >>> > >> David >>>>> >>> > >> ----- >>>>> >>> > >> >>>>> >>> > >>> } >>>>> >>> > >>> diff -r f02139a1ac84 src/java.base/share/native/libjli/java.c >>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed Apr 13 >>>>> 14:19:30 >>>>> >>> > >>> 2016 +0000 >>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat Apr 16 >>>>> 11:25:53 >>>>> >>> > >>> 2016 +0900 >>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>>> >>> > >>> >>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>> >>> > >>> >>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>> >>> > >>> */ >>>>> >>> > >>> #define LEAVE() \ >>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>> >>> > >>> do { \ >>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>> >>> > >>> >>>>> >>> > >>> + /* Set native thread name. */ >>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>> >>> > >>> + >>>>> >>> > >>> /* Invoke main method. */ >>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>> mainArgs); >>>>> >>> > >>> >>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>> >>> > >>> joptString); >>>>> >>> > >>> } >>>>> >>> > >>> >>>>> >>> > >>> +/** >>>>> >>> > >>> + * Set native thread name as possible. >>>>> >>> > >>> + */ >>>>> >>> > >>> +static void >>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>> >>> > >>> +{ >>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>> >>> > >>> + jstring nameString; >>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>> >>> > >>> + NULL_CHECK(cls); >>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>> setNativeThreadNameID, >>>>> >>> > >>> nameString); >>>>> >>> > >>> +} >>>>> >>> > >>> + >>>>> >>> > >>> /* >>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>> >>> > >>> */ >>>>> >>> > >>> ---------------- >>>>> >>> > >>> >>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>> >>> > >>> >>>>> >>> > >>>> However this is still a change to the exported JVM >>>>> interface and so >>>>> >>> > >>>> has to be approved. >>>>> >>> > >>> >>>>> >>> > >>> Do you mean that this change needs CCC? >>>>> >>> > >>> >>>>> >>> > >>> >>>>> >>> > >>> Thanks, >>>>> >>> > >>> >>>>> >>> > >>> Yasumasa >>>>> >>> > >>> >>>>> >>> > >>> >>>>> >>> > >>> [1] >>>>> >>> > >>> >>>>> >>> >>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>> >>> > >>> >>>>> >>> > >>> >>>>> >>> > >>> >>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>> Hi David, >>>>> >>> > >>>>> >>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>> >>> thread and >>>>> >>> > >>>>>> JNI attached threads >>>>> >>> > >>>>> >>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>> >>> > >>>>> >>>>> >>> > >>>>> >>>>> >>> > >>>>>> Though that will introduce a change in behaviour by itself as >>>>> >>> setName >>>>> >>> > >>>>>> will no longer set the native name for the main thread. >>>>> >>> > >>>>> >>>>> >>> > >>>>> I know. >>>>> >>> > >>>> >>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>> considered a >>>>> >>> > >>>> regression that setName stops setting the native thread >>>>> main, even >>>>> >>> > >>>> though we never really intended it to work in the first place. >>>>> >>> :( Such >>>>> >>> > >>>> a change needs to go through CCC. >>>>> >>> > >>>> >>>>> >>> > >>>>> I checked changeset history. >>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, >>>>> and it is >>>>> >>> > >>>>> backported JDK 8. >>>>> >>> > >>>> >>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>> >>> > >>>> >>>>> >>> > >>>>> However, this function seems to be called from >>>>> >>> Thread#setNativeName() >>>>> >>> > >>>>> only. >>>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>>> >>> > >>>>> >>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>> >>> JVM_SetNativeThreadName() >>>>> >>> > >>>>> for force setting. >>>>> >>> > >>>>> (e.g. "bool forced") >>>>> >>> > >>>>> >>>>> >>> > >>>>> It makes a change of JVM API. >>>>> >>> > >>>>> However, this function is NOT public, so I think we can >>>>> add one >>>>> >>> more >>>>> >>> > >>>>> argument. >>>>> >>> > >>>>> >>>>> >>> > >>>>> What do you think about this? >>>>> >>> > >>>>> If it is accepted, we can set native thread name from Java >>>>> >>> launcher. >>>>> >>> > >>>> >>>>> >>> > >>>> The private/public aspect of the Java API is not really at >>>>> >>> issue. Yes >>>>> >>> > >>>> we would add another arg to the JVM function to allow it to >>>>> apply to >>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg reflect that >>>>> >>> not just >>>>> >>> > >>>> "force"). However this is still a change to the exported JVM >>>>> >>> interface >>>>> >>> > >>>> and so has to be approved. Further, we expect the launcher to >>>>> >>> use the >>>>> >>> > >>>> supported JNI interface (as other processes would), not the >>>>> internal >>>>> >>> > >>>> JVM interface that exists for the JDK sources to communicate >>>>> >>> with the >>>>> >>> > >>>> JVM. >>>>> >>> > >>>> >>>>> >>> > >>>> David >>>>> >>> > >>>> ----- >>>>> >>> > >>>> >>>>> >>> > >>>>> >>>>> >>> > >>>>> Thanks, >>>>> >>> > >>>>> >>>>> >>> > >>>>> Yasumasa >>>>> >>> > >>>>> >>>>> >>> > >>>>> >>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>> >>> > >>>>>> Hi Yasumasa, >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>> Hi David, >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as being a >>>>> >>> JNI-attached >>>>> >>> > >>>>>>>> thread seems accidental to me >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> Should I file it to JBS? >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for main >>>>> >>> thread and >>>>> >>> > >>>>>> JNI attached threads >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> Though that will introduce a change in behaviour by itself as >>>>> >>> setName >>>>> >>> > >>>>>> will no longer set the native name for the main thread. >>>>> >>> > >>>>>> >>>>> >>> > >>>>>>> I think that we can fix as below: >>>>> >>> > >>>>>>> --------------- >>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 13:31:11 >>>>> >>> 2016 +0200 >>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 17:50:10 >>>>> >>> 2016 +0900 >>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization is complete >>>>> >>> - nop if >>>>> >>> > >>>>>>> no agents. >>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>> >>> > >>>>>>> + >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>>> constructor. >>>>> >>> > >>>>>> >>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing >>>>> >>> > >>>>>>> backend."); >>>>> >>> > >>>>>>> } >>>>> >>> > >>>>>>> --------------- >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>>> If it wants to name its native threads then it is free >>>>> to do so, >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change native >>>>> >>> thread name >>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>> >>> > >>>>>>> However, I think that it should be changed if Java developer >>>>> >>> calls >>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>>> >>> > >>>>>>> Threads::create_vm(). >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> If it is allowed, I want to fix SetNativeThreadName() as >>>>> below. >>>>> >>> > >>>>>>> What do you think about this? >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>> threads was a >>>>> >>> > >>>>>> deliberate one** - this functionality originated with the OSX >>>>> >>> port and >>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>> feature was to >>>>> >>> > >>>>>> ensure it didn't mess with thread names that had been set by >>>>> >>> the host >>>>> >>> > >>>>>> process. If we do as you propose then we will just have an >>>>> >>> > >>>>>> inconsistency for people to complain about: "why does my >>>>> >>> native thread >>>>> >>> > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>>> this, the >>>>> >>> > >>>>>> semantics and limitations (truncation, current thread only, >>>>> >>> non-JNI >>>>> >>> > >>>>>> threads only) of setting the native thread name were supposed >>>>> >>> to be >>>>> >>> > >>>>>> documented in the release notes - but as far as I can see >>>>> that >>>>> >>> never >>>>> >>> > >>>>>> happened. :( >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> My position on this remains that if it is desirable for >>>>> the main >>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names >>>>> then the >>>>> >>> > >>>>>> launcher needs to be setting them using the available >>>>> platform >>>>> >>> APIs. >>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by the VM >>>>> >>> code for >>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> Any change in behaviour in relation to Thread.setName would >>>>> >>> have to go >>>>> >>> > >>>>>> through our CCC process I think. But a change in the launcher >>>>> >>> would >>>>> >>> > >>>>>> not. >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> Sorry. >>>>> >>> > >>>>>> >>>>> >>> > >>>>>> David >>>>> >>> > >>>>>> ----- >>>>> >>> > >>>>>> >>>>> >>> > >>>>>>> --------------- >>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 13:31:11 >>>>> >>> 2016 +0200 >>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 17:50:10 >>>>> >>> 2016 +0900 >>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>> >>> > >>>>>>> JavaThread* thr = java_lang_Thread::thread(java_thread); >>>>> >>> > >>>>>>> // Thread naming only supported for the current thread, >>>>> >>> doesn't >>>>> >>> > >>>>>>> work >>>>> >>> > >>>>>>> for >>>>> >>> > >>>>>>> // target threads. >>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>> >>> !thr->has_attached_via_jni()) { >>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>> >>> > >>>>>>> // we don't set the name of an attached thread to avoid >>>>> >>> stepping >>>>> >>> > >>>>>>> // on other programs >>>>> >>> > >>>>>>> const char *thread_name = >>>>> >>> > >>>>>>> >>>>> >>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>> >>> > >>>>>>> --------------- >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> Thanks, >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> Yasumasa >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> >>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>>>> Roger, >>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> David, >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>>> don't like >>>>> >>> > >>>>>>>>>>>> exposing >>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after initializing VM >>>>> (before >>>>> >>> > >>>>>>>>> calling >>>>> >>> > >>>>>>>>> main method), >>>>> >>> > >>>>>>>>> I could set native thread name. >>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). >>>>> So we >>>>> >>> can't >>>>> >>> > >>>>>>>>> set >>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>>> morning. >>>>> >>> Which, >>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise here that >>>>> >>> we don't >>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. The fact >>>>> >>> that the >>>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>>> thread seems >>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only >>>>> working by >>>>> >>> > >>>>>>>> accident for the initial attach, and can't be used for the >>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread inconsistently >>>>> >>> named at >>>>> >>> > >>>>>>>> the native level. >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has to be >>>>> >>> treated like >>>>> >>> > >>>>>>>> any other process that might host a JVM. If it wants to >>>>> name its >>>>> >>> > >>>>>>>> native threads then it is free to do so, but I would not be >>>>> >>> exporting >>>>> >>> > >>>>>>>> a function from the JVM to do that - it would have to >>>>> use the OS >>>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform basis. >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> Sorry. >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> David >>>>> >>> > >>>>>>>> ----- >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>> >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> >>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>> >>> > >>>>>>>>>> Hi, >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> Comments: >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but perform >>>>> >>> different >>>>> >>> > >>>>>>>>>> functions: >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> - The first function applies to the current thread, the >>>>> >>> second >>>>> >>> > >>>>>>>>>> one a >>>>> >>> > >>>>>>>>>> specific java thread. >>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment somewhere >>>>> >>> about >>>>> >>> > >>>>>>>>>> what >>>>> >>> > >>>>>>>>>> the new function does. >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to >>>>> (void*) >>>>> >>> > >>>>>>>>>> instead of >>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>> >>> > >>>>>>>>>> - 737: looks wrong to overwriteifn->GetCreatedJavaVMs >>>>> >>> used at >>>>> >>> > >>>>>>>>>> line 730 >>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep the cast >>>>> >>> on the >>>>> >>> > >>>>>>>>>> same >>>>> >>> > >>>>>>>>>> line as dlsym... >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> $.02, Roger >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't had >>>>> time to >>>>> >>> > >>>>>>>>>>>> check - >>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>> >>> thread >>>>> >>> > >>>>>>>>>>>> then >>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>> >>> should >>>>> >>> > >>>>>>>>>>>> work >>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>> treatment of >>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>>> confirmed >>>>> >>> native >>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>> >>> > >>>>>>>>>>> --------- >>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>> Exception{ >>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>> >>> > >>>>>>>>>>> } >>>>> >>> > >>>>>>>>>>> } >>>>> >>> > >>>>>>>>>>> --------- >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>>> don't like >>>>> >>> > >>>>>>>>>>>> exposing >>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> >>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>>>>>>>> Hi, >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>> >>> > >>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native thread >>>>> >>> name, and JLI >>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>> >>> > >>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>>> >>> core-libs will >>>>> >>> > >>>>>>>>>>>>>> need to >>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - >>>>> now cc'd. >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>> >>> Thread.setName >>>>> >>> > >>>>>>>>>>>>>> rather >>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>> hotspot changes >>>>> >>> > >>>>>>>>>>>>>> needed in >>>>> >>> > >>>>>>>>>>>>>> that case. >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>> Thread#setName() in >>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>> >>> > >>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, which is >>>>> >>> why the >>>>> >>> > >>>>>>>>>>>> native >>>>> >>> > >>>>>>>>>>>> name is not set. >>>>> >>> > >>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached thread. >>>>> >>> > >>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't had >>>>> time to >>>>> >>> > >>>>>>>>>>>> check - >>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a JNI-attached >>>>> >>> thread >>>>> >>> > >>>>>>>>>>>> then >>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my suggestion >>>>> >>> should >>>>> >>> > >>>>>>>>>>>> work >>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>> treatment of >>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>> >>> > >>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>>> don't like >>>>> >>> > >>>>>>>>>>>> exposing >>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>> >>> > >>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>>> David >>>>> >>> > >>>>>>>>>>>> ----- >>>>> >>> > >>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a function to set >>>>> >>> native >>>>> >>> > >>>>>>>>>>>>> thread name. >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> [1] >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> >>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>>>>> David >>>>> >>> > >>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as well ... >>>>> >>> > >>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>> >>> > >>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have >>>>> been on >>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>> >>> > >>>>>>>>>>>>>>>> This >>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct >>>>> as we >>>>> >>> do not >>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>>> includes the >>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>> >>> > >>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>> David >>>>> >>> > >>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>> >>> > >>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>> >>> > >>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>> >>>>> >>> >>: >>>>> >>> > >>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga wrote: >>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga >>>>> wrote: >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>> >>> >>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>>>> >>> >>>: >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>> Suenaga wrote: >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>>>> >>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>>>> >>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>>>> >>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>>>> >>> >>>>: >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>> >>> JavaThread(); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> main_thread->initialize_thread_current(); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>> >>> main_thread->set_native_thread_name("main"); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>> >>> set_active_handles >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> main_thread->record_stack_base_and_size(); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing something? >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to thread >>>>> >>> name in >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>> setName(). >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, >>>>> native >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is already >>>>> >>> starte >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>>> thrrad name >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>> something like >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp >>>>> Tue >>>>> >>> Mar 29 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp >>>>> Wed >>>>> >>> Mar 30 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop create_initial_thread(Handle >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>> initial_thread_name = >>>>> >>> "main"; >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass (THREAD, k); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > java_lang_Thread::set_thread(thread_oop(), >>>>> >>> thread); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> java_lang_Thread::set_priority(thread_oop(), >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>> thread_oop, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself >>>>> 'java' and >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process >>>>> (and >>>>> >>> thus >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process >>>>> is not >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>> >>> JavaThread. So I >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main thread. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it anyhow, since >>>>> >>> we want >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name >>>>> might >>>>> >>> have >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | head -4 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like >>>>> 'Java Main >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>>>> >>> launcher - e.g. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread >>>>> name, >>>>> >>> I think >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >>>>> >>> Suenaga wrote: >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set thread >>>>> >>> name via >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>>> have it. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, >>>>> and main >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>>> should have >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you >>>>> review it? >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>> > >>>>>>>>>> >>>>> >>> > >>>>> >>> >>>>> >> > From joe.darcy at oracle.com Sat Apr 23 17:07:24 2016 From: joe.darcy at oracle.com (joe darcy) Date: Sat, 23 Apr 2016 10:07:24 -0700 Subject: Annotation with array of Annotation In-Reply-To: <571B236A.8090609@gmx.org> References: <571B236A.8090609@gmx.org> Message-ID: <571BABCC.9030504@oracle.com> On 4/23/2016 12:25 AM, Jochen Theodorou wrote: > Hi all, > > I know the following does not compile and does right so by the JLS: > > public @interface SomeCollector { > Annotation[] value(); > } > > I know also that it would be easy to support with the existing > infrastructure. What I am looking for, is the reasoning as of why this > is not allowed besides what is directly in the JLS. I am trying to > understand the background a bit more. Has someone a pointer? > Some rationale for design decisions in the annotations facility are contained in the documents for JSR 175: JSR 175: A Metadata Facility for the Java Programming Language https://jcp.org/en/jsr/detail?id=175 Cheers, -Joe From dl at cs.oswego.edu Sun Apr 24 13:13:58 2016 From: dl at cs.oswego.edu (Doug Lea) Date: Sun, 24 Apr 2016 09:13:58 -0400 Subject: RFR(s): 8154801 deprecate java.util.Observable/Observer In-Reply-To: <571989A8.3010901@oracle.com> References: <571989A8.3010901@oracle.com> Message-ID: <571CC696.8080908@cs.oswego.edu> On 04/21/2016 10:17 PM, Stuart Marks wrote: > Hi all, > > Here's a small proposal to deprecate the java.util.Observable and Observer. This > deprecation will not be for removal. These days, anyone encountering these is probably hitting them by mistake while using RxJava or other reactive-stream frameworks. In which case, users will normally want to instead use the jdk9 java.util.concurrent.Flow APIs that all reactive-streams frameworks should be compatible/interoperable with in their planned upcoming jdk9-compatible versions. I'm not sure how to state this now in any @Deprecated docs or other Observable and Observer javadocs though. -Doug From kumar.x.srinivasan at oracle.com Sun Apr 24 14:52:47 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Sun, 24 Apr 2016 07:52:47 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571B7796.8030905@gmail.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> Message-ID: <571CDDBF.7000909@oracle.com> Hi Yasumasa, Looks good. Thanks Kumar On 4/23/2016 6:24 AM, Yasumasa Suenaga wrote: > Hi Kumar, > > Thank you for your comment! > I've fixed them and uploaded new webrev. Could you review again? > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ > > > Thanks, > > Yasumasa > > > On 2016/04/23 1:14, Kumar Srinivasan wrote: >> >> Also a couple of minor suggestions: >> >> - * Set native thread name as possible. >> + * Set native thread name if possible. >> >> >> + /* >> - * We can clear pending exception because exception at this point >> - * is not critical. >> + */ >> >> + /* >> + * Clear non critical pending exceptions at this point. >> + */ >> >> Thanks >> Kumar >> >>> Hi, >>> >>> This is in the wrong place: >>> >>> 1715 if ((*env)->ExceptionOccurred(env)) { >>> 1716 /* >>> 1717 * We can clear pending exception because exception at >>> this point >>> 1718 * is not critical. >>> 1719 */ >>> 1720 (*env)->ExceptionClear(env); >>> 1721 } >>> >>> This above needs to be after >>> 391 SetNativeThreadName(env, "main"); >>> 392 >>> >>> Here is why, supposing 1704 through 1711, returns a NULL, >>> but have also encountered an exception. In which case >>> the method SetNativeThreadName will return to the caller, as >>> if nothing has happened, because NULL_CHECK simply checks for NULL >>> and returns to the caller. This will cause the caller to enter >>> the VM with exceptions. >>> >>> Kumar >>> >>> >>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> I don't think we need to report the exception, but can just ignore >>>>> it. Either way we have to clear the exception before continuing. >>>> >>>> I've fixed it in new webrev: >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/22 15:33, David Holmes wrote: >>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>> Hi all, >>>>>> >>>>>> I have uploaded webrev.04 as below. >>>>>> Could you review again? >>>>>> >>>>>> > - hotspot: >>>>>> > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>> >>>>> Looks fine. >>>>> >>>>>> > >>>>>> > - jdk: >>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>> >>>>> As per private email (but repeated here on the record) in java.c: >>>>> >>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>> 1716 JLI_ReportExceptionDescription(env); >>>>> 1717 } >>>>> >>>>> I don't think we need to report the exception, but can just ignore >>>>> it. Either way we have to clear the exception before continuing. >>>>> >>>>> Thanks, >>>>> David >>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>> >: >>>>>> > >>>>>> > Hi David, >>>>>> > >>>>>> > Thank you for your comment. >>>>>> > I uploaded new webrev. Could you review again? >>>>>> > >>>>>> > - hotspot: >>>>>> > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>> > >>>>>> > - jdk: >>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>> > >>>>>> > >>>>>> >> That aside I'm not sure why you do this so late in the >>>>>> process, I >>>>>> would have done it immediately after here: >>>>>> > >>>>>> > >>>>>> > I think that native thread name ("main") should be set just >>>>>> before >>>>>> > main method call. >>>>>> > However, main thread is already started, so I moved it as you >>>>>> suggested. >>>>>> > >>>>>> > >>>>>> >> One thing I dislike about the current structure is that we >>>>>> have to >>>>>> go from char* to java.lang.String to call setNativeName which >>>>>> then calls >>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>> char* ! >>>>>> > >>>>>> > >>>>>> > SoI proposed to export new JVM function to set native thread >>>>>> name with >>>>>> > const char *. >>>>>> > >>>>>> > >>>>>> > Thanks, >>>>>> > >>>>>> > Yasumasa >>>>>> > >>>>>> > >>>>>> > >>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>> >> >>>>>> >> Hi Yasumasa, >>>>>> >> >>>>>> >> Thanks for persevering with this to get it into the current >>>>>> form. >>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>> >> >>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>> >>> >>>>>> >>> Hi Gerard, >>>>>> >>> >>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>> >>>>>> >>> >>>>> >>: >>>>>> >>> > >>>>>> >>> > hi Yasumasa, >>>>>> >>> > >>>>>> >>> > Nice work. I have 2 questions: >>>>>> >>> > >>>>>> >>> > ======== >>>>>> >>> > File: java.c >>>>>> >>> > >>>>>> >>> > #1 Shouldn?t we be checking for >>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>> >>> after every single JNI call? In this example instead of >>>>>> NULL_CHECK, >>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>> >>> >>>>>> >>> It is not critical if we encounter error at JNI function >>>>>> call because >>>>>> >>> we cannot set native thread name only. >>>>>> >>> So I think that we do not need to leave from launcher process. >>>>>> >> >>>>>> >> >>>>>> >> I agree we do not need to abort if an exception occurs (and >>>>>> in fact >>>>>> I don't think an exception is even possible from this code), but we >>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>> extensively >>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>> is all >>>>>> wrong! More on this code below ... >>>>>> >> >>>>>> >> Other comments: >>>>>> >> >>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>> >> >>>>>> >> Please add a comment to the method now that you removed the >>>>>> internal >>>>>> comment: >>>>>> >> >>>>>> >> // Sets the native thread name for a JavaThread. If specifically >>>>>> >> // requested JNI-attached threads can also have their native >>>>>> name set; >>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>> interfere >>>>>> >> // with the application that created them. >>>>>> >> >>>>>> >> --- >>>>>> >> >>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>> >> >>>>>> >> Please add the following comments: >>>>>> >> >>>>>> >> + // Don't modify JNI-attached threads >>>>>> >> setNativeName(name, false); >>>>>> >> >>>>>> >> + // May be called directly via JNI or reflection (when >>>>>> permitted) to >>>>>> >> + // allow JNI-attached threads to set their native name >>>>>> >> private native void setNativeName(String name, boolean >>>>>> allowAttachedThread); >>>>>> >> >>>>>> >> --- >>>>>> >> >>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>> >> >>>>>> >> 328 #define LEAVE() \ >>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>> >> >>>>>> >> I was going to suggest this be set later, but realized we >>>>>> have to be >>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>> >> >>>>>> >> + /* Set native thread name. */ >>>>>> >> + SetNativeThreadName(env, "main"); >>>>>> >> >>>>>> >> The comment is redundant given the name of the method. That >>>>>> aside >>>>>> I'm not sure why you do this so late in the process, I would have >>>>>> done >>>>>> it immediately after here: >>>>>> >> >>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>> >> 388 exit(1); >>>>>> >> 389 } >>>>>> >> + SetNativeThreadName(env, "main"); >>>>>> >> >>>>>> >> >>>>>> >> + /** >>>>>> >> + * Set native thread name as possible. >>>>>> >> + */ >>>>>> >> >>>>>> >> Other than the as->if change I'm unclear where the "possible" >>>>>> bit >>>>>> comes into play - why would it not be possible? >>>>>> >> >>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>> "java/lang/Thread")); >>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>> (*env)->GetStaticMethodID(env, >>>>>> cls, >>>>>> >> 1707 "currentThread", >>>>>> "()Ljava/lang/Thread;")); >>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>> >> 1709 currentThreadID)); >>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>> (*env)->GetMethodID(env, cls, >>>>>> >> 1711 "setNativeName", >>>>>> "(Ljava/lang/String;Z)V")); >>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>> name)); >>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>> setNativeNameID, >>>>>> >> 1714 nameString, JNI_TRUE); >>>>>> >> >>>>>> >> As above NULL_CHECK is fine here, but we should check for and >>>>>> clear >>>>>> any pending exception after CallVoidMethod. >>>>>> >> >>>>>> >> One thing I dislike about the current structure is that we >>>>>> have to >>>>>> go from char* to java.lang.String to call setNativeName which >>>>>> then calls >>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>> char* ! >>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>> is an >>>>>> issue we can revisit this. >>>>>> >> >>>>>> >> Thanks, >>>>>> >> David >>>>>> >> ----- >>>>>> >> >>>>>> >> >>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>> native >>>>>> thread >>>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>>> >>> >>>>>> >>> Sorry for my bad English :-) >>>>>> >>> >>>>>> >>> Thanks, >>>>>> >>> >>>>>> >>> Yasumasa >>>>>> >>> >>>>>> >>> > cheers >>>>>> >>> > >>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>> >>>>>> >>> >> wrote: >>>>>> >>> > > >>>>>> >>> > > Hi David, >>>>>> >>> > > >>>>>> >>> > > I uploaded new webrev: >>>>>> >>> > > >>>>>> >>> > > - hotspot: >>>>>> >>> > > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>> >>> > > >>>>>> >>> > > - jdk: >>>>>> >>> > > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>> >>> > > >>>>>> >>> > > >>>>>> >>> > >> it won't work unless you change the semantics of >>>>>> setName so I'm >>>>>> >>> not sure what you were thinking here. To take advantage of >>>>>> an arg >>>>>> taking >>>>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>>>> no Java >>>>>> >>> code will call it . ??? >>>>>> >>> > > >>>>>> >>> > > I added a flag for setting native thread name to >>>>>> JNI-attached >>>>>> thread. >>>>>> >>> > > This change can set native thread name if main thread >>>>>> changes to >>>>>> >>> JNI-attached thread. >>>>>> >>> > > >>>>>> >>> > > >>>>>> >>> > > Thanks, >>>>>> >>> > > >>>>>> >>> > > Yasumasa >>>>>> >>> > > >>>>>> >>> > > >>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>> Hi David, >>>>>> >>> > >>> >>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>> considered a >>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>> main, even >>>>>> >>> > >>>> though we never really intended it to work in the >>>>>> first place. >>>>>> >>> :( Such >>>>>> >>> > >>>> a change needs to go through CCC. >>>>>> >>> > >>> >>>>>> >>> > >>> I understood. >>>>>> >>> > >>> Can I send CCC request? >>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>> >>> > >> >>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>> sponsor for >>>>>> >>> that. But at this stage I don't think I agree with the >>>>>> proposed change >>>>>> >>> because of the change in behaviour - there's no way to >>>>>> restore the >>>>>> >>> "broken" behaviour. >>>>>> >>> > >> >>>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 >>>>>> [1]. >>>>>> >>> > >> >>>>>> >>> > >> Okay we can do that. >>>>>> >>> > >> >>>>>> >>> > >>> >>>>>> >>> > >>>> Further, we expect the launcher to use the supported >>>>>> JNI >>>>>> >>> interface (as >>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>> interface that >>>>>> >>> exists for >>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>> >>> > >>> >>>>>> >>> > >>> I think that we do not use JVM interface if we add >>>>>> new method in >>>>>> >>> > >>> LauncherHelper as below: >>>>>> >>> > >>> ---------------- >>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>> >>> > >>> >>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> >>> > >>> --- >>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>> >>> > >>> +++ >>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>> >>> > >>> else >>>>>> >>> > >>> return md.toNameAndVersion() + " (" + >>>>>> loc + ")"; >>>>>> >>> > >>> } >>>>>> >>> > >>> + >>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>> >>> > >>> + } >>>>>> >>> > >> >>>>>> >>> > >> You could also make that call via JNI directly, so not >>>>>> sure the >>>>>> >>> helper adds much here. But it won't work unless you change the >>>>>> semantics >>>>>> >>> of setName so I'm not sure what you were thinking here. To take >>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>> need to >>>>>> call >>>>>> >>> it directly as no Java code will call it . ??? >>>>>> >>> > >> >>>>>> >>> > >> David >>>>>> >>> > >> ----- >>>>>> >>> > >> >>>>>> >>> > >>> } >>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>> src/java.base/share/native/libjli/java.c >>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>>>> Apr 13 >>>>>> 14:19:30 >>>>>> >>> > >>> 2016 +0000 >>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>>>> Apr 16 >>>>>> 11:25:53 >>>>>> >>> > >>> 2016 +0900 >>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>> *name); >>>>>> >>> > >>> >>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>> >>> > >>> >>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>> >>> > >>> */ >>>>>> >>> > >>> #define LEAVE() \ >>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>> >>> > >>> do { \ >>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>> JNI_OK) { \ >>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>> >>> > >>> >>>>>> >>> > >>> + /* Set native thread name. */ >>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>> >>> > >>> + >>>>>> >>> > >>> /* Invoke main method. */ >>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>> mainArgs); >>>>>> >>> > >>> >>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>> >>> > >>> joptString); >>>>>> >>> > >>> } >>>>>> >>> > >>> >>>>>> >>> > >>> +/** >>>>>> >>> > >>> + * Set native thread name as possible. >>>>>> >>> > >>> + */ >>>>>> >>> > >>> +static void >>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>> >>> > >>> +{ >>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>> >>> > >>> + jstring nameString; >>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>> name)); >>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>> setNativeThreadNameID, >>>>>> >>> > >>> nameString); >>>>>> >>> > >>> +} >>>>>> >>> > >>> + >>>>>> >>> > >>> /* >>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>> >>> > >>> */ >>>>>> >>> > >>> ---------------- >>>>>> >>> > >>> >>>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>> >>> > >>> >>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>> interface and so >>>>>> >>> > >>>> has to be approved. >>>>>> >>> > >>> >>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> Thanks, >>>>>> >>> > >>> >>>>>> >>> > >>> Yasumasa >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> [1] >>>>>> >>> > >>> >>>>>> >>> >>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>> >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>> Hi David, >>>>>> >>> > >>>>> >>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>> for main >>>>>> >>> thread and >>>>>> >>> > >>>>>> JNI attached threads >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> >>>>>> >>> > >>>>>> Though that will introduce a change in behaviour >>>>>> by itself as >>>>>> >>> setName >>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>> thread. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> I know. >>>>>> >>> > >>>> >>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>> considered a >>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>> main, even >>>>>> >>> > >>>> though we never really intended it to work in the >>>>>> first place. >>>>>> >>> :( Such >>>>>> >>> > >>>> a change needs to go through CCC. >>>>>> >>> > >>>> >>>>>> >>> > >>>>> I checked changeset history. >>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>> JDK-7098194, >>>>>> and it is >>>>>> >>> > >>>>> backported JDK 8. >>>>>> >>> > >>>> >>>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>>> >>> > >>>> >>>>>> >>> > >>>>> However, this function seems to be called from >>>>>> >>> Thread#setNativeName() >>>>>> >>> > >>>>> only. >>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>> >>> JVM_SetNativeThreadName() >>>>>> >>> > >>>>> for force setting. >>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>> >>> > >>>>> However, this function is NOT public, so I think we >>>>>> can >>>>>> add one >>>>>> >>> more >>>>>> >>> > >>>>> argument. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> What do you think about this? >>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>> from Java >>>>>> >>> launcher. >>>>>> >>> > >>>> >>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>> really at >>>>>> >>> issue. Yes >>>>>> >>> > >>>> we would add another arg to the JVM function to >>>>>> allow it to >>>>>> apply to >>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>> reflect that >>>>>> >>> not just >>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>> exported JVM >>>>>> >>> interface >>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>> launcher to >>>>>> >>> use the >>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>> not the >>>>>> internal >>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>> communicate >>>>>> >>> with the >>>>>> >>> > >>>> JVM. >>>>>> >>> > >>>> >>>>>> >>> > >>>> David >>>>>> >>> > >>>> ----- >>>>>> >>> > >>>> >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> Thanks, >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> Yasumasa >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>> Hi David, >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>>>> being a >>>>>> >>> JNI-attached >>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>> for main >>>>>> >>> thread and >>>>>> >>> > >>>>>> JNI attached threads >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> Though that will introduce a change in behaviour >>>>>> by itself as >>>>>> >>> setName >>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>> thread. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr >>>>>> 14 13:31:11 >>>>>> >>> 2016 +0200 >>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr >>>>>> 15 17:50:10 >>>>>> >>> 2016 +0900 >>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>> is complete >>>>>> >>> - nop if >>>>>> >>> > >>>>>>> no agents. >>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>> >>> > >>>>>>> + >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>>>> constructor. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>> tracing >>>>>> >>> > >>>>>>> backend."); >>>>>> >>> > >>>>>>> } >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>>> If it wants to name its native threads then it >>>>>> is free >>>>>> to do so, >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>> change native >>>>>> >>> thread name >>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>> >>> > >>>>>>> However, I think that it should be changed if >>>>>> Java developer >>>>>> >>> calls >>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>> SetNativeThreadName() as >>>>>> below. >>>>>> >>> > >>>>>>> What do you think about this? >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>>> threads was a >>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>> with the OSX >>>>>> >>> port and >>>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>>> feature was to >>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>> been set by >>>>>> >>> the host >>>>>> >>> > >>>>>> process. If we do as you propose then we will just >>>>>> have an >>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>> does my >>>>>> >>> native thread >>>>>> >>> > >>>>>> only have a name if I call >>>>>> cur.setName(cur.getName()) ?" >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>>>> this, the >>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>> thread only, >>>>>> >>> non-JNI >>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>> were supposed >>>>>> >>> to be >>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>> can see >>>>>> that >>>>>> >>> never >>>>>> >>> > >>>>>> happened. :( >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>> desirable for >>>>>> the main >>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>> names >>>>>> then the >>>>>> >>> > >>>>>> launcher needs to be setting them using the available >>>>>> platform >>>>>> >>> APIs. >>>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced >>>>>> by the VM >>>>>> >>> code for >>>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>> Thread.setName would >>>>>> >>> have to go >>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>> the launcher >>>>>> >>> would >>>>>> >>> > >>>>>> not. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> Sorry. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> David >>>>>> >>> > >>>>>> ----- >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr >>>>>> 14 13:31:11 >>>>>> >>> 2016 +0200 >>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr >>>>>> 15 17:50:10 >>>>>> >>> 2016 +0900 >>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>> java_lang_Thread::thread(java_thread); >>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>> current thread, >>>>>> >>> doesn't >>>>>> >>> > >>>>>>> work >>>>>> >>> > >>>>>>> for >>>>>> >>> > >>>>>>> // target threads. >>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>> >>> !thr->has_attached_via_jni()) { >>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>> thread to avoid >>>>>> >>> stepping >>>>>> >>> > >>>>>>> // on other programs >>>>>> >>> > >>>>>>> const char *thread_name = >>>>>> >>> > >>>>>>> >>>>>> >>> >>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>> >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Thanks, >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Yasumasa >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>> Roger, >>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> David, >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>> this. I >>>>>> don't like >>>>>> >>> > >>>>>>>>>>>> exposing >>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>> initializing VM >>>>>> (before >>>>>> >>> > >>>>>>>>> calling >>>>>> >>> > >>>>>>>>> main method), >>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>> AttachCurrentThread(). >>>>>> So we >>>>>> >>> can't >>>>>> >>> > >>>>>>>>> set >>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>>>> morning. >>>>>> >>> Which, >>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>> premise here that >>>>>> >>> we don't >>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>> The fact >>>>>> >>> that the >>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>>>> thread seems >>>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is >>>>>> only >>>>>> working by >>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>> used for the >>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>> inconsistently >>>>>> >>> named at >>>>>> >>> > >>>>>>>> the native level. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>>>> to be >>>>>> >>> treated like >>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>> wants to >>>>>> name its >>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>> would not be >>>>>> >>> exporting >>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>> have to >>>>>> use the OS >>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>> platform-by-platform basis. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> Sorry. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> David >>>>>> >>> > >>>>>>>> ----- >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>> >>> > >>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> Comments: >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>>>> perform >>>>>> >>> different >>>>>> >>> > >>>>>>>>>> functions: >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>> JVM_SetNativeThreadName >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>> thread, the >>>>>> >>> second >>>>>> >>> > >>>>>>>>>> one a >>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>>>> somewhere >>>>>> >>> about >>>>>> >>> > >>>>>>>>>> what >>>>>> >>> > >>>>>>>>>> the new function does. >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>> casts to >>>>>> (void*) >>>>>> >>> > >>>>>>>>>> instead of >>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>> overwriteifn->GetCreatedJavaVMs >>>>>> >>> used at >>>>>> >>> > >>>>>>>>>> line 730 >>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>>>> the cast >>>>>> >>> on the >>>>>> >>> > >>>>>>>>>> same >>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>> haven't had >>>>>> time to >>>>>> >>> > >>>>>>>>>>>> check - >>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>> JNI-attached >>>>>> >>> thread >>>>>> >>> > >>>>>>>>>>>> then >>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>> suggestion >>>>>> >>> should >>>>>> >>> > >>>>>>>>>>>> work >>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>> treatment of >>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>>>> confirmed >>>>>> >>> native >>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>> >>> > >>>>>>>>>>> --------- >>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>>> Exception{ >>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>> >>> > >>>>>>>>>>> } >>>>>> >>> > >>>>>>>>>>> } >>>>>> >>> > >>>>>>>>>>> --------- >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>> this. I >>>>>> don't like >>>>>> >>> > >>>>>>>>>>>> exposing >>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>> comment. >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>> wrote: >>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>>>> thread >>>>>> >>> name, and JLI >>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>> >>> > >>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>>>> >>> core-libs will >>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>> Kumar) - >>>>>> now cc'd. >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>> >>> Thread.setName >>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>>> hotspot changes >>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>> Thread#setName() in >>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>>>> which is >>>>>> >>> why the >>>>>> >>> > >>>>>>>>>>>> native >>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>> attached thread. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>> haven't had >>>>>> time to >>>>>> >>> > >>>>>>>>>>>> check - >>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>> JNI-attached >>>>>> >>> thread >>>>>> >>> > >>>>>>>>>>>> then >>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>> suggestion >>>>>> >>> should >>>>>> >>> > >>>>>>>>>>>> work >>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>> treatment of >>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>> this. I >>>>>> don't like >>>>>> >>> > >>>>>>>>>>>> exposing >>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>> David >>>>>> >>> > >>>>>>>>>>>> ----- >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>> function to set >>>>>> >>> native >>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> >>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>> David >>>>>> >>> > >>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>> well ... >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>> have >>>>>> been on >>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>> correct >>>>>> as we >>>>>> >>> do not >>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>>>> includes the >>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>> wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer >>>>>> :-) >>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>> >>>>>> >>> >>: >>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>> Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>> Suenaga >>>>>> wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>> >>> >>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> >>>>> >>>: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>>> Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>>>>> >>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> >>>>> >>>>: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>> set it: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = >>>>>> new >>>>>> >>> JavaThread(); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> main_thread->initialize_thread_current(); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>> >>> set_active_handles >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> main_thread->record_stack_base_and_size(); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> >>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>> something? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>> to thread >>>>>> >>> name in >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>>> setName(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in >>>>>> Java app, >>>>>> native >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread >>>>>> is already >>>>>> >>> starte >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>>>> thrrad name >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>> something like >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>> a/src/share/vm/runtime/thread.cpp >>>>>> Tue >>>>>> >>> Mar 29 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>> b/src/share/vm/runtime/thread.cpp >>>>>> Wed >>>>>> >>> Mar 30 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>> create_initial_thread(Handle >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>> initial_thread_name = >>>>>> >>> "main"; >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> >>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>> (THREAD, k); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>> >>> thread); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> thread->set_threadObj(thread_oop()); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> java_lang_String::create_from_str("main", >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>>> thread_oop, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>> itself >>>>>> 'java' and >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>> process >>>>>> (and >>>>>> >>> thus >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>> process >>>>>> is not >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>> with >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>>> >>> JavaThread. So I >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>>>> thread. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>> anyhow, since >>>>>> >>> we want >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>> thread name >>>>>> might >>>>>> >>> have >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' >>>>>> | head -4 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>> like >>>>>> 'Java Main >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>> Java >>>>>> >>> launcher - e.g. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>> thread >>>>>> name, >>>>>> >>> I think >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>> Yasumasa >>>>>> >>> Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>>>> thread >>>>>> >>> name via >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>>>> have it. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>>>> name, >>>>>> and main >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>>>> should have >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could >>>>>> you >>>>>> review it? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>> >>> >>>>>> >>> >> From amy.lu at oracle.com Mon Apr 25 03:00:20 2016 From: amy.lu at oracle.com (Amy Lu) Date: Mon, 25 Apr 2016 11:00:20 +0800 Subject: JDK 9 RFR of JDK-8154911: Move GCDuringIteration.java back to tier1 Message-ID: <571D8844.5040805@oracle.com> java/util/WeakHashMap/GCDuringIteration.java This test was failing intermittently (JDK-6842353) and demoted to tier2. Mentioned issues have been resolved and no open bug (no failure reported) till now. This patch is to move the test back to tier1. bug: https://bugs.openjdk.java.net/browse/JDK-8154911 webrev: http://cr.openjdk.java.net/~amlu/8154911/webrev.00/ Thanks, Amy --- old/test/TEST.groups 2016-04-25 10:54:59.000000000 +0800 +++ new/test/TEST.groups 2016-04-25 10:54:58.000000000 +0800 @@ -29,7 +29,6 @@ :jdk_lang \ -java/lang/ProcessHandle/TreeTest.java \ :jdk_util \ - -java/util/WeakHashMap/GCDuringIteration.java \ -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ sun/nio/cs/ISO8859x.java \ @@ -39,7 +38,6 @@ tier2 = \ java/lang/ProcessHandle/TreeTest.java \ - java/util/WeakHashMap/GCDuringIteration.java \ java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ :jdk_io \ From david.holmes at oracle.com Mon Apr 25 05:46:35 2016 From: david.holmes at oracle.com (David Holmes) Date: Mon, 25 Apr 2016 15:46:35 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571A381E.9050605@oracle.com> References: <56F3F90D.9010408@gmail.com> <56FC3D4B.2000700@oracle.com> <56FC3DF8.4080309@oracle.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> Message-ID: <571DAF3B.9030200@oracle.com> On 23/04/2016 12:41 AM, Kumar Srinivasan wrote: > Hi, > > This is in the wrong place: > > 1715 if ((*env)->ExceptionOccurred(env)) { > 1716 /* > 1717 * We can clear pending exception because exception at this > point > 1718 * is not critical. > 1719 */ > 1720 (*env)->ExceptionClear(env); > 1721 } > > This above needs to be after > 391 SetNativeThreadName(env, "main"); > 392 > > Here is why, supposing 1704 through 1711, returns a NULL, > but have also encountered an exception. In which case > the method SetNativeThreadName will return to the caller, as > if nothing has happened, because NULL_CHECK simply checks for NULL > and returns to the caller. This will cause the caller to enter > the VM with exceptions. Ah! Now I see the pattern. All the existing functions that use NULL_CHECK are followed by CHECK_EXCEPTION_LEAVE. Thanks for pointing that out Kumar! David > Kumar > > > On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >> Hi David, >> >>> I don't think we need to report the exception, but can just ignore >>> it. Either way we have to clear the exception before continuing. >> >> I've fixed it in new webrev: >> >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/22 15:33, David Holmes wrote: >>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>> Hi all, >>>> >>>> I have uploaded webrev.04 as below. >>>> Could you review again? >>>> >>>> > - hotspot: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>> >>> Looks fine. >>> >>>> > >>>> > - jdk: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>> >>> As per private email (but repeated here on the record) in java.c: >>> >>> 715 if ((*env)->ExceptionOccurred(env)) { >>> 1716 JLI_ReportExceptionDescription(env); >>> 1717 } >>> >>> I don't think we need to report the exception, but can just ignore >>> it. Either way we have to clear the exception before continuing. >>> >>> Thanks, >>> David >>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>> >: >>>> > >>>> > Hi David, >>>> > >>>> > Thank you for your comment. >>>> > I uploaded new webrev. Could you review again? >>>> > >>>> > - hotspot: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>> > >>>> > - jdk: >>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>> > >>>> > >>>> >> That aside I'm not sure why you do this so late in the process, I >>>> would have done it immediately after here: >>>> > >>>> > >>>> > I think that native thread name ("main") should be set just before >>>> > main method call. >>>> > However, main thread is already started, so I moved it as you >>>> suggested. >>>> > >>>> > >>>> >> One thing I dislike about the current structure is that we have to >>>> go from char* to java.lang.String to call setNativeName which then >>>> calls >>>> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >>>> > >>>> > >>>> > SoI proposed to export new JVM function to set native thread name >>>> with >>>> > const char *. >>>> > >>>> > >>>> > Thanks, >>>> > >>>> > Yasumasa >>>> > >>>> > >>>> > >>>> > On 2016/04/19 14:04, David Holmes wrote: >>>> >> >>>> >> Hi Yasumasa, >>>> >> >>>> >> Thanks for persevering with this to get it into the current form. >>>> Sorry I haven't been able to do a detailed review until now. >>>> >> >>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>> >>> >>>> >>> Hi Gerard, >>>> >>> >>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>> >>>> >>> >>> >>: >>>> >>> > >>>> >>> > hi Yasumasa, >>>> >>> > >>>> >>> > Nice work. I have 2 questions: >>>> >>> > >>>> >>> > ======== >>>> >>> > File: java.c >>>> >>> > >>>> >>> > #1 Shouldn?t we be checking for >>>> ?(*env)->ExceptionOccurred(env)? >>>> >>> after every single JNI call? In this example instead of >>>> NULL_CHECK, >>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>> >>> >>>> >>> It is not critical if we encounter error at JNI function call >>>> because >>>> >>> we cannot set native thread name only. >>>> >>> So I think that we do not need to leave from launcher process. >>>> >> >>>> >> >>>> >> I agree we do not need to abort if an exception occurs (and in fact >>>> I don't think an exception is even possible from this code), but we >>>> should ensure any pending exception is cleared before any futher JNI >>>> calls might be made. Note that NULL_CHECK is already used extensively >>>> throughout the launcher code - so if this usage is wrong then it is all >>>> wrong! More on this code below ... >>>> >> >>>> >> Other comments: >>>> >> >>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>> >> >>>> >> Please add a comment to the method now that you removed the >>>> internal >>>> comment: >>>> >> >>>> >> // Sets the native thread name for a JavaThread. If specifically >>>> >> // requested JNI-attached threads can also have their native >>>> name set; >>>> >> // otherwise we do not modify JNI-attached threads as it may >>>> interfere >>>> >> // with the application that created them. >>>> >> >>>> >> --- >>>> >> >>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>> >> >>>> >> Please add the following comments: >>>> >> >>>> >> + // Don't modify JNI-attached threads >>>> >> setNativeName(name, false); >>>> >> >>>> >> + // May be called directly via JNI or reflection (when >>>> permitted) to >>>> >> + // allow JNI-attached threads to set their native name >>>> >> private native void setNativeName(String name, boolean >>>> allowAttachedThread); >>>> >> >>>> >> --- >>>> >> >>>> >> jd/src/java.base/share/native/libjli/java.c >>>> >> >>>> >> 328 #define LEAVE() \ >>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> >> >>>> >> I was going to suggest this be set later, but realized we have >>>> to be >>>> attached to do this and that happens inside DestroyJavaVM. :) >>>> >> >>>> >> + /* Set native thread name. */ >>>> >> + SetNativeThreadName(env, "main"); >>>> >> >>>> >> The comment is redundant given the name of the method. That aside >>>> I'm not sure why you do this so late in the process, I would have done >>>> it immediately after here: >>>> >> >>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>> >> 388 exit(1); >>>> >> 389 } >>>> >> + SetNativeThreadName(env, "main"); >>>> >> >>>> >> >>>> >> + /** >>>> >> + * Set native thread name as possible. >>>> >> + */ >>>> >> >>>> >> Other than the as->if change I'm unclear where the "possible" bit >>>> comes into play - why would it not be possible? >>>> >> >>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>> "java/lang/Thread")); >>>> >> 1706 NULL_CHECK(currentThreadID = >>>> (*env)->GetStaticMethodID(env, >>>> cls, >>>> >> 1707 "currentThread", >>>> "()Ljava/lang/Thread;")); >>>> >> 1708 NULL_CHECK(currentThread = >>>> (*env)->CallStaticObjectMethod(env, cls, >>>> >> 1709 currentThreadID)); >>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, cls, >>>> >> 1711 "setNativeName", >>>> "(Ljava/lang/String;Z)V")); >>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, name)); >>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>> setNativeNameID, >>>> >> 1714 nameString, JNI_TRUE); >>>> >> >>>> >> As above NULL_CHECK is fine here, but we should check for and clear >>>> any pending exception after CallVoidMethod. >>>> >> >>>> >> One thing I dislike about the current structure is that we have to >>>> go from char* to java.lang.String to call setNativeName which then >>>> calls >>>> JVM_SetNativeThreadName which converts the j.l.String back to a char* ! >>>> Overall I wonder about the affect on startup cost. But if there is an >>>> issue we can revisit this. >>>> >> >>>> >> Thanks, >>>> >> David >>>> >> ----- >>>> >> >>>> >> >>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set native >>>> thread >>>> >>> name if possible.? not "Set native thread name as possible.?? >>>> >>> >>>> >>> Sorry for my bad English :-) >>>> >>> >>>> >>> Thanks, >>>> >>> >>>> >>> Yasumasa >>>> >>> >>>> >>> > cheers >>>> >>> > >>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>> >>>> >>> >> wrote: >>>> >>> > > >>>> >>> > > Hi David, >>>> >>> > > >>>> >>> > > I uploaded new webrev: >>>> >>> > > >>>> >>> > > - hotspot: >>>> >>> > > >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>> >>> > > >>>> >>> > > - jdk: >>>> >>> > > >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>> >>> > > >>>> >>> > > >>>> >>> > >> it won't work unless you change the semantics of setName >>>> so I'm >>>> >>> not sure what you were thinking here. To take advantage of an arg >>>> taking >>>> >>> JVM_SetNativThreadName you would need to call it directly as no >>>> Java >>>> >>> code will call it . ??? >>>> >>> > > >>>> >>> > > I added a flag for setting native thread name to JNI-attached >>>> thread. >>>> >>> > > This change can set native thread name if main thread >>>> changes to >>>> >>> JNI-attached thread. >>>> >>> > > >>>> >>> > > >>>> >>> > > Thanks, >>>> >>> > > >>>> >>> > > Yasumasa >>>> >>> > > >>>> >>> > > >>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>> >>> > >>> Hi David, >>>> >>> > >>> >>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>> considered a >>>> >>> > >>>> regression that setName stops setting the native thread >>>> main, even >>>> >>> > >>>> though we never really intended it to work in the first >>>> place. >>>> >>> :( Such >>>> >>> > >>>> a change needs to go through CCC. >>>> >>> > >>> >>>> >>> > >>> I understood. >>>> >>> > >>> Can I send CCC request? >>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>> >>> > >> >>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>> sponsor for >>>> >>> that. But at this stage I don't think I agree with the proposed >>>> change >>>> >>> because of the change in behaviour - there's no way to restore the >>>> >>> "broken" behaviour. >>>> >>> > >> >>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 [1]. >>>> >>> > >> >>>> >>> > >> Okay we can do that. >>>> >>> > >> >>>> >>> > >>> >>>> >>> > >>>> Further, we expect the launcher to use the supported JNI >>>> >>> interface (as >>>> >>> > >>>> other processes would), not the internal JVM interface >>>> that >>>> >>> exists for >>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>> >>> > >>> >>>> >>> > >>> I think that we do not use JVM interface if we add new >>>> method in >>>> >>> > >>> LauncherHelper as below: >>>> >>> > >>> ---------------- >>>> >>> > >>> diff -r f02139a1ac84 >>>> >>> > >>> >>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> >>> > >>> --- >>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>> >>> > >>> +++ >>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>> >>> > >>> @@ -960,4 +960,8 @@ >>>> >>> > >>> else >>>> >>> > >>> return md.toNameAndVersion() + " (" + loc + >>>> ")"; >>>> >>> > >>> } >>>> >>> > >>> + >>>> >>> > >>> + static void setNativeThreadName(String name) { >>>> >>> > >>> + Thread.currentThread().setName(name); >>>> >>> > >>> + } >>>> >>> > >> >>>> >>> > >> You could also make that call via JNI directly, so not >>>> sure the >>>> >>> helper adds much here. But it won't work unless you change the >>>> semantics >>>> >>> of setName so I'm not sure what you were thinking here. To take >>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>> need to >>>> call >>>> >>> it directly as no Java code will call it . ??? >>>> >>> > >> >>>> >>> > >> David >>>> >>> > >> ----- >>>> >>> > >> >>>> >>> > >>> } >>>> >>> > >>> diff -r f02139a1ac84 >>>> src/java.base/share/native/libjli/java.c >>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>> Apr 13 >>>> 14:19:30 >>>> >>> > >>> 2016 +0000 >>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>> Apr 16 >>>> 11:25:53 >>>> >>> > >>> 2016 +0900 >>>> >>> > >>> @@ -125,6 +125,7 @@ >>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char *name); >>>> >>> > >>> >>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>> >>> > >>> >>>> >>> > >>> @@ -325,6 +326,7 @@ >>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>> >>> > >>> */ >>>> >>> > >>> #define LEAVE() \ >>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> >>> > >>> do { \ >>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>> >>> > >>> @@ -488,6 +490,9 @@ >>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>> >>> > >>> >>>> >>> > >>> + /* Set native thread name. */ >>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>> >>> > >>> + >>>> >>> > >>> /* Invoke main method. */ >>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>> mainArgs); >>>> >>> > >>> >>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>> >>> > >>> joptString); >>>> >>> > >>> } >>>> >>> > >>> >>>> >>> > >>> +/** >>>> >>> > >>> + * Set native thread name as possible. >>>> >>> > >>> + */ >>>> >>> > >>> +static void >>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>> >>> > >>> +{ >>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>> >>> > >>> + jstring nameString; >>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>> >>> > >>> + NULL_CHECK(cls); >>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>> >>> (*env)->GetStaticMethodID(env, cls, >>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>> name)); >>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>> setNativeThreadNameID, >>>> >>> > >>> nameString); >>>> >>> > >>> +} >>>> >>> > >>> + >>>> >>> > >>> /* >>>> >>> > >>> * Prints default usage or the Xusage message, see >>>> >>> > >>> sun.launcher.LauncherHelper.java >>>> >>> > >>> */ >>>> >>> > >>> ---------------- >>>> >>> > >>> >>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>> >>> > >>> >>>> >>> > >>>> However this is still a change to the exported JVM >>>> interface and so >>>> >>> > >>>> has to be approved. >>>> >>> > >>> >>>> >>> > >>> Do you mean that this change needs CCC? >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> Thanks, >>>> >>> > >>> >>>> >>> > >>> Yasumasa >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> [1] >>>> >>> > >>> >>>> >>> >>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>> >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> >>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>> >>> > >>>>> Hi David, >>>> >>> > >>>>> >>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>> >>> > >>>>>> >>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for >>>> main >>>> >>> thread and >>>> >>> > >>>>>> JNI attached threads >>>> >>> > >>>>> >>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>> >>> > >>>>> >>>> >>> > >>>>> >>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>> itself as >>>> >>> setName >>>> >>> > >>>>>> will no longer set the native name for the main thread. >>>> >>> > >>>>> >>>> >>> > >>>>> I know. >>>> >>> > >>>> >>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>> considered a >>>> >>> > >>>> regression that setName stops setting the native thread >>>> main, even >>>> >>> > >>>> though we never really intended it to work in the first >>>> place. >>>> >>> :( Such >>>> >>> > >>>> a change needs to go through CCC. >>>> >>> > >>>> >>>> >>> > >>>>> I checked changeset history. >>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in JDK-7098194, >>>> and it is >>>> >>> > >>>>> backported JDK 8. >>>> >>> > >>>> >>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>> >>> > >>>> >>>> >>> > >>>>> However, this function seems to be called from >>>> >>> Thread#setNativeName() >>>> >>> > >>>>> only. >>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>> >>> > >>>>> >>>> >>> > >>>>> Thus I think that we can add an argument to >>>> >>> JVM_SetNativeThreadName() >>>> >>> > >>>>> for force setting. >>>> >>> > >>>>> (e.g. "bool forced") >>>> >>> > >>>>> >>>> >>> > >>>>> It makes a change of JVM API. >>>> >>> > >>>>> However, this function is NOT public, so I think we can >>>> add one >>>> >>> more >>>> >>> > >>>>> argument. >>>> >>> > >>>>> >>>> >>> > >>>>> What do you think about this? >>>> >>> > >>>>> If it is accepted, we can set native thread name from >>>> Java >>>> >>> launcher. >>>> >>> > >>>> >>>> >>> > >>>> The private/public aspect of the Java API is not really at >>>> >>> issue. Yes >>>> >>> > >>>> we would add another arg to the JVM function to allow >>>> it to >>>> apply to >>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>> reflect that >>>> >>> not just >>>> >>> > >>>> "force"). However this is still a change to the >>>> exported JVM >>>> >>> interface >>>> >>> > >>>> and so has to be approved. Further, we expect the >>>> launcher to >>>> >>> use the >>>> >>> > >>>> supported JNI interface (as other processes would), not >>>> the >>>> internal >>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>> communicate >>>> >>> with the >>>> >>> > >>>> JVM. >>>> >>> > >>>> >>>> >>> > >>>> David >>>> >>> > >>>> ----- >>>> >>> > >>>> >>>> >>> > >>>>> >>>> >>> > >>>>> Thanks, >>>> >>> > >>>>> >>>> >>> > >>>>> Yasumasa >>>> >>> > >>>>> >>>> >>> > >>>>> >>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>> >>> > >>>>>> Hi Yasumasa, >>>> >>> > >>>>>> >>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>> Hi David, >>>> >>> > >>>>>>> >>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>> being a >>>> >>> JNI-attached >>>> >>> > >>>>>>>> thread seems accidental to me >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Should I file it to JBS? >>>> >>> > >>>>>> >>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>> >>> > >>>>>> >>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // for >>>> main >>>> >>> thread and >>>> >>> > >>>>>> JNI attached threads >>>> >>> > >>>>>> >>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>> itself as >>>> >>> setName >>>> >>> > >>>>>> will no longer set the native name for the main thread. >>>> >>> > >>>>>> >>>> >>> > >>>>>>> I think that we can fix as below: >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>> 13:31:11 >>>> >>> 2016 +0200 >>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>> 17:50:10 >>>> >>> 2016 +0900 >>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>> >>> > >>>>>>> // must do this before set_active_handles >>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization is >>>> complete >>>> >>> - nop if >>>> >>> > >>>>>>> no agents. >>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> + // Change attach status to "attached" >>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>> >>> > >>>>>>> + >>>> >>> > >>>>>> >>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>> constructor. >>>> >>> > >>>>>> >>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start tracing >>>> >>> > >>>>>>> backend."); >>>> >>> > >>>>>>> } >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> >>>> >>> > >>>>>>>> If it wants to name its native threads then it is free >>>> to do so, >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>> native >>>> >>> thread name >>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>> developer >>>> >>> calls >>>> >>> > >>>>>>> Thread#setName() explicitly. >>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>> >>> > >>>>>>> Threads::create_vm(). >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> If it is allowed, I want to fix >>>> SetNativeThreadName() as >>>> below. >>>> >>> > >>>>>>> What do you think about this? >>>> >>> > >>>>>> >>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>> threads was a >>>> >>> > >>>>>> deliberate one** - this functionality originated with >>>> the OSX >>>> >>> port and >>>> >>> > >>>>>> it was reported that the initial feedback with this >>>> feature was to >>>> >>> > >>>>>> ensure it didn't mess with thread names that had been >>>> set by >>>> >>> the host >>>> >>> > >>>>>> process. If we do as you propose then we will just >>>> have an >>>> >>> > >>>>>> inconsistency for people to complain about: "why does my >>>> >>> native thread >>>> >>> > >>>>>> only have a name if I call cur.setName(cur.getName()) ?" >>>> >>> > >>>>>> >>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>> this, the >>>> >>> > >>>>>> semantics and limitations (truncation, current thread >>>> only, >>>> >>> non-JNI >>>> >>> > >>>>>> threads only) of setting the native thread name were >>>> supposed >>>> >>> to be >>>> >>> > >>>>>> documented in the release notes - but as far as I can >>>> see >>>> that >>>> >>> never >>>> >>> > >>>>>> happened. :( >>>> >>> > >>>>>> >>>> >>> > >>>>>> My position on this remains that if it is desirable for >>>> the main >>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names >>>> then the >>>> >>> > >>>>>> launcher needs to be setting them using the available >>>> platform >>>> >>> APIs. >>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>> the VM >>>> >>> code for >>>> >>> > >>>>>> this - due to the need to verify API availability. >>>> >>> > >>>>>> >>>> >>> > >>>>>> Any change in behaviour in relation to Thread.setName >>>> would >>>> >>> have to go >>>> >>> > >>>>>> through our CCC process I think. But a change in the >>>> launcher >>>> >>> would >>>> >>> > >>>>>> not. >>>> >>> > >>>>>> >>>> >>> > >>>>>> Sorry. >>>> >>> > >>>>>> >>>> >>> > >>>>>> David >>>> >>> > >>>>>> ----- >>>> >>> > >>>>>> >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>> 13:31:11 >>>> >>> 2016 +0200 >>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>> 17:50:10 >>>> >>> 2016 +0900 >>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>> >>> > >>>>>>> JavaThread* thr = >>>> java_lang_Thread::thread(java_thread); >>>> >>> > >>>>>>> // Thread naming only supported for the current >>>> thread, >>>> >>> doesn't >>>> >>> > >>>>>>> work >>>> >>> > >>>>>>> for >>>> >>> > >>>>>>> // target threads. >>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>> >>> !thr->has_attached_via_jni()) { >>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>> >>> > >>>>>>> // we don't set the name of an attached thread >>>> to avoid >>>> >>> stepping >>>> >>> > >>>>>>> // on other programs >>>> >>> > >>>>>>> const char *thread_name = >>>> >>> > >>>>>>> >>>> >>> >>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>> >>> > >>>>>>> --------------- >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Thanks, >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> Yasumasa >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> >>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>> Roger, >>>> >>> > >>>>>>>>> Thanks for your comment! >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> David, >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>> don't like >>>> >>> > >>>>>>>>>>>> exposing >>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>> initializing VM >>>> (before >>>> >>> > >>>>>>>>> calling >>>> >>> > >>>>>>>>> main method), >>>> >>> > >>>>>>>>> I could set native thread name. >>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls AttachCurrentThread(). >>>> So we >>>> >>> can't >>>> >>> > >>>>>>>>> set >>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>> morning. >>>> >>> Which, >>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>> here that >>>> >>> we don't >>>> >>> > >>>>>>>> set the name of threads not created by the JVM. The >>>> fact >>>> >>> that the >>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>> thread seems >>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is only >>>> working by >>>> >>> > >>>>>>>> accident for the initial attach, and can't be used >>>> for the >>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>> inconsistently >>>> >>> named at >>>> >>> > >>>>>>>> the native level. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has to be >>>> >>> treated like >>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>> wants to >>>> name its >>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>> would not be >>>> >>> exporting >>>> >>> > >>>>>>>> a function from the JVM to do that - it would have to >>>> use the OS >>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>> basis. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> Sorry. >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> David >>>> >>> > >>>>>>>> ----- >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>> >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> Thanks, >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> >>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>> >>> > >>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> Comments: >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>> perform >>>> >>> different >>>> >>> > >>>>>>>>>> functions: >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs JVM_SetNativeThreadName >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> - The first function applies to the current >>>> thread, the >>>> >>> second >>>> >>> > >>>>>>>>>> one a >>>> >>> > >>>>>>>>>> specific java thread. >>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>> somewhere >>>> >>> about >>>> >>> > >>>>>>>>>> what >>>> >>> > >>>>>>>>>> the new function does. >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to >>>> (void*) >>>> >>> > >>>>>>>>>> instead of >>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>> overwriteifn->GetCreatedJavaVMs >>>> >>> used at >>>> >>> > >>>>>>>>>> line 730 >>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>> the cast >>>> >>> on the >>>> >>> > >>>>>>>>>> same >>>> >>> > >>>>>>>>>> line as dlsym... >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> $.02, Roger >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> >>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't >>>> had >>>> time to >>>> >>> > >>>>>>>>>>>> check - >>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>> JNI-attached >>>> >>> thread >>>> >>> > >>>>>>>>>>>> then >>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>> suggestion >>>> >>> should >>>> >>> > >>>>>>>>>>>> work >>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>> treatment of >>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>> confirmed >>>> >>> native >>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>> >>> > >>>>>>>>>>> --------- >>>> >>> > >>>>>>>>>>> public class Sleep{ >>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>> Exception{ >>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>> >>> > >>>>>>>>>>> } >>>> >>> > >>>>>>>>>>> } >>>> >>> > >>>>>>>>>>> --------- >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>> don't like >>>> >>> > >>>>>>>>>>>> exposing >>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's comment. >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> >>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>> >>> > >>>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>> thread >>>> >>> name, and JLI >>>> >>> > >>>>>>>>>>>>>>> uses it >>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>> >>> > >>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>> >>> core-libs will >>>> >>> > >>>>>>>>>>>>>> need to >>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular Kumar) - >>>> now cc'd. >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Thanks! >>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>> >>> Thread.setName >>>> >>> > >>>>>>>>>>>>>> rather >>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>> hotspot changes >>>> >>> > >>>>>>>>>>>>>> needed in >>>> >>> > >>>>>>>>>>>>>> that case. >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>> Thread#setName() in >>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>> which is >>>> >>> why the >>>> >>> > >>>>>>>>>>>> native >>>> >>> > >>>>>>>>>>>> name is not set. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI attached >>>> thread. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> That is an interesting question which I haven't >>>> had >>>> time to >>>> >>> > >>>>>>>>>>>> check - >>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>> JNI-attached >>>> >>> thread >>>> >>> > >>>>>>>>>>>> then >>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>> suggestion >>>> >>> should >>>> >>> > >>>>>>>>>>>> work >>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>> treatment of >>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>> don't like >>>> >>> > >>>>>>>>>>>> exposing >>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>> David >>>> >>> > >>>>>>>>>>>> ----- >>>> >>> > >>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>> function to set >>>> >>> native >>>> >>> > >>>>>>>>>>>>> thread name. >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> [1] >>>> >>> > >>>>>>>>>>>>> >>>> >>> >>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>> David >>>> >>> > >>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as well >>>> ... >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have >>>> been on >>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>> >>> > >>>>>>>>>>>>>>>> This >>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be correct >>>> as we >>>> >>> do not >>>> >>> > >>>>>>>>>>>>>>>> set the >>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>> includes the >>>> >>> > >>>>>>>>>>>>>>>> "main" >>>> >>> > >>>>>>>>>>>>>>>> thread. >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> David >>>> >>> > >>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>> >>> > >>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>> >>> > >>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>> >>>> >>> >>: >>>> >>> > >>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>> >>> > >>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>> >>> > >>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>> >>> > >>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa Suenaga >>>> wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa Suenaga >>>> wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>> >>> >>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> >>>: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>> Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>> >>>> >>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>> >>>> >>> >>>>: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't set it: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>> a/src/share/vm/runtime/thread.cpp Thu >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>> b/src/share/vm/runtime/thread.cpp Thu >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>> >>> JavaThread(); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> main_thread->initialize_thread_current(); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>> >>> main_thread->set_native_thread_name("main"); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>> >>> set_active_handles >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> main_thread->record_stack_base_and_size(); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>> something? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same to >>>> thread >>>> >>> name in >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>> setName(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java app, >>>> native >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>> already >>>> >>> starte >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>> thrrad name >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>> something like >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- a/src/share/vm/runtime/thread.cpp >>>> Tue >>>> >>> Mar 29 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ b/src/share/vm/runtime/thread.cpp >>>> Wed >>>> >>> Mar 30 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>> create_initial_thread(Handle >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>> initial_thread_name = >>>> >>> "main"; >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>> (THREAD, k); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> klass->allocate_instance_handle(CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> java_lang_Thread::set_thread(thread_oop(), >>>> >>> thread); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> java_lang_Thread::set_priority(thread_oop(), >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> java_lang_String::create_from_str("main", >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> thread->set_native_thread_name(initial_thread_name); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>> thread_oop, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself >>>> 'java' and >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the process >>>> (and >>>> >>> thus >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the process >>>> is not >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>> >>> JavaThread. So I >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>> thread. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>> anyhow, since >>>> >>> we want >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread name >>>> might >>>> >>> have >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' | >>>> head -4 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like >>>> 'Java Main >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>>> >>> launcher - e.g. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main thread >>>> name, >>>> >>> I think >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >>>> >>> Suenaga wrote: >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>> thread >>>> >>> name via >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>> have it. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native name, >>>> and main >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>> should have >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you >>>> review it? >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>> >>> > >>>>>>>>>> >>>> >>> > >>>> >>> >>>> > From david.holmes at oracle.com Mon Apr 25 05:47:59 2016 From: david.holmes at oracle.com (David Holmes) Date: Mon, 25 Apr 2016 15:47:59 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571B7796.8030905@gmail.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> Message-ID: <571DAF8F.1080305@oracle.com> Looks good to me. I'll sponsor this "tomorrow". Thanks, David On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: > Hi Kumar, > > Thank you for your comment! > I've fixed them and uploaded new webrev. Could you review again? > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ > > > Thanks, > > Yasumasa > > > On 2016/04/23 1:14, Kumar Srinivasan wrote: >> >> Also a couple of minor suggestions: >> >> - * Set native thread name as possible. >> + * Set native thread name if possible. >> >> >> + /* >> - * We can clear pending exception because exception at this point >> - * is not critical. >> + */ >> >> + /* >> + * Clear non critical pending exceptions at this point. >> + */ >> >> Thanks >> Kumar >> >>> Hi, >>> >>> This is in the wrong place: >>> >>> 1715 if ((*env)->ExceptionOccurred(env)) { >>> 1716 /* >>> 1717 * We can clear pending exception because exception at >>> this point >>> 1718 * is not critical. >>> 1719 */ >>> 1720 (*env)->ExceptionClear(env); >>> 1721 } >>> >>> This above needs to be after >>> 391 SetNativeThreadName(env, "main"); >>> 392 >>> >>> Here is why, supposing 1704 through 1711, returns a NULL, >>> but have also encountered an exception. In which case >>> the method SetNativeThreadName will return to the caller, as >>> if nothing has happened, because NULL_CHECK simply checks for NULL >>> and returns to the caller. This will cause the caller to enter >>> the VM with exceptions. >>> >>> Kumar >>> >>> >>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> I don't think we need to report the exception, but can just ignore >>>>> it. Either way we have to clear the exception before continuing. >>>> >>>> I've fixed it in new webrev: >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/22 15:33, David Holmes wrote: >>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>> Hi all, >>>>>> >>>>>> I have uploaded webrev.04 as below. >>>>>> Could you review again? >>>>>> >>>>>> > - hotspot: >>>>>> > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>> >>>>> Looks fine. >>>>> >>>>>> > >>>>>> > - jdk: >>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>> >>>>> As per private email (but repeated here on the record) in java.c: >>>>> >>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>> 1716 JLI_ReportExceptionDescription(env); >>>>> 1717 } >>>>> >>>>> I don't think we need to report the exception, but can just ignore >>>>> it. Either way we have to clear the exception before continuing. >>>>> >>>>> Thanks, >>>>> David >>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>> >: >>>>>> > >>>>>> > Hi David, >>>>>> > >>>>>> > Thank you for your comment. >>>>>> > I uploaded new webrev. Could you review again? >>>>>> > >>>>>> > - hotspot: >>>>>> > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>> > >>>>>> > - jdk: >>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>> > >>>>>> > >>>>>> >> That aside I'm not sure why you do this so late in the process, I >>>>>> would have done it immediately after here: >>>>>> > >>>>>> > >>>>>> > I think that native thread name ("main") should be set just before >>>>>> > main method call. >>>>>> > However, main thread is already started, so I moved it as you >>>>>> suggested. >>>>>> > >>>>>> > >>>>>> >> One thing I dislike about the current structure is that we >>>>>> have to >>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>> calls >>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>> char* ! >>>>>> > >>>>>> > >>>>>> > SoI proposed to export new JVM function to set native thread >>>>>> name with >>>>>> > const char *. >>>>>> > >>>>>> > >>>>>> > Thanks, >>>>>> > >>>>>> > Yasumasa >>>>>> > >>>>>> > >>>>>> > >>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>> >> >>>>>> >> Hi Yasumasa, >>>>>> >> >>>>>> >> Thanks for persevering with this to get it into the current form. >>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>> >> >>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>> >>> >>>>>> >>> Hi Gerard, >>>>>> >>> >>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>> >>>>>> >>> >>>>> >>: >>>>>> >>> > >>>>>> >>> > hi Yasumasa, >>>>>> >>> > >>>>>> >>> > Nice work. I have 2 questions: >>>>>> >>> > >>>>>> >>> > ======== >>>>>> >>> > File: java.c >>>>>> >>> > >>>>>> >>> > #1 Shouldn?t we be checking for >>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>> >>> after every single JNI call? In this example instead of >>>>>> NULL_CHECK, >>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>> >>> >>>>>> >>> It is not critical if we encounter error at JNI function call >>>>>> because >>>>>> >>> we cannot set native thread name only. >>>>>> >>> So I think that we do not need to leave from launcher process. >>>>>> >> >>>>>> >> >>>>>> >> I agree we do not need to abort if an exception occurs (and in >>>>>> fact >>>>>> I don't think an exception is even possible from this code), but we >>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>> calls might be made. Note that NULL_CHECK is already used extensively >>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>> is all >>>>>> wrong! More on this code below ... >>>>>> >> >>>>>> >> Other comments: >>>>>> >> >>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>> >> >>>>>> >> Please add a comment to the method now that you removed the >>>>>> internal >>>>>> comment: >>>>>> >> >>>>>> >> // Sets the native thread name for a JavaThread. If specifically >>>>>> >> // requested JNI-attached threads can also have their native >>>>>> name set; >>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>> interfere >>>>>> >> // with the application that created them. >>>>>> >> >>>>>> >> --- >>>>>> >> >>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>> >> >>>>>> >> Please add the following comments: >>>>>> >> >>>>>> >> + // Don't modify JNI-attached threads >>>>>> >> setNativeName(name, false); >>>>>> >> >>>>>> >> + // May be called directly via JNI or reflection (when >>>>>> permitted) to >>>>>> >> + // allow JNI-attached threads to set their native name >>>>>> >> private native void setNativeName(String name, boolean >>>>>> allowAttachedThread); >>>>>> >> >>>>>> >> --- >>>>>> >> >>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>> >> >>>>>> >> 328 #define LEAVE() \ >>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>> >> >>>>>> >> I was going to suggest this be set later, but realized we have >>>>>> to be >>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>> >> >>>>>> >> + /* Set native thread name. */ >>>>>> >> + SetNativeThreadName(env, "main"); >>>>>> >> >>>>>> >> The comment is redundant given the name of the method. That aside >>>>>> I'm not sure why you do this so late in the process, I would have >>>>>> done >>>>>> it immediately after here: >>>>>> >> >>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>> >> 388 exit(1); >>>>>> >> 389 } >>>>>> >> + SetNativeThreadName(env, "main"); >>>>>> >> >>>>>> >> >>>>>> >> + /** >>>>>> >> + * Set native thread name as possible. >>>>>> >> + */ >>>>>> >> >>>>>> >> Other than the as->if change I'm unclear where the "possible" bit >>>>>> comes into play - why would it not be possible? >>>>>> >> >>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>> "java/lang/Thread")); >>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>> (*env)->GetStaticMethodID(env, >>>>>> cls, >>>>>> >> 1707 "currentThread", >>>>>> "()Ljava/lang/Thread;")); >>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>> >> 1709 currentThreadID)); >>>>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, >>>>>> cls, >>>>>> >> 1711 "setNativeName", >>>>>> "(Ljava/lang/String;Z)V")); >>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>> name)); >>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>> setNativeNameID, >>>>>> >> 1714 nameString, JNI_TRUE); >>>>>> >> >>>>>> >> As above NULL_CHECK is fine here, but we should check for and >>>>>> clear >>>>>> any pending exception after CallVoidMethod. >>>>>> >> >>>>>> >> One thing I dislike about the current structure is that we >>>>>> have to >>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>> calls >>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>> char* ! >>>>>> Overall I wonder about the affect on startup cost. But if there is an >>>>>> issue we can revisit this. >>>>>> >> >>>>>> >> Thanks, >>>>>> >> David >>>>>> >> ----- >>>>>> >> >>>>>> >> >>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>> native >>>>>> thread >>>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>>> >>> >>>>>> >>> Sorry for my bad English :-) >>>>>> >>> >>>>>> >>> Thanks, >>>>>> >>> >>>>>> >>> Yasumasa >>>>>> >>> >>>>>> >>> > cheers >>>>>> >>> > >>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>> >>>>>> >>> >> wrote: >>>>>> >>> > > >>>>>> >>> > > Hi David, >>>>>> >>> > > >>>>>> >>> > > I uploaded new webrev: >>>>>> >>> > > >>>>>> >>> > > - hotspot: >>>>>> >>> > > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>> >>> > > >>>>>> >>> > > - jdk: >>>>>> >>> > > >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>> >>> > > >>>>>> >>> > > >>>>>> >>> > >> it won't work unless you change the semantics of >>>>>> setName so I'm >>>>>> >>> not sure what you were thinking here. To take advantage of an >>>>>> arg >>>>>> taking >>>>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>>>> no Java >>>>>> >>> code will call it . ??? >>>>>> >>> > > >>>>>> >>> > > I added a flag for setting native thread name to >>>>>> JNI-attached >>>>>> thread. >>>>>> >>> > > This change can set native thread name if main thread >>>>>> changes to >>>>>> >>> JNI-attached thread. >>>>>> >>> > > >>>>>> >>> > > >>>>>> >>> > > Thanks, >>>>>> >>> > > >>>>>> >>> > > Yasumasa >>>>>> >>> > > >>>>>> >>> > > >>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>> Hi David, >>>>>> >>> > >>> >>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>> considered a >>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>> main, even >>>>>> >>> > >>>> though we never really intended it to work in the >>>>>> first place. >>>>>> >>> :( Such >>>>>> >>> > >>>> a change needs to go through CCC. >>>>>> >>> > >>> >>>>>> >>> > >>> I understood. >>>>>> >>> > >>> Can I send CCC request? >>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>> >>> > >> >>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>> sponsor for >>>>>> >>> that. But at this stage I don't think I agree with the >>>>>> proposed change >>>>>> >>> because of the change in behaviour - there's no way to >>>>>> restore the >>>>>> >>> "broken" behaviour. >>>>>> >>> > >> >>>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 >>>>>> [1]. >>>>>> >>> > >> >>>>>> >>> > >> Okay we can do that. >>>>>> >>> > >> >>>>>> >>> > >>> >>>>>> >>> > >>>> Further, we expect the launcher to use the supported JNI >>>>>> >>> interface (as >>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>> interface that >>>>>> >>> exists for >>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>> >>> > >>> >>>>>> >>> > >>> I think that we do not use JVM interface if we add new >>>>>> method in >>>>>> >>> > >>> LauncherHelper as below: >>>>>> >>> > >>> ---------------- >>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>> >>> > >>> >>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> >>> > >>> --- >>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>> >>> > >>> +++ >>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>> >>> > >>> else >>>>>> >>> > >>> return md.toNameAndVersion() + " (" + loc >>>>>> + ")"; >>>>>> >>> > >>> } >>>>>> >>> > >>> + >>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>> >>> > >>> + } >>>>>> >>> > >> >>>>>> >>> > >> You could also make that call via JNI directly, so not >>>>>> sure the >>>>>> >>> helper adds much here. But it won't work unless you change the >>>>>> semantics >>>>>> >>> of setName so I'm not sure what you were thinking here. To take >>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>> need to >>>>>> call >>>>>> >>> it directly as no Java code will call it . ??? >>>>>> >>> > >> >>>>>> >>> > >> David >>>>>> >>> > >> ----- >>>>>> >>> > >> >>>>>> >>> > >>> } >>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>> src/java.base/share/native/libjli/java.c >>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>>>> Apr 13 >>>>>> 14:19:30 >>>>>> >>> > >>> 2016 +0000 >>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>>>> Apr 16 >>>>>> 11:25:53 >>>>>> >>> > >>> 2016 +0900 >>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>> *name); >>>>>> >>> > >>> >>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>> >>> > >>> >>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>> >>> > >>> */ >>>>>> >>> > >>> #define LEAVE() \ >>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>> >>> > >>> do { \ >>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) >>>>>> { \ >>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>> >>> > >>> >>>>>> >>> > >>> + /* Set native thread name. */ >>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>> >>> > >>> + >>>>>> >>> > >>> /* Invoke main method. */ >>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>> mainArgs); >>>>>> >>> > >>> >>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>> >>> > >>> joptString); >>>>>> >>> > >>> } >>>>>> >>> > >>> >>>>>> >>> > >>> +/** >>>>>> >>> > >>> + * Set native thread name as possible. >>>>>> >>> > >>> + */ >>>>>> >>> > >>> +static void >>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>> >>> > >>> +{ >>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>> >>> > >>> + jstring nameString; >>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>> name)); >>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>> setNativeThreadNameID, >>>>>> >>> > >>> nameString); >>>>>> >>> > >>> +} >>>>>> >>> > >>> + >>>>>> >>> > >>> /* >>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>> >>> > >>> */ >>>>>> >>> > >>> ---------------- >>>>>> >>> > >>> >>>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>> >>> > >>> >>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>> interface and so >>>>>> >>> > >>>> has to be approved. >>>>>> >>> > >>> >>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> Thanks, >>>>>> >>> > >>> >>>>>> >>> > >>> Yasumasa >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> [1] >>>>>> >>> > >>> >>>>>> >>> >>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>> >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> >>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>> Hi David, >>>>>> >>> > >>>>> >>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>> for main >>>>>> >>> thread and >>>>>> >>> > >>>>>> JNI attached threads >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> >>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>> itself as >>>>>> >>> setName >>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>> thread. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> I know. >>>>>> >>> > >>>> >>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>> considered a >>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>> main, even >>>>>> >>> > >>>> though we never really intended it to work in the >>>>>> first place. >>>>>> >>> :( Such >>>>>> >>> > >>>> a change needs to go through CCC. >>>>>> >>> > >>>> >>>>>> >>> > >>>>> I checked changeset history. >>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>> JDK-7098194, >>>>>> and it is >>>>>> >>> > >>>>> backported JDK 8. >>>>>> >>> > >>>> >>>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>>> >>> > >>>> >>>>>> >>> > >>>>> However, this function seems to be called from >>>>>> >>> Thread#setNativeName() >>>>>> >>> > >>>>> only. >>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>> >>> JVM_SetNativeThreadName() >>>>>> >>> > >>>>> for force setting. >>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>> >>> > >>>>> However, this function is NOT public, so I think we can >>>>>> add one >>>>>> >>> more >>>>>> >>> > >>>>> argument. >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> What do you think about this? >>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>> from Java >>>>>> >>> launcher. >>>>>> >>> > >>>> >>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>> really at >>>>>> >>> issue. Yes >>>>>> >>> > >>>> we would add another arg to the JVM function to allow >>>>>> it to >>>>>> apply to >>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>> reflect that >>>>>> >>> not just >>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>> exported JVM >>>>>> >>> interface >>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>> launcher to >>>>>> >>> use the >>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>> not the >>>>>> internal >>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>> communicate >>>>>> >>> with the >>>>>> >>> > >>>> JVM. >>>>>> >>> > >>>> >>>>>> >>> > >>>> David >>>>>> >>> > >>>> ----- >>>>>> >>> > >>>> >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> Thanks, >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> Yasumasa >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> >>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>> Hi David, >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>>>> being a >>>>>> >>> JNI-attached >>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>> for main >>>>>> >>> thread and >>>>>> >>> > >>>>>> JNI attached threads >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>> itself as >>>>>> >>> setName >>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>> thread. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>>>> 13:31:11 >>>>>> >>> 2016 +0200 >>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>>>> 17:50:10 >>>>>> >>> 2016 +0900 >>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>> is complete >>>>>> >>> - nop if >>>>>> >>> > >>>>>>> no agents. >>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>> >>> > >>>>>>> + >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>>>> constructor. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>> tracing >>>>>> >>> > >>>>>>> backend."); >>>>>> >>> > >>>>>>> } >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>>> If it wants to name its native threads then it is >>>>>> free >>>>>> to do so, >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>>>> native >>>>>> >>> thread name >>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>>>> developer >>>>>> >>> calls >>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>> SetNativeThreadName() as >>>>>> below. >>>>>> >>> > >>>>>>> What do you think about this? >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>>> threads was a >>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>> with the OSX >>>>>> >>> port and >>>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>>> feature was to >>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>> been set by >>>>>> >>> the host >>>>>> >>> > >>>>>> process. If we do as you propose then we will just >>>>>> have an >>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>> does my >>>>>> >>> native thread >>>>>> >>> > >>>>>> only have a name if I call >>>>>> cur.setName(cur.getName()) ?" >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>>>> this, the >>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>> thread only, >>>>>> >>> non-JNI >>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>> were supposed >>>>>> >>> to be >>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>> can see >>>>>> that >>>>>> >>> never >>>>>> >>> > >>>>>> happened. :( >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> My position on this remains that if it is desirable >>>>>> for >>>>>> the main >>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native names >>>>>> then the >>>>>> >>> > >>>>>> launcher needs to be setting them using the available >>>>>> platform >>>>>> >>> APIs. >>>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>>>> the VM >>>>>> >>> code for >>>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>> Thread.setName would >>>>>> >>> have to go >>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>> the launcher >>>>>> >>> would >>>>>> >>> > >>>>>> not. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> Sorry. >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>> David >>>>>> >>> > >>>>>> ----- >>>>>> >>> > >>>>>> >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>>>> 13:31:11 >>>>>> >>> 2016 +0200 >>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>>>> 17:50:10 >>>>>> >>> 2016 +0900 >>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>> java_lang_Thread::thread(java_thread); >>>>>> >>> > >>>>>>> // Thread naming only supported for the current >>>>>> thread, >>>>>> >>> doesn't >>>>>> >>> > >>>>>>> work >>>>>> >>> > >>>>>>> for >>>>>> >>> > >>>>>>> // target threads. >>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>> >>> !thr->has_attached_via_jni()) { >>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>> thread to avoid >>>>>> >>> stepping >>>>>> >>> > >>>>>>> // on other programs >>>>>> >>> > >>>>>>> const char *thread_name = >>>>>> >>> > >>>>>>> >>>>>> >>> >>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>> >>> > >>>>>>> --------------- >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Thanks, >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> Yasumasa >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> >>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>> Roger, >>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> David, >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>>>> don't like >>>>>> >>> > >>>>>>>>>>>> exposing >>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>> initializing VM >>>>>> (before >>>>>> >>> > >>>>>>>>> calling >>>>>> >>> > >>>>>>>>> main method), >>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>> AttachCurrentThread(). >>>>>> So we >>>>>> >>> can't >>>>>> >>> > >>>>>>>>> set >>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>>>> morning. >>>>>> >>> Which, >>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>>>> here that >>>>>> >>> we don't >>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>> The fact >>>>>> >>> that the >>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>>>> thread seems >>>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is >>>>>> only >>>>>> working by >>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>> used for the >>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>> inconsistently >>>>>> >>> named at >>>>>> >>> > >>>>>>>> the native level. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>>>> to be >>>>>> >>> treated like >>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>> wants to >>>>>> name its >>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>> would not be >>>>>> >>> exporting >>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>> have to >>>>>> use the OS >>>>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>>>> basis. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> Sorry. >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> David >>>>>> >>> > >>>>>>>> ----- >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>> >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> >>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>> >>> > >>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> Comments: >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>>>> perform >>>>>> >>> different >>>>>> >>> > >>>>>>>>>> functions: >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>> JVM_SetNativeThreadName >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>> thread, the >>>>>> >>> second >>>>>> >>> > >>>>>>>>>> one a >>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>>>> somewhere >>>>>> >>> about >>>>>> >>> > >>>>>>>>>> what >>>>>> >>> > >>>>>>>>>> the new function does. >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 casts to >>>>>> (void*) >>>>>> >>> > >>>>>>>>>> instead of >>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>> overwriteifn->GetCreatedJavaVMs >>>>>> >>> used at >>>>>> >>> > >>>>>>>>>> line 730 >>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>>>> the cast >>>>>> >>> on the >>>>>> >>> > >>>>>>>>>> same >>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>> haven't had >>>>>> time to >>>>>> >>> > >>>>>>>>>>>> check - >>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>> JNI-attached >>>>>> >>> thread >>>>>> >>> > >>>>>>>>>>>> then >>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>> suggestion >>>>>> >>> should >>>>>> >>> > >>>>>>>>>>>> work >>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>> treatment of >>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>>>> confirmed >>>>>> >>> native >>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>> >>> > >>>>>>>>>>> --------- >>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>>> Exception{ >>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>> >>> > >>>>>>>>>>> } >>>>>> >>> > >>>>>>>>>>> } >>>>>> >>> > >>>>>>>>>>> --------- >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>>>> don't like >>>>>> >>> > >>>>>>>>>>>> exposing >>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>> comment. >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>>>> thread >>>>>> >>> name, and JLI >>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>> >>> > >>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>>>> >>> core-libs will >>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>> Kumar) - >>>>>> now cc'd. >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>> >>> Thread.setName >>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>>> hotspot changes >>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>> Thread#setName() in >>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>>>> which is >>>>>> >>> why the >>>>>> >>> > >>>>>>>>>>>> native >>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>> attached thread. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>> haven't had >>>>>> time to >>>>>> >>> > >>>>>>>>>>>> check - >>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>> JNI-attached >>>>>> >>> thread >>>>>> >>> > >>>>>>>>>>>> then >>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>> suggestion >>>>>> >>> should >>>>>> >>> > >>>>>>>>>>>> work >>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>> treatment of >>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about this. I >>>>>> don't like >>>>>> >>> > >>>>>>>>>>>> exposing >>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>> David >>>>>> >>> > >>>>>>>>>>>> ----- >>>>>> >>> > >>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>> function to set >>>>>> >>> native >>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> >>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>> David >>>>>> >>> > >>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>> well ... >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry have >>>>>> been on >>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>> correct >>>>>> as we >>>>>> >>> do not >>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>>>> includes the >>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>> wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer :-) >>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>> >>>>>> >>> >>: >>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>> Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>> Suenaga >>>>>> wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>> >>> >>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> >>>: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>>> Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>> >>>>>> >>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>> >>> >>>>> >>>>: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>> set it: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = new >>>>>> >>> JavaThread(); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> main_thread->initialize_thread_current(); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>> >>> set_active_handles >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> main_thread->record_stack_base_and_size(); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> >>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>> something? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>> to thread >>>>>> >>> name in >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>>> setName(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java >>>>>> app, >>>>>> native >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>>>> already >>>>>> >>> starte >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>>>> thrrad name >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>> something like >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>> a/src/share/vm/runtime/thread.cpp >>>>>> Tue >>>>>> >>> Mar 29 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>> b/src/share/vm/runtime/thread.cpp >>>>>> Wed >>>>>> >>> Mar 30 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>> create_initial_thread(Handle >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>> initial_thread_name = >>>>>> >>> "main"; >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>> (THREAD, k); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>> >>> thread); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > thread->set_threadObj(thread_oop()); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> java_lang_String::create_from_str("main", >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>>> thread_oop, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name itself >>>>>> 'java' and >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>> process >>>>>> (and >>>>>> >>> thus >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>> process >>>>>> is not >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread with >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>>> >>> JavaThread. So I >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>>>> thread. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>> anyhow, since >>>>>> >>> we want >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread >>>>>> name >>>>>> might >>>>>> >>> have >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' >>>>>> | head -4 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something like >>>>>> 'Java Main >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a Java >>>>>> >>> launcher - e.g. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>> thread >>>>>> name, >>>>>> >>> I think >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, Yasumasa >>>>>> >>> Suenaga wrote: >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>>>> thread >>>>>> >>> name via >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>>>> have it. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>>>> name, >>>>>> and main >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>>>> should have >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could you >>>>>> review it? >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>> > >>>>>>>>>> >>>>>> >>> > >>>>>> >>> >>>>>> >>> >> From kubota.yuji at gmail.com Mon Apr 25 08:49:57 2016 From: kubota.yuji at gmail.com (KUBOTA Yuji) Date: Mon, 25 Apr 2016 17:49:57 +0900 Subject: PING: RFR: JDK-4347142: Need method to set Password protection to Zip entries In-Reply-To: <5716b7c8.c8e4420a.f47c1.ffff9b05SMTPIN_ADDED_BROKEN@mx.google.com> References: <56F9A4F4.6040108@oracle.com> <5707E1E8.9060202@gmail.com> <5716b7c8.c8e4420a.f47c1.ffff9b05SMTPIN_ADDED_BROKEN@mx.google.com> Message-ID: 2016-04-20 7:57 GMT+09:00 : > I have to agree. I don't think it makes sense to add a known-vulnerable > encryption algorithm to the JDK. It might work perfectly well for one > use case but it will eventually be used by someone who doesn't take the > time to understand it, assumes that it provides strong encryption when > it doesn't, gets burned, and then blames Java. Yes, Mark. We never hope to make OpenJDK be blamed with our proposal. Mark, I am glad if you are interested in this proposal if using any strong encryption algorithm like Sherman's implementation (AES encryption). If so, we hope to continue discussion the better way to fill our needs and given comments for improving OpenJDK. Thanks, Yuji From nadeesh.tv at oracle.com Mon Apr 25 14:38:57 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Mon, 25 Apr 2016 20:08:57 +0530 Subject: RFR:JDK-8148949:DateTimeFormatter pattern letters 'A','n','N' Message-ID: <571E2C01.6050407@oracle.com> HI all, Please review a fix for Bug ID - https://bugs.openjdk.java.net/browse/JDK-8148949 Issue - Pattern letters 'A' does not match the intent of LDML/CLDR Solution - Changed the definition of pattern letters 'A','n','N' Webrev - http://cr.openjdk.java.net/~ntv/8148949/webrev.00/ -- Thanks and Regards, Nadeesh TV From stevenschlansker at gmail.com Mon Apr 25 19:33:51 2016 From: stevenschlansker at gmail.com (Steven Schlansker) Date: Mon, 25 Apr 2016 12:33:51 -0700 Subject: UNIXProcess.toString -- include more useful information Message-ID: Hi core-libs-dev, I recently was diagnosing a problem relating to an external program invoked via the ProcessBuilder API. The returned Process is an instance of java.lang.UNIXProcess, which does not have a toString method. While I understand that the concepts of "pid" etc are not cross-platform, it might be useful to operators to have the toString method dump them as diagnostic information. Imagine if instead of "java.lang.UNIXProcess@" you could see "UNIXProcess[running=true, pid=1234]" "UNIXProcess[running=false, exitCode=127]" This seems like it would be a fairly trivial change that could help some operator down the road. Is this a reasonable request? Thanks, Steven From martinrb at google.com Mon Apr 25 19:49:27 2016 From: martinrb at google.com (Martin Buchholz) Date: Mon, 25 Apr 2016 12:49:27 -0700 Subject: UNIXProcess.toString -- include more useful information In-Reply-To: References: Message-ID: This is a reasonable request. But if you put platform-specific information into the String, then people will start treating that as an API (parsing the string), which is undesirable. On Mon, Apr 25, 2016 at 12:33 PM, Steven Schlansker wrote: > Hi core-libs-dev, > > I recently was diagnosing a problem relating to an external program invoked via > the ProcessBuilder API. > > The returned Process is an instance of java.lang.UNIXProcess, which does > not have a toString method. > > While I understand that the concepts of "pid" etc are not cross-platform, > it might be useful to operators to have the toString method > dump them as diagnostic information. > > Imagine if instead of > > "java.lang.UNIXProcess@" > > you could see > > "UNIXProcess[running=true, pid=1234]" > "UNIXProcess[running=false, exitCode=127]" > > This seems like it would be a fairly trivial change that could help some > operator down the road. > > Is this a reasonable request? Thanks, > Steven > From stuart.marks at oracle.com Mon Apr 25 21:26:18 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 25 Apr 2016 14:26:18 -0700 Subject: TCCL memory leak in RMI registry creation In-Reply-To: <5719F6E9.9040203@apache.org> References: <5715043B.4090901@apache.org> <57164DDA.9070806@Oracle.com> <5718C04D.1080002@apache.org> <5718DB6B.6000103@apache.org> <571954E5.50004@oracle.com> <5719F6E9.9040203@apache.org> Message-ID: On 4/22/16 3:03 AM, Mark Thomas wrote: > Excellent. Thank you very much for that. It does indeed work. Glad to hear it! >> It's probably necessary to unexport and maybe also unbind everything >> from this registry as well, as Roger had suggested previously. > > For the record, if the module/application creates the registry, > unexporting the registry is sufficient. However, an additional GC cycle > is required to clean up the references if unexport and unbind are not > called. Hm. That might be the case for this test program, but in general, I'm concerned it might not be sufficient. There's no requirement in RMI that every exported object be in the registry. If a remote object is exported, and another JVM has a stub that references this remote object, that object will be kept alive indefinitely by DGC. Clearing out the registry won't help with this. > The good news is that, with the information above, this leak is > something that modules/applications can and should do something about. I think the general rule has to be that, if an application has exported a remote object, that object should be unexported when the application shuts down. This applies equally well to registry objects created by the application. Unfortunately doing this in RMI is probably uncommon practice, since most documentation, tutorials, examples, etc. only cover bringing up an RMI service, and they don't cover shutdown. For example, the Java Tutorial on RMI [1] doesn't seem to talk about this issue at all. I suspect that most examples out there assume that RMI services will run for the lifetime of the JVM. Most applications simply follow this and probably don't include any logic for cleaning up after themselves. [1] http://docs.oracle.com/javase/tutorial/rmi/overview.html > This moves the problem to how to detect when modules/applications fail > to clean up an RMI Registry they created. I'd like to be able to provide > nice loud error messages when this happens. Open questions are: > - How to get a list of RMI registries? > - How to determine the TCCL for a registry (held in the ccl field of the > associated sun.rmi.transport.Target object) so I can figure out if a > module/application created it? I don't have a good answer for this. I do think that talking about registries is a bit of a distraction. As I mentioned above, the general problem can occur with any remote object, and a registry is mostly an ordinary remote object. All remote objects in this JVM are kept in the ObjectTable, and the cleanup code you have looks through this for Target objects with the right ccl etc. already. If you want the cleanup function to continue to be active in production use of Tomcat, then you'll probably need to explore the JVM command-line options that enable the reflective access to continue, e.g. -XaddExports or -Xpatch. A variant of this is to get one's hands on the remote object itself and then call unexportObject() on it, instead of directly removing things from the various maps. This probably does the cleanup in a more robust fashion, though it doesn't help with the main problem of getting reflective access. If this doesn't need to run in production, and can be run only in, say, some "diagnostic mode," (not sure if such a thing exists) then there are some other possibilities. For example, one might load an agent, or use the debugger interface, to track remote objects being exported and unexported. If, after shutting down an application, remote objects remain exported, this could cause some errors to be issued. s'marks From stuart.marks at oracle.com Mon Apr 25 21:35:38 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 25 Apr 2016 14:35:38 -0700 Subject: RFR(s): 8154801 deprecate java.util.Observable/Observer In-Reply-To: <571CC696.8080908@cs.oswego.edu> References: <571989A8.3010901@oracle.com> <571CC696.8080908@cs.oswego.edu> Message-ID: On 4/24/16 6:13 AM, Doug Lea wrote: > These days, anyone encountering these is probably hitting them > by mistake while using RxJava or other reactive-stream frameworks. > In which case, users will normally want to instead use the jdk9 > java.util.concurrent.Flow APIs that all reactive-streams frameworks > should be compatible/interoperable with in their planned upcoming > jdk9-compatible versions. I'm not sure how to state this now in > any @Deprecated docs or other Observable and Observer javadocs though. Ah, good point! I can certainly add a note saying that these old Observer/Observable types have nothing to do with reactive streams, and also add a link to the Flow APIs. I'll do this in a follow-on bug report: JDK-8155052. s'marks From stuart.marks at oracle.com Mon Apr 25 23:05:13 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 25 Apr 2016 16:05:13 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() Message-ID: Hi all, Please review these webrevs that deprecate Optional.get() and to replace it with Optional.getWhenPresent(). The corresponding changes are also applied to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and OptionalLong.getAsLong(). Unlike most deprecations, this isn't about the function or the utility of some API, it's about the name. The solution is basically to rename the API. The problem is that "get" shows up as the "obvious" choice in things like IDE code completion, leading to code that mishandles empty Optionals. Typical Stack Overflow discourse runs something like this: Q: what do I do with this Optional thing A: just call get() Q: thanks, it works! Of course, it works until it doesn't. Examining the JDK's use of Optional.get(), I didn't see very many cases that called get() without first checking for the presence of a value. But I did see quite a number of cases like this: if (opt.isPresent()) { doSomething(opt.get()); } else { doSomethingElse(); } In many of these cases, the code could be refactored to use other Optional methods such as filter(), map(), or ifPresent(). In any case this reinforces the contention that use of get() leads to poor code. For this changeset, in just about all cases I've simply replaced the call to get() with a call to getWhenPresent(). In a couple cases I replaced the stream calls .filter(Optional::isPresent).map(Optional::get) with .flatMap(Optional::stream) which I hope will become the new idiom for unwrapping a stream of Optionals. While many cases could be cleaned up further, I didn't change them. The reasons are that I didn't want to spend too much time putting code cleanup into the critical path of this changeset (I'd be happy to help later); doing so would create potential conflicts with code coming in from the Jigsaw forest; and there are non-obvious places where converting from a conditional to one of the lambda-based methods could cause performance problems at startup. There are also a few cases where simplification is prevented because it would end up causing the resulting lambda expressions to throw checked exceptions. :-( Webrevs here: http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ Thanks, s'marks From jonathan.gibbons at oracle.com Mon Apr 25 23:35:52 2016 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Mon, 25 Apr 2016 16:35:52 -0700 Subject: Fwd: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> Message-ID: <571EA9D8.3010702@oracle.com> Since the justification for this change appears to be that the IDEs might help write people write bad code, why not look to the IDEs to generate a warning when using Optional.get outside of the context of Optional.isPresent? In other words, is this really such a good change? -- Jon On 04/25/2016 04:14 PM, Stuart Marks wrote: > One of the changes in the langtools webrev > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > > is in the compiler. Please review. > > Thanks, > > s'marks > > > -------- Forwarded Message -------- > Subject: RFR(m): 8140281 deprecate Optional.get() > Date: Mon, 25 Apr 2016 16:05:13 -0700 > From: Stuart Marks > To: core-libs-dev > > Hi all, > > Please review these webrevs that deprecate Optional.get() and to > replace it with Optional.getWhenPresent(). The corresponding changes > are also applied to OptionalDouble.getAsDouble(), > OptionalInt.getAsInt(), and OptionalLong.getAsLong(). > > Unlike most deprecations, this isn't about the function or the utility > of some API, it's about the name. The solution is basically to rename > the API. The problem is that "get" shows up as the "obvious" choice in > things like IDE code completion, leading to code that mishandles empty > Optionals. Typical Stack Overflow discourse runs something like this: > > Q: what do I do with this Optional thing > > A: just call get() > > Q: thanks, it works! > > Of course, it works until it doesn't. > > Examining the JDK's use of Optional.get(), I didn't see very many > cases that called get() without first checking for the presence of a > value. But I did see quite a number of cases like this: > > if (opt.isPresent()) { > doSomething(opt.get()); > } else { > doSomethingElse(); > } > > In many of these cases, the code could be refactored to use other > Optional methods such as filter(), map(), or ifPresent(). > > In any case this reinforces the contention that use of get() leads to > poor code. > > For this changeset, in just about all cases I've simply replaced the > call to get() with a call to getWhenPresent(). In a couple cases I > replaced the stream calls > > .filter(Optional::isPresent).map(Optional::get) > > with > > .flatMap(Optional::stream) > > which I hope will become the new idiom for unwrapping a stream of > Optionals. > > While many cases could be cleaned up further, I didn't change them. > The reasons are that I didn't want to spend too much time putting code > cleanup into the critical path of this changeset (I'd be happy to help > later); doing so would create potential conflicts with code coming in > from the Jigsaw forest; and there are non-obvious places where > converting from a conditional to one of the lambda-based methods could > cause performance problems at startup. > > There are also a few cases where simplification is prevented because > it would end up causing the resulting lambda expressions to throw > checked exceptions. :-( > > Webrevs here: > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ > > Thanks, > > s'marks From stuart.marks at oracle.com Tue Apr 26 00:18:19 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 25 Apr 2016 17:18:19 -0700 Subject: Fwd: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <571EA9D8.3010702@oracle.com> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> Message-ID: On 4/25/16 4:35 PM, Jonathan Gibbons wrote: > Since the justification for this change appears to be that the IDEs might help > write people write bad code, why not look to the IDEs to generate a warning when > using Optional.get outside of the context of Optional.isPresent? > > In other words, is this really such a good change? Well I think it's more than just IDEs. The root cause is the API name "get". In Java we're getting things all the time, and we think nothing of it. The problem is when code tries to get something that isn't there. Historically, callers have had to check for null, and of course it's always been a problem if that check is forgotten. We've introduced Optional to avoid this. The problem is that the obvious thing to do is to get() the value out of the Optional, but this buys us right back into the what-if-the-value-is-missing case that we had with nulls. Consider this code from LogManager.java from the jdk webrev: [1] 2106 for (String pk : properties) { 2107 ConfigProperty cp = ConfigProperty.find(pk).get(); OK, so we find something and get something out of it. Big deal. But with the change to getWhenPresent(), this code is now: 2106 for (String pk : properties) { 2107 ConfigProperty cp = ConfigProperty.find(pk).getWhenPresent(); From this, it's clear that find() returns an Optional, and that this code is asserting that a value is always present in this Optional. Offhand I don't know if this assertion is in fact true for this code. If it is true, then the name "getWhenPresent" is telling the reader an important fact about the relationships among the data structures this code uses. If it's *not* true, when this code is being reviewed (or when it's debugged after a failure), it ought to raise questions like, "Under what circumstances is this value absent?" Those are important points that aren't raised by a simple get(). s'marks [1] http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.logging/share/classes/java/util/logging/LogManager.java.sdiff.html From vitalyd at gmail.com Tue Apr 26 00:46:12 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Mon, 25 Apr 2016 20:46:12 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> Message-ID: On Monday, April 25, 2016, Stuart Marks wrote: > > > On 4/25/16 4:35 PM, Jonathan Gibbons wrote: > >> Since the justification for this change appears to be that the IDEs might >> help >> write people write bad code, why not look to the IDEs to generate a >> warning when >> using Optional.get outside of the context of Optional.isPresent? >> >> In other words, is this really such a good change? >> > > Well I think it's more than just IDEs. The root cause is the API name > "get". In Java we're getting things all the time, and we think nothing of > it. The problem is when code tries to get something that isn't there. > Historically, callers have had to check for null, and of course it's always > been a problem if that check is forgotten. > > We've introduced Optional to avoid this. The problem is that the obvious > thing to do is to get() the value out of the Optional, but this buys us > right back into the what-if-the-value-is-missing case that we had with > nulls. Why is this the "obvious" thing? Because a few stackoverflow threads went like that? > > Consider this code from LogManager.java from the jdk webrev: [1] > > 2106 for (String pk : properties) { > 2107 ConfigProperty cp = ConfigProperty.find(pk).get(); > > OK, so we find something and get something out of it. Big deal. But with > the change to getWhenPresent(), this code is now: > > 2106 for (String pk : properties) { > 2107 ConfigProperty cp = > ConfigProperty.find(pk).getWhenPresent(); > > From this, it's clear that find() returns an Optional, and that this code > is asserting that a value is always present in this Optional. It's not clear it returns an Optional - it could be returning some other type that happens to have a getWhenPresent. What would be clear it's an Optional is to have a local of that type and assign find(pk) to it. > > Offhand I don't know if this assertion is in fact true for this code. If > it is true, then the name "getWhenPresent" is telling the reader an > important fact about the relationships among the data structures this code > uses. If it's *not* true, when this code is being reviewed (or when it's > debugged after a failure), it ought to raise questions like, "Under what > circumstances is this value absent?" Those are important points that aren't > raised by a simple get(). Descriptive names are good, but like Jon, I'm not buying this change. Is it really wrong to tell people to read the javadoc? And is that worth the deprecation churn? It's going to be needlessly verbose (esp in existing code that already checked isPresent) for no strong benefit. If someone is mindlessly having their IDE write code for them, this isn't going to prevent poor code. For code review purposes, if it's important to call out that something is Optional then use the type somewhere explicitly. My $.02 > > s'marks > > > > [1] > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.logging/share/classes/java/util/logging/LogManager.java.sdiff.html > -- Sent from my phone From david.holmes at oracle.com Tue Apr 26 02:16:00 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 26 Apr 2016 12:16:00 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571DAF8F.1080305@oracle.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> Message-ID: <571ECF60.4060703@oracle.com> Hi Yasumasa, Kumar, Turns out this change breaks the behaviour of the launcher in the case that main() completes by throwing an exception. What we have in the launcher is: (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; LEAVE(); where LEAVE would have expanded to: if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ JLI_ReportErrorMessage(JVM_ERROR2); \ ret = 1; \ } \ if (JNI_TRUE) { \ (*vm)->DestroyJavaVM(vm); \ return ret; \ } \ so note that we are potentially calling DetachCurrentThread with an exception pending - which is prohibited by JNI**, but which we actually rely on for desired operation as DetachCurrentThread calls thread->exit() which performs uncaught exception handling (ie it prints the exception message and stacktrace) and then clears the exception! (Hence DestroyJavaVM is not called with any pending exceptions.) **JNI spec needs to be modified here. With the current change we have now inserted the following at the start of LEAVE: SetNativeThreadName(env, "DestroyJavaVM"); \ if ((*env)->ExceptionOccurred(env)) { \ (*env)->ExceptionClear(env); \ } \ this has two unintended consequences: 1. SetNativeThreadName itself calls a number of JNI methods, with the exception pending - which is not permitted. So straight away where we have: NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); FindBootStrapClass calls JVM_FindClassFromBootLoader, which make calls using the VM's CHECK_NULL macro - which checks for a pending exception (which it finds) and returns NULL. So the jli NULL_CHECK macro then reports a JNI error: Error: A JNI error has occurred, please check your installation and try again 2. There is no longer an exception from main() for DetachCurrentThread to report, so we exit with a return code of 1 as required, but don't report the exception message/stacktrace. I don't see a reasonable solution for this other than abandoning the attempt to change the name from "main" to "DestroyJavaVM" - which if we can't do, I question the utility of setting the name in the first place (while it might be useful in some circumstances [when main() is running] it will cause confusion in others [when main() has exited]). David ----- On 25/04/2016 3:47 PM, David Holmes wrote: > Looks good to me. > > I'll sponsor this "tomorrow". > > Thanks, > David > > On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >> Hi Kumar, >> >> Thank you for your comment! >> I've fixed them and uploaded new webrev. Could you review again? >> >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >> >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>> >>> Also a couple of minor suggestions: >>> >>> - * Set native thread name as possible. >>> + * Set native thread name if possible. >>> >>> >>> + /* >>> - * We can clear pending exception because exception at this point >>> - * is not critical. >>> + */ >>> >>> + /* >>> + * Clear non critical pending exceptions at this point. >>> + */ >>> >>> Thanks >>> Kumar >>> >>>> Hi, >>>> >>>> This is in the wrong place: >>>> >>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>> 1716 /* >>>> 1717 * We can clear pending exception because exception at >>>> this point >>>> 1718 * is not critical. >>>> 1719 */ >>>> 1720 (*env)->ExceptionClear(env); >>>> 1721 } >>>> >>>> This above needs to be after >>>> 391 SetNativeThreadName(env, "main"); >>>> 392 >>>> >>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>> but have also encountered an exception. In which case >>>> the method SetNativeThreadName will return to the caller, as >>>> if nothing has happened, because NULL_CHECK simply checks for NULL >>>> and returns to the caller. This will cause the caller to enter >>>> the VM with exceptions. >>>> >>>> Kumar >>>> >>>> >>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> I don't think we need to report the exception, but can just ignore >>>>>> it. Either way we have to clear the exception before continuing. >>>>> >>>>> I've fixed it in new webrev: >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>> Hi all, >>>>>>> >>>>>>> I have uploaded webrev.04 as below. >>>>>>> Could you review again? >>>>>>> >>>>>>> > - hotspot: >>>>>>> > >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>> >>>>>> Looks fine. >>>>>> >>>>>>> > >>>>>>> > - jdk: >>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>> >>>>>> As per private email (but repeated here on the record) in java.c: >>>>>> >>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>> 1717 } >>>>>> >>>>>> I don't think we need to report the exception, but can just ignore >>>>>> it. Either way we have to clear the exception before continuing. >>>>>> >>>>>> Thanks, >>>>>> David >>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>> >: >>>>>>> > >>>>>>> > Hi David, >>>>>>> > >>>>>>> > Thank you for your comment. >>>>>>> > I uploaded new webrev. Could you review again? >>>>>>> > >>>>>>> > - hotspot: >>>>>>> > >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>> > >>>>>>> > - jdk: >>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>> > >>>>>>> > >>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>> process, I >>>>>>> would have done it immediately after here: >>>>>>> > >>>>>>> > >>>>>>> > I think that native thread name ("main") should be set just >>>>>>> before >>>>>>> > main method call. >>>>>>> > However, main thread is already started, so I moved it as you >>>>>>> suggested. >>>>>>> > >>>>>>> > >>>>>>> >> One thing I dislike about the current structure is that we >>>>>>> have to >>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>> calls >>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>> char* ! >>>>>>> > >>>>>>> > >>>>>>> > SoI proposed to export new JVM function to set native thread >>>>>>> name with >>>>>>> > const char *. >>>>>>> > >>>>>>> > >>>>>>> > Thanks, >>>>>>> > >>>>>>> > Yasumasa >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>> >> >>>>>>> >> Hi Yasumasa, >>>>>>> >> >>>>>>> >> Thanks for persevering with this to get it into the current >>>>>>> form. >>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>> >> >>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>> >>> >>>>>>> >>> Hi Gerard, >>>>>>> >>> >>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>> >>>>>>> >>> >>>>>> >>: >>>>>>> >>> > >>>>>>> >>> > hi Yasumasa, >>>>>>> >>> > >>>>>>> >>> > Nice work. I have 2 questions: >>>>>>> >>> > >>>>>>> >>> > ======== >>>>>>> >>> > File: java.c >>>>>>> >>> > >>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>> >>> after every single JNI call? In this example instead of >>>>>>> NULL_CHECK, >>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>> >>> >>>>>>> >>> It is not critical if we encounter error at JNI function call >>>>>>> because >>>>>>> >>> we cannot set native thread name only. >>>>>>> >>> So I think that we do not need to leave from launcher process. >>>>>>> >> >>>>>>> >> >>>>>>> >> I agree we do not need to abort if an exception occurs (and in >>>>>>> fact >>>>>>> I don't think an exception is even possible from this code), but we >>>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>> extensively >>>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>>> is all >>>>>>> wrong! More on this code below ... >>>>>>> >> >>>>>>> >> Other comments: >>>>>>> >> >>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>> >> >>>>>>> >> Please add a comment to the method now that you removed the >>>>>>> internal >>>>>>> comment: >>>>>>> >> >>>>>>> >> // Sets the native thread name for a JavaThread. If specifically >>>>>>> >> // requested JNI-attached threads can also have their native >>>>>>> name set; >>>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>>> interfere >>>>>>> >> // with the application that created them. >>>>>>> >> >>>>>>> >> --- >>>>>>> >> >>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>> >> >>>>>>> >> Please add the following comments: >>>>>>> >> >>>>>>> >> + // Don't modify JNI-attached threads >>>>>>> >> setNativeName(name, false); >>>>>>> >> >>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>> permitted) to >>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>> >> private native void setNativeName(String name, boolean >>>>>>> allowAttachedThread); >>>>>>> >> >>>>>>> >> --- >>>>>>> >> >>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>> >> >>>>>>> >> 328 #define LEAVE() \ >>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>> >> >>>>>>> >> I was going to suggest this be set later, but realized we have >>>>>>> to be >>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>> >> >>>>>>> >> + /* Set native thread name. */ >>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>> >> >>>>>>> >> The comment is redundant given the name of the method. That >>>>>>> aside >>>>>>> I'm not sure why you do this so late in the process, I would have >>>>>>> done >>>>>>> it immediately after here: >>>>>>> >> >>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>> >> 388 exit(1); >>>>>>> >> 389 } >>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>> >> >>>>>>> >> >>>>>>> >> + /** >>>>>>> >> + * Set native thread name as possible. >>>>>>> >> + */ >>>>>>> >> >>>>>>> >> Other than the as->if change I'm unclear where the "possible" >>>>>>> bit >>>>>>> comes into play - why would it not be possible? >>>>>>> >> >>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>> "java/lang/Thread")); >>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>> (*env)->GetStaticMethodID(env, >>>>>>> cls, >>>>>>> >> 1707 "currentThread", >>>>>>> "()Ljava/lang/Thread;")); >>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>> >> 1709 currentThreadID)); >>>>>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, >>>>>>> cls, >>>>>>> >> 1711 "setNativeName", >>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>> name)); >>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>> setNativeNameID, >>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>> >> >>>>>>> >> As above NULL_CHECK is fine here, but we should check for and >>>>>>> clear >>>>>>> any pending exception after CallVoidMethod. >>>>>>> >> >>>>>>> >> One thing I dislike about the current structure is that we >>>>>>> have to >>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>> calls >>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>> char* ! >>>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>>> is an >>>>>>> issue we can revisit this. >>>>>>> >> >>>>>>> >> Thanks, >>>>>>> >> David >>>>>>> >> ----- >>>>>>> >> >>>>>>> >> >>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>>> native >>>>>>> thread >>>>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>>>> >>> >>>>>>> >>> Sorry for my bad English :-) >>>>>>> >>> >>>>>>> >>> Thanks, >>>>>>> >>> >>>>>>> >>> Yasumasa >>>>>>> >>> >>>>>>> >>> > cheers >>>>>>> >>> > >>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>> >>>>>>> >>> >> wrote: >>>>>>> >>> > > >>>>>>> >>> > > Hi David, >>>>>>> >>> > > >>>>>>> >>> > > I uploaded new webrev: >>>>>>> >>> > > >>>>>>> >>> > > - hotspot: >>>>>>> >>> > > >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>> >>> > > >>>>>>> >>> > > - jdk: >>>>>>> >>> > > >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>> >>> > > >>>>>>> >>> > > >>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>> setName so I'm >>>>>>> >>> not sure what you were thinking here. To take advantage of an >>>>>>> arg >>>>>>> taking >>>>>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>>>>> no Java >>>>>>> >>> code will call it . ??? >>>>>>> >>> > > >>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>> JNI-attached >>>>>>> thread. >>>>>>> >>> > > This change can set native thread name if main thread >>>>>>> changes to >>>>>>> >>> JNI-attached thread. >>>>>>> >>> > > >>>>>>> >>> > > >>>>>>> >>> > > Thanks, >>>>>>> >>> > > >>>>>>> >>> > > Yasumasa >>>>>>> >>> > > >>>>>>> >>> > > >>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>> >>> > >>> Hi David, >>>>>>> >>> > >>> >>>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>>> considered a >>>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>>> main, even >>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>> first place. >>>>>>> >>> :( Such >>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>> >>> > >>> >>>>>>> >>> > >>> I understood. >>>>>>> >>> > >>> Can I send CCC request? >>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>>> >>> > >> >>>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>>> sponsor for >>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>> proposed change >>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>> restore the >>>>>>> >>> "broken" behaviour. >>>>>>> >>> > >> >>>>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 >>>>>>> [1]. >>>>>>> >>> > >> >>>>>>> >>> > >> Okay we can do that. >>>>>>> >>> > >> >>>>>>> >>> > >>> >>>>>>> >>> > >>>> Further, we expect the launcher to use the supported >>>>>>> JNI >>>>>>> >>> interface (as >>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>> interface that >>>>>>> >>> exists for >>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>> >>> > >>> >>>>>>> >>> > >>> I think that we do not use JVM interface if we add new >>>>>>> method in >>>>>>> >>> > >>> LauncherHelper as below: >>>>>>> >>> > >>> ---------------- >>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>> >>> > >>> >>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> >>> > >>> --- >>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>> >>> > >>> +++ >>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>> >>> > >>> else >>>>>>> >>> > >>> return md.toNameAndVersion() + " (" + loc >>>>>>> + ")"; >>>>>>> >>> > >>> } >>>>>>> >>> > >>> + >>>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>> >>> > >>> + } >>>>>>> >>> > >> >>>>>>> >>> > >> You could also make that call via JNI directly, so not >>>>>>> sure the >>>>>>> >>> helper adds much here. But it won't work unless you change the >>>>>>> semantics >>>>>>> >>> of setName so I'm not sure what you were thinking here. To take >>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>>> need to >>>>>>> call >>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>> >>> > >> >>>>>>> >>> > >> David >>>>>>> >>> > >> ----- >>>>>>> >>> > >> >>>>>>> >>> > >>> } >>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>> src/java.base/share/native/libjli/java.c >>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>>>>> Apr 13 >>>>>>> 14:19:30 >>>>>>> >>> > >>> 2016 +0000 >>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>>>>> Apr 16 >>>>>>> 11:25:53 >>>>>>> >>> > >>> 2016 +0900 >>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>> *name); >>>>>>> >>> > >>> >>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>> >>> > >>> >>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>> >>> > >>> */ >>>>>>> >>> > >>> #define LEAVE() \ >>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>> >>> > >>> do { \ >>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) >>>>>>> { \ >>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>> >>> > >>> >>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>> >>> > >>> + >>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>> mainArgs); >>>>>>> >>> > >>> >>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>> >>> > >>> joptString); >>>>>>> >>> > >>> } >>>>>>> >>> > >>> >>>>>>> >>> > >>> +/** >>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>> >>> > >>> + */ >>>>>>> >>> > >>> +static void >>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>> >>> > >>> +{ >>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>> >>> > >>> + jstring nameString; >>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>> name)); >>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>> setNativeThreadNameID, >>>>>>> >>> > >>> nameString); >>>>>>> >>> > >>> +} >>>>>>> >>> > >>> + >>>>>>> >>> > >>> /* >>>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>> >>> > >>> */ >>>>>>> >>> > >>> ---------------- >>>>>>> >>> > >>> >>>>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>>> >>> > >>> >>>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>>> interface and so >>>>>>> >>> > >>>> has to be approved. >>>>>>> >>> > >>> >>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>> >>> > >>> >>>>>>> >>> > >>> >>>>>>> >>> > >>> Thanks, >>>>>>> >>> > >>> >>>>>>> >>> > >>> Yasumasa >>>>>>> >>> > >>> >>>>>>> >>> > >>> >>>>>>> >>> > >>> [1] >>>>>>> >>> > >>> >>>>>>> >>> >>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>> >>>>>>> >>>>>>> >>> > >>> >>>>>>> >>> > >>> >>>>>>> >>> > >>> >>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>> >>> > >>>>> Hi David, >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>> for main >>>>>>> >>> thread and >>>>>>> >>> > >>>>>> JNI attached threads >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>> itself as >>>>>>> >>> setName >>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>> thread. >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> I know. >>>>>>> >>> > >>>> >>>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>>> considered a >>>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>>> main, even >>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>> first place. >>>>>>> >>> :( Such >>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>> >>> > >>>> >>>>>>> >>> > >>>>> I checked changeset history. >>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>> JDK-7098194, >>>>>>> and it is >>>>>>> >>> > >>>>> backported JDK 8. >>>>>>> >>> > >>>> >>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>> >>> > >>>> >>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>> >>> Thread#setNativeName() >>>>>>> >>> > >>>>> only. >>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>> >>> JVM_SetNativeThreadName() >>>>>>> >>> > >>>>> for force setting. >>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>> >>> > >>>>> However, this function is NOT public, so I think we >>>>>>> can >>>>>>> add one >>>>>>> >>> more >>>>>>> >>> > >>>>> argument. >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> What do you think about this? >>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>> from Java >>>>>>> >>> launcher. >>>>>>> >>> > >>>> >>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>> really at >>>>>>> >>> issue. Yes >>>>>>> >>> > >>>> we would add another arg to the JVM function to allow >>>>>>> it to >>>>>>> apply to >>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>> reflect that >>>>>>> >>> not just >>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>> exported JVM >>>>>>> >>> interface >>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>> launcher to >>>>>>> >>> use the >>>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>>> not the >>>>>>> internal >>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>> communicate >>>>>>> >>> with the >>>>>>> >>> > >>>> JVM. >>>>>>> >>> > >>>> >>>>>>> >>> > >>>> David >>>>>>> >>> > >>>> ----- >>>>>>> >>> > >>>> >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> Thanks, >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> Yasumasa >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> >>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>> >>> > >>>>>>> Hi David, >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>>>>> being a >>>>>>> >>> JNI-attached >>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>> for main >>>>>>> >>> thread and >>>>>>> >>> > >>>>>> JNI attached threads >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>> itself as >>>>>>> >>> setName >>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>> thread. >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>> >>> > >>>>>>> --------------- >>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>>>>> 13:31:11 >>>>>>> >>> 2016 +0200 >>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>>>>> 17:50:10 >>>>>>> >>> 2016 +0900 >>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>>> is complete >>>>>>> >>> - nop if >>>>>>> >>> > >>>>>>> no agents. >>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>> >>> > >>>>>>> + >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>>>>> constructor. >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>> tracing >>>>>>> >>> > >>>>>>> backend."); >>>>>>> >>> > >>>>>>> } >>>>>>> >>> > >>>>>>> --------------- >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>>> If it wants to name its native threads then it is >>>>>>> free >>>>>>> to do so, >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>>>>> native >>>>>>> >>> thread name >>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>>>>> developer >>>>>>> >>> calls >>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>> SetNativeThreadName() as >>>>>>> below. >>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>>>> threads was a >>>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>>> with the OSX >>>>>>> >>> port and >>>>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>>>> feature was to >>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>>> been set by >>>>>>> >>> the host >>>>>>> >>> > >>>>>> process. If we do as you propose then we will just >>>>>>> have an >>>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>>> does my >>>>>>> >>> native thread >>>>>>> >>> > >>>>>> only have a name if I call >>>>>>> cur.setName(cur.getName()) ?" >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>>>>> this, the >>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>> thread only, >>>>>>> >>> non-JNI >>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>> were supposed >>>>>>> >>> to be >>>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>>> can see >>>>>>> that >>>>>>> >>> never >>>>>>> >>> > >>>>>> happened. :( >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> My position on this remains that if it is desirable >>>>>>> for >>>>>>> the main >>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>>> names >>>>>>> then the >>>>>>> >>> > >>>>>> launcher needs to be setting them using the available >>>>>>> platform >>>>>>> >>> APIs. >>>>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>>>>> the VM >>>>>>> >>> code for >>>>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>> Thread.setName would >>>>>>> >>> have to go >>>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>>> the launcher >>>>>>> >>> would >>>>>>> >>> > >>>>>> not. >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> Sorry. >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>> David >>>>>>> >>> > >>>>>> ----- >>>>>>> >>> > >>>>>> >>>>>>> >>> > >>>>>>> --------------- >>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>>>>> 13:31:11 >>>>>>> >>> 2016 +0200 >>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>>>>> 17:50:10 >>>>>>> >>> 2016 +0900 >>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>> java_lang_Thread::thread(java_thread); >>>>>>> >>> > >>>>>>> // Thread naming only supported for the current >>>>>>> thread, >>>>>>> >>> doesn't >>>>>>> >>> > >>>>>>> work >>>>>>> >>> > >>>>>>> for >>>>>>> >>> > >>>>>>> // target threads. >>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>> thread to avoid >>>>>>> >>> stepping >>>>>>> >>> > >>>>>>> // on other programs >>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>> >>> > >>>>>>> >>>>>>> >>> >>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>> >>>>>>> >>> > >>>>>>> --------------- >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> Thanks, >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> Yasumasa >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> >>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>> >>> > >>>>>>>>> Roger, >>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> David, >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>> this. I >>>>>>> don't like >>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>> initializing VM >>>>>>> (before >>>>>>> >>> > >>>>>>>>> calling >>>>>>> >>> > >>>>>>>>> main method), >>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>> AttachCurrentThread(). >>>>>>> So we >>>>>>> >>> can't >>>>>>> >>> > >>>>>>>>> set >>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>>>>> morning. >>>>>>> >>> Which, >>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>>>>> here that >>>>>>> >>> we don't >>>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>>> The fact >>>>>>> >>> that the >>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>>>>> thread seems >>>>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is >>>>>>> only >>>>>>> working by >>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>> used for the >>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>> inconsistently >>>>>>> >>> named at >>>>>>> >>> > >>>>>>>> the native level. >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>>>>> to be >>>>>>> >>> treated like >>>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>>> wants to >>>>>>> name its >>>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>>> would not be >>>>>>> >>> exporting >>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>> have to >>>>>>> use the OS >>>>>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>>>>> basis. >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> Sorry. >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> David >>>>>>> >>> > >>>>>>>> ----- >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>> >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> >>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>>>>> perform >>>>>>> >>> different >>>>>>> >>> > >>>>>>>>>> functions: >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>> JVM_SetNativeThreadName >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>>> thread, the >>>>>>> >>> second >>>>>>> >>> > >>>>>>>>>> one a >>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>>>>> somewhere >>>>>>> >>> about >>>>>>> >>> > >>>>>>>>>> what >>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>> casts to >>>>>>> (void*) >>>>>>> >>> > >>>>>>>>>> instead of >>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>> >>> used at >>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>>>>> the cast >>>>>>> >>> on the >>>>>>> >>> > >>>>>>>>>> same >>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>> haven't had >>>>>>> time to >>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>> JNI-attached >>>>>>> >>> thread >>>>>>> >>> > >>>>>>>>>>>> then >>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>> suggestion >>>>>>> >>> should >>>>>>> >>> > >>>>>>>>>>>> work >>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>> treatment of >>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>>>>> confirmed >>>>>>> >>> native >>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>>>> Exception{ >>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>> >>> > >>>>>>>>>>> } >>>>>>> >>> > >>>>>>>>>>> } >>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>> this. I >>>>>>> don't like >>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>> comment. >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>> wrote: >>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>>>>> thread >>>>>>> >>> name, and JLI >>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>>>>> >>> core-libs will >>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>> Kumar) - >>>>>>> now cc'd. >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>>> >>> Thread.setName >>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>>>> hotspot changes >>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>> Thread#setName() in >>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>>> >>> > >>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>>>>> which is >>>>>>> >>> why the >>>>>>> >>> > >>>>>>>>>>>> native >>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>> >>> > >>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>> attached thread. >>>>>>> >>> > >>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>> haven't had >>>>>>> time to >>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>> JNI-attached >>>>>>> >>> thread >>>>>>> >>> > >>>>>>>>>>>> then >>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>> suggestion >>>>>>> >>> should >>>>>>> >>> > >>>>>>>>>>>> work >>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>> treatment of >>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>> >>> > >>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>> this. I >>>>>>> don't like >>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>> >>> > >>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>>> David >>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>> >>> > >>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>> function to set >>>>>>> >>> native >>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> >>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>> >>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>>> well ... >>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>>> have >>>>>>> been on >>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>>> correct >>>>>>> as we >>>>>>> >>> do not >>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>>>>> includes the >>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>>> wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer >>>>>>> :-) >>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>> >>>>>>> >>> >>: >>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>> Suenaga wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>> Suenaga >>>>>>> wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>> >>> >>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>>>>>> >>> >>>>>> >>>: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>>>> Suenaga wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>>>>>> >>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>>>>>> >>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>> >>>>>>> >>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>> >>>>>>> >>> >>>>>> >>>>: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>>> set it: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = >>>>>>> new >>>>>>> >>> JavaThread(); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>> >>> set_active_handles >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> main_thread->record_stack_base_and_size(); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> >>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>>> something? >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>>> to thread >>>>>>> >>> name in >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>>>> setName(). >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java >>>>>>> app, >>>>>>> native >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>>>>> already >>>>>>> >>> starte >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>>>>> thrrad name >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>>> something like >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>> Tue >>>>>>> >>> Mar 29 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>> Wed >>>>>>> >>> Mar 30 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>> create_initial_thread(Handle >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>> initial_thread_name = >>>>>>> >>> "main"; >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> >>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>> (THREAD, k); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>> >>> thread); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> thread->set_threadObj(thread_oop()); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> java_lang_String::create_from_str("main", >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>>>> thread_oop, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>> itself >>>>>>> 'java' and >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>>> process >>>>>>> (and >>>>>>> >>> thus >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>>> process >>>>>>> is not >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>>> with >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>>>> >>> JavaThread. So I >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>>>>> thread. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>> anyhow, since >>>>>>> >>> we want >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread >>>>>>> name >>>>>>> might >>>>>>> >>> have >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' >>>>>>> | head -4 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>>> like >>>>>>> 'Java Main >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>>> Java >>>>>>> >>> launcher - e.g. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>>> thread >>>>>>> name, >>>>>>> >>> I think >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>> Yasumasa >>>>>>> >>> Suenaga wrote: >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>>>>> thread >>>>>>> >>> name via >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>>>>> have it. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>>>>> name, >>>>>>> and main >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>>>>> should have >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could >>>>>>> you >>>>>>> review it? >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>> > >>>>>>>>>> >>>>>>> >>> > >>>>>>> >>> >>>>>>> >>>> >>> From yasuenag at gmail.com Tue Apr 26 03:11:52 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Tue, 26 Apr 2016 12:11:52 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571ECF60.4060703@oracle.com> References: <56F3F90D.9010408@gmail.com> <570E42D2.4060609@oracle.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> Message-ID: <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> Hi David, Kumar, I think that we should evacuate original exception before DestroyJavaVM thread name is set. http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ I added it to LEAVE macro in new webrev. I tested it with following code. It works fine. ------------- public void main(String[] args){ throw new RuntimeException("test"); } ------------- What do you think about it? Thanks, Yasumasa On 2016/04/26 11:16, David Holmes wrote: > Hi Yasumasa, Kumar, > > Turns out this change breaks the behaviour of the launcher in the case that main() completes by throwing an exception. > > What we have in the launcher is: > > (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); > ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; > LEAVE(); > > where LEAVE would have expanded to: > > if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ > JLI_ReportErrorMessage(JVM_ERROR2); \ > ret = 1; \ > } \ > if (JNI_TRUE) { \ > (*vm)->DestroyJavaVM(vm); \ > return ret; \ > } \ > > so note that we are potentially calling DetachCurrentThread with an exception pending - which is prohibited by JNI**, but which we actually rely on for desired operation as DetachCurrentThread calls thread->exit() which performs uncaught exception handling (ie it prints the exception message and stacktrace) and then clears the exception! (Hence DestroyJavaVM is not called with any pending exceptions.) > > **JNI spec needs to be modified here. > > With the current change we have now inserted the following at the start of LEAVE: > > SetNativeThreadName(env, "DestroyJavaVM"); \ > if ((*env)->ExceptionOccurred(env)) { \ > (*env)->ExceptionClear(env); \ > } \ > > this has two unintended consequences: > > 1. SetNativeThreadName itself calls a number of JNI methods, with the exception pending - which is not permitted. So straight away where we have: > > NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); > > FindBootStrapClass calls JVM_FindClassFromBootLoader, which make calls using the VM's CHECK_NULL macro - which checks for a pending exception (which it finds) and returns NULL. So the jli NULL_CHECK macro then reports a JNI error: > > Error: A JNI error has occurred, please check your installation and try again > > > 2. There is no longer an exception from main() for DetachCurrentThread to report, so we exit with a return code of 1 as required, but don't report the exception message/stacktrace. > > I don't see a reasonable solution for this other than abandoning the attempt to change the name from "main" to "DestroyJavaVM" - which if we can't do, I question the utility of setting the name in the first place (while it might be useful in some circumstances [when main() is running] it will cause confusion in others [when main() has exited]). > > David > ----- > > On 25/04/2016 3:47 PM, David Holmes wrote: >> Looks good to me. >> >> I'll sponsor this "tomorrow". >> >> Thanks, >> David >> >> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>> Hi Kumar, >>> >>> Thank you for your comment! >>> I've fixed them and uploaded new webrev. Could you review again? >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>> >>>> Also a couple of minor suggestions: >>>> >>>> - * Set native thread name as possible. >>>> + * Set native thread name if possible. >>>> >>>> >>>> + /* >>>> - * We can clear pending exception because exception at this point >>>> - * is not critical. >>>> + */ >>>> >>>> + /* >>>> + * Clear non critical pending exceptions at this point. >>>> + */ >>>> >>>> Thanks >>>> Kumar >>>> >>>>> Hi, >>>>> >>>>> This is in the wrong place: >>>>> >>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>> 1716 /* >>>>> 1717 * We can clear pending exception because exception at >>>>> this point >>>>> 1718 * is not critical. >>>>> 1719 */ >>>>> 1720 (*env)->ExceptionClear(env); >>>>> 1721 } >>>>> >>>>> This above needs to be after >>>>> 391 SetNativeThreadName(env, "main"); >>>>> 392 >>>>> >>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>> but have also encountered an exception. In which case >>>>> the method SetNativeThreadName will return to the caller, as >>>>> if nothing has happened, because NULL_CHECK simply checks for NULL >>>>> and returns to the caller. This will cause the caller to enter >>>>> the VM with exceptions. >>>>> >>>>> Kumar >>>>> >>>>> >>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>>> I don't think we need to report the exception, but can just ignore >>>>>>> it. Either way we have to clear the exception before continuing. >>>>>> >>>>>> I've fixed it in new webrev: >>>>>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi all, >>>>>>>> >>>>>>>> I have uploaded webrev.04 as below. >>>>>>>> Could you review again? >>>>>>>> >>>>>>>> > - hotspot: >>>>>>>> > >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>> >>>>>>> Looks fine. >>>>>>> >>>>>>>> > >>>>>>>> > - jdk: >>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>> >>>>>>> As per private email (but repeated here on the record) in java.c: >>>>>>> >>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>> 1717 } >>>>>>> >>>>>>> I don't think we need to report the exception, but can just ignore >>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>> >: >>>>>>>> > >>>>>>>> > Hi David, >>>>>>>> > >>>>>>>> > Thank you for your comment. >>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>> > >>>>>>>> > - hotspot: >>>>>>>> > >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>> > >>>>>>>> > - jdk: >>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>> > >>>>>>>> > >>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>> process, I >>>>>>>> would have done it immediately after here: >>>>>>>> > >>>>>>>> > >>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>> before >>>>>>>> > main method call. >>>>>>>> > However, main thread is already started, so I moved it as you >>>>>>>> suggested. >>>>>>>> > >>>>>>>> > >>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>> have to >>>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>>> calls >>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>> char* ! >>>>>>>> > >>>>>>>> > >>>>>>>> > SoI proposed to export new JVM function to set native thread >>>>>>>> name with >>>>>>>> > const char *. >>>>>>>> > >>>>>>>> > >>>>>>>> > Thanks, >>>>>>>> > >>>>>>>> > Yasumasa >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>> >> >>>>>>>> >> Hi Yasumasa, >>>>>>>> >> >>>>>>>> >> Thanks for persevering with this to get it into the current >>>>>>>> form. >>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>> >> >>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>> >>> >>>>>>>> >>> Hi Gerard, >>>>>>>> >>> >>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>> >>>>>>>> >>> >>>>>>> >>: >>>>>>>> >>> > >>>>>>>> >>> > hi Yasumasa, >>>>>>>> >>> > >>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>> >>> > >>>>>>>> >>> > ======== >>>>>>>> >>> > File: java.c >>>>>>>> >>> > >>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>> NULL_CHECK, >>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>> >>> >>>>>>>> >>> It is not critical if we encounter error at JNI function call >>>>>>>> because >>>>>>>> >>> we cannot set native thread name only. >>>>>>>> >>> So I think that we do not need to leave from launcher process. >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> I agree we do not need to abort if an exception occurs (and in >>>>>>>> fact >>>>>>>> I don't think an exception is even possible from this code), but we >>>>>>>> should ensure any pending exception is cleared before any futher JNI >>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>> extensively >>>>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>>>> is all >>>>>>>> wrong! More on this code below ... >>>>>>>> >> >>>>>>>> >> Other comments: >>>>>>>> >> >>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>> >> >>>>>>>> >> Please add a comment to the method now that you removed the >>>>>>>> internal >>>>>>>> comment: >>>>>>>> >> >>>>>>>> >> // Sets the native thread name for a JavaThread. If specifically >>>>>>>> >> // requested JNI-attached threads can also have their native >>>>>>>> name set; >>>>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>>>> interfere >>>>>>>> >> // with the application that created them. >>>>>>>> >> >>>>>>>> >> --- >>>>>>>> >> >>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>> >> >>>>>>>> >> Please add the following comments: >>>>>>>> >> >>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>> >> setNativeName(name, false); >>>>>>>> >> >>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>> permitted) to >>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>> allowAttachedThread); >>>>>>>> >> >>>>>>>> >> --- >>>>>>>> >> >>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>> >> >>>>>>>> >> 328 #define LEAVE() \ >>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>> >> >>>>>>>> >> I was going to suggest this be set later, but realized we have >>>>>>>> to be >>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>> >> >>>>>>>> >> + /* Set native thread name. */ >>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>> >> >>>>>>>> >> The comment is redundant given the name of the method. That >>>>>>>> aside >>>>>>>> I'm not sure why you do this so late in the process, I would have >>>>>>>> done >>>>>>>> it immediately after here: >>>>>>>> >> >>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>> >> 388 exit(1); >>>>>>>> >> 389 } >>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> + /** >>>>>>>> >> + * Set native thread name as possible. >>>>>>>> >> + */ >>>>>>>> >> >>>>>>>> >> Other than the as->if change I'm unclear where the "possible" >>>>>>>> bit >>>>>>>> comes into play - why would it not be possible? >>>>>>>> >> >>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>> "java/lang/Thread")); >>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>> cls, >>>>>>>> >> 1707 "currentThread", >>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>> >> 1709 currentThreadID)); >>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, >>>>>>>> cls, >>>>>>>> >> 1711 "setNativeName", >>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>> name)); >>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>> setNativeNameID, >>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>> >> >>>>>>>> >> As above NULL_CHECK is fine here, but we should check for and >>>>>>>> clear >>>>>>>> any pending exception after CallVoidMethod. >>>>>>>> >> >>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>> have to >>>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>>> calls >>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>> char* ! >>>>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>>>> is an >>>>>>>> issue we can revisit this. >>>>>>>> >> >>>>>>>> >> Thanks, >>>>>>>> >> David >>>>>>>> >> ----- >>>>>>>> >> >>>>>>>> >> >>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>>>> native >>>>>>>> thread >>>>>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>>>>> >>> >>>>>>>> >>> Sorry for my bad English :-) >>>>>>>> >>> >>>>>>>> >>> Thanks, >>>>>>>> >>> >>>>>>>> >>> Yasumasa >>>>>>>> >>> >>>>>>>> >>> > cheers >>>>>>>> >>> > >>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>> >>>>>>>> >>> >> wrote: >>>>>>>> >>> > > >>>>>>>> >>> > > Hi David, >>>>>>>> >>> > > >>>>>>>> >>> > > I uploaded new webrev: >>>>>>>> >>> > > >>>>>>>> >>> > > - hotspot: >>>>>>>> >>> > > >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>> >>> > > >>>>>>>> >>> > > - jdk: >>>>>>>> >>> > > >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>> >>> > > >>>>>>>> >>> > > >>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>> setName so I'm >>>>>>>> >>> not sure what you were thinking here. To take advantage of an >>>>>>>> arg >>>>>>>> taking >>>>>>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>>>>>> no Java >>>>>>>> >>> code will call it . ??? >>>>>>>> >>> > > >>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>> JNI-attached >>>>>>>> thread. >>>>>>>> >>> > > This change can set native thread name if main thread >>>>>>>> changes to >>>>>>>> >>> JNI-attached thread. >>>>>>>> >>> > > >>>>>>>> >>> > > >>>>>>>> >>> > > Thanks, >>>>>>>> >>> > > >>>>>>>> >>> > > Yasumasa >>>>>>>> >>> > > >>>>>>>> >>> > > >>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>> >>> > >>> Hi David, >>>>>>>> >>> > >>> >>>>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>>>> considered a >>>>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>>>> main, even >>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>> first place. >>>>>>>> >>> :( Such >>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> I understood. >>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>>>> >>> > >> >>>>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>>>> sponsor for >>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>> proposed change >>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>> restore the >>>>>>>> >>> "broken" behaviour. >>>>>>>> >>> > >> >>>>>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 >>>>>>>> [1]. >>>>>>>> >>> > >> >>>>>>>> >>> > >> Okay we can do that. >>>>>>>> >>> > >> >>>>>>>> >>> > >>> >>>>>>>> >>> > >>>> Further, we expect the launcher to use the supported >>>>>>>> JNI >>>>>>>> >>> interface (as >>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>> interface that >>>>>>>> >>> exists for >>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> I think that we do not use JVM interface if we add new >>>>>>>> method in >>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>> >>> > >>> ---------------- >>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>> >>> > >>> >>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>> >>> > >>> --- >>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>> >>> > >>> +++ >>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>> >>> > >>> else >>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" + loc >>>>>>>> + ")"; >>>>>>>> >>> > >>> } >>>>>>>> >>> > >>> + >>>>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>> >>> > >>> + } >>>>>>>> >>> > >> >>>>>>>> >>> > >> You could also make that call via JNI directly, so not >>>>>>>> sure the >>>>>>>> >>> helper adds much here. But it won't work unless you change the >>>>>>>> semantics >>>>>>>> >>> of setName so I'm not sure what you were thinking here. To take >>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>>>> need to >>>>>>>> call >>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>> >>> > >> >>>>>>>> >>> > >> David >>>>>>>> >>> > >> ----- >>>>>>>> >>> > >> >>>>>>>> >>> > >>> } >>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>>>>>> Apr 13 >>>>>>>> 14:19:30 >>>>>>>> >>> > >>> 2016 +0000 >>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>>>>>> Apr 16 >>>>>>>> 11:25:53 >>>>>>>> >>> > >>> 2016 +0900 >>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean doXUsage); >>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char *optString); >>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char *optString); >>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>> *name); >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>> >>> > >>> */ >>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>> >>> > >>> do { \ >>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) >>>>>>>> { \ >>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, argc); >>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>> >>> > >>> + >>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>> mainArgs); >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>> >>> > >>> joptString); >>>>>>>> >>> > >>> } >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> +/** >>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>> >>> > >>> + */ >>>>>>>> >>> > >>> +static void >>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>> >>> > >>> +{ >>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>> >>> > >>> + jstring nameString; >>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>> name)); >>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>> setNativeThreadNameID, >>>>>>>> >>> > >>> nameString); >>>>>>>> >>> > >>> +} >>>>>>>> >>> > >>> + >>>>>>>> >>> > >>> /* >>>>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>> >>> > >>> */ >>>>>>>> >>> > >>> ---------------- >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>>>> >>> > >>> >>>>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>>>> interface and so >>>>>>>> >>> > >>>> has to be approved. >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> Thanks, >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> Yasumasa >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> [1] >>>>>>>> >>> > >>> >>>>>>>> >>> >>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>> >>>>>>>> >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> >>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>> >>> > >>>>> Hi David, >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>> for main >>>>>>>> >>> thread and >>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>>> itself as >>>>>>>> >>> setName >>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>> thread. >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> I know. >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>> That change in behaviour may be a problem, it could be >>>>>>>> considered a >>>>>>>> >>> > >>>> regression that setName stops setting the native thread >>>>>>>> main, even >>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>> first place. >>>>>>>> >>> :( Such >>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>> JDK-7098194, >>>>>>>> and it is >>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>> >>> Thread#setNativeName() >>>>>>>> >>> > >>>>> only. >>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private method. >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>> >>> > >>>>> for force setting. >>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>> >>> > >>>>> However, this function is NOT public, so I think we >>>>>>>> can >>>>>>>> add one >>>>>>>> >>> more >>>>>>>> >>> > >>>>> argument. >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>> from Java >>>>>>>> >>> launcher. >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>> really at >>>>>>>> >>> issue. Yes >>>>>>>> >>> > >>>> we would add another arg to the JVM function to allow >>>>>>>> it to >>>>>>>> apply to >>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>> reflect that >>>>>>>> >>> not just >>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>> exported JVM >>>>>>>> >>> interface >>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>> launcher to >>>>>>>> >>> use the >>>>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>>>> not the >>>>>>>> internal >>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>> communicate >>>>>>>> >>> with the >>>>>>>> >>> > >>>> JVM. >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>> David >>>>>>>> >>> > >>>> ----- >>>>>>>> >>> > >>>> >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> Thanks, >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> Yasumasa >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> >>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>>>>>> being a >>>>>>>> >>> JNI-attached >>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>> for main >>>>>>>> >>> thread and >>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>>> itself as >>>>>>>> >>> setName >>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>> thread. >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>> >>> > >>>>>>> --------------- >>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 src/share/vm/runtime/thread.cpp >>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>>>>>> 13:31:11 >>>>>>>> >>> 2016 +0200 >>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>>>>>> 17:50:10 >>>>>>>> >>> 2016 +0900 >>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>>>> is complete >>>>>>>> >>> - nop if >>>>>>>> >>> > >>>>>>> no agents. >>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>> >>> > >>>>>>> + >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> I think we can do this straight after the JavaThread >>>>>>>> constructor. >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>> tracing >>>>>>>> >>> > >>>>>>> backend."); >>>>>>>> >>> > >>>>>>> } >>>>>>>> >>> > >>>>>>> --------------- >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then it is >>>>>>>> free >>>>>>>> to do so, >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>>>>>> native >>>>>>>> >>> thread name >>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>>>>>> developer >>>>>>>> >>> calls >>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>> >>> > >>>>>>> It is not the same of changing native thread name at >>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>> SetNativeThreadName() as >>>>>>>> below. >>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>>>>> threads was a >>>>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>>>> with the OSX >>>>>>>> >>> port and >>>>>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>>>>> feature was to >>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>>>> been set by >>>>>>>> >>> the host >>>>>>>> >>> > >>>>>> process. If we do as you propose then we will just >>>>>>>> have an >>>>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>>>> does my >>>>>>>> >>> native thread >>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> ** If you follow the bugs and related discussions on >>>>>>>> this, the >>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>> thread only, >>>>>>>> >>> non-JNI >>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>> were supposed >>>>>>>> >>> to be >>>>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>>>> can see >>>>>>>> that >>>>>>>> >>> never >>>>>>>> >>> > >>>>>> happened. :( >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> My position on this remains that if it is desirable >>>>>>>> for >>>>>>>> the main >>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>>>> names >>>>>>>> then the >>>>>>>> >>> > >>>>>> launcher needs to be setting them using the available >>>>>>>> platform >>>>>>>> >>> APIs. >>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>>>>>> the VM >>>>>>>> >>> code for >>>>>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>> Thread.setName would >>>>>>>> >>> have to go >>>>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>>>> the launcher >>>>>>>> >>> would >>>>>>>> >>> > >>>>>> not. >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> Sorry. >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>> David >>>>>>>> >>> > >>>>>> ----- >>>>>>>> >>> > >>>>>> >>>>>>>> >>> > >>>>>>> --------------- >>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>>>>>> 13:31:11 >>>>>>>> >>> 2016 +0200 >>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>>>>>> 17:50:10 >>>>>>>> >>> 2016 +0900 >>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>> >>> > >>>>>>> // Thread naming only supported for the current >>>>>>>> thread, >>>>>>>> >>> doesn't >>>>>>>> >>> > >>>>>>> work >>>>>>>> >>> > >>>>>>> for >>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>> thread to avoid >>>>>>>> >>> stepping >>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> >>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>> >>>>>>>> >>> > >>>>>>> --------------- >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> >>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> David, >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>> this. I >>>>>>>> don't like >>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>> initializing VM >>>>>>>> (before >>>>>>>> >>> > >>>>>>>>> calling >>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>> AttachCurrentThread(). >>>>>>>> So we >>>>>>>> >>> can't >>>>>>>> >>> > >>>>>>>>> set >>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier this >>>>>>>> morning. >>>>>>>> >>> Which, >>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>>>>>> here that >>>>>>>> >>> we don't >>>>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>>>> The fact >>>>>>>> >>> that the >>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a JNI-attached >>>>>>>> thread seems >>>>>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is >>>>>>>> only >>>>>>>> working by >>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>> used for the >>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>> inconsistently >>>>>>>> >>> named at >>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>>>>>> to be >>>>>>>> >>> treated like >>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>>>> wants to >>>>>>>> name its >>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>>>> would not be >>>>>>>> >>> exporting >>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>> have to >>>>>>>> use the OS >>>>>>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>>>>>> basis. >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> David >>>>>>>> >>> > >>>>>>>> ----- >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>> >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> >>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>>>>>> perform >>>>>>>> >>> different >>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>> JVM_SetNativeThreadName >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>>>> thread, the >>>>>>>> >>> second >>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>>>>>> somewhere >>>>>>>> >>> about >>>>>>>> >>> > >>>>>>>>>> what >>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>> casts to >>>>>>>> (void*) >>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>> >>> used at >>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>>>>>> the cast >>>>>>>> >>> on the >>>>>>>> >>> > >>>>>>>>>> same >>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>> haven't had >>>>>>>> time to >>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>> JNI-attached >>>>>>>> >>> thread >>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>>> suggestion >>>>>>>> >>> should >>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>>> treatment of >>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, and I >>>>>>>> confirmed >>>>>>>> >>> native >>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>>>>> Exception{ >>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>> this. I >>>>>>>> don't like >>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>> comment. >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga wrote: >>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>> wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>>>>>> thread >>>>>>>> >>> name, and JLI >>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another team so >>>>>>>> >>> core-libs will >>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>> Kumar) - >>>>>>>> now cc'd. >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java upcall to >>>>>>>> >>> Thread.setName >>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>>>>> hotspot changes >>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>> Thread#setName() in >>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>>>>>> which is >>>>>>>> >>> why the >>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>> attached thread. >>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>> haven't had >>>>>>>> time to >>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>> JNI-attached >>>>>>>> >>> thread >>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>>> suggestion >>>>>>>> >>> should >>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>>> treatment of >>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>> this. I >>>>>>>> don't like >>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>> function to set >>>>>>>> >>> native >>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> >>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>> >>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>>>> well ... >>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>>>> have >>>>>>>> been on >>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>>>> correct >>>>>>>> as we >>>>>>>> >>> do not >>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, which >>>>>>>> includes the >>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>>>> wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer >>>>>>>> :-) >>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>> >>>>>>>> >>> >>: >>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>> Suenaga wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>> Suenaga >>>>>>>> wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>> >>> >>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>>>>>>> >>> >>>>>>> >>>: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>>>>> Suenaga wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>>>>>>> >>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>>>>>>> >>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>> >>>>>>>> >>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>>>>>>> >>> >>>>>>> >>>>: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>>>> set it: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = >>>>>>>> new >>>>>>>> >>> JavaThread(); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> main_thread->initialize_thread_current(); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>> >>> set_active_handles >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> >>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>>>> something? >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>>>> to thread >>>>>>>> >>> name in >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>>>>> setName(). >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java >>>>>>>> app, >>>>>>>> native >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>>>>>> already >>>>>>>> >>> starte >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of setting >>>>>>>> thrrad name >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>>>> something like >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>> Tue >>>>>>>> >>> Mar 29 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>> Wed >>>>>>>> >>> Mar 30 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>> create_initial_thread(Handle >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>> initial_thread_name = >>>>>>>> >>> "main"; >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> >>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>> (THREAD, k); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>> >>> thread); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> java_lang_String::create_from_str("main", >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>>>>> thread_oop, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev later. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>> itself >>>>>>>> 'java' and >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>>>> process >>>>>>>> (and >>>>>>>> >>> thus >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>>>> process >>>>>>>> is not >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>>>> with >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>>>>> >>> JavaThread. So I >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>>>>>> thread. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>> anyhow, since >>>>>>>> >>> we want >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread >>>>>>>> name >>>>>>>> might >>>>>>>> >>> have >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. /proc. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' >>>>>>>> | head -4 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>>>> like >>>>>>>> 'Java Main >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>>>> Java >>>>>>>> >>> launcher - e.g. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, etc. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>>>> thread >>>>>>>> name, >>>>>>>> >>> I think >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>> Yasumasa >>>>>>>> >>> Suenaga wrote: >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>>>>>> thread >>>>>>>> >>> name via >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread does not >>>>>>>> have it. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>>>>>> name, >>>>>>>> and main >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main thread >>>>>>>> should have >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could >>>>>>>> you >>>>>>>> review it? >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>> > >>>>>>>>>> >>>>>>>> >>> > >>>>>>>> >>> >>>>>>>> >>>>> >>>> From david.holmes at oracle.com Tue Apr 26 05:16:05 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 26 Apr 2016 15:16:05 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> References: <56F3F90D.9010408@gmail.com> <570E65B6.2010809@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> Message-ID: <571EF995.3000109@oracle.com> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: > Hi David, Kumar, > > I think that we should evacuate original exception before DestroyJavaVM > thread name is set. > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ > > I added it to LEAVE macro in new webrev. BTW: in the LEAVE macro, stylistically all the code should be in the do { } while(false); loop. I overlooked that initially. > I tested it with following code. It works fine. > > ------------- > public void main(String[] args){ > throw new RuntimeException("test"); > } > ------------- > > What do you think about it? I thought about being able to save/restore the original pending exception but could not see a simple way to restore it - ie just by poking it back into the thread's pending exception field. The problem with using env->Throw is that it acts like the initial throwing of the exception and will have a number of side-effects that then get doubled up: - logging statements (UL and Event logging) - OOM counting I'm not sure whether that is acceptable or not That aside you should check if orig_throwable is non-null before clearing to avoid an unnecessary JNI call. Also "Resume original exception" -> "Restore any original exception" Thanks, David ----- > > Thanks, > > Yasumasa > > > On 2016/04/26 11:16, David Holmes wrote: >> Hi Yasumasa, Kumar, >> >> Turns out this change breaks the behaviour of the launcher in the case >> that main() completes by throwing an exception. >> >> What we have in the launcher is: >> >> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >> LEAVE(); >> >> where LEAVE would have expanded to: >> >> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >> JLI_ReportErrorMessage(JVM_ERROR2); \ >> ret = 1; \ >> } \ >> if (JNI_TRUE) { \ >> (*vm)->DestroyJavaVM(vm); \ >> return ret; \ >> } \ >> >> so note that we are potentially calling DetachCurrentThread with an >> exception pending - which is prohibited by JNI**, but which we >> actually rely on for desired operation as DetachCurrentThread calls >> thread->exit() which performs uncaught exception handling (ie it >> prints the exception message and stacktrace) and then clears the >> exception! (Hence DestroyJavaVM is not called with any pending >> exceptions.) >> >> **JNI spec needs to be modified here. >> >> With the current change we have now inserted the following at the >> start of LEAVE: >> >> SetNativeThreadName(env, "DestroyJavaVM"); \ >> if ((*env)->ExceptionOccurred(env)) { \ >> (*env)->ExceptionClear(env); \ >> } \ >> >> this has two unintended consequences: >> >> 1. SetNativeThreadName itself calls a number of JNI methods, with the >> exception pending - which is not permitted. So straight away where we >> have: >> >> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >> >> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make calls >> using the VM's CHECK_NULL macro - which checks for a pending exception >> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >> reports a JNI error: >> >> Error: A JNI error has occurred, please check your installation and >> try again >> >> >> 2. There is no longer an exception from main() for DetachCurrentThread >> to report, so we exit with a return code of 1 as required, but don't >> report the exception message/stacktrace. >> >> I don't see a reasonable solution for this other than abandoning the >> attempt to change the name from "main" to "DestroyJavaVM" - which if >> we can't do, I question the utility of setting the name in the first >> place (while it might be useful in some circumstances [when main() is >> running] it will cause confusion in others [when main() has exited]). >> >> David >> ----- >> >> On 25/04/2016 3:47 PM, David Holmes wrote: >>> Looks good to me. >>> >>> I'll sponsor this "tomorrow". >>> >>> Thanks, >>> David >>> >>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>> Hi Kumar, >>>> >>>> Thank you for your comment! >>>> I've fixed them and uploaded new webrev. Could you review again? >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>> >>>>> Also a couple of minor suggestions: >>>>> >>>>> - * Set native thread name as possible. >>>>> + * Set native thread name if possible. >>>>> >>>>> >>>>> + /* >>>>> - * We can clear pending exception because exception at this >>>>> point >>>>> - * is not critical. >>>>> + */ >>>>> >>>>> + /* >>>>> + * Clear non critical pending exceptions at this point. >>>>> + */ >>>>> >>>>> Thanks >>>>> Kumar >>>>> >>>>>> Hi, >>>>>> >>>>>> This is in the wrong place: >>>>>> >>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>> 1716 /* >>>>>> 1717 * We can clear pending exception because exception at >>>>>> this point >>>>>> 1718 * is not critical. >>>>>> 1719 */ >>>>>> 1720 (*env)->ExceptionClear(env); >>>>>> 1721 } >>>>>> >>>>>> This above needs to be after >>>>>> 391 SetNativeThreadName(env, "main"); >>>>>> 392 >>>>>> >>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>> but have also encountered an exception. In which case >>>>>> the method SetNativeThreadName will return to the caller, as >>>>>> if nothing has happened, because NULL_CHECK simply checks for NULL >>>>>> and returns to the caller. This will cause the caller to enter >>>>>> the VM with exceptions. >>>>>> >>>>>> Kumar >>>>>> >>>>>> >>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>> Hi David, >>>>>>> >>>>>>>> I don't think we need to report the exception, but can just ignore >>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>> >>>>>>> I've fixed it in new webrev: >>>>>>> >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>> Hi all, >>>>>>>>> >>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>> Could you review again? >>>>>>>>> >>>>>>>>> > - hotspot: >>>>>>>>> > >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>> >>>>>>>> >>>>>>>> Looks fine. >>>>>>>> >>>>>>>>> > >>>>>>>>> > - jdk: >>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>> >>>>>>>> As per private email (but repeated here on the record) in java.c: >>>>>>>> >>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>> 1717 } >>>>>>>> >>>>>>>> I don't think we need to report the exception, but can just ignore >>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>> >>>>>>>> Thanks, >>>>>>>> David >>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>> >: >>>>>>>>> > >>>>>>>>> > Hi David, >>>>>>>>> > >>>>>>>>> > Thank you for your comment. >>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>> > >>>>>>>>> > - hotspot: >>>>>>>>> > >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>> >>>>>>>>> > >>>>>>>>> > - jdk: >>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>> > >>>>>>>>> > >>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>> process, I >>>>>>>>> would have done it immediately after here: >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>>> before >>>>>>>>> > main method call. >>>>>>>>> > However, main thread is already started, so I moved it as you >>>>>>>>> suggested. >>>>>>>>> > >>>>>>>>> > >>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>> have to >>>>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>>>> calls >>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>> char* ! >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > SoI proposed to export new JVM function to set native thread >>>>>>>>> name with >>>>>>>>> > const char *. >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > Thanks, >>>>>>>>> > >>>>>>>>> > Yasumasa >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>> >> >>>>>>>>> >> Hi Yasumasa, >>>>>>>>> >> >>>>>>>>> >> Thanks for persevering with this to get it into the current >>>>>>>>> form. >>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>> >> >>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>> >>> >>>>>>>>> >>> Hi Gerard, >>>>>>>>> >>> >>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>> >>>>>>>>> >>> >>>>>>>> >>: >>>>>>>>> >>> > >>>>>>>>> >>> > hi Yasumasa, >>>>>>>>> >>> > >>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>> >>> > >>>>>>>>> >>> > ======== >>>>>>>>> >>> > File: java.c >>>>>>>>> >>> > >>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>> NULL_CHECK, >>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>> >>> >>>>>>>>> >>> It is not critical if we encounter error at JNI function call >>>>>>>>> because >>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>> process. >>>>>>>>> >> >>>>>>>>> >> >>>>>>>>> >> I agree we do not need to abort if an exception occurs (and in >>>>>>>>> fact >>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>> but we >>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>> futher JNI >>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>> extensively >>>>>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>>>>> is all >>>>>>>>> wrong! More on this code below ... >>>>>>>>> >> >>>>>>>>> >> Other comments: >>>>>>>>> >> >>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>> >> >>>>>>>>> >> Please add a comment to the method now that you removed the >>>>>>>>> internal >>>>>>>>> comment: >>>>>>>>> >> >>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>> specifically >>>>>>>>> >> // requested JNI-attached threads can also have their native >>>>>>>>> name set; >>>>>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>>>>> interfere >>>>>>>>> >> // with the application that created them. >>>>>>>>> >> >>>>>>>>> >> --- >>>>>>>>> >> >>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>> >> >>>>>>>>> >> Please add the following comments: >>>>>>>>> >> >>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>> >> setNativeName(name, false); >>>>>>>>> >> >>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>> permitted) to >>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>> allowAttachedThread); >>>>>>>>> >> >>>>>>>>> >> --- >>>>>>>>> >> >>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>> >> >>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>> >> >>>>>>>>> >> I was going to suggest this be set later, but realized we have >>>>>>>>> to be >>>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>>> >> >>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>> >> >>>>>>>>> >> The comment is redundant given the name of the method. That >>>>>>>>> aside >>>>>>>>> I'm not sure why you do this so late in the process, I would have >>>>>>>>> done >>>>>>>>> it immediately after here: >>>>>>>>> >> >>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>> >> 388 exit(1); >>>>>>>>> >> 389 } >>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>> >> >>>>>>>>> >> >>>>>>>>> >> + /** >>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>> >> + */ >>>>>>>>> >> >>>>>>>>> >> Other than the as->if change I'm unclear where the "possible" >>>>>>>>> bit >>>>>>>>> comes into play - why would it not be possible? >>>>>>>>> >> >>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>> "java/lang/Thread")); >>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>> cls, >>>>>>>>> >> 1707 "currentThread", >>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, >>>>>>>>> cls, >>>>>>>>> >> 1711 "setNativeName", >>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>> name)); >>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>> setNativeNameID, >>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>> >> >>>>>>>>> >> As above NULL_CHECK is fine here, but we should check for and >>>>>>>>> clear >>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>> >> >>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>> have to >>>>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>>>> calls >>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>> char* ! >>>>>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>>>>> is an >>>>>>>>> issue we can revisit this. >>>>>>>>> >> >>>>>>>>> >> Thanks, >>>>>>>>> >> David >>>>>>>>> >> ----- >>>>>>>>> >> >>>>>>>>> >> >>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>>>>> native >>>>>>>>> thread >>>>>>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>>>>>> >>> >>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>> >>> >>>>>>>>> >>> Thanks, >>>>>>>>> >>> >>>>>>>>> >>> Yasumasa >>>>>>>>> >>> >>>>>>>>> >>> > cheers >>>>>>>>> >>> > >>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>> >>>>>>>>> >>> >> >>>>>>>>> wrote: >>>>>>>>> >>> > > >>>>>>>>> >>> > > Hi David, >>>>>>>>> >>> > > >>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>> >>> > > >>>>>>>>> >>> > > - hotspot: >>>>>>>>> >>> > > >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>> >>>>>>>>> >>> > > >>>>>>>>> >>> > > - jdk: >>>>>>>>> >>> > > >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>> >>> > > >>>>>>>>> >>> > > >>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>> setName so I'm >>>>>>>>> >>> not sure what you were thinking here. To take advantage of an >>>>>>>>> arg >>>>>>>>> taking >>>>>>>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>>>>>>> no Java >>>>>>>>> >>> code will call it . ??? >>>>>>>>> >>> > > >>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>> JNI-attached >>>>>>>>> thread. >>>>>>>>> >>> > > This change can set native thread name if main thread >>>>>>>>> changes to >>>>>>>>> >>> JNI-attached thread. >>>>>>>>> >>> > > >>>>>>>>> >>> > > >>>>>>>>> >>> > > Thanks, >>>>>>>>> >>> > > >>>>>>>>> >>> > > Yasumasa >>>>>>>>> >>> > > >>>>>>>>> >>> > > >>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>> >>> > >>> Hi David, >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>> could be >>>>>>>>> considered a >>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>> thread >>>>>>>>> main, even >>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>> first place. >>>>>>>>> >>> :( Such >>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> I understood. >>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>>>>> >>> > >> >>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>>>>> sponsor for >>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>> proposed change >>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>> restore the >>>>>>>>> >>> "broken" behaviour. >>>>>>>>> >>> > >> >>>>>>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 >>>>>>>>> [1]. >>>>>>>>> >>> > >> >>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>> >>> > >> >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>>> Further, we expect the launcher to use the supported >>>>>>>>> JNI >>>>>>>>> >>> interface (as >>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>> interface that >>>>>>>>> >>> exists for >>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> I think that we do not use JVM interface if we add new >>>>>>>>> method in >>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>> >>> > >>> ---------------- >>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>> >>> > >>> >>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>> >>> > >>> --- >>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>> >>> > >>> +++ >>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>> >>> > >>> else >>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" + loc >>>>>>>>> + ")"; >>>>>>>>> >>> > >>> } >>>>>>>>> >>> > >>> + >>>>>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>> >>> > >>> + } >>>>>>>>> >>> > >> >>>>>>>>> >>> > >> You could also make that call via JNI directly, so not >>>>>>>>> sure the >>>>>>>>> >>> helper adds much here. But it won't work unless you change >>>>>>>>> the >>>>>>>>> semantics >>>>>>>>> >>> of setName so I'm not sure what you were thinking here. To >>>>>>>>> take >>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>>>>> need to >>>>>>>>> call >>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>> >>> > >> >>>>>>>>> >>> > >> David >>>>>>>>> >>> > >> ----- >>>>>>>>> >>> > >> >>>>>>>>> >>> > >>> } >>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>>>>>>> Apr 13 >>>>>>>>> 14:19:30 >>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>>>>>>> Apr 16 >>>>>>>>> 11:25:53 >>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>> doXUsage); >>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>> *optString); >>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>> *optString); >>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>>> *name); >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>> >>> > >>> */ >>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>> >>> > >>> do { \ >>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) >>>>>>>>> { \ >>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>> argc); >>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>> >>> > >>> + >>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>>> mainArgs); >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>> >>> > >>> joptString); >>>>>>>>> >>> > >>> } >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> +/** >>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>> >>> > >>> + */ >>>>>>>>> >>> > >>> +static void >>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>> >>> > >>> +{ >>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>> name)); >>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>> setNativeThreadNameID, >>>>>>>>> >>> > >>> nameString); >>>>>>>>> >>> > >>> +} >>>>>>>>> >>> > >>> + >>>>>>>>> >>> > >>> /* >>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>> >>> > >>> */ >>>>>>>>> >>> > >>> ---------------- >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>>>>> interface and so >>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> Thanks, >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> Yasumasa >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> [1] >>>>>>>>> >>> > >>> >>>>>>>>> >>> >>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> >>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>> for main >>>>>>>>> >>> thread and >>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>>>> itself as >>>>>>>>> >>> setName >>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>> thread. >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> I know. >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>> could be >>>>>>>>> considered a >>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>> thread >>>>>>>>> main, even >>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>> first place. >>>>>>>>> >>> :( Such >>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>> JDK-7098194, >>>>>>>>> and it is >>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>> >>> Thread#setNativeName() >>>>>>>>> >>> > >>>>> only. >>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>> method. >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>> >>> > >>>>> However, this function is NOT public, so I think we >>>>>>>>> can >>>>>>>>> add one >>>>>>>>> >>> more >>>>>>>>> >>> > >>>>> argument. >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>>> from Java >>>>>>>>> >>> launcher. >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>>> really at >>>>>>>>> >>> issue. Yes >>>>>>>>> >>> > >>>> we would add another arg to the JVM function to allow >>>>>>>>> it to >>>>>>>>> apply to >>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>>> reflect that >>>>>>>>> >>> not just >>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>> exported JVM >>>>>>>>> >>> interface >>>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>>> launcher to >>>>>>>>> >>> use the >>>>>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>>>>> not the >>>>>>>>> internal >>>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>>> communicate >>>>>>>>> >>> with the >>>>>>>>> >>> > >>>> JVM. >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>> David >>>>>>>>> >>> > >>>> ----- >>>>>>>>> >>> > >>>> >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> >>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>>>>>>> being a >>>>>>>>> >>> JNI-attached >>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>> for main >>>>>>>>> >>> thread and >>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>>>> itself as >>>>>>>>> >>> setName >>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>> thread. >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>>>>>>> 13:31:11 >>>>>>>>> >>> 2016 +0200 >>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>>>>>>> 17:50:10 >>>>>>>>> >>> 2016 +0900 >>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>>>>> is complete >>>>>>>>> >>> - nop if >>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>> >>> > >>>>>>> + >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>> JavaThread >>>>>>>>> constructor. >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>>> tracing >>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>> >>> > >>>>>>> } >>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then it is >>>>>>>>> free >>>>>>>>> to do so, >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>>>>>>> native >>>>>>>>> >>> thread name >>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>>>>>>> developer >>>>>>>>> >>> calls >>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>> name at >>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>> SetNativeThreadName() as >>>>>>>>> below. >>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>>>>>> threads was a >>>>>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>>>>> with the OSX >>>>>>>>> >>> port and >>>>>>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>>>>>> feature was to >>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>>>>> been set by >>>>>>>>> >>> the host >>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will just >>>>>>>>> have an >>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>>>>> does my >>>>>>>>> >>> native thread >>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>> discussions on >>>>>>>>> this, the >>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>>> thread only, >>>>>>>>> >>> non-JNI >>>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>>> were supposed >>>>>>>>> >>> to be >>>>>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>>>>> can see >>>>>>>>> that >>>>>>>>> >>> never >>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> My position on this remains that if it is desirable >>>>>>>>> for >>>>>>>>> the main >>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>>>>> names >>>>>>>>> then the >>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>> available >>>>>>>>> platform >>>>>>>>> >>> APIs. >>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>>>>>>> the VM >>>>>>>>> >>> code for >>>>>>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>> Thread.setName would >>>>>>>>> >>> have to go >>>>>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>>>>> the launcher >>>>>>>>> >>> would >>>>>>>>> >>> > >>>>>> not. >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>> David >>>>>>>>> >>> > >>>>>> ----- >>>>>>>>> >>> > >>>>>> >>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>>>>>>> 13:31:11 >>>>>>>>> >>> 2016 +0200 >>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>>>>>>> 17:50:10 >>>>>>>>> >>> 2016 +0900 >>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the current >>>>>>>>> thread, >>>>>>>>> >>> doesn't >>>>>>>>> >>> > >>>>>>> work >>>>>>>>> >>> > >>>>>>> for >>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>> thread to avoid >>>>>>>>> >>> stepping >>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> >>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>> >>>>>>>>> >>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> >>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>> this. I >>>>>>>>> don't like >>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>> initializing VM >>>>>>>>> (before >>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>> AttachCurrentThread(). >>>>>>>>> So we >>>>>>>>> >>> can't >>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier >>>>>>>>> this >>>>>>>>> morning. >>>>>>>>> >>> Which, >>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>>>>>>> here that >>>>>>>>> >>> we don't >>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>>>>> The fact >>>>>>>>> >>> that the >>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>> JNI-attached >>>>>>>>> thread seems >>>>>>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is >>>>>>>>> only >>>>>>>>> working by >>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>>> used for the >>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>>> inconsistently >>>>>>>>> >>> named at >>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>>>>>>> to be >>>>>>>>> >>> treated like >>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>>>>> wants to >>>>>>>>> name its >>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>>>>> would not be >>>>>>>>> >>> exporting >>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>>> have to >>>>>>>>> use the OS >>>>>>>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>>>>>>> basis. >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> David >>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>> >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>>>>>>> perform >>>>>>>>> >>> different >>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>> JVM_SetNativeThreadName >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>>>>> thread, the >>>>>>>>> >>> second >>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>>>>>>> somewhere >>>>>>>>> >>> about >>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>> casts to >>>>>>>>> (void*) >>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>> >>> used at >>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>>>>>>> the cast >>>>>>>>> >>> on the >>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>> haven't had >>>>>>>>> time to >>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>> JNI-attached >>>>>>>>> >>> thread >>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>>>> suggestion >>>>>>>>> >>> should >>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>>>> treatment of >>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, >>>>>>>>> and I >>>>>>>>> confirmed >>>>>>>>> >>> native >>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>>>>>> Exception{ >>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>> this. I >>>>>>>>> don't like >>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>>> comment. >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>> wrote: >>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>>> wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>>>>>>> thread >>>>>>>>> >>> name, and JLI >>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>> team so >>>>>>>>> >>> core-libs will >>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>>> Kumar) - >>>>>>>>> now cc'd. >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>> upcall to >>>>>>>>> >>> Thread.setName >>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>>>>>> hotspot changes >>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>> Thread#setName() in >>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>>>>>>> which is >>>>>>>>> >>> why the >>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>> attached thread. >>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>> haven't had >>>>>>>>> time to >>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>> JNI-attached >>>>>>>>> >>> thread >>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>>>> suggestion >>>>>>>>> >>> should >>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>>>> treatment of >>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>> this. I >>>>>>>>> don't like >>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>> function to set >>>>>>>>> >>> native >>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> >>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>>>>> well ... >>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>>>>> have >>>>>>>>> been on >>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>>>>> correct >>>>>>>>> as we >>>>>>>>> >>> do not >>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, >>>>>>>>> which >>>>>>>>> includes the >>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>>>>> wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer >>>>>>>>> :-) >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>> >>>>>>>>> >>> >>>>>>>> >>: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn >>>>>>>>> wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>> Suenaga wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>> wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>>> Suenaga >>>>>>>>> wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>> >>> >>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>>>>>>>> >>> >>>>>>>> >>>: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>>>>>> Suenaga wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>>>>>>>> >>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>>>>>>>> >>> >>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>> >>>>>>>>> >>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>>>>>>>> >>> >>>>>>>> >>>>: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>>>>> set it: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = >>>>>>>>> new >>>>>>>>> >>> JavaThread(); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>> >>> set_active_handles >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> >>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>>>>> something? >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>>>>> to thread >>>>>>>>> >>> name in >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>>>>>> setName(). >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java >>>>>>>>> app, >>>>>>>>> native >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>>>>>>> already >>>>>>>>> >>> starte >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>> setting >>>>>>>>> thrrad name >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>>>>> something like >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>> Tue >>>>>>>>> >>> Mar 29 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>> Wed >>>>>>>>> >>> Mar 30 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>> create_initial_thread(Handle >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>> initial_thread_name = >>>>>>>>> >>> "main"; >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> >>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>>> (THREAD, k); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>> >>> thread); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>>>>>> thread_oop, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev >>>>>>>>> later. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>>> itself >>>>>>>>> 'java' and >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>>>>> process >>>>>>>>> (and >>>>>>>>> >>> thus >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>>>>> process >>>>>>>>> is not >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>>>>> with >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>>>>>> >>> JavaThread. So I >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>>>>>>> thread. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>>> anyhow, since >>>>>>>>> >>> we want >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread >>>>>>>>> name >>>>>>>>> might >>>>>>>>> >>> have >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>> /proc. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' >>>>>>>>> | head -4 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>>>>> like >>>>>>>>> 'Java Main >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>>>>> Java >>>>>>>>> >>> launcher - e.g. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, >>>>>>>>> etc. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>>>>> thread >>>>>>>>> name, >>>>>>>>> >>> I think >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>> Yasumasa >>>>>>>>> >>> Suenaga wrote: >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>>>>>>> thread >>>>>>>>> >>> name via >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>> does not >>>>>>>>> have it. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>>>>>>> name, >>>>>>>>> and main >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>> thread >>>>>>>>> should have >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could >>>>>>>>> you >>>>>>>>> review it? >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>> >>> > >>>>>>>>> >>> >>>>>>>>> >>>>>> >>>>> From stuart.marks at oracle.com Tue Apr 26 06:06:47 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Mon, 25 Apr 2016 23:06:47 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> Message-ID: On 4/25/16 5:46 PM, Vitaly Davidovich wrote: > We've introduced Optional to avoid this. The problem is that the obvious > thing to do is to get() the value out of the Optional, but this buys us > right back into the what-if-the-value-is-missing case that we had with nulls. > > Why is this the "obvious" thing? Because a few stackoverflow threads went like > that? Well, the Stack Overflow exchange was a caricature. But without looking too hard, I found this code: [2] return stringList.stream().filter(...).findFirst().get() != null; [2] http://stackoverflow.com/q/36346409/1441122 The person, presumably new to Java 8, was able to determine that findFirst() returned an Optional instead of the desired value, and was able to figure out enough to call get(), and even thought enough about the possibly-absent case to check it against null. But the person had to ask on Stack Overflow about how to solve the problem. Now I obviously don't know the exact thought process that went on, but get() has among the shortest of name of the Optional methods, and has no arguments, so it seems like it ought to be called more more frequently compared to more specialized methods like ifPresentOrElse() or orElseThrow(). There are other items on Stack Overflow such as these: [3] [4]. But these probably aren't what you're looking for. :-) [3] http://stackoverflow.com/a/26328555/1441122 [4] http://stackoverflow.com/a/23464794/1441122 > It's not clear it returns an Optional - it could be returning some other type > that happens to have a getWhenPresent. What would be clear it's an Optional is > to have a local of that type and assign find(pk) to it. Of course there's always a possibility that there's some other API that has getWhenPresent() on it. There isn't one in the JDK, and I've been unable to find one elsewhere. So "getWhenPresent" should be different enough to trigger a different thought pattern, as opposed to a plain "get" which fades into the background. The Optional API was designed to be chained, so you don't want to pull it into a local variable. > Descriptive names are good, but like Jon, I'm not buying this change. Is it > really wrong to tell people to read the javadoc? And is that worth the > deprecation churn? It's going to be needlessly verbose (esp in existing code > that already checked isPresent) for no strong benefit. If someone is mindlessly > having their IDE write code for them, this isn't going to prevent poor code. > For code review purposes, if it's important to call out that something is > Optional then use the type somewhere explicitly. Personally I'm generally skeptical of simple name changes, but after having gone through a bunch of examples of the use of get(), my skepticism melted away. It really does seem to be misused a significant fraction of the time, possibly even a majority of the time. Beginners and Java 8 learners will probably fall into the trap of forgetting to check. But JDK programmers, who are decidedly not beginners, are writing code that uses get() unnecessarily: ======================================== http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java.sdiff.html 206 if (source.isPresent()) { 207 executor.runTask(source.get(), deque); 208 } could be rewritten as source.ifPresent(archive -> executor.runTask(archive, deque)); ======================================== http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java.sdiff.html 476 Optional req = options.requires.stream() 477 .filter(mn -> !modules.containsKey(mn)) 478 .findFirst(); 479 if (req.isPresent()) { 480 throw new BadArgs("err.module.not.found", req.get()); 481 } could be rewritten as options.requires.stream() .filter(mn -> !modules.containsKey(mn)) .findFirst() .ifPresent(s -> throw new BadArgs("err.module.not.found", s)); ======================================== http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java.sdiff.html 1203 String hist = replayableHistory 1204 .subList(first + 1, replayableHistory.size()) 1205 .stream() 1206 .reduce( (a, b) -> a + RECORD_SEPARATOR + b) 1207 .get(); could be rewritten as String hist = String.join(RECORD_SEPARATOR, replayableHistory.subList(first + 1, replayableHistory.size())); (It's also not clear to me that the sublist is guaranteed to be nonempty, so the first snippet might fail in get().) ======================================== http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.base/share/classes/java/lang/module/Resolver.java.sdiff.html 100 if (mref.location().isPresent()) 101 trace(" (%s)", mref.location().get()); could be rewritten as mref.location().ifPresent(loc -> trace(" (%s)", loc); ======================================== http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.base/share/classes/java/lang/reflect/Layer.java.sdiff.html 364 Optional oparent = cf.parent(); 365 if (!oparent.isPresent() || oparent.get() != this.configuration()) { 366 throw new IllegalArgumentException( 367 "Parent of configuration != configuration of this Layer"); could be rewritten as cf.parent() .filter(cfg -> cfg == this.configuration()) .orElseThrow(() -> throw new IllegalArgumentException( "Parent of configuration != configuration of this Layer")); ======================================== If you go to grepcode.com, find the source for Optional.get() -- I used 8u40-b25 -- and then click the little arrow next to get(), you can find a bunch of uses of Optional.get(). A startlingly large fraction of them can be simplified in a similar manner to the JDK examples I showed above, bypassing the need to call get(). (I did a quick check of the first ten examples, and I think about seven could be improved, depending on how you count.) It really does look to me like get() is a bad API. It's not people "mindlessly" having their IDE write code. The problem is that get() is deceptively attractive. Even people remember to check it, they put the checking around the get(), instead of looking at Optional's other methods. This is what results in the needlessly verbose code. A minority of the cases are justified in using get(). If this is renamed to getWhenPresent(), it becomes slightly more verbose, but it also specifically states that the programmer is making an assertion about the presence of a value -- a worthwhile improvement. Is it worth the churn? Well, the problem is only going to get worse. I believe that if we don't deprecate get() now, a few years down the road, the problem will be so bad, we'll say "I wish we had deprecated it back in JDK 9 when we were talking about it then." Just like right now we're saying, "I wish we had fixed it before JDK 8 shipped." s'marks From ali.ebrahimi1781 at gmail.com Tue Apr 26 06:26:43 2016 From: ali.ebrahimi1781 at gmail.com (Ali Ebrahimi) Date: Tue, 26 Apr 2016 10:56:43 +0430 Subject: Fwd: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <571EABBE.8040606@oracle.com> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA7ED.4080609@oracle.com> <0cdc0050-8508-2be5-8e25-35fbad98d024@oracle.com> <571EABBE.8040606@oracle.com> Message-ID: Hi, I agree with Jon, Vitaly, I think the name Optional completely describe its intents and semantics so I don't think we need more descriptive method name here. Optional === may be have value So Optional.get === may be return value Therefore, I think this all effort doesn't add any (or enough) value, So isn't worth of it (from resource POV). Done side: The all current source codes that uses this method when compiling with java9 get dozen of warnings. On Tue, Apr 26, 2016 at 4:13 AM, Jonathan Gibbons < jonathan.gibbons at oracle.com> wrote: > OK. > > The best I can say is that I disagree with the underlying change (to > deprecate Optional.get) but that if the API change is generally agreed to, > then I reluctantly agree with the edit here. > > The bug needs a noreg-label. > > -- jon > > > > > On 04/25/2016 04:37 PM, Stuart Marks wrote: > >> >> >> On 4/25/16 4:27 PM, Jonathan Gibbons wrote: >> >>> Enter.java: >>> It's pretty ugly that the recommended usage is to have to add a >>> SuppressWarnings >>> for a reasonable and valid use of Optional.get. >>> >>> Are you sure this is the API you want? >>> >> >> Ah, I had neglected to explain this one, sorry. >> >> In the majority cases, uses of get() can be refactored away to use one of >> the other Optional methods. >> >> In just about all the remaining cases, the code should use the >> replacement method getWhenPresent(), which has the same semantics as the >> current get() call. This is called for if lambdas should be avoided because >> of startup performance, or because of checked exceptions, or if it's >> provable from context that a value is always present. >> >> The case of Enter.java is a special one; it gets compiled with the boot >> libraries (JDK 8) and getWhenPresent() doesn't exist in those. It doesn't >> generate a warning though. But as you explained to me the other day, this >> code is later recompiled against the JDK 9 libraries, and in that case it >> does generate the warning. >> >> So for this case I think calling get() with @SuppressWarnings is the way >> to proceed. I opted to extract a local variable and put @SW on it, in order >> to minimize its scope, but if you prefer an alternative I'd be happy to >> change it. >> >> s'marks >> > > -- Best Regards, Ali Ebrahimi From felix.yang at oracle.com Tue Apr 26 08:53:33 2016 From: felix.yang at oracle.com (Felix Yang) Date: Tue, 26 Apr 2016 16:53:33 +0800 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests Message-ID: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> Hi all, please review the fix to explicitly declare module dependencies for rmi tests. Bug: https://bugs.openjdk.java.net/browse/JDK-8154733 Webrev: http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.00/ Thanks, Felix From forax at univ-mlv.fr Tue Apr 26 09:13:26 2016 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Tue, 26 Apr 2016 09:13:26 +0000 Subject: Fwd: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA7ED.4080609@oracle.com> <0cdc0050-8508-2be5-8e25-35fbad98d024@oracle.com> <571EABBE.8040606@oracle.com> Message-ID: I agree with Jon, Vitaly and Ali, get is good candidate to @Bikeshed not for @Deprecated. R?mi Le 26 avril 2016 08:26:43 CEST, Ali Ebrahimi a ?crit : >Hi, >I agree with Jon, Vitaly, >I think the name Optional completely describe its intents and semantics >so >I don't think we need more descriptive method name here. >Optional === may be have value >So >Optional.get === may be return value > >Therefore, I think this all effort doesn't add any (or enough) value, >So >isn't worth of it (from resource POV). >Done side: The all current source codes that uses this method when >compiling with java9 get dozen of warnings. > >On Tue, Apr 26, 2016 at 4:13 AM, Jonathan Gibbons < >jonathan.gibbons at oracle.com> wrote: > >> OK. >> >> The best I can say is that I disagree with the underlying change (to >> deprecate Optional.get) but that if the API change is generally >agreed to, >> then I reluctantly agree with the edit here. >> >> The bug needs a noreg-label. >> >> -- jon >> >> >> >> >> On 04/25/2016 04:37 PM, Stuart Marks wrote: >> >>> >>> >>> On 4/25/16 4:27 PM, Jonathan Gibbons wrote: >>> >>>> Enter.java: >>>> It's pretty ugly that the recommended usage is to have to add a >>>> SuppressWarnings >>>> for a reasonable and valid use of Optional.get. >>>> >>>> Are you sure this is the API you want? >>>> >>> >>> Ah, I had neglected to explain this one, sorry. >>> >>> In the majority cases, uses of get() can be refactored away to use >one of >>> the other Optional methods. >>> >>> In just about all the remaining cases, the code should use the >>> replacement method getWhenPresent(), which has the same semantics as >the >>> current get() call. This is called for if lambdas should be avoided >because >>> of startup performance, or because of checked exceptions, or if it's >>> provable from context that a value is always present. >>> >>> The case of Enter.java is a special one; it gets compiled with the >boot >>> libraries (JDK 8) and getWhenPresent() doesn't exist in those. It >doesn't >>> generate a warning though. But as you explained to me the other day, >this >>> code is later recompiled against the JDK 9 libraries, and in that >case it >>> does generate the warning. >>> >>> So for this case I think calling get() with @SuppressWarnings is the >way >>> to proceed. I opted to extract a local variable and put @SW on it, >in order >>> to minimize its scope, but if you prefer an alternative I'd be happy >to >>> change it. >>> >>> s'marks >>> >> >> From amy.lu at oracle.com Tue Apr 26 09:21:17 2016 From: amy.lu at oracle.com (Amy Lu) Date: Tue, 26 Apr 2016 17:21:17 +0800 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests In-Reply-To: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> References: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> Message-ID: <571F330D.6060307@oracle.com> Hi, Felix With modules declares in TEST.propertiesshould avoid have to modify test file one by one... Maybe I missed things please correct me. Example: $ cat jdk/test/java/rmi/TEST.properties modules = java.rmi Thanks, Amy On 4/26/16 4:53 PM, Felix Yang wrote: > Hi all, > > please review the fix to explicitly declare module dependencies > for rmi tests. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8154733 > Webrev: http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.00/ > > Thanks, > Felix From yasuenag at gmail.com Tue Apr 26 09:22:52 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Tue, 26 Apr 2016 18:22:52 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571EF995.3000109@oracle.com> References: <56F3F90D.9010408@gmail.com> <570EE58F.4060809@oracle.com> <570F13E3.6000802@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> Message-ID: Hi David, > I thought about being able to save/restore the original pending exception but could not see a simple way to restore it - ie just by poking it back into the thread's pending exception field. The problem with using env->Throw is that it acts like the initial throwing of the exception and will have a number of side-effects that then get doubled up: > - logging statements (UL and Event logging) > - OOM counting Thanks, I understood. >>> so note that we are potentially calling DetachCurrentThread with an >>> exception pending - which is prohibited by JNI**, but which we >>> actually rely on for desired operation as DetachCurrentThread calls >>> thread->exit() which performs uncaught exception handling (ie it >>> prints the exception message and stacktrace) and then clears the >>> exception! (Hence DestroyJavaVM is not called with any pending >>> exceptions.) I think we can call uncaught exception handler before calling DestroyJavaVM(). I added it in new webrev for jdk: http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ DispatchUncaughtException() in java.c emulates uncaught exception handler call in JavaThread::exit(). I think this patch can provide the solution for our issue. Could you check it? Thanks, Yasumasa On 2016/04/26 14:16, David Holmes wrote: > On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >> Hi David, Kumar, >> >> I think that we should evacuate original exception before DestroyJavaVM >> thread name is set. >> >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >> >> I added it to LEAVE macro in new webrev. > > BTW: in the LEAVE macro, stylistically all the code should be in the do { } while(false); loop. I overlooked that initially. > >> I tested it with following code. It works fine. >> >> ------------- >> public void main(String[] args){ >> throw new RuntimeException("test"); >> } >> ------------- >> >> What do you think about it? > > I thought about being able to save/restore the original pending exception but could not see a simple way to restore it - ie just by poking it back into the thread's pending exception field. The problem with using env->Throw is that it acts like the initial throwing of the exception and will have a number of side-effects that then get doubled up: > - logging statements (UL and Event logging) > - OOM counting > > I'm not sure whether that is acceptable or not > > That aside you should check if orig_throwable is non-null before clearing to avoid an unnecessary JNI call. > > Also "Resume original exception" -> "Restore any original exception" > > Thanks, > David > ----- > >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/26 11:16, David Holmes wrote: >>> Hi Yasumasa, Kumar, >>> >>> Turns out this change breaks the behaviour of the launcher in the case >>> that main() completes by throwing an exception. >>> >>> What we have in the launcher is: >>> >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>> LEAVE(); >>> >>> where LEAVE would have expanded to: >>> >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>> ret = 1; \ >>> } \ >>> if (JNI_TRUE) { \ >>> (*vm)->DestroyJavaVM(vm); \ >>> return ret; \ >>> } \ >>> >>> so note that we are potentially calling DetachCurrentThread with an >>> exception pending - which is prohibited by JNI**, but which we >>> actually rely on for desired operation as DetachCurrentThread calls >>> thread->exit() which performs uncaught exception handling (ie it >>> prints the exception message and stacktrace) and then clears the >>> exception! (Hence DestroyJavaVM is not called with any pending >>> exceptions.) >>> >>> **JNI spec needs to be modified here. >>> >>> With the current change we have now inserted the following at the >>> start of LEAVE: >>> >>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>> if ((*env)->ExceptionOccurred(env)) { \ >>> (*env)->ExceptionClear(env); \ >>> } \ >>> >>> this has two unintended consequences: >>> >>> 1. SetNativeThreadName itself calls a number of JNI methods, with the >>> exception pending - which is not permitted. So straight away where we >>> have: >>> >>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>> >>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make calls >>> using the VM's CHECK_NULL macro - which checks for a pending exception >>> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >>> reports a JNI error: >>> >>> Error: A JNI error has occurred, please check your installation and >>> try again >>> >>> >>> 2. There is no longer an exception from main() for DetachCurrentThread >>> to report, so we exit with a return code of 1 as required, but don't >>> report the exception message/stacktrace. >>> >>> I don't see a reasonable solution for this other than abandoning the >>> attempt to change the name from "main" to "DestroyJavaVM" - which if >>> we can't do, I question the utility of setting the name in the first >>> place (while it might be useful in some circumstances [when main() is >>> running] it will cause confusion in others [when main() has exited]). >>> >>> David >>> ----- >>> >>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>> Looks good to me. >>>> >>>> I'll sponsor this "tomorrow". >>>> >>>> Thanks, >>>> David >>>> >>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>> Hi Kumar, >>>>> >>>>> Thank you for your comment! >>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>> >>>>>> Also a couple of minor suggestions: >>>>>> >>>>>> - * Set native thread name as possible. >>>>>> + * Set native thread name if possible. >>>>>> >>>>>> >>>>>> + /* >>>>>> - * We can clear pending exception because exception at this >>>>>> point >>>>>> - * is not critical. >>>>>> + */ >>>>>> >>>>>> + /* >>>>>> + * Clear non critical pending exceptions at this point. >>>>>> + */ >>>>>> >>>>>> Thanks >>>>>> Kumar >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> This is in the wrong place: >>>>>>> >>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>> 1716 /* >>>>>>> 1717 * We can clear pending exception because exception at >>>>>>> this point >>>>>>> 1718 * is not critical. >>>>>>> 1719 */ >>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>> 1721 } >>>>>>> >>>>>>> This above needs to be after >>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>> 392 >>>>>>> >>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>> but have also encountered an exception. In which case >>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>> if nothing has happened, because NULL_CHECK simply checks for NULL >>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>> the VM with exceptions. >>>>>>> >>>>>>> Kumar >>>>>>> >>>>>>> >>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>> Hi David, >>>>>>>> >>>>>>>>> I don't think we need to report the exception, but can just ignore >>>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>> >>>>>>>> I've fixed it in new webrev: >>>>>>>> >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi all, >>>>>>>>>> >>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>> Could you review again? >>>>>>>>>> >>>>>>>>>> > - hotspot: >>>>>>>>>> > >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>> >>>>>>>>> >>>>>>>>> Looks fine. >>>>>>>>> >>>>>>>>>> > >>>>>>>>>> > - jdk: >>>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>> >>>>>>>>> As per private email (but repeated here on the record) in java.c: >>>>>>>>> >>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>> 1717 } >>>>>>>>> >>>>>>>>> I don't think we need to report the exception, but can just ignore >>>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> David >>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>> >: >>>>>>>>>> > >>>>>>>>>> > Hi David, >>>>>>>>>> > >>>>>>>>>> > Thank you for your comment. >>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>> > >>>>>>>>>> > - hotspot: >>>>>>>>>> > >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>> >>>>>>>>>> > >>>>>>>>>> > - jdk: >>>>>>>>>> > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>> process, I >>>>>>>>>> would have done it immediately after here: >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>>>> before >>>>>>>>>> > main method call. >>>>>>>>>> > However, main thread is already started, so I moved it as you >>>>>>>>>> suggested. >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>> have to >>>>>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>>>>> calls >>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>>> char* ! >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > SoI proposed to export new JVM function to set native thread >>>>>>>>>> name with >>>>>>>>>> > const char *. >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > Thanks, >>>>>>>>>> > >>>>>>>>>> > Yasumasa >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>> >> >>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>> >> >>>>>>>>>> >> Thanks for persevering with this to get it into the current >>>>>>>>>> form. >>>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>>> >> >>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>> >>> >>>>>>>>>> >>> Hi Gerard, >>>>>>>>>> >>> >>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>> >>>>>>>>>> >>> >>>>>>>>> >>: >>>>>>>>>> >>> > >>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>> >>> > >>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>> >>> > >>>>>>>>>> >>> > ======== >>>>>>>>>> >>> > File: java.c >>>>>>>>>> >>> > >>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>>> NULL_CHECK, >>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>> >>> >>>>>>>>>> >>> It is not critical if we encounter error at JNI function call >>>>>>>>>> because >>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>> process. >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >> I agree we do not need to abort if an exception occurs (and in >>>>>>>>>> fact >>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>> but we >>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>> futher JNI >>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>> extensively >>>>>>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>>>>>> is all >>>>>>>>>> wrong! More on this code below ... >>>>>>>>>> >> >>>>>>>>>> >> Other comments: >>>>>>>>>> >> >>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>> >> >>>>>>>>>> >> Please add a comment to the method now that you removed the >>>>>>>>>> internal >>>>>>>>>> comment: >>>>>>>>>> >> >>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>> specifically >>>>>>>>>> >> // requested JNI-attached threads can also have their native >>>>>>>>>> name set; >>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>>>>>> interfere >>>>>>>>>> >> // with the application that created them. >>>>>>>>>> >> >>>>>>>>>> >> --- >>>>>>>>>> >> >>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>> >> >>>>>>>>>> >> Please add the following comments: >>>>>>>>>> >> >>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>> >> >>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>> permitted) to >>>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>>> allowAttachedThread); >>>>>>>>>> >> >>>>>>>>>> >> --- >>>>>>>>>> >> >>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>> >> >>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>> >> >>>>>>>>>> >> I was going to suggest this be set later, but realized we have >>>>>>>>>> to be >>>>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>>>> >> >>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>> >> >>>>>>>>>> >> The comment is redundant given the name of the method. That >>>>>>>>>> aside >>>>>>>>>> I'm not sure why you do this so late in the process, I would have >>>>>>>>>> done >>>>>>>>>> it immediately after here: >>>>>>>>>> >> >>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>> >> 388 exit(1); >>>>>>>>>> >> 389 } >>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >> + /** >>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>> >> + */ >>>>>>>>>> >> >>>>>>>>>> >> Other than the as->if change I'm unclear where the "possible" >>>>>>>>>> bit >>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>> >> >>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>> "java/lang/Thread")); >>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>> cls, >>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = (*env)->GetMethodID(env, >>>>>>>>>> cls, >>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>>> name)); >>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>> setNativeNameID, >>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>> >> >>>>>>>>>> >> As above NULL_CHECK is fine here, but we should check for and >>>>>>>>>> clear >>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>> >> >>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>> have to >>>>>>>>>> go from char* to java.lang.String to call setNativeName which then >>>>>>>>>> calls >>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>>> char* ! >>>>>>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>>>>>> is an >>>>>>>>>> issue we can revisit this. >>>>>>>>>> >> >>>>>>>>>> >> Thanks, >>>>>>>>>> >> David >>>>>>>>>> >> ----- >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>>>>>> native >>>>>>>>>> thread >>>>>>>>>> >>> name if possible.? not "Set native thread name as possible.?? >>>>>>>>>> >>> >>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>> >>> >>>>>>>>>> >>> Thanks, >>>>>>>>>> >>> >>>>>>>>>> >>> Yasumasa >>>>>>>>>> >>> >>>>>>>>>> >>> > cheers >>>>>>>>>> >>> > >>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>> >>>>>>>>>> >>> >> >>>>>>>>>> wrote: >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > Hi David, >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > - hotspot: >>>>>>>>>> >>> > > >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>> >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > - jdk: >>>>>>>>>> >>> > > >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > >>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>> setName so I'm >>>>>>>>>> >>> not sure what you were thinking here. To take advantage of an >>>>>>>>>> arg >>>>>>>>>> taking >>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it directly as >>>>>>>>>> no Java >>>>>>>>>> >>> code will call it . ??? >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>> JNI-attached >>>>>>>>>> thread. >>>>>>>>>> >>> > > This change can set native thread name if main thread >>>>>>>>>> changes to >>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > Thanks, >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > Yasumasa >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > >>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>> could be >>>>>>>>>> considered a >>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>> thread >>>>>>>>>> main, even >>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>> first place. >>>>>>>>>> >>> :( Such >>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> I understood. >>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at Oracle.) >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>>>>>> sponsor for >>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>> proposed change >>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>> restore the >>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >>> I want to continue to discuss about it on JDK-8154331 >>>>>>>>>> [1]. >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the supported >>>>>>>>>> JNI >>>>>>>>>> >>> interface (as >>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>> interface that >>>>>>>>>> >>> exists for >>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we add new >>>>>>>>>> method in >>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>> >>> > >>> >>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>> >>> > >>> --- >>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>> >>> > >>> +++ >>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>> >>> > >>> else >>>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" + loc >>>>>>>>>> + ")"; >>>>>>>>>> >>> > >>> } >>>>>>>>>> >>> > >>> + >>>>>>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>> >>> > >>> + } >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >> You could also make that call via JNI directly, so not >>>>>>>>>> sure the >>>>>>>>>> >>> helper adds much here. But it won't work unless you change >>>>>>>>>> the >>>>>>>>>> semantics >>>>>>>>>> >>> of setName so I'm not sure what you were thinking here. To >>>>>>>>>> take >>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>>>>>> need to >>>>>>>>>> call >>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >> David >>>>>>>>>> >>> > >> ----- >>>>>>>>>> >>> > >> >>>>>>>>>> >>> > >>> } >>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c Wed >>>>>>>>>> Apr 13 >>>>>>>>>> 14:19:30 >>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c Sat >>>>>>>>>> Apr 16 >>>>>>>>>> 11:25:53 >>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>> doXUsage); >>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>> *optString); >>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>> *optString); >>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>>>> *name); >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>> >>> > >>> */ >>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>> >>> > >>> do { \ >>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) >>>>>>>>>> { \ >>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>> argc); >>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>> >>> > >>> + >>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>>>> mainArgs); >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>> >>> > >>> joptString); >>>>>>>>>> >>> > >>> } >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> +/** >>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>> >>> > >>> + */ >>>>>>>>>> >>> > >>> +static void >>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>> >>> > >>> +{ >>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>>> name)); >>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>> setNativeThreadNameID, >>>>>>>>>> >>> > >>> nameString); >>>>>>>>>> >>> > >>> +} >>>>>>>>>> >>> > >>> + >>>>>>>>>> >>> > >>> /* >>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>> >>> > >>> */ >>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> So I want to add new arg to JVM_SetNativeThreadName(). >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>>>>>> interface and so >>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> [1] >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> >>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> >>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>>> for main >>>>>>>>>> >>> thread and >>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>>>>> itself as >>>>>>>>>> >>> setName >>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>> thread. >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>> could be >>>>>>>>>> considered a >>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>> thread >>>>>>>>>> main, even >>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>> first place. >>>>>>>>>> >>> :( Such >>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>> JDK-7098194, >>>>>>>>>> and it is >>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in 7u2. >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>> >>> > >>>>> only. >>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>>> method. >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I think we >>>>>>>>>> can >>>>>>>>>> add one >>>>>>>>>> >>> more >>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>>>> from Java >>>>>>>>>> >>> launcher. >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>>>> really at >>>>>>>>>> >>> issue. Yes >>>>>>>>>> >>> > >>>> we would add another arg to the JVM function to allow >>>>>>>>>> it to >>>>>>>>>> apply to >>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>>>> reflect that >>>>>>>>>> >>> not just >>>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>>> exported JVM >>>>>>>>>> >>> interface >>>>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>>>> launcher to >>>>>>>>>> >>> use the >>>>>>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>>>>>> not the >>>>>>>>>> internal >>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>>>> communicate >>>>>>>>>> >>> with the >>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>> David >>>>>>>>>> >>> > >>>> ----- >>>>>>>>>> >>> > >>>> >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> >>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not tagged as >>>>>>>>>> being a >>>>>>>>>> >>> JNI-attached >>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>>> for main >>>>>>>>>> >>> thread and >>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> Though that will introduce a change in behaviour by >>>>>>>>>> itself as >>>>>>>>>> >>> setName >>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>> thread. >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu Apr 14 >>>>>>>>>> 13:31:11 >>>>>>>>>> >>> 2016 +0200 >>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri Apr 15 >>>>>>>>>> 17:50:10 >>>>>>>>>> >>> 2016 +0900 >>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new JavaThread(true); >>>>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>>>>>> is complete >>>>>>>>>> >>> - nop if >>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>> JavaThread >>>>>>>>>> constructor. >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>>>> tracing >>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then it is >>>>>>>>>> free >>>>>>>>>> to do so, >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot change >>>>>>>>>> native >>>>>>>>>> >>> thread name >>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>> >>> > >>>>>>> However, I think that it should be changed if Java >>>>>>>>>> developer >>>>>>>>>> >>> calls >>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>>> name at >>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>> SetNativeThreadName() as >>>>>>>>>> below. >>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> The decision to not change the name of JNI-attached >>>>>>>>>> threads was a >>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>>>>>> with the OSX >>>>>>>>>> >>> port and >>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback with this >>>>>>>>>> feature was to >>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>>>>>> been set by >>>>>>>>>> >>> the host >>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will just >>>>>>>>>> have an >>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>>>>>> does my >>>>>>>>>> >>> native thread >>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>> discussions on >>>>>>>>>> this, the >>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>>>> thread only, >>>>>>>>>> >>> non-JNI >>>>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>>>> were supposed >>>>>>>>>> >>> to be >>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>>>>>> can see >>>>>>>>>> that >>>>>>>>>> >>> never >>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> My position on this remains that if it is desirable >>>>>>>>>> for >>>>>>>>>> the main >>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>>>>>> names >>>>>>>>>> then the >>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>> available >>>>>>>>>> platform >>>>>>>>>> >>> APIs. >>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as evidenced by >>>>>>>>>> the VM >>>>>>>>>> >>> code for >>>>>>>>>> >>> > >>>>>> this - due to the need to verify API availability. >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>> Thread.setName would >>>>>>>>>> >>> have to go >>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>>>>>> the launcher >>>>>>>>>> >>> would >>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>> David >>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>> >>> > >>>>>> >>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu Apr 14 >>>>>>>>>> 13:31:11 >>>>>>>>>> >>> 2016 +0200 >>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri Apr 15 >>>>>>>>>> 17:50:10 >>>>>>>>>> >>> 2016 +0900 >>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the current >>>>>>>>>> thread, >>>>>>>>>> >>> doesn't >>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>>> thread to avoid >>>>>>>>>> >>> stepping >>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> >>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> >>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>> this. I >>>>>>>>>> don't like >>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>> initializing VM >>>>>>>>>> (before >>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>> AttachCurrentThread(). >>>>>>>>>> So we >>>>>>>>>> >>> can't >>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier >>>>>>>>>> this >>>>>>>>>> morning. >>>>>>>>>> >>> Which, >>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic premise >>>>>>>>>> here that >>>>>>>>>> >>> we don't >>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>>>>>> The fact >>>>>>>>>> >>> that the >>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>> JNI-attached >>>>>>>>>> thread seems >>>>>>>>>> >>> > >>>>>>>> accidental to me - so JVM_SetNativeThreadName is >>>>>>>>>> only >>>>>>>>>> working by >>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>>>> used for the >>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>>>> inconsistently >>>>>>>>>> >>> named at >>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher has >>>>>>>>>> to be >>>>>>>>>> >>> treated like >>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>>>>>> wants to >>>>>>>>>> name its >>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>>>>>> would not be >>>>>>>>>> >>> exporting >>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>>>> have to >>>>>>>>>> use the OS >>>>>>>>>> >>> > >>>>>>>> specific API's for that on a platform-by-platform >>>>>>>>>> basis. >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar but >>>>>>>>>> perform >>>>>>>>>> >>> different >>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>>>>>> thread, the >>>>>>>>>> >>> second >>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a comment >>>>>>>>>> somewhere >>>>>>>>>> >>> about >>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>>> casts to >>>>>>>>>> (void*) >>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>> >>> used at >>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible keep >>>>>>>>>> the cast >>>>>>>>>> >>> on the >>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>> haven't had >>>>>>>>>> time to >>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>> JNI-attached >>>>>>>>>> >>> thread >>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>>>>> suggestion >>>>>>>>>> >>> should >>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>>>>> treatment of >>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, >>>>>>>>>> and I >>>>>>>>>> confirmed >>>>>>>>>> >>> native >>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) throws >>>>>>>>>> Exception{ >>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>> this. I >>>>>>>>>> don't like >>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>>>> comment. >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>>> wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>>>> wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set native >>>>>>>>>> thread >>>>>>>>>> >>> name, and JLI >>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>>> team so >>>>>>>>>> >>> core-libs will >>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>>>> Kumar) - >>>>>>>>>> now cc'd. >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>> upcall to >>>>>>>>>> >>> Thread.setName >>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting JVM_SetNativeThreadName. No >>>>>>>>>> hotspot changes >>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>>> Thread#setName() in >>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not alive, >>>>>>>>>> which is >>>>>>>>>> >>> why the >>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>> attached thread. >>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>> haven't had >>>>>>>>>> time to >>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>> JNI-attached >>>>>>>>>> >>> thread >>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't then my >>>>>>>>>> suggestion >>>>>>>>>> >>> should >>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency in our >>>>>>>>>> treatment of >>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>> this. I >>>>>>>>>> don't like >>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>>> function to set >>>>>>>>>> >>> native >>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>>>>>> well ... >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>>>>>> have >>>>>>>>>> been on >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>>>>>> correct >>>>>>>>>> as we >>>>>>>>>> >>> do not >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, >>>>>>>>>> which >>>>>>>>>> includes the >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>>>>>> wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more reviewer >>>>>>>>>> :-) >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>> >>: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn >>>>>>>>>> wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>>> Suenaga wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>>> wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>>>> Suenaga >>>>>>>>>> wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>> >>> >>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>>> >>> >>>>>>>>> >>>: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, Yasumasa >>>>>>>>>> Suenaga wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>>> >>> >>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>>> >>> >>>>>>>>> >>>>: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>>>>>> set it: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* main_thread = >>>>>>>>>> new >>>>>>>>>> >>> JavaThread(); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>> >>> set_active_handles >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>>>>>> something? >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>>>>>> to thread >>>>>>>>>> >>> name in >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in Thread or >>>>>>>>>> setName(). >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in Java >>>>>>>>>> app, >>>>>>>>>> native >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main thread is >>>>>>>>>> already >>>>>>>>>> >>> starte >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is set in >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>> setting >>>>>>>>>> thrrad name >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>>>>>> something like >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>> Tue >>>>>>>>>> >>> Mar 29 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>> Wed >>>>>>>>>> >>> Mar 30 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>> create_initial_thread(Handle >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>> initial_thread_name = >>>>>>>>>> >>> "main"; >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>>>> (THREAD, k); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>> >>> thread); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaCalls::call_special(&result, >>>>>>>>>> thread_oop, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev >>>>>>>>>> later. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>>>> itself >>>>>>>>>> 'java' and >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>>>>>> process >>>>>>>>>> (and >>>>>>>>>> >>> thus >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>>>>>> process >>>>>>>>>> is not >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>>>>>> with >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is for >>>>>>>>>> >>> JavaThread. So I >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native main >>>>>>>>>> thread. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>>>> anyhow, since >>>>>>>>>> >>> we want >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java thread >>>>>>>>>> name >>>>>>>>>> might >>>>>>>>>> >>> have >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>>> /proc. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid comm' >>>>>>>>>> | head -4 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>>>>>> like >>>>>>>>>> 'Java Main >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>>>>>> Java >>>>>>>>>> >>> launcher - e.g. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, >>>>>>>>>> etc. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>>>>>> thread >>>>>>>>>> name, >>>>>>>>>> >>> I think >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new webrev? >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>>> Yasumasa >>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will set >>>>>>>>>> thread >>>>>>>>>> >>> name via >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>> does not >>>>>>>>>> have it. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have native >>>>>>>>>> name, >>>>>>>>>> and main >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>>> thread >>>>>>>>>> should have >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. Could >>>>>>>>>> you >>>>>>>>>> review it? >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>> >>> > >>>>>>>>>> >>> >>>>>>>>>> >>>>>>> >>>>>> From david.holmes at oracle.com Tue Apr 26 09:35:55 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 26 Apr 2016 19:35:55 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: References: <56F3F90D.9010408@gmail.com> <570F8DDE.5000002@oracle.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> Message-ID: <571F367B.3010200@oracle.com> On 26/04/2016 7:22 PM, Yasumasa Suenaga wrote: > Hi David, > >> I thought about being able to save/restore the original pending >> exception but could not see a simple way to restore it - ie just by >> poking it back into the thread's pending exception field. The problem >> with using env->Throw is that it acts like the initial throwing of the >> exception and will have a number of side-effects that then get doubled >> up: >> - logging statements (UL and Event logging) >> - OOM counting > > Thanks, I understood. > >>>> so note that we are potentially calling DetachCurrentThread with an >>>> exception pending - which is prohibited by JNI**, but which we >>>> actually rely on for desired operation as DetachCurrentThread calls >>>> thread->exit() which performs uncaught exception handling (ie it >>>> prints the exception message and stacktrace) and then clears the >>>> exception! (Hence DestroyJavaVM is not called with any pending >>>> exceptions.) > > I think we can call uncaught exception handler before calling > DestroyJavaVM(). > I added it in new webrev for jdk: > > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ > http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ > > DispatchUncaughtException() in java.c emulates uncaught exception handler > call in JavaThread::exit(). > I think this patch can provide the solution for our issue. > > Could you check it? Sorry - this is getting far too disruptive. I do not support changing the way the main thread behaves upon completion, just because we want to set a native thread name. David ----- > > Thanks, > > Yasumasa > > > On 2016/04/26 14:16, David Holmes wrote: >> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >>> Hi David, Kumar, >>> >>> I think that we should evacuate original exception before DestroyJavaVM >>> thread name is set. >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >>> >>> I added it to LEAVE macro in new webrev. >> >> BTW: in the LEAVE macro, stylistically all the code should be in the >> do { } while(false); loop. I overlooked that initially. >> >>> I tested it with following code. It works fine. >>> >>> ------------- >>> public void main(String[] args){ >>> throw new RuntimeException("test"); >>> } >>> ------------- >>> >>> What do you think about it? >> >> I thought about being able to save/restore the original pending >> exception but could not see a simple way to restore it - ie just by >> poking it back into the thread's pending exception field. The problem >> with using env->Throw is that it acts like the initial throwing of the >> exception and will have a number of side-effects that then get doubled >> up: >> - logging statements (UL and Event logging) >> - OOM counting >> >> I'm not sure whether that is acceptable or not >> >> That aside you should check if orig_throwable is non-null before >> clearing to avoid an unnecessary JNI call. >> >> Also "Resume original exception" -> "Restore any original exception" >> >> Thanks, >> David >> ----- >> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/26 11:16, David Holmes wrote: >>>> Hi Yasumasa, Kumar, >>>> >>>> Turns out this change breaks the behaviour of the launcher in the case >>>> that main() completes by throwing an exception. >>>> >>>> What we have in the launcher is: >>>> >>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>>> LEAVE(); >>>> >>>> where LEAVE would have expanded to: >>>> >>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>> ret = 1; \ >>>> } \ >>>> if (JNI_TRUE) { \ >>>> (*vm)->DestroyJavaVM(vm); \ >>>> return ret; \ >>>> } \ >>>> >>>> so note that we are potentially calling DetachCurrentThread with an >>>> exception pending - which is prohibited by JNI**, but which we >>>> actually rely on for desired operation as DetachCurrentThread calls >>>> thread->exit() which performs uncaught exception handling (ie it >>>> prints the exception message and stacktrace) and then clears the >>>> exception! (Hence DestroyJavaVM is not called with any pending >>>> exceptions.) >>>> >>>> **JNI spec needs to be modified here. >>>> >>>> With the current change we have now inserted the following at the >>>> start of LEAVE: >>>> >>>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>>> if ((*env)->ExceptionOccurred(env)) { \ >>>> (*env)->ExceptionClear(env); \ >>>> } \ >>>> >>>> this has two unintended consequences: >>>> >>>> 1. SetNativeThreadName itself calls a number of JNI methods, with the >>>> exception pending - which is not permitted. So straight away where we >>>> have: >>>> >>>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>> >>>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make calls >>>> using the VM's CHECK_NULL macro - which checks for a pending exception >>>> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >>>> reports a JNI error: >>>> >>>> Error: A JNI error has occurred, please check your installation and >>>> try again >>>> >>>> >>>> 2. There is no longer an exception from main() for DetachCurrentThread >>>> to report, so we exit with a return code of 1 as required, but don't >>>> report the exception message/stacktrace. >>>> >>>> I don't see a reasonable solution for this other than abandoning the >>>> attempt to change the name from "main" to "DestroyJavaVM" - which if >>>> we can't do, I question the utility of setting the name in the first >>>> place (while it might be useful in some circumstances [when main() is >>>> running] it will cause confusion in others [when main() has exited]). >>>> >>>> David >>>> ----- >>>> >>>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>>> Looks good to me. >>>>> >>>>> I'll sponsor this "tomorrow". >>>>> >>>>> Thanks, >>>>> David >>>>> >>>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>>> Hi Kumar, >>>>>> >>>>>> Thank you for your comment! >>>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>>> >>>>>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>>> >>>>>>> Also a couple of minor suggestions: >>>>>>> >>>>>>> - * Set native thread name as possible. >>>>>>> + * Set native thread name if possible. >>>>>>> >>>>>>> >>>>>>> + /* >>>>>>> - * We can clear pending exception because exception at this >>>>>>> point >>>>>>> - * is not critical. >>>>>>> + */ >>>>>>> >>>>>>> + /* >>>>>>> + * Clear non critical pending exceptions at this point. >>>>>>> + */ >>>>>>> >>>>>>> Thanks >>>>>>> Kumar >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> This is in the wrong place: >>>>>>>> >>>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>> 1716 /* >>>>>>>> 1717 * We can clear pending exception because exception at >>>>>>>> this point >>>>>>>> 1718 * is not critical. >>>>>>>> 1719 */ >>>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>>> 1721 } >>>>>>>> >>>>>>>> This above needs to be after >>>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>>> 392 >>>>>>>> >>>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>>> but have also encountered an exception. In which case >>>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>>> if nothing has happened, because NULL_CHECK simply checks for NULL >>>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>>> the VM with exceptions. >>>>>>>> >>>>>>>> Kumar >>>>>>>> >>>>>>>> >>>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>>> Hi David, >>>>>>>>> >>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>> ignore >>>>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>>> >>>>>>>>> I've fixed it in new webrev: >>>>>>>>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi all, >>>>>>>>>>> >>>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>>> Could you review again? >>>>>>>>>>> >>>>>>>>>>> > - hotspot: >>>>>>>>>>> > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Looks fine. >>>>>>>>>> >>>>>>>>>>> > >>>>>>>>>>> > - jdk: >>>>>>>>>>> > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>> >>>>>>>>>> As per private email (but repeated here on the record) in java.c: >>>>>>>>>> >>>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>>> 1717 } >>>>>>>>>> >>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>> ignore >>>>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> David >>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>>> >: >>>>>>>>>>> > >>>>>>>>>>> > Hi David, >>>>>>>>>>> > >>>>>>>>>>> > Thank you for your comment. >>>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>>> > >>>>>>>>>>> > - hotspot: >>>>>>>>>>> > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> > >>>>>>>>>>> > - jdk: >>>>>>>>>>> > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>>> process, I >>>>>>>>>>> would have done it immediately after here: >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>>>>> before >>>>>>>>>>> > main method call. >>>>>>>>>>> > However, main thread is already started, so I moved it as you >>>>>>>>>>> suggested. >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>> have to >>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>> then >>>>>>>>>>> calls >>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>>>> char* ! >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > SoI proposed to export new JVM function to set native thread >>>>>>>>>>> name with >>>>>>>>>>> > const char *. >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > Thanks, >>>>>>>>>>> > >>>>>>>>>>> > Yasumasa >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>>> >> >>>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>>> >> >>>>>>>>>>> >> Thanks for persevering with this to get it into the current >>>>>>>>>>> form. >>>>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>>>> >> >>>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>> >>>>>>>>>>> >>> Hi Gerard, >>>>>>>>>>> >>> >>>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> >>: >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > ======== >>>>>>>>>>> >>> > File: java.c >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>>>> NULL_CHECK, >>>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>> >>> >>>>>>>>>>> >>> It is not critical if we encounter error at JNI function >>>>>>>>>>> call >>>>>>>>>>> because >>>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>>> process. >>>>>>>>>>> >> >>>>>>>>>>> >> >>>>>>>>>>> >> I agree we do not need to abort if an exception occurs >>>>>>>>>>> (and in >>>>>>>>>>> fact >>>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>>> but we >>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>> futher JNI >>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>> extensively >>>>>>>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>>>>>>> is all >>>>>>>>>>> wrong! More on this code below ... >>>>>>>>>>> >> >>>>>>>>>>> >> Other comments: >>>>>>>>>>> >> >>>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>>> >> >>>>>>>>>>> >> Please add a comment to the method now that you removed the >>>>>>>>>>> internal >>>>>>>>>>> comment: >>>>>>>>>>> >> >>>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>>> specifically >>>>>>>>>>> >> // requested JNI-attached threads can also have their native >>>>>>>>>>> name set; >>>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>>>>>>> interfere >>>>>>>>>>> >> // with the application that created them. >>>>>>>>>>> >> >>>>>>>>>>> >> --- >>>>>>>>>>> >> >>>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>>> >> >>>>>>>>>>> >> Please add the following comments: >>>>>>>>>>> >> >>>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>>> >> >>>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>>> permitted) to >>>>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>>>> allowAttachedThread); >>>>>>>>>>> >> >>>>>>>>>>> >> --- >>>>>>>>>>> >> >>>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>>> >> >>>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>> >> >>>>>>>>>>> >> I was going to suggest this be set later, but realized we >>>>>>>>>>> have >>>>>>>>>>> to be >>>>>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>>>>> >> >>>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>> >> >>>>>>>>>>> >> The comment is redundant given the name of the method. That >>>>>>>>>>> aside >>>>>>>>>>> I'm not sure why you do this so late in the process, I would >>>>>>>>>>> have >>>>>>>>>>> done >>>>>>>>>>> it immediately after here: >>>>>>>>>>> >> >>>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>>> >> 388 exit(1); >>>>>>>>>>> >> 389 } >>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>> >> >>>>>>>>>>> >> >>>>>>>>>>> >> + /** >>>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>>> >> + */ >>>>>>>>>>> >> >>>>>>>>>>> >> Other than the as->if change I'm unclear where the >>>>>>>>>>> "possible" >>>>>>>>>>> bit >>>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>>> >> >>>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>>> "java/lang/Thread")); >>>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>>> cls, >>>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>>>>>>> (*env)->GetMethodID(env, >>>>>>>>>>> cls, >>>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>>>> name)); >>>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>>> setNativeNameID, >>>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>>> >> >>>>>>>>>>> >> As above NULL_CHECK is fine here, but we should check for >>>>>>>>>>> and >>>>>>>>>>> clear >>>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>>> >> >>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>> have to >>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>> then >>>>>>>>>>> calls >>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>>>> char* ! >>>>>>>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>>>>>>> is an >>>>>>>>>>> issue we can revisit this. >>>>>>>>>>> >> >>>>>>>>>>> >> Thanks, >>>>>>>>>>> >> David >>>>>>>>>>> >> ----- >>>>>>>>>>> >> >>>>>>>>>>> >> >>>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>>>>>>> native >>>>>>>>>>> thread >>>>>>>>>>> >>> name if possible.? not "Set native thread name as >>>>>>>>>>> possible.?? >>>>>>>>>>> >>> >>>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>>> >>> >>>>>>>>>>> >>> Thanks, >>>>>>>>>>> >>> >>>>>>>>>>> >>> Yasumasa >>>>>>>>>>> >>> >>>>>>>>>>> >>> > cheers >>>>>>>>>>> >>> > >>>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>>> >>>>>>>>>>> >>> >> >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > Hi David, >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > - hotspot: >>>>>>>>>>> >>> > > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > - jdk: >>>>>>>>>>> >>> > > >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>>> setName so I'm >>>>>>>>>>> >>> not sure what you were thinking here. To take advantage >>>>>>>>>>> of an >>>>>>>>>>> arg >>>>>>>>>>> taking >>>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it >>>>>>>>>>> directly as >>>>>>>>>>> no Java >>>>>>>>>>> >>> code will call it . ??? >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>>> JNI-attached >>>>>>>>>>> thread. >>>>>>>>>>> >>> > > This change can set native thread name if main thread >>>>>>>>>>> changes to >>>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > Thanks, >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > Yasumasa >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > >>>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>> could be >>>>>>>>>>> considered a >>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>> thread >>>>>>>>>>> main, even >>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>> first place. >>>>>>>>>>> >>> :( Such >>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> I understood. >>>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at >>>>>>>>>>> Oracle.) >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>>>>>>> sponsor for >>>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>>> proposed change >>>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>>> restore the >>>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >>> I want to continue to discuss about it on >>>>>>>>>>> JDK-8154331 >>>>>>>>>>> [1]. >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the >>>>>>>>>>> supported >>>>>>>>>>> JNI >>>>>>>>>>> >>> interface (as >>>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>>> interface that >>>>>>>>>>> >>> exists for >>>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we >>>>>>>>>>> add new >>>>>>>>>>> method in >>>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>> >>> > >>> >>>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>> >>> > >>> --- >>>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>>> >>> > >>> +++ >>>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>>> >>> > >>> else >>>>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" >>>>>>>>>>> + loc >>>>>>>>>>> + ")"; >>>>>>>>>>> >>> > >>> } >>>>>>>>>>> >>> > >>> + >>>>>>>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>>> >>> > >>> + } >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >> You could also make that call via JNI directly, so >>>>>>>>>>> not >>>>>>>>>>> sure the >>>>>>>>>>> >>> helper adds much here. But it won't work unless you change >>>>>>>>>>> the >>>>>>>>>>> semantics >>>>>>>>>>> >>> of setName so I'm not sure what you were thinking here. To >>>>>>>>>>> take >>>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>>>>>>> need to >>>>>>>>>>> call >>>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >> David >>>>>>>>>>> >>> > >> ----- >>>>>>>>>>> >>> > >> >>>>>>>>>>> >>> > >>> } >>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c >>>>>>>>>>> Wed >>>>>>>>>>> Apr 13 >>>>>>>>>>> 14:19:30 >>>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c >>>>>>>>>>> Sat >>>>>>>>>>> Apr 16 >>>>>>>>>>> 11:25:53 >>>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>>> doXUsage); >>>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>>> *optString); >>>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>>> *optString); >>>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>>>>> *name); >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>>> >>> > >>> */ >>>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>> >>> > >>> do { \ >>>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>>>>>>> JNI_OK) >>>>>>>>>>> { \ >>>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>>> argc); >>>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>>> >>> > >>> + >>>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>>>>> mainArgs); >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>>> >>> > >>> joptString); >>>>>>>>>>> >>> > >>> } >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> +/** >>>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>>> >>> > >>> + */ >>>>>>>>>>> >>> > >>> +static void >>>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>>> >>> > >>> +{ >>>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = >>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>> name)); >>>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>>> setNativeThreadNameID, >>>>>>>>>>> >>> > >>> nameString); >>>>>>>>>>> >>> > >>> +} >>>>>>>>>>> >>> > >>> + >>>>>>>>>>> >>> > >>> /* >>>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>>> >>> > >>> */ >>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> So I want to add new arg to >>>>>>>>>>> JVM_SetNativeThreadName(). >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>>>>>>> interface and so >>>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> [1] >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> >>>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> >>>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>>>> for main >>>>>>>>>>> >>> thread and >>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>> behaviour by >>>>>>>>>>> itself as >>>>>>>>>>> >>> setName >>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>> thread. >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>> could be >>>>>>>>>>> considered a >>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>> thread >>>>>>>>>>> main, even >>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>> first place. >>>>>>>>>>> >>> :( Such >>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>>> JDK-7098194, >>>>>>>>>>> and it is >>>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in >>>>>>>>>>> 7u2. >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>>> >>> > >>>>> only. >>>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>>>> method. >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I >>>>>>>>>>> think we >>>>>>>>>>> can >>>>>>>>>>> add one >>>>>>>>>>> >>> more >>>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>>>>> from Java >>>>>>>>>>> >>> launcher. >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>>>>> really at >>>>>>>>>>> >>> issue. Yes >>>>>>>>>>> >>> > >>>> we would add another arg to the JVM function to >>>>>>>>>>> allow >>>>>>>>>>> it to >>>>>>>>>>> apply to >>>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>>>>> reflect that >>>>>>>>>>> >>> not just >>>>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>>>> exported JVM >>>>>>>>>>> >>> interface >>>>>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>>>>> launcher to >>>>>>>>>>> >>> use the >>>>>>>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>>>>>>> not the >>>>>>>>>>> internal >>>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>>>>> communicate >>>>>>>>>>> >>> with the >>>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>> David >>>>>>>>>>> >>> > >>>> ----- >>>>>>>>>>> >>> > >>>> >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> >>>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not >>>>>>>>>>> tagged as >>>>>>>>>>> being a >>>>>>>>>>> >>> JNI-attached >>>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>>>> for main >>>>>>>>>>> >>> thread and >>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>> behaviour by >>>>>>>>>>> itself as >>>>>>>>>>> >>> setName >>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>> thread. >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>> Apr 14 >>>>>>>>>>> 13:31:11 >>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri >>>>>>>>>>> Apr 15 >>>>>>>>>>> 17:50:10 >>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new >>>>>>>>>>> JavaThread(true); >>>>>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>>>>>>> is complete >>>>>>>>>>> >>> - nop if >>>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>>> JavaThread >>>>>>>>>>> constructor. >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>>>>> tracing >>>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then >>>>>>>>>>> it is >>>>>>>>>>> free >>>>>>>>>>> to do so, >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>>>>>>> change >>>>>>>>>>> native >>>>>>>>>>> >>> thread name >>>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>>> >>> > >>>>>>> However, I think that it should be changed if >>>>>>>>>>> Java >>>>>>>>>>> developer >>>>>>>>>>> >>> calls >>>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>>>> name at >>>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>>> SetNativeThreadName() as >>>>>>>>>>> below. >>>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> The decision to not change the name of >>>>>>>>>>> JNI-attached >>>>>>>>>>> threads was a >>>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>>>>>>> with the OSX >>>>>>>>>>> >>> port and >>>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback with >>>>>>>>>>> this >>>>>>>>>>> feature was to >>>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>>>>>>> been set by >>>>>>>>>>> >>> the host >>>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will >>>>>>>>>>> just >>>>>>>>>>> have an >>>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>>>>>>> does my >>>>>>>>>>> >>> native thread >>>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>>> discussions on >>>>>>>>>>> this, the >>>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>>>>> thread only, >>>>>>>>>>> >>> non-JNI >>>>>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>>>>> were supposed >>>>>>>>>>> >>> to be >>>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>>>>>>> can see >>>>>>>>>>> that >>>>>>>>>>> >>> never >>>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>>>>>>> desirable >>>>>>>>>>> for >>>>>>>>>>> the main >>>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>>>>>>> names >>>>>>>>>>> then the >>>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>>> available >>>>>>>>>>> platform >>>>>>>>>>> >>> APIs. >>>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as >>>>>>>>>>> evidenced by >>>>>>>>>>> the VM >>>>>>>>>>> >>> code for >>>>>>>>>>> >>> > >>>>>> this - due to the need to verify API >>>>>>>>>>> availability. >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>>> Thread.setName would >>>>>>>>>>> >>> have to go >>>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>>>>>>> the launcher >>>>>>>>>>> >>> would >>>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>> David >>>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu >>>>>>>>>>> Apr 14 >>>>>>>>>>> 13:31:11 >>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri >>>>>>>>>>> Apr 15 >>>>>>>>>>> 17:50:10 >>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>>>>>>> current >>>>>>>>>>> thread, >>>>>>>>>>> >>> doesn't >>>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>>>> thread to avoid >>>>>>>>>>> >>> stepping >>>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> >>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>> this. I >>>>>>>>>>> don't like >>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>>> initializing VM >>>>>>>>>>> (before >>>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>>> AttachCurrentThread(). >>>>>>>>>>> So we >>>>>>>>>>> >>> can't >>>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier >>>>>>>>>>> this >>>>>>>>>>> morning. >>>>>>>>>>> >>> Which, >>>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>>>>>>> premise >>>>>>>>>>> here that >>>>>>>>>>> >>> we don't >>>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>>>>>>> The fact >>>>>>>>>>> >>> that the >>>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>>> JNI-attached >>>>>>>>>>> thread seems >>>>>>>>>>> >>> > >>>>>>>> accidental to me - so >>>>>>>>>>> JVM_SetNativeThreadName is >>>>>>>>>>> only >>>>>>>>>>> working by >>>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>>>>> used for the >>>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>>>>> inconsistently >>>>>>>>>>> >>> named at >>>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher >>>>>>>>>>> has >>>>>>>>>>> to be >>>>>>>>>>> >>> treated like >>>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>>>>>>> wants to >>>>>>>>>>> name its >>>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>>>>>>> would not be >>>>>>>>>>> >>> exporting >>>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>>>>> have to >>>>>>>>>>> use the OS >>>>>>>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>>>>>>> platform-by-platform >>>>>>>>>>> basis. >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar >>>>>>>>>>> but >>>>>>>>>>> perform >>>>>>>>>>> >>> different >>>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>>>>>>> thread, the >>>>>>>>>>> >>> second >>>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a >>>>>>>>>>> comment >>>>>>>>>>> somewhere >>>>>>>>>>> >>> about >>>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>>>> casts to >>>>>>>>>>> (void*) >>>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>>> >>> used at >>>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible >>>>>>>>>>> keep >>>>>>>>>>> the cast >>>>>>>>>>> >>> on the >>>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>> haven't had >>>>>>>>>>> time to >>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>> JNI-attached >>>>>>>>>>> >>> thread >>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>> then my >>>>>>>>>>> suggestion >>>>>>>>>>> >>> should >>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>> in our >>>>>>>>>>> treatment of >>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, >>>>>>>>>>> and I >>>>>>>>>>> confirmed >>>>>>>>>>> >>> native >>>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) >>>>>>>>>>> throws >>>>>>>>>>> Exception{ >>>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>> this. I >>>>>>>>>>> don't like >>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>>>>> comment. >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set >>>>>>>>>>> native >>>>>>>>>>> thread >>>>>>>>>>> >>> name, and JLI >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>>>> team so >>>>>>>>>>> >>> core-libs will >>>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>>>>> Kumar) - >>>>>>>>>>> now cc'd. >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>>> upcall to >>>>>>>>>>> >>> Thread.setName >>>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting >>>>>>>>>>> JVM_SetNativeThreadName. No >>>>>>>>>>> hotspot changes >>>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>>>> Thread#setName() in >>>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not >>>>>>>>>>> alive, >>>>>>>>>>> which is >>>>>>>>>>> >>> why the >>>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>>> attached thread. >>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>> haven't had >>>>>>>>>>> time to >>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>> JNI-attached >>>>>>>>>>> >>> thread >>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>> then my >>>>>>>>>>> suggestion >>>>>>>>>>> >>> should >>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>> in our >>>>>>>>>>> treatment of >>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>> this. I >>>>>>>>>>> don't like >>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>>>> function to set >>>>>>>>>>> >>> native >>>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>>>>>>> well ... >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>>>>>>> have >>>>>>>>>>> been on >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>>>>>>> correct >>>>>>>>>>> as we >>>>>>>>>>> >>> do not >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, >>>>>>>>>>> which >>>>>>>>>>> includes the >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more >>>>>>>>>>> reviewer >>>>>>>>>>> :-) >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> >>: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>>>> Suenaga wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>>>>> Suenaga >>>>>>>>>>> wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>> >>> >>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> >>>: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, >>>>>>>>>>> Yasumasa >>>>>>>>>>> Suenaga wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>> >>>>: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>>>>>>> set it: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* >>>>>>>>>>> main_thread = >>>>>>>>>>> new >>>>>>>>>>> >>> JavaThread(); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>> >>> set_active_handles >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>>>>>>> something? >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>>>>>>> to thread >>>>>>>>>>> >>> name in >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in >>>>>>>>>>> Thread or >>>>>>>>>>> setName(). >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in >>>>>>>>>>> Java >>>>>>>>>>> app, >>>>>>>>>>> native >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main >>>>>>>>>>> thread is >>>>>>>>>>> already >>>>>>>>>>> >>> starte >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is >>>>>>>>>>> set in >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>>> setting >>>>>>>>>>> thrrad name >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>>>>>>> something like >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>>> Tue >>>>>>>>>>> >>> Mar 29 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>>> Wed >>>>>>>>>>> >>> Mar 30 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>>> create_initial_thread(Handle >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>>> initial_thread_name = >>>>>>>>>>> >>> "main"; >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> >>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>>>>> (THREAD, k); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>> >>> thread); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> JavaCalls::call_special(&result, >>>>>>>>>>> thread_oop, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev >>>>>>>>>>> later. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>>>>> itself >>>>>>>>>>> 'java' and >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>>>>>>> process >>>>>>>>>>> (and >>>>>>>>>>> >>> thus >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>>>>>>> process >>>>>>>>>>> is not >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>>>>>>> with >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is >>>>>>>>>>> for >>>>>>>>>>> >>> JavaThread. So I >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native >>>>>>>>>>> main >>>>>>>>>>> thread. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>>>>> anyhow, since >>>>>>>>>>> >>> we want >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>>>>>>> thread >>>>>>>>>>> name >>>>>>>>>>> might >>>>>>>>>>> >>> have >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>>>> /proc. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid >>>>>>>>>>> comm' >>>>>>>>>>> | head -4 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>>>>>>> like >>>>>>>>>>> 'Java Main >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>>>>>>> Java >>>>>>>>>>> >>> launcher - e.g. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, >>>>>>>>>>> etc. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>>>>>>> thread >>>>>>>>>>> name, >>>>>>>>>>> >>> I think >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new >>>>>>>>>>> webrev? >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will >>>>>>>>>>> set >>>>>>>>>>> thread >>>>>>>>>>> >>> name via >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>>> does not >>>>>>>>>>> have it. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have >>>>>>>>>>> native >>>>>>>>>>> name, >>>>>>>>>>> and main >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>>>> thread >>>>>>>>>>> should have >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. >>>>>>>>>>> Could >>>>>>>>>>> you >>>>>>>>>>> review it? >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>> >>> > >>>>>>>>>>> >>> >>>>>>>>>>> >>>>>>>> >>>>>>> From Alan.Bateman at oracle.com Tue Apr 26 09:58:43 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 26 Apr 2016 10:58:43 +0100 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests In-Reply-To: <571F330D.6060307@oracle.com> References: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> <571F330D.6060307@oracle.com> Message-ID: <571F3BD3.8090103@oracle.com> On 26/04/2016 10:21, Amy Lu wrote: > Hi, Felix > > With modules declares in TEST.propertiesshould avoid have to modify > test file one by one... Maybe I missed things please correct me. > > Example: > $ cat jdk/test/java/rmi/TEST.properties > modules = java.rmi Yes, this avoid needing to add @modules to each test in test/java/rmi/**. -Alan From scolebourne at joda.org Tue Apr 26 10:43:50 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Tue, 26 Apr 2016 11:43:50 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: Message-ID: In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this would be painful and add no value. While I understand the pain from some developers not understanding the feature, this is hardly unique in the world of Java. Developers learn the right way of doing something soon enough. And while if (opt.isPresent()) { opt.get() } is sometimes not ideal, in other cases it is the only practical choice (eg. where the method needs to have a return statement inside the if statement). Changing this to if (opt.isPresent()) { opt.getWhenPresent() } is just noise - I can see the "present" part twice. I just don't think I can support the rename (although many of the webrev tidy-ups are probably good). Stephen On 26 April 2016 at 00:05, Stuart Marks wrote: > Hi all, > > Please review these webrevs that deprecate Optional.get() and to replace it > with Optional.getWhenPresent(). The corresponding changes are also applied > to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and > OptionalLong.getAsLong(). > > Unlike most deprecations, this isn't about the function or the utility of > some API, it's about the name. The solution is basically to rename the API. > The problem is that "get" shows up as the "obvious" choice in things like > IDE code completion, leading to code that mishandles empty Optionals. > Typical Stack Overflow discourse runs something like this: > > Q: what do I do with this Optional thing > > A: just call get() > > Q: thanks, it works! > > Of course, it works until it doesn't. > > Examining the JDK's use of Optional.get(), I didn't see very many cases that > called get() without first checking for the presence of a value. But I did > see quite a number of cases like this: > > if (opt.isPresent()) { > doSomething(opt.get()); > } else { > doSomethingElse(); > } > > In many of these cases, the code could be refactored to use other Optional > methods such as filter(), map(), or ifPresent(). > > In any case this reinforces the contention that use of get() leads to poor > code. > > For this changeset, in just about all cases I've simply replaced the call to > get() with a call to getWhenPresent(). In a couple cases I replaced the > stream calls > > .filter(Optional::isPresent).map(Optional::get) > > with > > .flatMap(Optional::stream) > > which I hope will become the new idiom for unwrapping a stream of Optionals. > > While many cases could be cleaned up further, I didn't change them. The > reasons are that I didn't want to spend too much time putting code cleanup > into the critical path of this changeset (I'd be happy to help later); doing > so would create potential conflicts with code coming in from the Jigsaw > forest; and there are non-obvious places where converting from a conditional > to one of the lambda-based methods could cause performance problems at > startup. > > There are also a few cases where simplification is prevented because it > would end up causing the resulting lambda expressions to throw checked > exceptions. :-( > > Webrevs here: > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ > > Thanks, > > s'marks From amaembo at gmail.com Tue Apr 26 11:10:56 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Tue, 26 Apr 2016 17:10:56 +0600 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: Message-ID: <98009039.20160426171056@gmail.com> Hello! While I'm not a reviewer, I agree with Stephen. While I understand the rationale, such renaming would cause even more confusion and pain. Also I think this is not the worst part of Java API, so if we start to rename things, where should we stop then? With best regards, Tagir Valeev. SC> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this SC> would be painful and add no value. SC> While I understand the pain from some developers not understanding the SC> feature, this is hardly unique in the world of Java. Developers learn SC> the right way of doing something soon enough. SC> And while SC> if (opt.isPresent()) { SC> opt.get() SC> } SC> is sometimes not ideal, in other cases it is the only practical choice SC> (eg. where the method needs to have a return statement inside the if SC> statement). SC> Changing this to SC> if (opt.isPresent()) { SC> opt.getWhenPresent() SC> } SC> is just noise - I can see the "present" part twice. SC> I just don't think I can support the rename (although many of the SC> webrev tidy-ups are probably good). SC> Stephen SC> On 26 April 2016 at 00:05, Stuart Marks wrote: >> Hi all, >> >> Please review these webrevs that deprecate Optional.get() and to replace it >> with Optional.getWhenPresent(). The corresponding changes are also applied >> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >> OptionalLong.getAsLong(). >> >> Unlike most deprecations, this isn't about the function or the utility of >> some API, it's about the name. The solution is basically to rename the API. >> The problem is that "get" shows up as the "obvious" choice in things like >> IDE code completion, leading to code that mishandles empty Optionals. >> Typical Stack Overflow discourse runs something like this: >> >> Q: what do I do with this Optional thing >> >> A: just call get() >> >> Q: thanks, it works! >> >> Of course, it works until it doesn't. >> >> Examining the JDK's use of Optional.get(), I didn't see very many cases that >> called get() without first checking for the presence of a value. But I did >> see quite a number of cases like this: >> >> if (opt.isPresent()) { >> doSomething(opt.get()); >> } else { >> doSomethingElse(); >> } >> >> In many of these cases, the code could be refactored to use other Optional >> methods such as filter(), map(), or ifPresent(). >> >> In any case this reinforces the contention that use of get() leads to poor >> code. >> >> For this changeset, in just about all cases I've simply replaced the call to >> get() with a call to getWhenPresent(). In a couple cases I replaced the >> stream calls >> >> .filter(Optional::isPresent).map(Optional::get) >> >> with >> >> .flatMap(Optional::stream) >> >> which I hope will become the new idiom for unwrapping a stream of Optionals. >> >> While many cases could be cleaned up further, I didn't change them. The >> reasons are that I didn't want to spend too much time putting code cleanup >> into the critical path of this changeset (I'd be happy to help later); doing >> so would create potential conflicts with code coming in from the Jigsaw >> forest; and there are non-obvious places where converting from a conditional >> to one of the lambda-based methods could cause performance problems at >> startup. >> >> There are also a few cases where simplification is prevented because it >> would end up causing the resulting lambda expressions to throw checked >> exceptions. :-( >> >> Webrevs here: >> >> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >> >> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >> >> Thanks, >> >> s'marks From vitalyd at gmail.com Tue Apr 26 11:34:32 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Tue, 26 Apr 2016 07:34:32 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> Message-ID: On Tuesday, April 26, 2016, Stuart Marks wrote: > > > On 4/25/16 5:46 PM, Vitaly Davidovich wrote: > >> We've introduced Optional to avoid this. The problem is that the >> obvious >> thing to do is to get() the value out of the Optional, but this buys >> us >> right back into the what-if-the-value-is-missing case that we had >> with nulls. >> >> Why is this the "obvious" thing? Because a few stackoverflow threads went >> like >> that? >> > > Well, the Stack Overflow exchange was a caricature. But without looking > too hard, I found this code: [2] > > return stringList.stream().filter(...).findFirst().get() != null; > > [2] http://stackoverflow.com/q/36346409/1441122 > > The person, presumably new to Java 8, was able to determine that > findFirst() returned an Optional instead of the desired value, and was able > to figure out enough to call get(), and even thought enough about the > possibly-absent case to check it against null. But the person had to ask on > Stack Overflow about how to solve the problem. > > Now I obviously don't know the exact thought process that went on, but > get() has among the shortest of name of the Optional methods, and has no > arguments, so it seems like it ought to be called more more frequently > compared to more specialized methods like ifPresentOrElse() or > orElseThrow(). > > There are other items on Stack Overflow such as these: [3] [4]. But these > probably aren't what you're looking for. :-) > > [3] http://stackoverflow.com/a/26328555/1441122 > > [4] http://stackoverflow.com/a/23464794/1441122 Don't get me wrong - I'm sure examples of "misuse" exist, as you've clearly demonstrated. I'm just not convinced that deprecation at this stage of the game is a worthwhile endeavor. I'm not even sure I like the more explicit name in general given it "penalizes" correct usage by being overly verbose, as I mentioned in my previous reply. > > > It's not clear it returns an Optional - it could be returning some other >> type >> that happens to have a getWhenPresent. What would be clear it's an >> Optional is >> to have a local of that type and assign find(pk) to it. >> > > Of course there's always a possibility that there's some other API that > has getWhenPresent() on it. There isn't one in the JDK, and I've been > unable to find one elsewhere. So "getWhenPresent" should be different > enough to trigger a different thought pattern, as opposed to a plain "get" > which fades into the background. Right, it may cause someone to pause for a second. I'm just saying that the method name itself doesn't say it's an Optional. In fact, someone may assume it's Optional since the name is somewhat unique-ish but in fact it could be something else entirely with different behavior. At least get() is so "vague" that user ought to check at least what type the method is invoked on. But either way, this isn't really the thrust of my argument. > > The Optional API was designed to be chained, so you don't want to pull it > into a local variable. Sure, and that's usually good. But chaining can have readability issues associated with it when more than one type is involved in the chain. > > Descriptive names are good, but like Jon, I'm not buying this change. Is >> it >> really wrong to tell people to read the javadoc? And is that worth the >> deprecation churn? It's going to be needlessly verbose (esp in existing >> code >> that already checked isPresent) for no strong benefit. If someone is >> mindlessly >> having their IDE write code for them, this isn't going to prevent poor >> code. >> For code review purposes, if it's important to call out that something is >> Optional then use the type somewhere explicitly. >> > > Personally I'm generally skeptical of simple name changes, but after > having gone through a bunch of examples of the use of get(), my skepticism > melted away. It really does seem to be misused a significant fraction of > the time, possibly even a majority of the time. > > Beginners and Java 8 learners will probably fall into the trap of > forgetting to check. But JDK programmers, who are decidedly not beginners, > are writing code that uses get() unnecessarily: > > ======================================== > > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java.sdiff.html > > 206 if (source.isPresent()) { > 207 executor.runTask(source.get(), deque); > 208 } > > could be rewritten as > > source.ifPresent(archive -> executor.runTask(archive, deque)); Maybe, if the lambda capture allocation isn't an issue for this use case. > > ======================================== > > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java.sdiff.html > > 476 Optional req = options.requires.stream() > 477 .filter(mn -> !modules.containsKey(mn)) > 478 .findFirst(); > 479 if (req.isPresent()) { > 480 throw new BadArgs("err.module.not.found", req.get()); > 481 } > > could be rewritten as > > options.requires.stream() > .filter(mn -> !modules.containsKey(mn)) > .findFirst() > .ifPresent(s -> throw new BadArgs("err.module.not.found", > s)); > > ======================================== > > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java.sdiff.html > > 1203 String hist = replayableHistory > 1204 .subList(first + 1, replayableHistory.size()) > 1205 .stream() > 1206 .reduce( (a, b) -> a + RECORD_SEPARATOR + b) > 1207 .get(); > > could be rewritten as > > String hist = String.join(RECORD_SEPARATOR, > replayableHistory.subList(first + 1, > replayableHistory.size())); > > (It's also not clear to me that the sublist is guaranteed to be nonempty, > so the first snippet might fail in get().) > > ======================================== > > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.base/share/classes/java/lang/module/Resolver.java.sdiff.html > > 100 if (mref.location().isPresent()) > 101 trace(" (%s)", mref.location().get()); > > could be rewritten as > > mref.location().ifPresent(loc -> trace(" (%s)", loc); > > ======================================== > > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.base/share/classes/java/lang/reflect/Layer.java.sdiff.html > > 364 Optional oparent = cf.parent(); > 365 if (!oparent.isPresent() || oparent.get() != > this.configuration()) { > 366 throw new IllegalArgumentException( > 367 "Parent of configuration != configuration of this > Layer"); > > could be rewritten as > > cf.parent() > .filter(cfg -> cfg == this.configuration()) > .orElseThrow(() -> throw new IllegalArgumentException( > "Parent of configuration != configuration of this Layer")); > > ======================================== > > If you go to grepcode.com, find the source for Optional.get() -- I used > 8u40-b25 -- and then click the little arrow next to get(), you can find a > bunch of uses of Optional.get(). A startlingly large fraction of them can > be simplified in a similar manner to the JDK examples I showed above, > bypassing the need to call get(). (I did a quick check of the first ten > examples, and I think about seven could be improved, depending on how you > count.) > > It really does look to me like get() is a bad API. It's not people > "mindlessly" having their IDE write code. The problem is that get() is > deceptively attractive. Even people remember to check it, they put the > checking around the get(), instead of looking at Optional's other methods. > This is what results in the needlessly verbose code. It's a "simple" and direct API, not sure it's bad. The higher order APIs are nice and should be preferred, but they may come with performance overhead. > > A minority of the cases are justified in using get(). If this is renamed > to getWhenPresent(), it becomes slightly more verbose, but it also > specifically states that the programmer is making an assertion about the > presence of a value -- a worthwhile improvement. > > Is it worth the churn? Well, the problem is only going to get worse. I > believe that if we don't deprecate get() now, a few years down the road, > the problem will be so bad, we'll say "I wish we had deprecated it back in > JDK 9 when we were talking about it then." Just like right now we're > saying, "I wish we had fixed it before JDK 8 shipped." > > s'marks > -- Sent from my phone From nadeesh.tv at oracle.com Tue Apr 26 11:48:31 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Tue, 26 Apr 2016 17:18:31 +0530 Subject: RFR:JDK-8079628:java.time: DateTimeFormatter containing "DD" fails on 3-digit day-of-year value Message-ID: <571F558F.9090008@oracle.com> Hi all, Please review a fix for Bug ID - https://bugs.openjdk.java.net/browse/JDK-8079628 Issue - Pattern 'D' is not implemented as intended by CLDR Solution - Changed the definition of 'D' to D..D 1..3 appendValue(ChronoField.DAY_OF_YEAR, n, 19, SignStyle.NORMAL) Webrev - http://cr.openjdk.java.net/~ntv/8079628/webrev.00/ -- Thanks and Regards, Nadeesh TV From merkel05 at gmail.com Tue Apr 26 11:49:39 2016 From: merkel05 at gmail.com (Sergey Ustimenko) Date: Tue, 26 Apr 2016 14:49:39 +0300 Subject: RFR 8015594: java.util.Pattern.matcher function throws a NullPointerException Message-ID: Hi all! There is a bug described at https://bugs.openjdk.java.net/browse/JDK-8015594 The problem is that if we are using java.util.Pattern.matcher with NULL argument, then the NPE will be thrown. As Stuart Marks has noticed in the comments, that such behavior have not been specified, so it seems more convenient to update method's javadoc, saying that if argument is null, then the NPE will be thrown. I'm looking for review and sponsor. File with patch attached. diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/java/util/regex/Pattern.java @@ -1097,8 +1097,11 @@ * The character sequence to be matched * * @return A new matcher for this pattern + * @throws NullPointerException if the specified {@code input} + * is {@code null}. */ public Matcher matcher(CharSequence input) { + Objects.requireNonNull(input); if (!compiled) { synchronized(this) { if (!compiled) -------------- next part -------------- A non-text attachment was scrubbed... Name: JDK-8015594.patch Type: text/x-diff Size: 670 bytes Desc: not available URL: From scolebourne at joda.org Tue Apr 26 12:12:37 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Tue, 26 Apr 2016 13:12:37 +0100 Subject: RFR:JDK-8079628:java.time: DateTimeFormatter containing "DD" fails on 3-digit day-of-year value In-Reply-To: <571F558F.9090008@oracle.com> References: <571F558F.9090008@oracle.com> Message-ID: This change introduces inconsistencies and problems. For example, it will parse up to 19 digits for "D" but only up to 2 digits for "d". The following would be better: * D 1 appendValue(ChronoField.DAY_OF_YEAR) * DD 2 appendValue(ChronoField.DAY_OF_YEAR, 2, 3, SignStyle.NORMAL) * DDD 3 appendValue(ChronoField.DAY_OF_YEAR, 3) This limits the accepted input to 3 digits, which is quite sufficient here. It is also clearer for the common "D" and "DDD" cases. Note that a test case needs to cover adjacent value parsing for day-of-year. This pattern "yyyyDDD" should be tested and work. With the webrev changes, it will not work as adjacent value parsing mode will not be triggered. (The change will alter the meaning of "yyyyDD" but no-one should be using that anyway as it is broken, only working for the first 99 days of the year.) The code in TCKDateTimeFormatterBuilder needs a blank line after the new methods. Stephen On 26 April 2016 at 12:48, nadeesh tv wrote: > Hi all, > > Please review a fix for > > Bug ID - https://bugs.openjdk.java.net/browse/JDK-8079628 > > Issue - Pattern 'D' is not implemented as intended by CLDR > > Solution - Changed the definition of 'D' to D..D 1..3 > appendValue(ChronoField.DAY_OF_YEAR, n, 19, SignStyle.NORMAL) > > Webrev - http://cr.openjdk.java.net/~ntv/8079628/webrev.00/ > > -- > Thanks and Regards, > Nadeesh TV > From Alan.Bateman at oracle.com Tue Apr 26 12:26:22 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 26 Apr 2016 13:26:22 +0100 Subject: RFR 8015594: java.util.Pattern.matcher function throws a NullPointerException In-Reply-To: References: Message-ID: <571F5E6E.6030702@oracle.com> On 26/04/2016 12:49, Sergey Ustimenko wrote: > Hi all! > > There is a bug described at https://bugs.openjdk.java.net/browse/JDK-8015594 > > The problem is that if we are using java.util.Pattern.matcher with NULL > argument, > then the NPE will be thrown. As Stuart Marks has noticed in the comments, > that such > behavior have not been specified The package description has this *

      Unless otherwise noted, passing a null argument to a * method in any class or interface in this package will cause a * {@link java.lang.NullPointerException NullPointerException} to be * thrown. and so avoids needing to specifying it on every method. -Alan From felix.yang at oracle.com Tue Apr 26 12:50:10 2016 From: felix.yang at oracle.com (Felix Yang) Date: Tue, 26 Apr 2016 20:50:10 +0800 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests In-Reply-To: <571F330D.6060307@oracle.com> References: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> <571F330D.6060307@oracle.com> Message-ID: Hi Amy, thanks for pointing this out. Updated webrev: http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.01/ Felix On 2016/4/26 17:21, Amy Lu wrote: > Hi, Felix > > With modules declares in TEST.propertiesshould avoid have to modify > test file one by one... Maybe I missed things please correct me. > > Example: > $ cat jdk/test/java/rmi/TEST.properties > modules = java.rmi > > Thanks, > Amy > > On 4/26/16 4:53 PM, Felix Yang wrote: >> Hi all, >> >> please review the fix to explicitly declare module dependencies >> for rmi tests. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8154733 >> Webrev: http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.00/ >> >> Thanks, >> Felix > From yasuenag at gmail.com Tue Apr 26 12:54:54 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Tue, 26 Apr 2016 21:54:54 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571F367B.3010200@oracle.com> References: <56F3F90D.9010408@gmail.com> <570F9BFE.8010400@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> <571F367B.3010200@oracle.com> Message-ID: Hi David, For this issue, I think we can approach as following: 1. Export new JVM function to set native thread name It can avoid JNI call and can handle char* value. However this plan has been rejected. 2. Call uncaught exception handler from Launcher We have to clear (process) any pending exception before DetachCurrentThread() call. (not documented?) ------ > so note that we are potentially calling DetachCurrentThread with an > exception pending - which is prohibited by JNI** > **JNI spec needs to be modified here. ------ So we can process pending exception through uncaught exception handler. However, this plan has been rejected. 3. Do not set DestroyJavaVM name when exception is occurred It disrupts consistency for native thread name. 4. Attach to JVM to set native thread name for DestroyJavaVM It does not look good. If all of them are not accepted, I guess that it is difficult. Do you have any other idea? Thanks, Yasumasa On 2016/04/26 18:35, David Holmes wrote: > On 26/04/2016 7:22 PM, Yasumasa Suenaga wrote: >> Hi David, >> >>> I thought about being able to save/restore the original pending >>> exception but could not see a simple way to restore it - ie just by >>> poking it back into the thread's pending exception field. The problem >>> with using env->Throw is that it acts like the initial throwing of the >>> exception and will have a number of side-effects that then get doubled >>> up: >>> - logging statements (UL and Event logging) >>> - OOM counting >> >> Thanks, I understood. >> >>>>> so note that we are potentially calling DetachCurrentThread with an >>>>> exception pending - which is prohibited by JNI**, but which we >>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>> thread->exit() which performs uncaught exception handling (ie it >>>>> prints the exception message and stacktrace) and then clears the >>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>> exceptions.) >> >> I think we can call uncaught exception handler before calling >> DestroyJavaVM(). >> I added it in new webrev for jdk: >> >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ >> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ >> >> DispatchUncaughtException() in java.c emulates uncaught exception handler >> call in JavaThread::exit(). >> I think this patch can provide the solution for our issue. >> >> Could you check it? > > Sorry - this is getting far too disruptive. I do not support changing the way the main thread behaves upon completion, just because we want to set a native thread name. > > David > ----- > >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/26 14:16, David Holmes wrote: >>> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >>>> Hi David, Kumar, >>>> >>>> I think that we should evacuate original exception before DestroyJavaVM >>>> thread name is set. >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >>>> >>>> I added it to LEAVE macro in new webrev. >>> >>> BTW: in the LEAVE macro, stylistically all the code should be in the >>> do { } while(false); loop. I overlooked that initially. >>> >>>> I tested it with following code. It works fine. >>>> >>>> ------------- >>>> public void main(String[] args){ >>>> throw new RuntimeException("test"); >>>> } >>>> ------------- >>>> >>>> What do you think about it? >>> >>> I thought about being able to save/restore the original pending >>> exception but could not see a simple way to restore it - ie just by >>> poking it back into the thread's pending exception field. The problem >>> with using env->Throw is that it acts like the initial throwing of the >>> exception and will have a number of side-effects that then get doubled >>> up: >>> - logging statements (UL and Event logging) >>> - OOM counting >>> >>> I'm not sure whether that is acceptable or not >>> >>> That aside you should check if orig_throwable is non-null before >>> clearing to avoid an unnecessary JNI call. >>> >>> Also "Resume original exception" -> "Restore any original exception" >>> >>> Thanks, >>> David >>> ----- >>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/26 11:16, David Holmes wrote: >>>>> Hi Yasumasa, Kumar, >>>>> >>>>> Turns out this change breaks the behaviour of the launcher in the case >>>>> that main() completes by throwing an exception. >>>>> >>>>> What we have in the launcher is: >>>>> >>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>>>> LEAVE(); >>>>> >>>>> where LEAVE would have expanded to: >>>>> >>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>> ret = 1; \ >>>>> } \ >>>>> if (JNI_TRUE) { \ >>>>> (*vm)->DestroyJavaVM(vm); \ >>>>> return ret; \ >>>>> } \ >>>>> >>>>> so note that we are potentially calling DetachCurrentThread with an >>>>> exception pending - which is prohibited by JNI**, but which we >>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>> thread->exit() which performs uncaught exception handling (ie it >>>>> prints the exception message and stacktrace) and then clears the >>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>> exceptions.) >>>>> >>>>> **JNI spec needs to be modified here. >>>>> >>>>> With the current change we have now inserted the following at the >>>>> start of LEAVE: >>>>> >>>>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>> if ((*env)->ExceptionOccurred(env)) { \ >>>>> (*env)->ExceptionClear(env); \ >>>>> } \ >>>>> >>>>> this has two unintended consequences: >>>>> >>>>> 1. SetNativeThreadName itself calls a number of JNI methods, with the >>>>> exception pending - which is not permitted. So straight away where we >>>>> have: >>>>> >>>>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>>> >>>>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make calls >>>>> using the VM's CHECK_NULL macro - which checks for a pending exception >>>>> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >>>>> reports a JNI error: >>>>> >>>>> Error: A JNI error has occurred, please check your installation and >>>>> try again >>>>> >>>>> >>>>> 2. There is no longer an exception from main() for DetachCurrentThread >>>>> to report, so we exit with a return code of 1 as required, but don't >>>>> report the exception message/stacktrace. >>>>> >>>>> I don't see a reasonable solution for this other than abandoning the >>>>> attempt to change the name from "main" to "DestroyJavaVM" - which if >>>>> we can't do, I question the utility of setting the name in the first >>>>> place (while it might be useful in some circumstances [when main() is >>>>> running] it will cause confusion in others [when main() has exited]). >>>>> >>>>> David >>>>> ----- >>>>> >>>>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>>>> Looks good to me. >>>>>> >>>>>> I'll sponsor this "tomorrow". >>>>>> >>>>>> Thanks, >>>>>> David >>>>>> >>>>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>>>> Hi Kumar, >>>>>>> >>>>>>> Thank you for your comment! >>>>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>>>> >>>>>>> >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>>>> >>>>>>>> Also a couple of minor suggestions: >>>>>>>> >>>>>>>> - * Set native thread name as possible. >>>>>>>> + * Set native thread name if possible. >>>>>>>> >>>>>>>> >>>>>>>> + /* >>>>>>>> - * We can clear pending exception because exception at this >>>>>>>> point >>>>>>>> - * is not critical. >>>>>>>> + */ >>>>>>>> >>>>>>>> + /* >>>>>>>> + * Clear non critical pending exceptions at this point. >>>>>>>> + */ >>>>>>>> >>>>>>>> Thanks >>>>>>>> Kumar >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> This is in the wrong place: >>>>>>>>> >>>>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>> 1716 /* >>>>>>>>> 1717 * We can clear pending exception because exception at >>>>>>>>> this point >>>>>>>>> 1718 * is not critical. >>>>>>>>> 1719 */ >>>>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>>>> 1721 } >>>>>>>>> >>>>>>>>> This above needs to be after >>>>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>>>> 392 >>>>>>>>> >>>>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>>>> but have also encountered an exception. In which case >>>>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>>>> if nothing has happened, because NULL_CHECK simply checks for NULL >>>>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>>>> the VM with exceptions. >>>>>>>>> >>>>>>>>> Kumar >>>>>>>>> >>>>>>>>> >>>>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi David, >>>>>>>>>> >>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>> ignore >>>>>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>>>> >>>>>>>>>> I've fixed it in new webrev: >>>>>>>>>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>>>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Hi all, >>>>>>>>>>>> >>>>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>>>> Could you review again? >>>>>>>>>>>> >>>>>>>>>>>> > - hotspot: >>>>>>>>>>>> > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Looks fine. >>>>>>>>>>> >>>>>>>>>>>> > >>>>>>>>>>>> > - jdk: >>>>>>>>>>>> > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>> >>>>>>>>>>> As per private email (but repeated here on the record) in java.c: >>>>>>>>>>> >>>>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>>>> 1717 } >>>>>>>>>>> >>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>> ignore >>>>>>>>>>> it. Either way we have to clear the exception before continuing. >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> David >>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>>>> >: >>>>>>>>>>>> > >>>>>>>>>>>> > Hi David, >>>>>>>>>>>> > >>>>>>>>>>>> > Thank you for your comment. >>>>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>>>> > >>>>>>>>>>>> > - hotspot: >>>>>>>>>>>> > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> > >>>>>>>>>>>> > - jdk: >>>>>>>>>>>> > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>>>> process, I >>>>>>>>>>>> would have done it immediately after here: >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>>>>>> before >>>>>>>>>>>> > main method call. >>>>>>>>>>>> > However, main thread is already started, so I moved it as you >>>>>>>>>>>> suggested. >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>>> have to >>>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>>> then >>>>>>>>>>>> calls >>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>>>>> char* ! >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > SoI proposed to export new JVM function to set native thread >>>>>>>>>>>> name with >>>>>>>>>>>> > const char *. >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > Thanks, >>>>>>>>>>>> > >>>>>>>>>>>> > Yasumasa >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>>>> >> >>>>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>>>> >> >>>>>>>>>>>> >> Thanks for persevering with this to get it into the current >>>>>>>>>>>> form. >>>>>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>>>>> >> >>>>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> Hi Gerard, >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> >>: >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>> > ======== >>>>>>>>>>>> >>> > File: java.c >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>>>>> NULL_CHECK, >>>>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> It is not critical if we encounter error at JNI function >>>>>>>>>>>> call >>>>>>>>>>>> because >>>>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>>>> process. >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> I agree we do not need to abort if an exception occurs >>>>>>>>>>>> (and in >>>>>>>>>>>> fact >>>>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>>>> but we >>>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>>> futher JNI >>>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>>> extensively >>>>>>>>>>>> throughout the launcher code - so if this usage is wrong then it >>>>>>>>>>>> is all >>>>>>>>>>>> wrong! More on this code below ... >>>>>>>>>>>> >> >>>>>>>>>>>> >> Other comments: >>>>>>>>>>>> >> >>>>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>>>> >> >>>>>>>>>>>> >> Please add a comment to the method now that you removed the >>>>>>>>>>>> internal >>>>>>>>>>>> comment: >>>>>>>>>>>> >> >>>>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>>>> specifically >>>>>>>>>>>> >> // requested JNI-attached threads can also have their native >>>>>>>>>>>> name set; >>>>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as it may >>>>>>>>>>>> interfere >>>>>>>>>>>> >> // with the application that created them. >>>>>>>>>>>> >> >>>>>>>>>>>> >> --- >>>>>>>>>>>> >> >>>>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>>>> >> >>>>>>>>>>>> >> Please add the following comments: >>>>>>>>>>>> >> >>>>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>>>> >> >>>>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>>>> permitted) to >>>>>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>>>>> allowAttachedThread); >>>>>>>>>>>> >> >>>>>>>>>>>> >> --- >>>>>>>>>>>> >> >>>>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>>>> >> >>>>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>> >> >>>>>>>>>>>> >> I was going to suggest this be set later, but realized we >>>>>>>>>>>> have >>>>>>>>>>>> to be >>>>>>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>>>>>> >> >>>>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>> >> >>>>>>>>>>>> >> The comment is redundant given the name of the method. That >>>>>>>>>>>> aside >>>>>>>>>>>> I'm not sure why you do this so late in the process, I would >>>>>>>>>>>> have >>>>>>>>>>>> done >>>>>>>>>>>> it immediately after here: >>>>>>>>>>>> >> >>>>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>>>> >> 388 exit(1); >>>>>>>>>>>> >> 389 } >>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> + /** >>>>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>>>> >> + */ >>>>>>>>>>>> >> >>>>>>>>>>>> >> Other than the as->if change I'm unclear where the >>>>>>>>>>>> "possible" >>>>>>>>>>>> bit >>>>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>>>> >> >>>>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>>>> "java/lang/Thread")); >>>>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>>>> cls, >>>>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>>>>>>>> (*env)->GetMethodID(env, >>>>>>>>>>>> cls, >>>>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>>>>> name)); >>>>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>>>> setNativeNameID, >>>>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>>>> >> >>>>>>>>>>>> >> As above NULL_CHECK is fine here, but we should check for >>>>>>>>>>>> and >>>>>>>>>>>> clear >>>>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>>>> >> >>>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>>> have to >>>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>>> then >>>>>>>>>>>> calls >>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back to a >>>>>>>>>>>> char* ! >>>>>>>>>>>> Overall I wonder about the affect on startup cost. But if there >>>>>>>>>>>> is an >>>>>>>>>>>> issue we can revisit this. >>>>>>>>>>>> >> >>>>>>>>>>>> >> Thanks, >>>>>>>>>>>> >> David >>>>>>>>>>>> >> ----- >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be ?Set >>>>>>>>>>>> native >>>>>>>>>>>> thread >>>>>>>>>>>> >>> name if possible.? not "Set native thread name as >>>>>>>>>>>> possible.?? >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> Thanks, >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> Yasumasa >>>>>>>>>>>> >>> >>>>>>>>>>>> >>> > cheers >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>>>> >>>>>>>>>>>> >>> >> >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > Hi David, >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > - hotspot: >>>>>>>>>>>> >>> > > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > - jdk: >>>>>>>>>>>> >>> > > >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>>>> setName so I'm >>>>>>>>>>>> >>> not sure what you were thinking here. To take advantage >>>>>>>>>>>> of an >>>>>>>>>>>> arg >>>>>>>>>>>> taking >>>>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it >>>>>>>>>>>> directly as >>>>>>>>>>>> no Java >>>>>>>>>>>> >>> code will call it . ??? >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> thread. >>>>>>>>>>>> >>> > > This change can set native thread name if main thread >>>>>>>>>>>> changes to >>>>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > Thanks, >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > Yasumasa >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > >>>>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>> could be >>>>>>>>>>>> considered a >>>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>>> thread >>>>>>>>>>>> main, even >>>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>>> first place. >>>>>>>>>>>> >>> :( Such >>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> I understood. >>>>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at >>>>>>>>>>>> Oracle.) >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would need a >>>>>>>>>>>> sponsor for >>>>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>>>> proposed change >>>>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>>>> restore the >>>>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >>> I want to continue to discuss about it on >>>>>>>>>>>> JDK-8154331 >>>>>>>>>>>> [1]. >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the >>>>>>>>>>>> supported >>>>>>>>>>>> JNI >>>>>>>>>>>> >>> interface (as >>>>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>>>> interface that >>>>>>>>>>>> >>> exists for >>>>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we >>>>>>>>>>>> add new >>>>>>>>>>>> method in >>>>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>> >>> > >>> --- >>>>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>>>> >>> > >>> +++ >>>>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>>>> >>> > >>> else >>>>>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" >>>>>>>>>>>> + loc >>>>>>>>>>>> + ")"; >>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>> >>> > >>> + static void setNativeThreadName(String name) { >>>>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>>>> >>> > >>> + } >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >> You could also make that call via JNI directly, so >>>>>>>>>>>> not >>>>>>>>>>>> sure the >>>>>>>>>>>> >>> helper adds much here. But it won't work unless you change >>>>>>>>>>>> the >>>>>>>>>>>> semantics >>>>>>>>>>>> >>> of setName so I'm not sure what you were thinking here. To >>>>>>>>>>>> take >>>>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you would >>>>>>>>>>>> need to >>>>>>>>>>>> call >>>>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >> David >>>>>>>>>>>> >>> > >> ----- >>>>>>>>>>>> >>> > >> >>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c >>>>>>>>>>>> Wed >>>>>>>>>>>> Apr 13 >>>>>>>>>>>> 14:19:30 >>>>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c >>>>>>>>>>>> Sat >>>>>>>>>>>> Apr 16 >>>>>>>>>>>> 11:25:53 >>>>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>>>> doXUsage); >>>>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>>>> *optString); >>>>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>>>> *optString); >>>>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>>>>>> *name); >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>> >>> > >>> do { \ >>>>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>>>>>>>> JNI_OK) >>>>>>>>>>>> { \ >>>>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>>>> argc); >>>>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>>>>>> mainArgs); >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>>>> >>> > >>> joptString); >>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> +/** >>>>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>>>> >>> > >>> + */ >>>>>>>>>>>> >>> > >>> +static void >>>>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>>>> >>> > >>> +{ >>>>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>>>> >>> > >>> + "setNativeThreadName", "(Ljava/lang/String;)V")); >>>>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = >>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>> name)); >>>>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>>>> setNativeThreadNameID, >>>>>>>>>>>> >>> > >>> nameString); >>>>>>>>>>>> >>> > >>> +} >>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>> >>> > >>> /* >>>>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, see >>>>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> So I want to add new arg to >>>>>>>>>>>> JVM_SetNativeThreadName(). >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>>> However this is still a change to the exported JVM >>>>>>>>>>>> interface and so >>>>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> [1] >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> >>>>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> >>>>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>>>>> for main >>>>>>>>>>>> >>> thread and >>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>>>> >>> > >>>>> I will send review request to hotspot-runtime-dev. >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>> behaviour by >>>>>>>>>>>> itself as >>>>>>>>>>>> >>> setName >>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>>> thread. >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>> could be >>>>>>>>>>>> considered a >>>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>>> thread >>>>>>>>>>>> main, even >>>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>>> first place. >>>>>>>>>>>> >>> :( Such >>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>>>> JDK-7098194, >>>>>>>>>>>> and it is >>>>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in >>>>>>>>>>>> 7u2. >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>>>> >>> > >>>>> only. >>>>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>>>>> method. >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I >>>>>>>>>>>> think we >>>>>>>>>>>> can >>>>>>>>>>>> add one >>>>>>>>>>>> >>> more >>>>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>>>>>> from Java >>>>>>>>>>>> >>> launcher. >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>>>>>> really at >>>>>>>>>>>> >>> issue. Yes >>>>>>>>>>>> >>> > >>>> we would add another arg to the JVM function to >>>>>>>>>>>> allow >>>>>>>>>>>> it to >>>>>>>>>>>> apply to >>>>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>>>>>> reflect that >>>>>>>>>>>> >>> not just >>>>>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>>>>> exported JVM >>>>>>>>>>>> >>> interface >>>>>>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>>>>>> launcher to >>>>>>>>>>>> >>> use the >>>>>>>>>>>> >>> > >>>> supported JNI interface (as other processes would), >>>>>>>>>>>> not the >>>>>>>>>>>> internal >>>>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>>>>>> communicate >>>>>>>>>>>> >>> with the >>>>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>> David >>>>>>>>>>>> >>> > >>>> ----- >>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not >>>>>>>>>>>> tagged as >>>>>>>>>>>> being a >>>>>>>>>>>> >>> JNI-attached >>>>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = false); // >>>>>>>>>>>> for main >>>>>>>>>>>> >>> thread and >>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>> behaviour by >>>>>>>>>>>> itself as >>>>>>>>>>>> >>> setName >>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>>> thread. >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>> Apr 14 >>>>>>>>>>>> 13:31:11 >>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri >>>>>>>>>>>> Apr 15 >>>>>>>>>>>> 17:50:10 >>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new >>>>>>>>>>>> JavaThread(true); >>>>>>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM initialization >>>>>>>>>>>> is complete >>>>>>>>>>>> >>> - nop if >>>>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>>>> JavaThread >>>>>>>>>>>> constructor. >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>>>>>> tracing >>>>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then >>>>>>>>>>>> it is >>>>>>>>>>>> free >>>>>>>>>>>> to do so, >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>>>>>>>> change >>>>>>>>>>>> native >>>>>>>>>>>> >>> thread name >>>>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>>>> >>> > >>>>>>> However, I think that it should be changed if >>>>>>>>>>>> Java >>>>>>>>>>>> developer >>>>>>>>>>>> >>> calls >>>>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>>>>> name at >>>>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>>>> SetNativeThreadName() as >>>>>>>>>>>> below. >>>>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> The decision to not change the name of >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> threads was a >>>>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality originated >>>>>>>>>>>> with the OSX >>>>>>>>>>>> >>> port and >>>>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback with >>>>>>>>>>>> this >>>>>>>>>>>> feature was to >>>>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that had >>>>>>>>>>>> been set by >>>>>>>>>>>> >>> the host >>>>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will >>>>>>>>>>>> just >>>>>>>>>>>> have an >>>>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: "why >>>>>>>>>>>> does my >>>>>>>>>>>> >>> native thread >>>>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>>>> discussions on >>>>>>>>>>>> this, the >>>>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>>>>>> thread only, >>>>>>>>>>>> >>> non-JNI >>>>>>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>>>>>> were supposed >>>>>>>>>>>> >>> to be >>>>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far as I >>>>>>>>>>>> can see >>>>>>>>>>>> that >>>>>>>>>>>> >>> never >>>>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>>>>>>>> desirable >>>>>>>>>>>> for >>>>>>>>>>>> the main >>>>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have native >>>>>>>>>>>> names >>>>>>>>>>>> then the >>>>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>>>> available >>>>>>>>>>>> platform >>>>>>>>>>>> >>> APIs. >>>>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as >>>>>>>>>>>> evidenced by >>>>>>>>>>>> the VM >>>>>>>>>>>> >>> code for >>>>>>>>>>>> >>> > >>>>>> this - due to the need to verify API >>>>>>>>>>>> availability. >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>>>> Thread.setName would >>>>>>>>>>>> >>> have to go >>>>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a change in >>>>>>>>>>>> the launcher >>>>>>>>>>>> >>> would >>>>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>> David >>>>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu >>>>>>>>>>>> Apr 14 >>>>>>>>>>>> 13:31:11 >>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri >>>>>>>>>>>> Apr 15 >>>>>>>>>>>> 17:50:10 >>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>>>>>>>> current >>>>>>>>>>>> thread, >>>>>>>>>>>> >>> doesn't >>>>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>>>>> thread to avoid >>>>>>>>>>>> >>> stepping >>>>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>> this. I >>>>>>>>>>>> don't like >>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>>>> initializing VM >>>>>>>>>>>> (before >>>>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>>>> AttachCurrentThread(). >>>>>>>>>>>> So we >>>>>>>>>>>> >>> can't >>>>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization earlier >>>>>>>>>>>> this >>>>>>>>>>>> morning. >>>>>>>>>>>> >>> Which, >>>>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>>>>>>>> premise >>>>>>>>>>>> here that >>>>>>>>>>>> >>> we don't >>>>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the JVM. >>>>>>>>>>>> The fact >>>>>>>>>>>> >>> that the >>>>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> thread seems >>>>>>>>>>>> >>> > >>>>>>>> accidental to me - so >>>>>>>>>>>> JVM_SetNativeThreadName is >>>>>>>>>>>> only >>>>>>>>>>>> working by >>>>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>>>>>> used for the >>>>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>>>>>> inconsistently >>>>>>>>>>>> >>> named at >>>>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher >>>>>>>>>>>> has >>>>>>>>>>>> to be >>>>>>>>>>>> >>> treated like >>>>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. If it >>>>>>>>>>>> wants to >>>>>>>>>>>> name its >>>>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, but I >>>>>>>>>>>> would not be >>>>>>>>>>>> >>> exporting >>>>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>>>>>> have to >>>>>>>>>>>> use the OS >>>>>>>>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>>>>>>>> platform-by-platform >>>>>>>>>>>> basis. >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar >>>>>>>>>>>> but >>>>>>>>>>>> perform >>>>>>>>>>>> >>> different >>>>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the current >>>>>>>>>>>> thread, the >>>>>>>>>>>> >>> second >>>>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a >>>>>>>>>>>> comment >>>>>>>>>>>> somewhere >>>>>>>>>>>> >>> about >>>>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>>>>> casts to >>>>>>>>>>>> (void*) >>>>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>> >>> used at >>>>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible >>>>>>>>>>>> keep >>>>>>>>>>>> the cast >>>>>>>>>>>> >>> on the >>>>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>> haven't had >>>>>>>>>>>> time to >>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> >>> thread >>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>> then my >>>>>>>>>>>> suggestion >>>>>>>>>>>> >>> should >>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>> in our >>>>>>>>>>>> treatment of >>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, >>>>>>>>>>>> and I >>>>>>>>>>>> confirmed >>>>>>>>>>>> >>> native >>>>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) >>>>>>>>>>>> throws >>>>>>>>>>>> Exception{ >>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>> this. I >>>>>>>>>>>> don't like >>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>>>>>> comment. >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set >>>>>>>>>>>> native >>>>>>>>>>>> thread >>>>>>>>>>>> >>> name, and JLI >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>>>>> team so >>>>>>>>>>>> >>> core-libs will >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>>>>>> Kumar) - >>>>>>>>>>>> now cc'd. >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>>>> upcall to >>>>>>>>>>>> >>> Thread.setName >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting >>>>>>>>>>>> JVM_SetNativeThreadName. No >>>>>>>>>>>> hotspot changes >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>>>>> Thread#setName() in >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread name. >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not >>>>>>>>>>>> alive, >>>>>>>>>>>> which is >>>>>>>>>>>> >>> why the >>>>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>>>> attached thread. >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>> haven't had >>>>>>>>>>>> time to >>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>>> JNI-attached >>>>>>>>>>>> >>> thread >>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>> then my >>>>>>>>>>>> suggestion >>>>>>>>>>>> >>> should >>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>> in our >>>>>>>>>>>> treatment of >>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>> this. I >>>>>>>>>>>> don't like >>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>>>>> function to set >>>>>>>>>>>> >>> native >>>>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original thread as >>>>>>>>>>>> well ... >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug (sorry >>>>>>>>>>>> have >>>>>>>>>>>> been on >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher to be >>>>>>>>>>>> correct >>>>>>>>>>>> as we >>>>>>>>>>>> >>> do not >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, >>>>>>>>>>>> which >>>>>>>>>>>> includes the >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa Suenaga >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more >>>>>>>>>>>> reviewer >>>>>>>>>>>> :-) >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> >>: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>>>>>> Suenaga >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>> >>> >>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> >>>: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>> >>>>: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you don't >>>>>>>>>>>> set it: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* >>>>>>>>>>>> main_thread = >>>>>>>>>>>> new >>>>>>>>>>>> >>> JavaThread(); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>> >>> set_active_handles >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I missing >>>>>>>>>>>> something? >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the same >>>>>>>>>>>> to thread >>>>>>>>>>>> >>> name in >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in >>>>>>>>>>>> Thread or >>>>>>>>>>>> setName(). >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in >>>>>>>>>>>> Java >>>>>>>>>>>> app, >>>>>>>>>>>> native >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main >>>>>>>>>>>> thread is >>>>>>>>>>>> already >>>>>>>>>>>> >>> starte >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is >>>>>>>>>>>> set in >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>>>> setting >>>>>>>>>>>> thrrad name >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But then >>>>>>>>>>>> something like >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>> Tue >>>>>>>>>>>> >>> Mar 29 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>> Wed >>>>>>>>>>>> >>> Mar 30 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial Thread >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>>>> create_initial_thread(Handle >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>>>> initial_thread_name = >>>>>>>>>>>> >>> "main"; >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> >>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>>>>>> (THREAD, k); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle thread_oop = >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>> >>> thread); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> JavaCalls::call_special(&result, >>>>>>>>>>>> thread_oop, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev >>>>>>>>>>>> later. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>>>>>> itself >>>>>>>>>>>> 'java' and >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to me. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of the >>>>>>>>>>>> process >>>>>>>>>>>> (and >>>>>>>>>>>> >>> thus >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is 'main'. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in the >>>>>>>>>>>> process >>>>>>>>>>>> is not >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main thread >>>>>>>>>>>> with >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is >>>>>>>>>>>> for >>>>>>>>>>>> >>> JavaThread. So I >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native >>>>>>>>>>>> main >>>>>>>>>>>> thread. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>>>>>> anyhow, since >>>>>>>>>>>> >>> we want >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>>>>>>>> thread >>>>>>>>>>>> name >>>>>>>>>>>> might >>>>>>>>>>>> >>> have >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>>>>> /proc. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid >>>>>>>>>>>> comm' >>>>>>>>>>>> | head -4 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with something >>>>>>>>>>>> like >>>>>>>>>>>> 'Java Main >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not be a >>>>>>>>>>>> Java >>>>>>>>>>>> >>> launcher - e.g. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI application, >>>>>>>>>>>> etc. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native main >>>>>>>>>>>> thread >>>>>>>>>>>> name, >>>>>>>>>>>> >>> I think >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new >>>>>>>>>>>> webrev? >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will >>>>>>>>>>>> set >>>>>>>>>>>> thread >>>>>>>>>>>> >>> name via >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>>>> does not >>>>>>>>>>>> have it. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have >>>>>>>>>>>> native >>>>>>>>>>>> name, >>>>>>>>>>>> and main >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>>>>> thread >>>>>>>>>>>> should have >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. >>>>>>>>>>>> Could >>>>>>>>>>>> you >>>>>>>>>>>> review it? >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>> >>> > >>>>>>>>>>>> >>> >>>>>>>>>>>> >>>>>>>>> >>>>>>>> From david.holmes at oracle.com Tue Apr 26 13:08:27 2016 From: david.holmes at oracle.com (David Holmes) Date: Tue, 26 Apr 2016 23:08:27 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: References: <56F3F90D.9010408@gmail.com> <570FA803.1010105@Oracle.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> <571F367B.3010200@oracle.com> Message-ID: <571F684B.9080501@oracle.com> On 26/04/2016 10:54 PM, Yasumasa Suenaga wrote: > Hi David, > > For this issue, I think we can approach as following: > > > 1. Export new JVM function to set native thread name > It can avoid JNI call and can handle char* value. > However this plan has been rejected. > > 2. Call uncaught exception handler from Launcher > We have to clear (process) any pending exception before > DetachCurrentThread() call. (not documented?) > ------ >> so note that we are potentially calling DetachCurrentThread with an >> exception pending - which is prohibited by JNI** > >> **JNI spec needs to be modified here. > ------ > So we can process pending exception through uncaught > exception handler. > However, this plan has been rejected. > > 3. Do not set DestroyJavaVM name when exception is occurred > It disrupts consistency for native thread name. > > 4. Attach to JVM to set native thread name for DestroyJavaVM > It does not look good. > > > If all of them are not accepted, I guess that it is difficult. > Do you have any other idea? Sorry I don't. The basic idea of having the launcher set the native thread name is fine, but the mechanism to do that has been problematic. The "real" solution (ie one that other applications hosting the jvm would need to use) is for the launcher to duplicate the per-platform logic for os::set_native_thread_name - but that was undesirable. Instead we have tried to avoid that by finding a way to use whatever is already in the JVM - but adding a new JVM interface to expose it directly is not ideal; and hooking into the java.lang.Thread code to avoid that has run into these other problems. I really don't want to take the logic for uncaught exception handling that is in Thread::exit and duplicate it in the launcher. The effort and disruption here really does not justify the "it would be nice to set the native thread name for the main thread" objective. I never expected this to be as problematic as it has turned out. Sorry. David ----- > > Thanks, > > Yasumasa > > > On 2016/04/26 18:35, David Holmes wrote: >> On 26/04/2016 7:22 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>>> I thought about being able to save/restore the original pending >>>> exception but could not see a simple way to restore it - ie just by >>>> poking it back into the thread's pending exception field. The problem >>>> with using env->Throw is that it acts like the initial throwing of the >>>> exception and will have a number of side-effects that then get doubled >>>> up: >>>> - logging statements (UL and Event logging) >>>> - OOM counting >>> >>> Thanks, I understood. >>> >>>>>> so note that we are potentially calling DetachCurrentThread with an >>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>> prints the exception message and stacktrace) and then clears the >>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>> exceptions.) >>> >>> I think we can call uncaught exception handler before calling >>> DestroyJavaVM(). >>> I added it in new webrev for jdk: >>> >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ >>> >>> DispatchUncaughtException() in java.c emulates uncaught exception >>> handler >>> call in JavaThread::exit(). >>> I think this patch can provide the solution for our issue. >>> >>> Could you check it? >> >> Sorry - this is getting far too disruptive. I do not support changing >> the way the main thread behaves upon completion, just because we want >> to set a native thread name. >> >> David >> ----- >> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/26 14:16, David Holmes wrote: >>>> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >>>>> Hi David, Kumar, >>>>> >>>>> I think that we should evacuate original exception before >>>>> DestroyJavaVM >>>>> thread name is set. >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >>>>> >>>>> I added it to LEAVE macro in new webrev. >>>> >>>> BTW: in the LEAVE macro, stylistically all the code should be in the >>>> do { } while(false); loop. I overlooked that initially. >>>> >>>>> I tested it with following code. It works fine. >>>>> >>>>> ------------- >>>>> public void main(String[] args){ >>>>> throw new RuntimeException("test"); >>>>> } >>>>> ------------- >>>>> >>>>> What do you think about it? >>>> >>>> I thought about being able to save/restore the original pending >>>> exception but could not see a simple way to restore it - ie just by >>>> poking it back into the thread's pending exception field. The problem >>>> with using env->Throw is that it acts like the initial throwing of the >>>> exception and will have a number of side-effects that then get doubled >>>> up: >>>> - logging statements (UL and Event logging) >>>> - OOM counting >>>> >>>> I'm not sure whether that is acceptable or not >>>> >>>> That aside you should check if orig_throwable is non-null before >>>> clearing to avoid an unnecessary JNI call. >>>> >>>> Also "Resume original exception" -> "Restore any original exception" >>>> >>>> Thanks, >>>> David >>>> ----- >>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/26 11:16, David Holmes wrote: >>>>>> Hi Yasumasa, Kumar, >>>>>> >>>>>> Turns out this change breaks the behaviour of the launcher in the >>>>>> case >>>>>> that main() completes by throwing an exception. >>>>>> >>>>>> What we have in the launcher is: >>>>>> >>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>>>>> LEAVE(); >>>>>> >>>>>> where LEAVE would have expanded to: >>>>>> >>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>> ret = 1; \ >>>>>> } \ >>>>>> if (JNI_TRUE) { \ >>>>>> (*vm)->DestroyJavaVM(vm); \ >>>>>> return ret; \ >>>>>> } \ >>>>>> >>>>>> so note that we are potentially calling DetachCurrentThread with an >>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>> prints the exception message and stacktrace) and then clears the >>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>> exceptions.) >>>>>> >>>>>> **JNI spec needs to be modified here. >>>>>> >>>>>> With the current change we have now inserted the following at the >>>>>> start of LEAVE: >>>>>> >>>>>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>> if ((*env)->ExceptionOccurred(env)) { \ >>>>>> (*env)->ExceptionClear(env); \ >>>>>> } \ >>>>>> >>>>>> this has two unintended consequences: >>>>>> >>>>>> 1. SetNativeThreadName itself calls a number of JNI methods, with the >>>>>> exception pending - which is not permitted. So straight away where we >>>>>> have: >>>>>> >>>>>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>>>> >>>>>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make >>>>>> calls >>>>>> using the VM's CHECK_NULL macro - which checks for a pending >>>>>> exception >>>>>> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >>>>>> reports a JNI error: >>>>>> >>>>>> Error: A JNI error has occurred, please check your installation and >>>>>> try again >>>>>> >>>>>> >>>>>> 2. There is no longer an exception from main() for >>>>>> DetachCurrentThread >>>>>> to report, so we exit with a return code of 1 as required, but don't >>>>>> report the exception message/stacktrace. >>>>>> >>>>>> I don't see a reasonable solution for this other than abandoning the >>>>>> attempt to change the name from "main" to "DestroyJavaVM" - which if >>>>>> we can't do, I question the utility of setting the name in the first >>>>>> place (while it might be useful in some circumstances [when main() is >>>>>> running] it will cause confusion in others [when main() has exited]). >>>>>> >>>>>> David >>>>>> ----- >>>>>> >>>>>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>>>>> Looks good to me. >>>>>>> >>>>>>> I'll sponsor this "tomorrow". >>>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> >>>>>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi Kumar, >>>>>>>> >>>>>>>> Thank you for your comment! >>>>>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>>>>> >>>>>>>> >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>>>>> >>>>>>>>> Also a couple of minor suggestions: >>>>>>>>> >>>>>>>>> - * Set native thread name as possible. >>>>>>>>> + * Set native thread name if possible. >>>>>>>>> >>>>>>>>> >>>>>>>>> + /* >>>>>>>>> - * We can clear pending exception because exception at this >>>>>>>>> point >>>>>>>>> - * is not critical. >>>>>>>>> + */ >>>>>>>>> >>>>>>>>> + /* >>>>>>>>> + * Clear non critical pending exceptions at this point. >>>>>>>>> + */ >>>>>>>>> >>>>>>>>> Thanks >>>>>>>>> Kumar >>>>>>>>> >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> This is in the wrong place: >>>>>>>>>> >>>>>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>> 1716 /* >>>>>>>>>> 1717 * We can clear pending exception because exception at >>>>>>>>>> this point >>>>>>>>>> 1718 * is not critical. >>>>>>>>>> 1719 */ >>>>>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>>>>> 1721 } >>>>>>>>>> >>>>>>>>>> This above needs to be after >>>>>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>>>>> 392 >>>>>>>>>> >>>>>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>>>>> but have also encountered an exception. In which case >>>>>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>>>>> if nothing has happened, because NULL_CHECK simply checks for >>>>>>>>>> NULL >>>>>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>>>>> the VM with exceptions. >>>>>>>>>> >>>>>>>>>> Kumar >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi David, >>>>>>>>>>> >>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>> ignore >>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>> continuing. >>>>>>>>>>> >>>>>>>>>>> I've fixed it in new webrev: >>>>>>>>>>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Hi all, >>>>>>>>>>>>> >>>>>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>> >>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>> > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Looks fine. >>>>>>>>>>>> >>>>>>>>>>>>> > >>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>> > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> As per private email (but repeated here on the record) in >>>>>>>>>>>> java.c: >>>>>>>>>>>> >>>>>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>>>>> 1717 } >>>>>>>>>>>> >>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>> ignore >>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>> continuing. >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> David >>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>>>>> >: >>>>>>>>>>>>> > >>>>>>>>>>>>> > Hi David, >>>>>>>>>>>>> > >>>>>>>>>>>>> > Thank you for your comment. >>>>>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>>>>> > >>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>> > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> > >>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>> > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>>>>> process, I >>>>>>>>>>>>> would have done it immediately after here: >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>>>>>>> before >>>>>>>>>>>>> > main method call. >>>>>>>>>>>>> > However, main thread is already started, so I moved it >>>>>>>>>>>>> as you >>>>>>>>>>>>> suggested. >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>>>> have to >>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>>>> then >>>>>>>>>>>>> calls >>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>> to a >>>>>>>>>>>>> char* ! >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > SoI proposed to export new JVM function to set native >>>>>>>>>>>>> thread >>>>>>>>>>>>> name with >>>>>>>>>>>>> > const char *. >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > Thanks, >>>>>>>>>>>>> > >>>>>>>>>>>>> > Yasumasa >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > >>>>>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Thanks for persevering with this to get it into the >>>>>>>>>>>>> current >>>>>>>>>>>>> form. >>>>>>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> Hi Gerard, >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> >>: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > ======== >>>>>>>>>>>>> >>> > File: java.c >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>>>>>> NULL_CHECK, >>>>>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> It is not critical if we encounter error at JNI function >>>>>>>>>>>>> call >>>>>>>>>>>>> because >>>>>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>>>>> process. >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> I agree we do not need to abort if an exception occurs >>>>>>>>>>>>> (and in >>>>>>>>>>>>> fact >>>>>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>>>>> but we >>>>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>>>> futher JNI >>>>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>>>> extensively >>>>>>>>>>>>> throughout the launcher code - so if this usage is wrong >>>>>>>>>>>>> then it >>>>>>>>>>>>> is all >>>>>>>>>>>>> wrong! More on this code below ... >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Other comments: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Please add a comment to the method now that you removed >>>>>>>>>>>>> the >>>>>>>>>>>>> internal >>>>>>>>>>>>> comment: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>>>>> specifically >>>>>>>>>>>>> >> // requested JNI-attached threads can also have their >>>>>>>>>>>>> native >>>>>>>>>>>>> name set; >>>>>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as >>>>>>>>>>>>> it may >>>>>>>>>>>>> interfere >>>>>>>>>>>>> >> // with the application that created them. >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> --- >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Please add the following comments: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>>>>> permitted) to >>>>>>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>>>>>> allowAttachedThread); >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> --- >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> I was going to suggest this be set later, but realized we >>>>>>>>>>>>> have >>>>>>>>>>>>> to be >>>>>>>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> The comment is redundant given the name of the method. >>>>>>>>>>>>> That >>>>>>>>>>>>> aside >>>>>>>>>>>>> I'm not sure why you do this so late in the process, I would >>>>>>>>>>>>> have >>>>>>>>>>>>> done >>>>>>>>>>>>> it immediately after here: >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>>>>> >> 388 exit(1); >>>>>>>>>>>>> >> 389 } >>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> + /** >>>>>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>>>>> >> + */ >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Other than the as->if change I'm unclear where the >>>>>>>>>>>>> "possible" >>>>>>>>>>>>> bit >>>>>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>>>>> "java/lang/Thread")); >>>>>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>>>>> cls, >>>>>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>>>>>>>>> (*env)->GetMethodID(env, >>>>>>>>>>>>> cls, >>>>>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>>>>>> name)); >>>>>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>>>>> setNativeNameID, >>>>>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> As above NULL_CHECK is fine here, but we should check for >>>>>>>>>>>>> and >>>>>>>>>>>>> clear >>>>>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>>>> have to >>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>>>> then >>>>>>>>>>>>> calls >>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>> to a >>>>>>>>>>>>> char* ! >>>>>>>>>>>>> Overall I wonder about the affect on startup cost. But if >>>>>>>>>>>>> there >>>>>>>>>>>>> is an >>>>>>>>>>>>> issue we can revisit this. >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>> >> David >>>>>>>>>>>>> >> ----- >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be >>>>>>>>>>>>> ?Set >>>>>>>>>>>>> native >>>>>>>>>>>>> thread >>>>>>>>>>>>> >>> name if possible.? not "Set native thread name as >>>>>>>>>>>>> possible.?? >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> Thanks, >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> Yasumasa >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>> > cheers >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>>>>> >>>>>>>>>>>>> >>> >> >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > Hi David, >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > - hotspot: >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > - jdk: >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>>>>> setName so I'm >>>>>>>>>>>>> >>> not sure what you were thinking here. To take advantage >>>>>>>>>>>>> of an >>>>>>>>>>>>> arg >>>>>>>>>>>>> taking >>>>>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it >>>>>>>>>>>>> directly as >>>>>>>>>>>>> no Java >>>>>>>>>>>>> >>> code will call it . ??? >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>> thread. >>>>>>>>>>>>> >>> > > This change can set native thread name if main >>>>>>>>>>>>> thread >>>>>>>>>>>>> changes to >>>>>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > Thanks, >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > Yasumasa >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > >>>>>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>> could be >>>>>>>>>>>>> considered a >>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>>>> thread >>>>>>>>>>>>> main, even >>>>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>>>> first place. >>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> I understood. >>>>>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at >>>>>>>>>>>>> Oracle.) >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would >>>>>>>>>>>>> need a >>>>>>>>>>>>> sponsor for >>>>>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>>>>> proposed change >>>>>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>>>>> restore the >>>>>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >>> I want to continue to discuss about it on >>>>>>>>>>>>> JDK-8154331 >>>>>>>>>>>>> [1]. >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the >>>>>>>>>>>>> supported >>>>>>>>>>>>> JNI >>>>>>>>>>>>> >>> interface (as >>>>>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>>>>> interface that >>>>>>>>>>>>> >>> exists for >>>>>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we >>>>>>>>>>>>> add new >>>>>>>>>>>>> method in >>>>>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>> >>> > >>> --- >>>>>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>>>>> >>> > >>> +++ >>>>>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>>>>> >>> > >>> else >>>>>>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" >>>>>>>>>>>>> + loc >>>>>>>>>>>>> + ")"; >>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>> >>> > >>> + static void setNativeThreadName(String >>>>>>>>>>>>> name) { >>>>>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>>>>> >>> > >>> + } >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >> You could also make that call via JNI directly, so >>>>>>>>>>>>> not >>>>>>>>>>>>> sure the >>>>>>>>>>>>> >>> helper adds much here. But it won't work unless you >>>>>>>>>>>>> change >>>>>>>>>>>>> the >>>>>>>>>>>>> semantics >>>>>>>>>>>>> >>> of setName so I'm not sure what you were thinking >>>>>>>>>>>>> here. To >>>>>>>>>>>>> take >>>>>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you >>>>>>>>>>>>> would >>>>>>>>>>>>> need to >>>>>>>>>>>>> call >>>>>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >> David >>>>>>>>>>>>> >>> > >> ----- >>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>> Wed >>>>>>>>>>>>> Apr 13 >>>>>>>>>>>>> 14:19:30 >>>>>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>> Sat >>>>>>>>>>>>> Apr 16 >>>>>>>>>>>>> 11:25:53 >>>>>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>>>>> doXUsage); >>>>>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>>>>> *optString); >>>>>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>>>>> *optString); >>>>>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>>>>>>> *name); >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>> >>> > >>> do { \ >>>>>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>>>>>>>>> JNI_OK) >>>>>>>>>>>>> { \ >>>>>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>>>>> argc); >>>>>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, >>>>>>>>>>>>> mainID, >>>>>>>>>>>>> mainArgs); >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>>>>> >>> > >>> joptString); >>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> +/** >>>>>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>>>>> >>> > >>> + */ >>>>>>>>>>>>> >>> > >>> +static void >>>>>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>>>>> >>> > >>> +{ >>>>>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>>>>> >>> > >>> + "setNativeThreadName", >>>>>>>>>>>>> "(Ljava/lang/String;)V")); >>>>>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = >>>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>>> name)); >>>>>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>>>>> setNativeThreadNameID, >>>>>>>>>>>>> >>> > >>> nameString); >>>>>>>>>>>>> >>> > >>> +} >>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>> >>> > >>> /* >>>>>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, >>>>>>>>>>>>> see >>>>>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> So I want to add new arg to >>>>>>>>>>>>> JVM_SetNativeThreadName(). >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>>> However this is still a change to the exported >>>>>>>>>>>>> JVM >>>>>>>>>>>>> interface and so >>>>>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> [1] >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>> false); // >>>>>>>>>>>>> for main >>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>>>>> >>> > >>>>> I will send review request to >>>>>>>>>>>>> hotspot-runtime-dev. >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>> behaviour by >>>>>>>>>>>>> itself as >>>>>>>>>>>>> >>> setName >>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>>>> thread. >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>> could be >>>>>>>>>>>>> considered a >>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>>>> thread >>>>>>>>>>>>> main, even >>>>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>>>> first place. >>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>>>>> JDK-7098194, >>>>>>>>>>>>> and it is >>>>>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in >>>>>>>>>>>>> 7u2. >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>>>>> >>> > >>>>> only. >>>>>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>>>>>> method. >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I >>>>>>>>>>>>> think we >>>>>>>>>>>>> can >>>>>>>>>>>>> add one >>>>>>>>>>>>> >>> more >>>>>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>>>>>>> from Java >>>>>>>>>>>>> >>> launcher. >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>>>>>>> really at >>>>>>>>>>>>> >>> issue. Yes >>>>>>>>>>>>> >>> > >>>> we would add another arg to the JVM function to >>>>>>>>>>>>> allow >>>>>>>>>>>>> it to >>>>>>>>>>>>> apply to >>>>>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>>>>>>> reflect that >>>>>>>>>>>>> >>> not just >>>>>>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>>>>>> exported JVM >>>>>>>>>>>>> >>> interface >>>>>>>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>>>>>>> launcher to >>>>>>>>>>>>> >>> use the >>>>>>>>>>>>> >>> > >>>> supported JNI interface (as other processes >>>>>>>>>>>>> would), >>>>>>>>>>>>> not the >>>>>>>>>>>>> internal >>>>>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>>>>>>> communicate >>>>>>>>>>>>> >>> with the >>>>>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>> David >>>>>>>>>>>>> >>> > >>>> ----- >>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not >>>>>>>>>>>>> tagged as >>>>>>>>>>>>> being a >>>>>>>>>>>>> >>> JNI-attached >>>>>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>> false); // >>>>>>>>>>>>> for main >>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>> behaviour by >>>>>>>>>>>>> itself as >>>>>>>>>>>>> >>> setName >>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>>>> thread. >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri >>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new >>>>>>>>>>>>> JavaThread(true); >>>>>>>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM >>>>>>>>>>>>> initialization >>>>>>>>>>>>> is complete >>>>>>>>>>>>> >>> - nop if >>>>>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>>>>> JavaThread >>>>>>>>>>>>> constructor. >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>>>>>>> tracing >>>>>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then >>>>>>>>>>>>> it is >>>>>>>>>>>>> free >>>>>>>>>>>>> to do so, >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>>>>>>>>> change >>>>>>>>>>>>> native >>>>>>>>>>>>> >>> thread name >>>>>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>>>>> >>> > >>>>>>> However, I think that it should be changed if >>>>>>>>>>>>> Java >>>>>>>>>>>>> developer >>>>>>>>>>>>> >>> calls >>>>>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>>>>>> name at >>>>>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>>>>> SetNativeThreadName() as >>>>>>>>>>>>> below. >>>>>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> The decision to not change the name of >>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>> threads was a >>>>>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality >>>>>>>>>>>>> originated >>>>>>>>>>>>> with the OSX >>>>>>>>>>>>> >>> port and >>>>>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback with >>>>>>>>>>>>> this >>>>>>>>>>>>> feature was to >>>>>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that >>>>>>>>>>>>> had >>>>>>>>>>>>> been set by >>>>>>>>>>>>> >>> the host >>>>>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will >>>>>>>>>>>>> just >>>>>>>>>>>>> have an >>>>>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: >>>>>>>>>>>>> "why >>>>>>>>>>>>> does my >>>>>>>>>>>>> >>> native thread >>>>>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>>>>> discussions on >>>>>>>>>>>>> this, the >>>>>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>>>>>>> thread only, >>>>>>>>>>>>> >>> non-JNI >>>>>>>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>>>>>>> were supposed >>>>>>>>>>>>> >>> to be >>>>>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far >>>>>>>>>>>>> as I >>>>>>>>>>>>> can see >>>>>>>>>>>>> that >>>>>>>>>>>>> >>> never >>>>>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>>>>>>>>> desirable >>>>>>>>>>>>> for >>>>>>>>>>>>> the main >>>>>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have >>>>>>>>>>>>> native >>>>>>>>>>>>> names >>>>>>>>>>>>> then the >>>>>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>>>>> available >>>>>>>>>>>>> platform >>>>>>>>>>>>> >>> APIs. >>>>>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as >>>>>>>>>>>>> evidenced by >>>>>>>>>>>>> the VM >>>>>>>>>>>>> >>> code for >>>>>>>>>>>>> >>> > >>>>>> this - due to the need to verify API >>>>>>>>>>>>> availability. >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>>>>> Thread.setName would >>>>>>>>>>>>> >>> have to go >>>>>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a >>>>>>>>>>>>> change in >>>>>>>>>>>>> the launcher >>>>>>>>>>>>> >>> would >>>>>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>> David >>>>>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu >>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri >>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>>>>>>>>> current >>>>>>>>>>>>> thread, >>>>>>>>>>>>> >>> doesn't >>>>>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>>>>>> thread to avoid >>>>>>>>>>>>> >>> stepping >>>>>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>>> this. I >>>>>>>>>>>>> don't like >>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>>>>> initializing VM >>>>>>>>>>>>> (before >>>>>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>>>>> AttachCurrentThread(). >>>>>>>>>>>>> So we >>>>>>>>>>>>> >>> can't >>>>>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization >>>>>>>>>>>>> earlier >>>>>>>>>>>>> this >>>>>>>>>>>>> morning. >>>>>>>>>>>>> >>> Which, >>>>>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>>>>>>>>> premise >>>>>>>>>>>>> here that >>>>>>>>>>>>> >>> we don't >>>>>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the >>>>>>>>>>>>> JVM. >>>>>>>>>>>>> The fact >>>>>>>>>>>>> >>> that the >>>>>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>> thread seems >>>>>>>>>>>>> >>> > >>>>>>>> accidental to me - so >>>>>>>>>>>>> JVM_SetNativeThreadName is >>>>>>>>>>>>> only >>>>>>>>>>>>> working by >>>>>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>>>>>>> used for the >>>>>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>>>>>>> inconsistently >>>>>>>>>>>>> >>> named at >>>>>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher >>>>>>>>>>>>> has >>>>>>>>>>>>> to be >>>>>>>>>>>>> >>> treated like >>>>>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. >>>>>>>>>>>>> If it >>>>>>>>>>>>> wants to >>>>>>>>>>>>> name its >>>>>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, >>>>>>>>>>>>> but I >>>>>>>>>>>>> would not be >>>>>>>>>>>>> >>> exporting >>>>>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>>>>>>> have to >>>>>>>>>>>>> use the OS >>>>>>>>>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>>>>>>>>> platform-by-platform >>>>>>>>>>>>> basis. >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar >>>>>>>>>>>>> but >>>>>>>>>>>>> perform >>>>>>>>>>>>> >>> different >>>>>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the >>>>>>>>>>>>> current >>>>>>>>>>>>> thread, the >>>>>>>>>>>>> >>> second >>>>>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a >>>>>>>>>>>>> comment >>>>>>>>>>>>> somewhere >>>>>>>>>>>>> >>> about >>>>>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>>>>>> casts to >>>>>>>>>>>>> (void*) >>>>>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>> >>> used at >>>>>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible >>>>>>>>>>>>> keep >>>>>>>>>>>>> the cast >>>>>>>>>>>>> >>> on the >>>>>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>>> haven't had >>>>>>>>>>>>> time to >>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>> >>> thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>> then my >>>>>>>>>>>>> suggestion >>>>>>>>>>>>> >>> should >>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>> in our >>>>>>>>>>>>> treatment of >>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, >>>>>>>>>>>>> and I >>>>>>>>>>>>> confirmed >>>>>>>>>>>>> >>> native >>>>>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) >>>>>>>>>>>>> throws >>>>>>>>>>>>> Exception{ >>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>>> this. I >>>>>>>>>>>>> don't like >>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>>>>>>> comment. >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set >>>>>>>>>>>>> native >>>>>>>>>>>>> thread >>>>>>>>>>>>> >>> name, and JLI >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>>>>>> team so >>>>>>>>>>>>> >>> core-libs will >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>>>>>>> Kumar) - >>>>>>>>>>>>> now cc'd. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>>>>> upcall to >>>>>>>>>>>>> >>> Thread.setName >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting >>>>>>>>>>>>> JVM_SetNativeThreadName. No >>>>>>>>>>>>> hotspot changes >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>>>>>> Thread#setName() in >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread >>>>>>>>>>>>> name. >>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not >>>>>>>>>>>>> alive, >>>>>>>>>>>>> which is >>>>>>>>>>>>> >>> why the >>>>>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>>>>> attached thread. >>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>>> haven't had >>>>>>>>>>>>> time to >>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>> >>> thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>> then my >>>>>>>>>>>>> suggestion >>>>>>>>>>>>> >>> should >>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>> in our >>>>>>>>>>>>> treatment of >>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>>> this. I >>>>>>>>>>>>> don't like >>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>>>>>> function to set >>>>>>>>>>>>> >>> native >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original >>>>>>>>>>>>> thread as >>>>>>>>>>>>> well ... >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug >>>>>>>>>>>>> (sorry >>>>>>>>>>>>> have >>>>>>>>>>>>> been on >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher >>>>>>>>>>>>> to be >>>>>>>>>>>>> correct >>>>>>>>>>>>> as we >>>>>>>>>>>>> >>> do not >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, >>>>>>>>>>>>> which >>>>>>>>>>>>> includes the >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa >>>>>>>>>>>>> Suenaga >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more >>>>>>>>>>>>> reviewer >>>>>>>>>>>>> :-) >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> >>: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>>>>>>> Suenaga >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>> >>> >>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> >>>: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>> >>>>: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you >>>>>>>>>>>>> don't >>>>>>>>>>>>> set it: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* >>>>>>>>>>>>> main_thread = >>>>>>>>>>>>> new >>>>>>>>>>>>> >>> JavaThread(); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>>> >>> set_active_handles >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I >>>>>>>>>>>>> missing >>>>>>>>>>>>> something? >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the >>>>>>>>>>>>> same >>>>>>>>>>>>> to thread >>>>>>>>>>>>> >>> name in >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in >>>>>>>>>>>>> Thread or >>>>>>>>>>>>> setName(). >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in >>>>>>>>>>>>> Java >>>>>>>>>>>>> app, >>>>>>>>>>>>> native >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main >>>>>>>>>>>>> thread is >>>>>>>>>>>>> already >>>>>>>>>>>>> >>> starte >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is >>>>>>>>>>>>> set in >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>>>>> setting >>>>>>>>>>>>> thrrad name >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But >>>>>>>>>>>>> then >>>>>>>>>>>>> something like >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>> Tue >>>>>>>>>>>>> >>> Mar 29 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>> Wed >>>>>>>>>>>>> >>> Mar 30 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial >>>>>>>>>>>>> Thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>>>>> create_initial_thread(Handle >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>>>>> initial_thread_name = >>>>>>>>>>>>> >>> "main"; >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>>>>>>> (THREAD, k); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle >>>>>>>>>>>>> thread_oop = >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>> >>> thread); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> JavaCalls::call_special(&result, >>>>>>>>>>>>> thread_oop, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev >>>>>>>>>>>>> later. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>>>>>>> itself >>>>>>>>>>>>> 'java' and >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to >>>>>>>>>>>>> me. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of >>>>>>>>>>>>> the >>>>>>>>>>>>> process >>>>>>>>>>>>> (and >>>>>>>>>>>>> >>> thus >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is >>>>>>>>>>>>> 'main'. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in >>>>>>>>>>>>> the >>>>>>>>>>>>> process >>>>>>>>>>>>> is not >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main >>>>>>>>>>>>> thread >>>>>>>>>>>>> with >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is >>>>>>>>>>>>> for >>>>>>>>>>>>> >>> JavaThread. So I >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native >>>>>>>>>>>>> main >>>>>>>>>>>>> thread. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>>>>>>> anyhow, since >>>>>>>>>>>>> >>> we want >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>>>>>>>>> thread >>>>>>>>>>>>> name >>>>>>>>>>>>> might >>>>>>>>>>>>> >>> have >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>>>>>> /proc. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid >>>>>>>>>>>>> comm' >>>>>>>>>>>>> | head -4 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with >>>>>>>>>>>>> something >>>>>>>>>>>>> like >>>>>>>>>>>>> 'Java Main >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not >>>>>>>>>>>>> be a >>>>>>>>>>>>> Java >>>>>>>>>>>>> >>> launcher - e.g. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI >>>>>>>>>>>>> application, >>>>>>>>>>>>> etc. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native >>>>>>>>>>>>> main >>>>>>>>>>>>> thread >>>>>>>>>>>>> name, >>>>>>>>>>>>> >>> I think >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new >>>>>>>>>>>>> webrev? >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will >>>>>>>>>>>>> set >>>>>>>>>>>>> thread >>>>>>>>>>>>> >>> name via >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>>>>> does not >>>>>>>>>>>>> have it. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have >>>>>>>>>>>>> native >>>>>>>>>>>>> name, >>>>>>>>>>>>> and main >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>>>>>> thread >>>>>>>>>>>>> should have >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. >>>>>>>>>>>>> Could >>>>>>>>>>>>> you >>>>>>>>>>>>> review it? >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>> From amy.lu at oracle.com Tue Apr 26 13:38:14 2016 From: amy.lu at oracle.com (Amy Lu) Date: Tue, 26 Apr 2016 21:38:14 +0800 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests In-Reply-To: References: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> <571F330D.6060307@oracle.com> Message-ID: <571F6F46.3090606@oracle.com> On 4/26/16 8:50 PM, Felix Yang wrote: > Hi Amy, > > thanks for pointing this out. Updated webrev: > > http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.01/ Thank you Felix for the updated webrev. This looks clear and good :-) Just one question, does this fix for all tests for jdk_rmi test group? jdk/test/java/rmi/reliability/juicer/AppleUserImpl.java does not declare java.logging dependency. Seems same to jdk/test/sun/rmi/runtime/Log/checkLogging/CheckLogging.java I did not do full check though. (It's fine if other tests are tracked by separate bugid.) As I'm not reviewer, please wait for reviewer's feedback. Thanks, Amy > > Felix > On 2016/4/26 17:21, Amy Lu wrote: >> Hi, Felix >> >> With modules declares in TEST.propertiesshould avoid have to modify >> test file one by one... Maybe I missed things please correct me. >> >> Example: >> $ cat jdk/test/java/rmi/TEST.properties >> modules = java.rmi >> >> Thanks, >> Amy >> >> On 4/26/16 4:53 PM, Felix Yang wrote: >>> Hi all, >>> >>> please review the fix to explicitly declare module dependencies >>> for rmi tests. >>> >>> Bug: https://bugs.openjdk.java.net/browse/JDK-8154733 >>> Webrev: http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.00/ >>> >>> Thanks, >>> Felix >> > From kumar.x.srinivasan at oracle.com Tue Apr 26 14:21:35 2016 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Tue, 26 Apr 2016 07:21:35 -0700 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571F684B.9080501@oracle.com> References: <56F3F90D.9010408@gmail.com> <570FB328.5020902@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> <571F367B.3010200@oracle.com> <571F684B.9080501@oracle.! com> Message-ID: <571F796F.9010301@oracle.com> On 4/26/2016 6:08 AM, David Holmes wrote: > On 26/04/2016 10:54 PM, Yasumasa Suenaga wrote: >> Hi David, >> >> For this issue, I think we can approach as following: >> >> >> 1. Export new JVM function to set native thread name >> It can avoid JNI call and can handle char* value. >> However this plan has been rejected. >> >> 2. Call uncaught exception handler from Launcher >> We have to clear (process) any pending exception before >> DetachCurrentThread() call. (not documented?) >> ------ >>> so note that we are potentially calling DetachCurrentThread with an >>> exception pending - which is prohibited by JNI** >> >>> **JNI spec needs to be modified here. >> ------ >> So we can process pending exception through uncaught >> exception handler. >> However, this plan has been rejected. >> >> 3. Do not set DestroyJavaVM name when exception is occurred >> It disrupts consistency for native thread name. >> >> 4. Attach to JVM to set native thread name for DestroyJavaVM >> It does not look good. >> >> >> If all of them are not accepted, I guess that it is difficult. >> Do you have any other idea? > > Sorry I don't. The basic idea of having the launcher set the native > thread name is fine, but the mechanism to do that has been > problematic. The "real" solution (ie one that other applications > hosting the jvm would need to use) is for the launcher to duplicate > the per-platform logic for os::set_native_thread_name - but that was > undesirable. Instead we have tried to avoid that by finding a way to > use whatever is already in the JVM - but adding a new JVM interface to > expose it directly is not ideal; and hooking into the java.lang.Thread > code to avoid that has run into these other problems. I really don't > want to take the logic for uncaught exception handling that is in > Thread::exit and duplicate it in the launcher. > > The effort and disruption here really does not justify the "it would > be nice to set the native thread name for the main thread" objective. > > I never expected this to be as problematic as it has turned out. I agree with Holmes-san, I think this needlessly complicates the launcher, more than I would like!, ie simply to set a name which seems to be useful only for folks trying to debug the VM ??? besides ps and few other OS related utils it has no visibility of value to the JRE or the JDK APIs. Thanks Kumar > > Sorry. > > David > ----- > > >> >> Thanks, >> >> Yasumasa >> >> >> On 2016/04/26 18:35, David Holmes wrote: >>> On 26/04/2016 7:22 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>>> I thought about being able to save/restore the original pending >>>>> exception but could not see a simple way to restore it - ie just by >>>>> poking it back into the thread's pending exception field. The problem >>>>> with using env->Throw is that it acts like the initial throwing of >>>>> the >>>>> exception and will have a number of side-effects that then get >>>>> doubled >>>>> up: >>>>> - logging statements (UL and Event logging) >>>>> - OOM counting >>>> >>>> Thanks, I understood. >>>> >>>>>>> so note that we are potentially calling DetachCurrentThread with an >>>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>>> prints the exception message and stacktrace) and then clears the >>>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>>> exceptions.) >>>> >>>> I think we can call uncaught exception handler before calling >>>> DestroyJavaVM(). >>>> I added it in new webrev for jdk: >>>> >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ >>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ >>>> >>>> DispatchUncaughtException() in java.c emulates uncaught exception >>>> handler >>>> call in JavaThread::exit(). >>>> I think this patch can provide the solution for our issue. >>>> >>>> Could you check it? >>> >>> Sorry - this is getting far too disruptive. I do not support changing >>> the way the main thread behaves upon completion, just because we want >>> to set a native thread name. >>> >>> David >>> ----- >>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/26 14:16, David Holmes wrote: >>>>> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >>>>>> Hi David, Kumar, >>>>>> >>>>>> I think that we should evacuate original exception before >>>>>> DestroyJavaVM >>>>>> thread name is set. >>>>>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >>>>>> >>>>>> I added it to LEAVE macro in new webrev. >>>>> >>>>> BTW: in the LEAVE macro, stylistically all the code should be in the >>>>> do { } while(false); loop. I overlooked that initially. >>>>> >>>>>> I tested it with following code. It works fine. >>>>>> >>>>>> ------------- >>>>>> public void main(String[] args){ >>>>>> throw new RuntimeException("test"); >>>>>> } >>>>>> ------------- >>>>>> >>>>>> What do you think about it? >>>>> >>>>> I thought about being able to save/restore the original pending >>>>> exception but could not see a simple way to restore it - ie just by >>>>> poking it back into the thread's pending exception field. The problem >>>>> with using env->Throw is that it acts like the initial throwing of >>>>> the >>>>> exception and will have a number of side-effects that then get >>>>> doubled >>>>> up: >>>>> - logging statements (UL and Event logging) >>>>> - OOM counting >>>>> >>>>> I'm not sure whether that is acceptable or not >>>>> >>>>> That aside you should check if orig_throwable is non-null before >>>>> clearing to avoid an unnecessary JNI call. >>>>> >>>>> Also "Resume original exception" -> "Restore any original exception" >>>>> >>>>> Thanks, >>>>> David >>>>> ----- >>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/26 11:16, David Holmes wrote: >>>>>>> Hi Yasumasa, Kumar, >>>>>>> >>>>>>> Turns out this change breaks the behaviour of the launcher in the >>>>>>> case >>>>>>> that main() completes by throwing an exception. >>>>>>> >>>>>>> What we have in the launcher is: >>>>>>> >>>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>>>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>>>>>> LEAVE(); >>>>>>> >>>>>>> where LEAVE would have expanded to: >>>>>>> >>>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>> ret = 1; \ >>>>>>> } \ >>>>>>> if (JNI_TRUE) { \ >>>>>>> (*vm)->DestroyJavaVM(vm); \ >>>>>>> return ret; \ >>>>>>> } \ >>>>>>> >>>>>>> so note that we are potentially calling DetachCurrentThread with an >>>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>>> prints the exception message and stacktrace) and then clears the >>>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>>> exceptions.) >>>>>>> >>>>>>> **JNI spec needs to be modified here. >>>>>>> >>>>>>> With the current change we have now inserted the following at the >>>>>>> start of LEAVE: >>>>>>> >>>>>>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>> if ((*env)->ExceptionOccurred(env)) { \ >>>>>>> (*env)->ExceptionClear(env); \ >>>>>>> } \ >>>>>>> >>>>>>> this has two unintended consequences: >>>>>>> >>>>>>> 1. SetNativeThreadName itself calls a number of JNI methods, >>>>>>> with the >>>>>>> exception pending - which is not permitted. So straight away >>>>>>> where we >>>>>>> have: >>>>>>> >>>>>>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>>>>> >>>>>>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make >>>>>>> calls >>>>>>> using the VM's CHECK_NULL macro - which checks for a pending >>>>>>> exception >>>>>>> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >>>>>>> reports a JNI error: >>>>>>> >>>>>>> Error: A JNI error has occurred, please check your installation and >>>>>>> try again >>>>>>> >>>>>>> >>>>>>> 2. There is no longer an exception from main() for >>>>>>> DetachCurrentThread >>>>>>> to report, so we exit with a return code of 1 as required, but >>>>>>> don't >>>>>>> report the exception message/stacktrace. >>>>>>> >>>>>>> I don't see a reasonable solution for this other than abandoning >>>>>>> the >>>>>>> attempt to change the name from "main" to "DestroyJavaVM" - >>>>>>> which if >>>>>>> we can't do, I question the utility of setting the name in the >>>>>>> first >>>>>>> place (while it might be useful in some circumstances [when >>>>>>> main() is >>>>>>> running] it will cause confusion in others [when main() has >>>>>>> exited]). >>>>>>> >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>>>>>> Looks good to me. >>>>>>>> >>>>>>>> I'll sponsor this "tomorrow". >>>>>>>> >>>>>>>> Thanks, >>>>>>>> David >>>>>>>> >>>>>>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>>>>>> Hi Kumar, >>>>>>>>> >>>>>>>>> Thank you for your comment! >>>>>>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>>>>>> >>>>>>>>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>>>>>> >>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Yasumasa >>>>>>>>> >>>>>>>>> >>>>>>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>>>>>> >>>>>>>>>> Also a couple of minor suggestions: >>>>>>>>>> >>>>>>>>>> - * Set native thread name as possible. >>>>>>>>>> + * Set native thread name if possible. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> + /* >>>>>>>>>> - * We can clear pending exception because exception at >>>>>>>>>> this >>>>>>>>>> point >>>>>>>>>> - * is not critical. >>>>>>>>>> + */ >>>>>>>>>> >>>>>>>>>> + /* >>>>>>>>>> + * Clear non critical pending exceptions at this point. >>>>>>>>>> + */ >>>>>>>>>> >>>>>>>>>> Thanks >>>>>>>>>> Kumar >>>>>>>>>> >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> This is in the wrong place: >>>>>>>>>>> >>>>>>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>> 1716 /* >>>>>>>>>>> 1717 * We can clear pending exception because >>>>>>>>>>> exception at >>>>>>>>>>> this point >>>>>>>>>>> 1718 * is not critical. >>>>>>>>>>> 1719 */ >>>>>>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>>>>>> 1721 } >>>>>>>>>>> >>>>>>>>>>> This above needs to be after >>>>>>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>>>>>> 392 >>>>>>>>>>> >>>>>>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>>>>>> but have also encountered an exception. In which case >>>>>>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>>>>>> if nothing has happened, because NULL_CHECK simply checks for >>>>>>>>>>> NULL >>>>>>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>>>>>> the VM with exceptions. >>>>>>>>>>> >>>>>>>>>>> Kumar >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>> Hi David, >>>>>>>>>>>> >>>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>>> ignore >>>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>>> continuing. >>>>>>>>>>>> >>>>>>>>>>>> I've fixed it in new webrev: >>>>>>>>>>>> >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> >>>>>>>>>>>> Yasumasa >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> Hi all, >>>>>>>>>>>>>> >>>>>>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>> >>>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Looks fine. >>>>>>>>>>>>> >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> As per private email (but repeated here on the record) in >>>>>>>>>>>>> java.c: >>>>>>>>>>>>> >>>>>>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>>>>>> 1717 } >>>>>>>>>>>>> >>>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>>> ignore >>>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>>> continuing. >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> David >>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>>>>>> >: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Hi David, >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Thank you for your comment. >>>>>>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>>>>>> process, I >>>>>>>>>>>>>> would have done it immediately after here: >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > I think that native thread name ("main") should be set >>>>>>>>>>>>>> just >>>>>>>>>>>>>> before >>>>>>>>>>>>>> > main method call. >>>>>>>>>>>>>> > However, main thread is already started, so I moved it >>>>>>>>>>>>>> as you >>>>>>>>>>>>>> suggested. >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> >> One thing I dislike about the current structure is >>>>>>>>>>>>>> that we >>>>>>>>>>>>>> have to >>>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName >>>>>>>>>>>>>> which >>>>>>>>>>>>>> then >>>>>>>>>>>>>> calls >>>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>>> to a >>>>>>>>>>>>>> char* ! >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > SoI proposed to export new JVM function to set native >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> name with >>>>>>>>>>>>>> > const char *. >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Thanks, >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > Yasumasa >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Thanks for persevering with this to get it into the >>>>>>>>>>>>>> current >>>>>>>>>>>>>> form. >>>>>>>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> Hi Gerard, >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>> > ======== >>>>>>>>>>>>>> >>> > File: java.c >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>>>>>>> NULL_CHECK, >>>>>>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> It is not critical if we encounter error at JNI >>>>>>>>>>>>>> function >>>>>>>>>>>>>> call >>>>>>>>>>>>>> because >>>>>>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>>>>>> process. >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> I agree we do not need to abort if an exception occurs >>>>>>>>>>>>>> (and in >>>>>>>>>>>>>> fact >>>>>>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>>>>>> but we >>>>>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>>>>> futher JNI >>>>>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>>>>> extensively >>>>>>>>>>>>>> throughout the launcher code - so if this usage is wrong >>>>>>>>>>>>>> then it >>>>>>>>>>>>>> is all >>>>>>>>>>>>>> wrong! More on this code below ... >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Other comments: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Please add a comment to the method now that you removed >>>>>>>>>>>>>> the >>>>>>>>>>>>>> internal >>>>>>>>>>>>>> comment: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>>>>>> specifically >>>>>>>>>>>>>> >> // requested JNI-attached threads can also have their >>>>>>>>>>>>>> native >>>>>>>>>>>>>> name set; >>>>>>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as >>>>>>>>>>>>>> it may >>>>>>>>>>>>>> interfere >>>>>>>>>>>>>> >> // with the application that created them. >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> --- >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Please add the following comments: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>>>>>> permitted) to >>>>>>>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>>>>>>> allowAttachedThread); >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> --- >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> I was going to suggest this be set later, but >>>>>>>>>>>>>> realized we >>>>>>>>>>>>>> have >>>>>>>>>>>>>> to be >>>>>>>>>>>>>> attached to do this and that happens inside >>>>>>>>>>>>>> DestroyJavaVM. :) >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> The comment is redundant given the name of the method. >>>>>>>>>>>>>> That >>>>>>>>>>>>>> aside >>>>>>>>>>>>>> I'm not sure why you do this so late in the process, I would >>>>>>>>>>>>>> have >>>>>>>>>>>>>> done >>>>>>>>>>>>>> it immediately after here: >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>>>>>> >> 388 exit(1); >>>>>>>>>>>>>> >> 389 } >>>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> + /** >>>>>>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>>>>>> >> + */ >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Other than the as->if change I'm unclear where the >>>>>>>>>>>>>> "possible" >>>>>>>>>>>>>> bit >>>>>>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>>>>>> "java/lang/Thread")); >>>>>>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>>>>>> cls, >>>>>>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>>>>>>>>>> (*env)->GetMethodID(env, >>>>>>>>>>>>>> cls, >>>>>>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>>>>>> >> 1712 NULL_CHECK(nameString = >>>>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>>>> name)); >>>>>>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>>>>>> setNativeNameID, >>>>>>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> As above NULL_CHECK is fine here, but we should check >>>>>>>>>>>>>> for >>>>>>>>>>>>>> and >>>>>>>>>>>>>> clear >>>>>>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> One thing I dislike about the current structure is >>>>>>>>>>>>>> that we >>>>>>>>>>>>>> have to >>>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName >>>>>>>>>>>>>> which >>>>>>>>>>>>>> then >>>>>>>>>>>>>> calls >>>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>>> to a >>>>>>>>>>>>>> char* ! >>>>>>>>>>>>>> Overall I wonder about the affect on startup cost. But if >>>>>>>>>>>>>> there >>>>>>>>>>>>>> is an >>>>>>>>>>>>>> issue we can revisit this. >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>> >> David >>>>>>>>>>>>>> >> ----- >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be >>>>>>>>>>>>>> ?Set >>>>>>>>>>>>>> native >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> name if possible.? not "Set native thread name as >>>>>>>>>>>>>> possible.?? >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> Thanks, >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> Yasumasa >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>> > cheers >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> >> >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > Hi David, >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > - hotspot: >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > - jdk: >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>>>>>> setName so I'm >>>>>>>>>>>>>> >>> not sure what you were thinking here. To take advantage >>>>>>>>>>>>>> of an >>>>>>>>>>>>>> arg >>>>>>>>>>>>>> taking >>>>>>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it >>>>>>>>>>>>>> directly as >>>>>>>>>>>>>> no Java >>>>>>>>>>>>>> >>> code will call it . ??? >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>> > > This change can set native thread name if main >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> changes to >>>>>>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > Thanks, >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > Yasumasa >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>>> could be >>>>>>>>>>>>>> considered a >>>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the >>>>>>>>>>>>>> native >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> main, even >>>>>>>>>>>>>> >>> > >>>> though we never really intended it to work >>>>>>>>>>>>>> in the >>>>>>>>>>>>>> first place. >>>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> I understood. >>>>>>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at >>>>>>>>>>>>>> Oracle.) >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would >>>>>>>>>>>>>> need a >>>>>>>>>>>>>> sponsor for >>>>>>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>>>>>> proposed change >>>>>>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>>>>>> restore the >>>>>>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >>> I want to continue to discuss about it on >>>>>>>>>>>>>> JDK-8154331 >>>>>>>>>>>>>> [1]. >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the >>>>>>>>>>>>>> supported >>>>>>>>>>>>>> JNI >>>>>>>>>>>>>> >>> interface (as >>>>>>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>>>>>> interface that >>>>>>>>>>>>>> >>> exists for >>>>>>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we >>>>>>>>>>>>>> add new >>>>>>>>>>>>>> method in >>>>>>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>> >>> > >>> --- >>>>>>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>>>>>> >>> > >>> +++ >>>>>>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>>>>>> >>> > >>> else >>>>>>>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" >>>>>>>>>>>>>> + loc >>>>>>>>>>>>>> + ")"; >>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>> >>> > >>> + static void setNativeThreadName(String >>>>>>>>>>>>>> name) { >>>>>>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>>>>>> >>> > >>> + } >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >> You could also make that call via JNI >>>>>>>>>>>>>> directly, so >>>>>>>>>>>>>> not >>>>>>>>>>>>>> sure the >>>>>>>>>>>>>> >>> helper adds much here. But it won't work unless you >>>>>>>>>>>>>> change >>>>>>>>>>>>>> the >>>>>>>>>>>>>> semantics >>>>>>>>>>>>>> >>> of setName so I'm not sure what you were thinking >>>>>>>>>>>>>> here. To >>>>>>>>>>>>>> take >>>>>>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you >>>>>>>>>>>>>> would >>>>>>>>>>>>>> need to >>>>>>>>>>>>>> call >>>>>>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >> David >>>>>>>>>>>>>> >>> > >> ----- >>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>> Wed >>>>>>>>>>>>>> Apr 13 >>>>>>>>>>>>>> 14:19:30 >>>>>>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>> Sat >>>>>>>>>>>>>> Apr 16 >>>>>>>>>>>>>> 11:25:53 >>>>>>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>>>>>> doXUsage); >>>>>>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>>>>>> *optString); >>>>>>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>>>>>> *optString); >>>>>>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, >>>>>>>>>>>>>> char >>>>>>>>>>>>>> *name); >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>>> >>> > >>> do { \ >>>>>>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>>>>>>>>>> JNI_OK) >>>>>>>>>>>>>> { \ >>>>>>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>>>>>> argc); >>>>>>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, >>>>>>>>>>>>>> mainID, >>>>>>>>>>>>>> mainArgs); >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>>>>>> >>> > >>> joptString); >>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> +/** >>>>>>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>>>>>> >>> > >>> + */ >>>>>>>>>>>>>> >>> > >>> +static void >>>>>>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>>>>>> >>> > >>> +{ >>>>>>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>>>>>> >>> > >>> + "setNativeThreadName", >>>>>>>>>>>>>> "(Ljava/lang/String;)V")); >>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = >>>>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>>>> name)); >>>>>>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>>>>>> setNativeThreadNameID, >>>>>>>>>>>>>> >>> > >>> nameString); >>>>>>>>>>>>>> >>> > >>> +} >>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>> >>> > >>> /* >>>>>>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, >>>>>>>>>>>>>> see >>>>>>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> So I want to add new arg to >>>>>>>>>>>>>> JVM_SetNativeThreadName(). >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>>> However this is still a change to the exported >>>>>>>>>>>>>> JVM >>>>>>>>>>>>>> interface and so >>>>>>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> [1] >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment >>>>>>>>>>>>>> here: >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>>> false); // >>>>>>>>>>>>>> for main >>>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>>>>>> >>> > >>>>> I will send review request to >>>>>>>>>>>>>> hotspot-runtime-dev. >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>>> behaviour by >>>>>>>>>>>>>> itself as >>>>>>>>>>>>>> >>> setName >>>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the >>>>>>>>>>>>>> main >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>>> could be >>>>>>>>>>>>>> considered a >>>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the >>>>>>>>>>>>>> native >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> main, even >>>>>>>>>>>>>> >>> > >>>> though we never really intended it to work >>>>>>>>>>>>>> in the >>>>>>>>>>>>>> first place. >>>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>>>>>> JDK-7098194, >>>>>>>>>>>>>> and it is >>>>>>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in >>>>>>>>>>>>>> 7u2. >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>>>>>> >>> > >>>>> only. >>>>>>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>>>>>>> method. >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I >>>>>>>>>>>>>> think we >>>>>>>>>>>>>> can >>>>>>>>>>>>>> add one >>>>>>>>>>>>>> >>> more >>>>>>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread >>>>>>>>>>>>>> name >>>>>>>>>>>>>> from Java >>>>>>>>>>>>>> >>> launcher. >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>> The private/public aspect of the Java API is >>>>>>>>>>>>>> not >>>>>>>>>>>>>> really at >>>>>>>>>>>>>> >>> issue. Yes >>>>>>>>>>>>>> >>> > >>>> we would add another arg to the JVM function to >>>>>>>>>>>>>> allow >>>>>>>>>>>>>> it to >>>>>>>>>>>>>> apply to >>>>>>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the >>>>>>>>>>>>>> arg >>>>>>>>>>>>>> reflect that >>>>>>>>>>>>>> >>> not just >>>>>>>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>>>>>>> exported JVM >>>>>>>>>>>>>> >>> interface >>>>>>>>>>>>>> >>> > >>>> and so has to be approved. Further, we >>>>>>>>>>>>>> expect the >>>>>>>>>>>>>> launcher to >>>>>>>>>>>>>> >>> use the >>>>>>>>>>>>>> >>> > >>>> supported JNI interface (as other processes >>>>>>>>>>>>>> would), >>>>>>>>>>>>>> not the >>>>>>>>>>>>>> internal >>>>>>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK >>>>>>>>>>>>>> sources to >>>>>>>>>>>>>> communicate >>>>>>>>>>>>>> >>> with the >>>>>>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>> David >>>>>>>>>>>>>> >>> > >>>> ----- >>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not >>>>>>>>>>>>>> tagged as >>>>>>>>>>>>>> being a >>>>>>>>>>>>>> >>> JNI-attached >>>>>>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment >>>>>>>>>>>>>> here: >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>>> false); // >>>>>>>>>>>>>> for main >>>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>>> behaviour by >>>>>>>>>>>>>> itself as >>>>>>>>>>>>>> >>> setName >>>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the >>>>>>>>>>>>>> main >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri >>>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new >>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new >>>>>>>>>>>>>> JavaThread(true); >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM >>>>>>>>>>>>>> initialization >>>>>>>>>>>>>> is complete >>>>>>>>>>>>>> >>> - nop if >>>>>>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>>>>>> JavaThread >>>>>>>>>>>>>> constructor. >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to >>>>>>>>>>>>>> start >>>>>>>>>>>>>> tracing >>>>>>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then >>>>>>>>>>>>>> it is >>>>>>>>>>>>>> free >>>>>>>>>>>>>> to do so, >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>>>>>>>>>> change >>>>>>>>>>>>>> native >>>>>>>>>>>>>> >>> thread name >>>>>>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>> > >>>>>>> However, I think that it should be >>>>>>>>>>>>>> changed if >>>>>>>>>>>>>> Java >>>>>>>>>>>>>> developer >>>>>>>>>>>>>> >>> calls >>>>>>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>>>>>>> name at >>>>>>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>>>>>> SetNativeThreadName() as >>>>>>>>>>>>>> below. >>>>>>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> The decision to not change the name of >>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>> threads was a >>>>>>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality >>>>>>>>>>>>>> originated >>>>>>>>>>>>>> with the OSX >>>>>>>>>>>>>> >>> port and >>>>>>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback >>>>>>>>>>>>>> with >>>>>>>>>>>>>> this >>>>>>>>>>>>>> feature was to >>>>>>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that >>>>>>>>>>>>>> had >>>>>>>>>>>>>> been set by >>>>>>>>>>>>>> >>> the host >>>>>>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will >>>>>>>>>>>>>> just >>>>>>>>>>>>>> have an >>>>>>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: >>>>>>>>>>>>>> "why >>>>>>>>>>>>>> does my >>>>>>>>>>>>>> >>> native thread >>>>>>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>>>>>> discussions on >>>>>>>>>>>>>> this, the >>>>>>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, >>>>>>>>>>>>>> current >>>>>>>>>>>>>> thread only, >>>>>>>>>>>>>> >>> non-JNI >>>>>>>>>>>>>> >>> > >>>>>> threads only) of setting the native thread >>>>>>>>>>>>>> name >>>>>>>>>>>>>> were supposed >>>>>>>>>>>>>> >>> to be >>>>>>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far >>>>>>>>>>>>>> as I >>>>>>>>>>>>>> can see >>>>>>>>>>>>>> that >>>>>>>>>>>>>> >>> never >>>>>>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>>>>>>>>>> desirable >>>>>>>>>>>>>> for >>>>>>>>>>>>>> the main >>>>>>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have >>>>>>>>>>>>>> native >>>>>>>>>>>>>> names >>>>>>>>>>>>>> then the >>>>>>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>>>>>> available >>>>>>>>>>>>>> platform >>>>>>>>>>>>>> >>> APIs. >>>>>>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as >>>>>>>>>>>>>> evidenced by >>>>>>>>>>>>>> the VM >>>>>>>>>>>>>> >>> code for >>>>>>>>>>>>>> >>> > >>>>>> this - due to the need to verify API >>>>>>>>>>>>>> availability. >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>>>>>> Thread.setName would >>>>>>>>>>>>>> >>> have to go >>>>>>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a >>>>>>>>>>>>>> change in >>>>>>>>>>>>>> the launcher >>>>>>>>>>>>>> >>> would >>>>>>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>> David >>>>>>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu >>>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri >>>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>>>>>>>>>> current >>>>>>>>>>>>>> thread, >>>>>>>>>>>>>> >>> doesn't >>>>>>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>>>>>>> thread to avoid >>>>>>>>>>>>>> >>> stepping >>>>>>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks >>>>>>>>>>>>>> about >>>>>>>>>>>>>> this. I >>>>>>>>>>>>>> don't like >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>>>>>> initializing VM >>>>>>>>>>>>>> (before >>>>>>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>>>>>> AttachCurrentThread(). >>>>>>>>>>>>>> So we >>>>>>>>>>>>>> >>> can't >>>>>>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization >>>>>>>>>>>>>> earlier >>>>>>>>>>>>>> this >>>>>>>>>>>>>> morning. >>>>>>>>>>>>>> >>> Which, >>>>>>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>>>>>>>>>> premise >>>>>>>>>>>>>> here that >>>>>>>>>>>>>> >>> we don't >>>>>>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the >>>>>>>>>>>>>> JVM. >>>>>>>>>>>>>> The fact >>>>>>>>>>>>>> >>> that the >>>>>>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>> thread seems >>>>>>>>>>>>>> >>> > >>>>>>>> accidental to me - so >>>>>>>>>>>>>> JVM_SetNativeThreadName is >>>>>>>>>>>>>> only >>>>>>>>>>>>>> working by >>>>>>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and >>>>>>>>>>>>>> can't be >>>>>>>>>>>>>> used for the >>>>>>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> inconsistently >>>>>>>>>>>>>> >>> named at >>>>>>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the >>>>>>>>>>>>>> launcher >>>>>>>>>>>>>> has >>>>>>>>>>>>>> to be >>>>>>>>>>>>>> >>> treated like >>>>>>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. >>>>>>>>>>>>>> If it >>>>>>>>>>>>>> wants to >>>>>>>>>>>>>> name its >>>>>>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, >>>>>>>>>>>>>> but I >>>>>>>>>>>>>> would not be >>>>>>>>>>>>>> >>> exporting >>>>>>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it >>>>>>>>>>>>>> would >>>>>>>>>>>>>> have to >>>>>>>>>>>>>> use the OS >>>>>>>>>>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>>>>>>>>>> platform-by-platform >>>>>>>>>>>>>> basis. >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too >>>>>>>>>>>>>> similar >>>>>>>>>>>>>> but >>>>>>>>>>>>>> perform >>>>>>>>>>>>>> >>> different >>>>>>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the >>>>>>>>>>>>>> current >>>>>>>>>>>>>> thread, the >>>>>>>>>>>>>> >>> second >>>>>>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a >>>>>>>>>>>>>> comment >>>>>>>>>>>>>> somewhere >>>>>>>>>>>>>> >>> about >>>>>>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>>>>>>> casts to >>>>>>>>>>>>>> (void*) >>>>>>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>>> >>> used at >>>>>>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible >>>>>>>>>>>>>> keep >>>>>>>>>>>>>> the cast >>>>>>>>>>>>>> >>> on the >>>>>>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>>>> haven't had >>>>>>>>>>>>>> time to >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is >>>>>>>>>>>>>> considered a >>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>> >>> thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>>> then my >>>>>>>>>>>>>> suggestion >>>>>>>>>>>>>> >>> should >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>>> in our >>>>>>>>>>>>>> treatment of >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA >>>>>>>>>>>>>> b112, >>>>>>>>>>>>>> and I >>>>>>>>>>>>>> confirmed >>>>>>>>>>>>>> >>> native >>>>>>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) >>>>>>>>>>>>>> throws >>>>>>>>>>>>>> Exception{ >>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks >>>>>>>>>>>>>> about >>>>>>>>>>>>>> this. I >>>>>>>>>>>>>> don't like >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing >>>>>>>>>>>>>> Kumar's >>>>>>>>>>>>>> comment. >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa >>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set >>>>>>>>>>>>>> native >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> name, and JLI >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>>>>>>> team so >>>>>>>>>>>>>> >>> core-libs will >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in >>>>>>>>>>>>>> particular >>>>>>>>>>>>>> Kumar) - >>>>>>>>>>>>>> now cc'd. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>>>>>> upcall to >>>>>>>>>>>>>> >>> Thread.setName >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting >>>>>>>>>>>>>> JVM_SetNativeThreadName. No >>>>>>>>>>>>>> hotspot changes >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to >>>>>>>>>>>>>> use >>>>>>>>>>>>>> Thread#setName() in >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread >>>>>>>>>>>>>> name. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not >>>>>>>>>>>>>> alive, >>>>>>>>>>>>>> which is >>>>>>>>>>>>>> >>> why the >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>>>>>> attached thread. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>>>> haven't had >>>>>>>>>>>>>> time to >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is >>>>>>>>>>>>>> considered a >>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>> >>> thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>>> then my >>>>>>>>>>>>>> suggestion >>>>>>>>>>>>>> >>> should >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>>> in our >>>>>>>>>>>>>> treatment of >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks >>>>>>>>>>>>>> about >>>>>>>>>>>>>> this. I >>>>>>>>>>>>>> don't like >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>>>>>>> function to set >>>>>>>>>>>>>> >>> native >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original >>>>>>>>>>>>>> thread as >>>>>>>>>>>>>> well ... >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug >>>>>>>>>>>>>> (sorry >>>>>>>>>>>>>> have >>>>>>>>>>>>>> been on >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher >>>>>>>>>>>>>> to be >>>>>>>>>>>>>> correct >>>>>>>>>>>>>> as we >>>>>>>>>>>>>> >>> do not >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via >>>>>>>>>>>>>> JNI, >>>>>>>>>>>>>> which >>>>>>>>>>>>>> includes the >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa >>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more >>>>>>>>>>>>>> reviewer >>>>>>>>>>>>>> :-) >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin >>>>>>>>>>>>>> Ehn >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>>: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin >>>>>>>>>>>>>> Ehn" >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>> >>>>: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you >>>>>>>>>>>>>> don't >>>>>>>>>>>>>> set it: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* >>>>>>>>>>>>>> main_thread = >>>>>>>>>>>>>> new >>>>>>>>>>>>>> >>> JavaThread(); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this >>>>>>>>>>>>>> before >>>>>>>>>>>>>> >>> set_active_handles >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I >>>>>>>>>>>>>> missing >>>>>>>>>>>>>> something? >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the >>>>>>>>>>>>>> same >>>>>>>>>>>>>> to thread >>>>>>>>>>>>>> >>> name in >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in >>>>>>>>>>>>>> Thread or >>>>>>>>>>>>>> setName(). >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new >>>>>>>>>>>>>> thread in >>>>>>>>>>>>>> Java >>>>>>>>>>>>>> app, >>>>>>>>>>>>>> native >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main >>>>>>>>>>>>>> thread is >>>>>>>>>>>>>> already >>>>>>>>>>>>>> >>> starte >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is >>>>>>>>>>>>>> set in >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>>>>>> setting >>>>>>>>>>>>>> thrrad name >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But >>>>>>>>>>>>>> then >>>>>>>>>>>>>> something like >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>> Tue >>>>>>>>>>>>>> >>> Mar 29 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>> Wed >>>>>>>>>>>>>> >>> Mar 30 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial >>>>>>>>>>>>>> Thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>>>>>> create_initial_thread(Handle >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>>>>>> initial_thread_name = >>>>>>>>>>>>>> >>> "main"; >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle >>>>>>>>>>>>>> klass >>>>>>>>>>>>>> (THREAD, k); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle >>>>>>>>>>>>>> thread_oop = >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>> >>> thread); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue >>>>>>>>>>>>>> result(T_VOID); >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> JavaCalls::call_special(&result, >>>>>>>>>>>>>> thread_oop, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new >>>>>>>>>>>>>> webrev >>>>>>>>>>>>>> later. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to >>>>>>>>>>>>>> name >>>>>>>>>>>>>> itself >>>>>>>>>>>>>> 'java' and >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to >>>>>>>>>>>>>> me. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of >>>>>>>>>>>>>> the >>>>>>>>>>>>>> process >>>>>>>>>>>>>> (and >>>>>>>>>>>>>> >>> thus >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is >>>>>>>>>>>>>> 'main'. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in >>>>>>>>>>>>>> the >>>>>>>>>>>>>> process >>>>>>>>>>>>>> is not >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> with >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> set_native_thread_name() is >>>>>>>>>>>>>> for >>>>>>>>>>>>>> >>> JavaThread. So I >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native >>>>>>>>>>>>>> main >>>>>>>>>>>>>> thread. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can >>>>>>>>>>>>>> change it >>>>>>>>>>>>>> anyhow, since >>>>>>>>>>>>>> >>> we want >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> name >>>>>>>>>>>>>> might >>>>>>>>>>>>>> >>> have >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>>>>>>> /proc. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid >>>>>>>>>>>>>> comm' >>>>>>>>>>>>>> | head -4 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with >>>>>>>>>>>>>> something >>>>>>>>>>>>>> like >>>>>>>>>>>>>> 'Java Main >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not >>>>>>>>>>>>>> be a >>>>>>>>>>>>>> Java >>>>>>>>>>>>>> >>> launcher - e.g. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI >>>>>>>>>>>>>> application, >>>>>>>>>>>>>> etc. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native >>>>>>>>>>>>>> main >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> name, >>>>>>>>>>>>>> >>> I think >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new >>>>>>>>>>>>>> webrev? >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux >>>>>>>>>>>>>> will >>>>>>>>>>>>>> set >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> name via >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>>>>>> does not >>>>>>>>>>>>>> have it. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have >>>>>>>>>>>>>> native >>>>>>>>>>>>>> name, >>>>>>>>>>>>>> and main >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>>>>>>> thread >>>>>>>>>>>>>> should have >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. >>>>>>>>>>>>>> Could >>>>>>>>>>>>>> you >>>>>>>>>>>>>> review it? >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> From andrey at tweak.su Tue Apr 26 14:25:57 2016 From: andrey at tweak.su (Andrey) Date: Tue, 26 Apr 2016 17:25:57 +0300 Subject: String.equalsIgnoreCase(...) optimization Message-ID: <753291461680757@web10h.yandex.ru> Hello!? I read source code equalsIgnoreCase(...) in String class?and saw that?it is not?optimal. This method check length and call regionMatches(...)? with 'constant' values http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/String.java#l1095? ... ? ?&& (anotherString.value.length == value.length) ? ? && regionMatches(true, 0, anotherString, 0, value.length); ... But regionMatches(...) check 'constant' values http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/String.java#l1338 // Note: toffset, ooffset, or len might be near -1>>>1. if ((ooffset < 0) || (toffset < 0) ? ? || (toffset > (long)value.length - len) ? ? || (ooffset > (long)other.value.length - len)) { ? return false; } and increment equalent variables to==po in loop http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/String.java#l1344 while (len-- > 0) { ? char c1 = ta[to++]; ? char c2 = pa[po++]; ... } and use if(...) in while loop http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/String.java#l1349 if (ignoreCase) { ... } May be?can create optimized?regionMatches(...) for use in equalsIgnoreCase(...)? From Roger.Riggs at Oracle.com Tue Apr 26 14:30:41 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 26 Apr 2016 10:30:41 -0400 Subject: UNIXProcess.toString -- include more useful information In-Reply-To: References: Message-ID: Hi, The pid (though os specific) is available from the Process API and so adding it to toString does not expose any additional implementation specific information. Getting accurate values for exitcode and running status would require a native call on windows but might be ok only for debugging. $.02, Roger On 4/25/2016 3:49 PM, Martin Buchholz wrote: > This is a reasonable request. > > But if you put platform-specific information into the String, then > people will start treating that as an API (parsing the string), which > is undesirable. > > On Mon, Apr 25, 2016 at 12:33 PM, Steven Schlansker > wrote: >> Hi core-libs-dev, >> >> I recently was diagnosing a problem relating to an external program invoked via >> the ProcessBuilder API. >> >> The returned Process is an instance of java.lang.UNIXProcess, which does >> not have a toString method. >> >> While I understand that the concepts of "pid" etc are not cross-platform, >> it might be useful to operators to have the toString method >> dump them as diagnostic information. >> >> Imagine if instead of >> >> "java.lang.UNIXProcess@" >> >> you could see >> >> "UNIXProcess[running=true, pid=1234]" >> "UNIXProcess[running=false, exitCode=127]" >> >> This seems like it would be a fairly trivial change that could help some >> operator down the road. >> >> Is this a reasonable request? Thanks, >> Steven >> From yasuenag at gmail.com Tue Apr 26 14:38:06 2016 From: yasuenag at gmail.com (Yasumasa Suenaga) Date: Tue, 26 Apr 2016 23:38:06 +0900 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <571F796F.9010301@oracle.com> References: <56F3F90D.9010408@gmail.com> <57106ED3.5090002@oracle.com> <5710AC04.3080909@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> <571F367B.3010200@oracle.com> <571F684B.9080501@oracle.! com> <571F796F.9010301@oracle.com> Message-ID: <74485460-c558-0b56-191b-07b7830834b6@gmail.com> Hi Kumar, David, > simply to set a name which seems to be useful only for folks trying to debug > the VM ??? besides ps and few other OS related utils it > has no visibility of value to the JRE or the JDK APIs. I want to check CPU time through ps command on Linux. Usually, I get "ps -eLf" and nid in threaddump to check which thread spends much CPU time. If I can get thread name from output of ps command, I can check it rapidly. So I want to set "main" name at least. Thanks, Yasumasa On 2016/04/26 23:21, Kumar Srinivasan wrote: > > On 4/26/2016 6:08 AM, David Holmes wrote: >> On 26/04/2016 10:54 PM, Yasumasa Suenaga wrote: >>> Hi David, >>> >>> For this issue, I think we can approach as following: >>> >>> >>> 1. Export new JVM function to set native thread name >>> It can avoid JNI call and can handle char* value. >>> However this plan has been rejected. >>> >>> 2. Call uncaught exception handler from Launcher >>> We have to clear (process) any pending exception before >>> DetachCurrentThread() call. (not documented?) >>> ------ >>>> so note that we are potentially calling DetachCurrentThread with an >>>> exception pending - which is prohibited by JNI** >>> >>>> **JNI spec needs to be modified here. >>> ------ >>> So we can process pending exception through uncaught >>> exception handler. >>> However, this plan has been rejected. >>> >>> 3. Do not set DestroyJavaVM name when exception is occurred >>> It disrupts consistency for native thread name. >>> >>> 4. Attach to JVM to set native thread name for DestroyJavaVM >>> It does not look good. >>> >>> >>> If all of them are not accepted, I guess that it is difficult. >>> Do you have any other idea? >> >> Sorry I don't. The basic idea of having the launcher set the native thread name is fine, but the mechanism to do that has been problematic. The "real" solution (ie one that other applications hosting the jvm would need to use) is for the launcher to duplicate the per-platform logic for os::set_native_thread_name - but that was undesirable. Instead we have tried to avoid that by finding a way to use whatever is already in the JVM - but adding a new JVM interface to expose it directly is not ideal; and hooking into the java.lang.Thread code to avoid that has run into these other problems. I really don't want to take the logic for uncaught exception handling that is in Thread::exit and duplicate it in the launcher. >> >> The effort and disruption here really does not justify the "it would be nice to set the native thread name for the main thread" objective. >> >> I never expected this to be as problematic as it has turned out. > > I agree with Holmes-san, I think this needlessly complicates > the launcher, more than I would like!, ie simply to set a name > which seems to be useful only for folks trying to debug > the VM ??? besides ps and few other OS related utils it > has no visibility of value to the JRE or the JDK APIs. > > Thanks > > Kumar > >> >> Sorry. >> >> David >> ----- >> >> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/04/26 18:35, David Holmes wrote: >>>> On 26/04/2016 7:22 PM, Yasumasa Suenaga wrote: >>>>> Hi David, >>>>> >>>>>> I thought about being able to save/restore the original pending >>>>>> exception but could not see a simple way to restore it - ie just by >>>>>> poking it back into the thread's pending exception field. The problem >>>>>> with using env->Throw is that it acts like the initial throwing of the >>>>>> exception and will have a number of side-effects that then get doubled >>>>>> up: >>>>>> - logging statements (UL and Event logging) >>>>>> - OOM counting >>>>> >>>>> Thanks, I understood. >>>>> >>>>>>>> so note that we are potentially calling DetachCurrentThread with an >>>>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>>>> prints the exception message and stacktrace) and then clears the >>>>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>>>> exceptions.) >>>>> >>>>> I think we can call uncaught exception handler before calling >>>>> DestroyJavaVM(). >>>>> I added it in new webrev for jdk: >>>>> >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ >>>>> >>>>> DispatchUncaughtException() in java.c emulates uncaught exception >>>>> handler >>>>> call in JavaThread::exit(). >>>>> I think this patch can provide the solution for our issue. >>>>> >>>>> Could you check it? >>>> >>>> Sorry - this is getting far too disruptive. I do not support changing >>>> the way the main thread behaves upon completion, just because we want >>>> to set a native thread name. >>>> >>>> David >>>> ----- >>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> On 2016/04/26 14:16, David Holmes wrote: >>>>>> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >>>>>>> Hi David, Kumar, >>>>>>> >>>>>>> I think that we should evacuate original exception before >>>>>>> DestroyJavaVM >>>>>>> thread name is set. >>>>>>> >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >>>>>>> >>>>>>> I added it to LEAVE macro in new webrev. >>>>>> >>>>>> BTW: in the LEAVE macro, stylistically all the code should be in the >>>>>> do { } while(false); loop. I overlooked that initially. >>>>>> >>>>>>> I tested it with following code. It works fine. >>>>>>> >>>>>>> ------------- >>>>>>> public void main(String[] args){ >>>>>>> throw new RuntimeException("test"); >>>>>>> } >>>>>>> ------------- >>>>>>> >>>>>>> What do you think about it? >>>>>> >>>>>> I thought about being able to save/restore the original pending >>>>>> exception but could not see a simple way to restore it - ie just by >>>>>> poking it back into the thread's pending exception field. The problem >>>>>> with using env->Throw is that it acts like the initial throwing of the >>>>>> exception and will have a number of side-effects that then get doubled >>>>>> up: >>>>>> - logging statements (UL and Event logging) >>>>>> - OOM counting >>>>>> >>>>>> I'm not sure whether that is acceptable or not >>>>>> >>>>>> That aside you should check if orig_throwable is non-null before >>>>>> clearing to avoid an unnecessary JNI call. >>>>>> >>>>>> Also "Resume original exception" -> "Restore any original exception" >>>>>> >>>>>> Thanks, >>>>>> David >>>>>> ----- >>>>>> >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Yasumasa >>>>>>> >>>>>>> >>>>>>> On 2016/04/26 11:16, David Holmes wrote: >>>>>>>> Hi Yasumasa, Kumar, >>>>>>>> >>>>>>>> Turns out this change breaks the behaviour of the launcher in the >>>>>>>> case >>>>>>>> that main() completes by throwing an exception. >>>>>>>> >>>>>>>> What we have in the launcher is: >>>>>>>> >>>>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); >>>>>>>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>>>>>>> LEAVE(); >>>>>>>> >>>>>>>> where LEAVE would have expanded to: >>>>>>>> >>>>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>> ret = 1; \ >>>>>>>> } \ >>>>>>>> if (JNI_TRUE) { \ >>>>>>>> (*vm)->DestroyJavaVM(vm); \ >>>>>>>> return ret; \ >>>>>>>> } \ >>>>>>>> >>>>>>>> so note that we are potentially calling DetachCurrentThread with an >>>>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>>>> actually rely on for desired operation as DetachCurrentThread calls >>>>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>>>> prints the exception message and stacktrace) and then clears the >>>>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>>>> exceptions.) >>>>>>>> >>>>>>>> **JNI spec needs to be modified here. >>>>>>>> >>>>>>>> With the current change we have now inserted the following at the >>>>>>>> start of LEAVE: >>>>>>>> >>>>>>>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>> if ((*env)->ExceptionOccurred(env)) { \ >>>>>>>> (*env)->ExceptionClear(env); \ >>>>>>>> } \ >>>>>>>> >>>>>>>> this has two unintended consequences: >>>>>>>> >>>>>>>> 1. SetNativeThreadName itself calls a number of JNI methods, with the >>>>>>>> exception pending - which is not permitted. So straight away where we >>>>>>>> have: >>>>>>>> >>>>>>>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>>>>>> >>>>>>>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make >>>>>>>> calls >>>>>>>> using the VM's CHECK_NULL macro - which checks for a pending >>>>>>>> exception >>>>>>>> (which it finds) and returns NULL. So the jli NULL_CHECK macro then >>>>>>>> reports a JNI error: >>>>>>>> >>>>>>>> Error: A JNI error has occurred, please check your installation and >>>>>>>> try again >>>>>>>> >>>>>>>> >>>>>>>> 2. There is no longer an exception from main() for >>>>>>>> DetachCurrentThread >>>>>>>> to report, so we exit with a return code of 1 as required, but don't >>>>>>>> report the exception message/stacktrace. >>>>>>>> >>>>>>>> I don't see a reasonable solution for this other than abandoning the >>>>>>>> attempt to change the name from "main" to "DestroyJavaVM" - which if >>>>>>>> we can't do, I question the utility of setting the name in the first >>>>>>>> place (while it might be useful in some circumstances [when main() is >>>>>>>> running] it will cause confusion in others [when main() has exited]). >>>>>>>> >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>>>>>>> Looks good to me. >>>>>>>>> >>>>>>>>> I'll sponsor this "tomorrow". >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> David >>>>>>>>> >>>>>>>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>>>>>>> Hi Kumar, >>>>>>>>>> >>>>>>>>>> Thank you for your comment! >>>>>>>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> Yasumasa >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>>>>>>> >>>>>>>>>>> Also a couple of minor suggestions: >>>>>>>>>>> >>>>>>>>>>> - * Set native thread name as possible. >>>>>>>>>>> + * Set native thread name if possible. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> + /* >>>>>>>>>>> - * We can clear pending exception because exception at this >>>>>>>>>>> point >>>>>>>>>>> - * is not critical. >>>>>>>>>>> + */ >>>>>>>>>>> >>>>>>>>>>> + /* >>>>>>>>>>> + * Clear non critical pending exceptions at this point. >>>>>>>>>>> + */ >>>>>>>>>>> >>>>>>>>>>> Thanks >>>>>>>>>>> Kumar >>>>>>>>>>> >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> This is in the wrong place: >>>>>>>>>>>> >>>>>>>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>>> 1716 /* >>>>>>>>>>>> 1717 * We can clear pending exception because exception at >>>>>>>>>>>> this point >>>>>>>>>>>> 1718 * is not critical. >>>>>>>>>>>> 1719 */ >>>>>>>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>>>>>>> 1721 } >>>>>>>>>>>> >>>>>>>>>>>> This above needs to be after >>>>>>>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>>>>>>> 392 >>>>>>>>>>>> >>>>>>>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>>>>>>> but have also encountered an exception. In which case >>>>>>>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>>>>>>> if nothing has happened, because NULL_CHECK simply checks for >>>>>>>>>>>> NULL >>>>>>>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>>>>>>> the VM with exceptions. >>>>>>>>>>>> >>>>>>>>>>>> Kumar >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>> Hi David, >>>>>>>>>>>>> >>>>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>>>> ignore >>>>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>>>> continuing. >>>>>>>>>>>>> >>>>>>>>>>>>> I've fixed it in new webrev: >>>>>>>>>>>>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> Hi all, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Looks fine. >>>>>>>>>>>>>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> As per private email (but repeated here on the record) in >>>>>>>>>>>>>> java.c: >>>>>>>>>>>>>> >>>>>>>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>>>>>>> 1717 } >>>>>>>>>>>>>> >>>>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>>>> ignore >>>>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>>>> continuing. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> David >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>>>>>>> >: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Hi David, >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Thank you for your comment. >>>>>>>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>>>>>>> process, I >>>>>>>>>>>>>>> would have done it immediately after here: >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > I think that native thread name ("main") should be set just >>>>>>>>>>>>>>> before >>>>>>>>>>>>>>> > main method call. >>>>>>>>>>>>>>> > However, main thread is already started, so I moved it >>>>>>>>>>>>>>> as you >>>>>>>>>>>>>>> suggested. >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>>>>>> then >>>>>>>>>>>>>>> calls >>>>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>>>> to a >>>>>>>>>>>>>>> char* ! >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > SoI proposed to export new JVM function to set native >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> name with >>>>>>>>>>>>>>> > const char *. >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Thanks, >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > Yasumasa >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Thanks for persevering with this to get it into the >>>>>>>>>>>>>>> current >>>>>>>>>>>>>>> form. >>>>>>>>>>>>>>> Sorry I haven't been able to do a detailed review until now. >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> Hi Gerard, >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > ======== >>>>>>>>>>>>>>> >>> > File: java.c >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>>>>>> >>> after every single JNI call? In this example instead of >>>>>>>>>>>>>>> NULL_CHECK, >>>>>>>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> It is not critical if we encounter error at JNI function >>>>>>>>>>>>>>> call >>>>>>>>>>>>>>> because >>>>>>>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>>>>>>> process. >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> I agree we do not need to abort if an exception occurs >>>>>>>>>>>>>>> (and in >>>>>>>>>>>>>>> fact >>>>>>>>>>>>>>> I don't think an exception is even possible from this code), >>>>>>>>>>>>>>> but we >>>>>>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>>>>>> futher JNI >>>>>>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>>>>>> extensively >>>>>>>>>>>>>>> throughout the launcher code - so if this usage is wrong >>>>>>>>>>>>>>> then it >>>>>>>>>>>>>>> is all >>>>>>>>>>>>>>> wrong! More on this code below ... >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Other comments: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Please add a comment to the method now that you removed >>>>>>>>>>>>>>> the >>>>>>>>>>>>>>> internal >>>>>>>>>>>>>>> comment: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>>>>>>> specifically >>>>>>>>>>>>>>> >> // requested JNI-attached threads can also have their >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> name set; >>>>>>>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as >>>>>>>>>>>>>>> it may >>>>>>>>>>>>>>> interfere >>>>>>>>>>>>>>> >> // with the application that created them. >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> --- >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Please add the following comments: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>>>>>>> permitted) to >>>>>>>>>>>>>>> >> + // allow JNI-attached threads to set their native name >>>>>>>>>>>>>>> >> private native void setNativeName(String name, boolean >>>>>>>>>>>>>>> allowAttachedThread); >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> --- >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> I was going to suggest this be set later, but realized we >>>>>>>>>>>>>>> have >>>>>>>>>>>>>>> to be >>>>>>>>>>>>>>> attached to do this and that happens inside DestroyJavaVM. :) >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> The comment is redundant given the name of the method. >>>>>>>>>>>>>>> That >>>>>>>>>>>>>>> aside >>>>>>>>>>>>>>> I'm not sure why you do this so late in the process, I would >>>>>>>>>>>>>>> have >>>>>>>>>>>>>>> done >>>>>>>>>>>>>>> it immediately after here: >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>>>>>>> >> 388 exit(1); >>>>>>>>>>>>>>> >> 389 } >>>>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> + /** >>>>>>>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>>>>>>> >> + */ >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Other than the as->if change I'm unclear where the >>>>>>>>>>>>>>> "possible" >>>>>>>>>>>>>>> bit >>>>>>>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>>>>>>> "java/lang/Thread")); >>>>>>>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>>>>>>> cls, >>>>>>>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>>>>>>>>>>> (*env)->GetMethodID(env, >>>>>>>>>>>>>>> cls, >>>>>>>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>>>>>>> >> 1712 NULL_CHECK(nameString = (*env)->NewStringUTF(env, >>>>>>>>>>>>>>> name)); >>>>>>>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>>>>>>> setNativeNameID, >>>>>>>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> As above NULL_CHECK is fine here, but we should check for >>>>>>>>>>>>>>> and >>>>>>>>>>>>>>> clear >>>>>>>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> One thing I dislike about the current structure is that we >>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName which >>>>>>>>>>>>>>> then >>>>>>>>>>>>>>> calls >>>>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>>>> to a >>>>>>>>>>>>>>> char* ! >>>>>>>>>>>>>>> Overall I wonder about the affect on startup cost. But if >>>>>>>>>>>>>>> there >>>>>>>>>>>>>>> is an >>>>>>>>>>>>>>> issue we can revisit this. >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>> >> David >>>>>>>>>>>>>>> >> ----- >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be >>>>>>>>>>>>>>> ?Set >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> >>> name if possible.? not "Set native thread name as >>>>>>>>>>>>>>> possible.?? >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> Thanks, >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> Yasumasa >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>> > cheers >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >> >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > Hi David, >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > - hotspot: >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > - jdk: >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>>>>>>> setName so I'm >>>>>>>>>>>>>>> >>> not sure what you were thinking here. To take advantage >>>>>>>>>>>>>>> of an >>>>>>>>>>>>>>> arg >>>>>>>>>>>>>>> taking >>>>>>>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it >>>>>>>>>>>>>>> directly as >>>>>>>>>>>>>>> no Java >>>>>>>>>>>>>>> >>> code will call it . ??? >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>> >>> > > This change can set native thread name if main >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> changes to >>>>>>>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > Thanks, >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > Yasumasa >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>>>> could be >>>>>>>>>>>>>>> considered a >>>>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> main, even >>>>>>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>>>>>> first place. >>>>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> I understood. >>>>>>>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at >>>>>>>>>>>>>>> Oracle.) >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would >>>>>>>>>>>>>>> need a >>>>>>>>>>>>>>> sponsor for >>>>>>>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>>>>>>> proposed change >>>>>>>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>>>>>>> restore the >>>>>>>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >>> I want to continue to discuss about it on >>>>>>>>>>>>>>> JDK-8154331 >>>>>>>>>>>>>>> [1]. >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the >>>>>>>>>>>>>>> supported >>>>>>>>>>>>>>> JNI >>>>>>>>>>>>>>> >>> interface (as >>>>>>>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>>>>>>> interface that >>>>>>>>>>>>>>> >>> exists for >>>>>>>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we >>>>>>>>>>>>>>> add new >>>>>>>>>>>>>>> method in >>>>>>>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>>> >>> > >>> --- >>>>>>>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>>>>>>> >>> > >>> +++ >>>>>>>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>>>>>>> >>> > >>> else >>>>>>>>>>>>>>> >>> > >>> return md.toNameAndVersion() + " (" >>>>>>>>>>>>>>> + loc >>>>>>>>>>>>>>> + ")"; >>>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>>> >>> > >>> + static void setNativeThreadName(String >>>>>>>>>>>>>>> name) { >>>>>>>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>>>>>>> >>> > >>> + } >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >> You could also make that call via JNI directly, so >>>>>>>>>>>>>>> not >>>>>>>>>>>>>>> sure the >>>>>>>>>>>>>>> >>> helper adds much here. But it won't work unless you >>>>>>>>>>>>>>> change >>>>>>>>>>>>>>> the >>>>>>>>>>>>>>> semantics >>>>>>>>>>>>>>> >>> of setName so I'm not sure what you were thinking >>>>>>>>>>>>>>> here. To >>>>>>>>>>>>>>> take >>>>>>>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you >>>>>>>>>>>>>>> would >>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>> call >>>>>>>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >> David >>>>>>>>>>>>>>> >>> > >> ----- >>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>> Wed >>>>>>>>>>>>>>> Apr 13 >>>>>>>>>>>>>>> 14:19:30 >>>>>>>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>> Sat >>>>>>>>>>>>>>> Apr 16 >>>>>>>>>>>>>>> 11:25:53 >>>>>>>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>>>>>>> doXUsage); >>>>>>>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>>>>>>> *optString); >>>>>>>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>>>>>>> *optString); >>>>>>>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* env, char >>>>>>>>>>>>>>> *name); >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>>>> >>> > >>> do { \ >>>>>>>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>>>>>>>>>>> JNI_OK) >>>>>>>>>>>>>>> { \ >>>>>>>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>>>>>>> argc); >>>>>>>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, >>>>>>>>>>>>>>> mainID, >>>>>>>>>>>>>>> mainArgs); >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>>>>>>> >>> > >>> joptString); >>>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> +/** >>>>>>>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>>>>>>> >>> > >>> + */ >>>>>>>>>>>>>>> >>> > >>> +static void >>>>>>>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>>>>>>> >>> > >>> +{ >>>>>>>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>>>>>>> >>> > >>> + "setNativeThreadName", >>>>>>>>>>>>>>> "(Ljava/lang/String;)V")); >>>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = >>>>>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>>>>> name)); >>>>>>>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>>>>>>> setNativeThreadNameID, >>>>>>>>>>>>>>> >>> > >>> nameString); >>>>>>>>>>>>>>> >>> > >>> +} >>>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>>> >>> > >>> /* >>>>>>>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, >>>>>>>>>>>>>>> see >>>>>>>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> So I want to add new arg to >>>>>>>>>>>>>>> JVM_SetNativeThreadName(). >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>>> However this is still a change to the exported >>>>>>>>>>>>>>> JVM >>>>>>>>>>>>>>> interface and so >>>>>>>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> [1] >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>>>> false); // >>>>>>>>>>>>>>> for main >>>>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>>>>>>> >>> > >>>>> I will send review request to >>>>>>>>>>>>>>> hotspot-runtime-dev. >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>>>> behaviour by >>>>>>>>>>>>>>> itself as >>>>>>>>>>>>>>> >>> setName >>>>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>>>> could be >>>>>>>>>>>>>>> considered a >>>>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the native >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> main, even >>>>>>>>>>>>>>> >>> > >>>> though we never really intended it to work in the >>>>>>>>>>>>>>> first place. >>>>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>>>>>>> JDK-7098194, >>>>>>>>>>>>>>> and it is >>>>>>>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX port in >>>>>>>>>>>>>>> 7u2. >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>>> However, this function seems to be called from >>>>>>>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>>>>>>> >>> > >>>>> only. >>>>>>>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is private >>>>>>>>>>>>>>> method. >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I >>>>>>>>>>>>>>> think we >>>>>>>>>>>>>>> can >>>>>>>>>>>>>>> add one >>>>>>>>>>>>>>> >>> more >>>>>>>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>>>>>>> >>> > >>>>> If it is accepted, we can set native thread name >>>>>>>>>>>>>>> from Java >>>>>>>>>>>>>>> >>> launcher. >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>> The private/public aspect of the Java API is not >>>>>>>>>>>>>>> really at >>>>>>>>>>>>>>> >>> issue. Yes >>>>>>>>>>>>>>> >>> > >>>> we would add another arg to the JVM function to >>>>>>>>>>>>>>> allow >>>>>>>>>>>>>>> it to >>>>>>>>>>>>>>> apply to >>>>>>>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer the arg >>>>>>>>>>>>>>> reflect that >>>>>>>>>>>>>>> >>> not just >>>>>>>>>>>>>>> >>> > >>>> "force"). However this is still a change to the >>>>>>>>>>>>>>> exported JVM >>>>>>>>>>>>>>> >>> interface >>>>>>>>>>>>>>> >>> > >>>> and so has to be approved. Further, we expect the >>>>>>>>>>>>>>> launcher to >>>>>>>>>>>>>>> >>> use the >>>>>>>>>>>>>>> >>> > >>>> supported JNI interface (as other processes >>>>>>>>>>>>>>> would), >>>>>>>>>>>>>>> not the >>>>>>>>>>>>>>> internal >>>>>>>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK sources to >>>>>>>>>>>>>>> communicate >>>>>>>>>>>>>>> >>> with the >>>>>>>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>> David >>>>>>>>>>>>>>> >>> > >>>> ----- >>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not >>>>>>>>>>>>>>> tagged as >>>>>>>>>>>>>>> being a >>>>>>>>>>>>>>> >>> JNI-attached >>>>>>>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment here: >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>>>> false); // >>>>>>>>>>>>>>> for main >>>>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>>>> behaviour by >>>>>>>>>>>>>>> itself as >>>>>>>>>>>>>>> >>> setName >>>>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for the main >>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri >>>>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os thread >>>>>>>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new JavaThread(); >>>>>>>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new >>>>>>>>>>>>>>> JavaThread(true); >>>>>>>>>>>>>>> >>> > >>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>>> >>> > >>>>>>> // must do this before set_active_handles >>>>>>>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM >>>>>>>>>>>>>>> initialization >>>>>>>>>>>>>>> is complete >>>>>>>>>>>>>>> >>> - nop if >>>>>>>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>>>>>>> >>> > >>>>>>> + main_thread->set_done_attaching_via_jni(); >>>>>>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>>>>>>> JavaThread >>>>>>>>>>>>>>> constructor. >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to start >>>>>>>>>>>>>>> tracing >>>>>>>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads then >>>>>>>>>>>>>>> it is >>>>>>>>>>>>>>> free >>>>>>>>>>>>>>> to do so, >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>>>>>>>>>>> change >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> >>> thread name >>>>>>>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached thread. >>>>>>>>>>>>>>> >>> > >>>>>>> However, I think that it should be changed if >>>>>>>>>>>>>>> Java >>>>>>>>>>>>>>> developer >>>>>>>>>>>>>>> >>> calls >>>>>>>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>>>>>>> >>> > >>>>>>> It is not the same of changing native thread >>>>>>>>>>>>>>> name at >>>>>>>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>>>>>>> SetNativeThreadName() as >>>>>>>>>>>>>>> below. >>>>>>>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> The decision to not change the name of >>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>> threads was a >>>>>>>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality >>>>>>>>>>>>>>> originated >>>>>>>>>>>>>>> with the OSX >>>>>>>>>>>>>>> >>> port and >>>>>>>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback with >>>>>>>>>>>>>>> this >>>>>>>>>>>>>>> feature was to >>>>>>>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that >>>>>>>>>>>>>>> had >>>>>>>>>>>>>>> been set by >>>>>>>>>>>>>>> >>> the host >>>>>>>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we will >>>>>>>>>>>>>>> just >>>>>>>>>>>>>>> have an >>>>>>>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: >>>>>>>>>>>>>>> "why >>>>>>>>>>>>>>> does my >>>>>>>>>>>>>>> >>> native thread >>>>>>>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>>>>>>> discussions on >>>>>>>>>>>>>>> this, the >>>>>>>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, current >>>>>>>>>>>>>>> thread only, >>>>>>>>>>>>>>> >>> non-JNI >>>>>>>>>>>>>>> >>> > >>>>>> threads only) of setting the native thread name >>>>>>>>>>>>>>> were supposed >>>>>>>>>>>>>>> >>> to be >>>>>>>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far >>>>>>>>>>>>>>> as I >>>>>>>>>>>>>>> can see >>>>>>>>>>>>>>> that >>>>>>>>>>>>>>> >>> never >>>>>>>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>>>>>>>>>>> desirable >>>>>>>>>>>>>>> for >>>>>>>>>>>>>>> the main >>>>>>>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> names >>>>>>>>>>>>>>> then the >>>>>>>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>>>>>>> available >>>>>>>>>>>>>>> platform >>>>>>>>>>>>>>> >>> APIs. >>>>>>>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as >>>>>>>>>>>>>>> evidenced by >>>>>>>>>>>>>>> the VM >>>>>>>>>>>>>>> >>> code for >>>>>>>>>>>>>>> >>> > >>>>>> this - due to the need to verify API >>>>>>>>>>>>>>> availability. >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>>>>>>> Thread.setName would >>>>>>>>>>>>>>> >>> have to go >>>>>>>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a >>>>>>>>>>>>>>> change in >>>>>>>>>>>>>>> the launcher >>>>>>>>>>>>>>> >>> would >>>>>>>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>> David >>>>>>>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu >>>>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri >>>>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>>>>>>>>>>> current >>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>> >>> doesn't >>>>>>>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>>>>>> >>> > >>>>>>> // we don't set the name of an attached >>>>>>>>>>>>>>> thread to avoid >>>>>>>>>>>>>>> >>> stepping >>>>>>>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>>>>> this. I >>>>>>>>>>>>>>> don't like >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>>>>>>> initializing VM >>>>>>>>>>>>>>> (before >>>>>>>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>>>>>>> AttachCurrentThread(). >>>>>>>>>>>>>>> So we >>>>>>>>>>>>>>> >>> can't >>>>>>>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization >>>>>>>>>>>>>>> earlier >>>>>>>>>>>>>>> this >>>>>>>>>>>>>>> morning. >>>>>>>>>>>>>>> >>> Which, >>>>>>>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>>>>>>>>>>> premise >>>>>>>>>>>>>>> here that >>>>>>>>>>>>>>> >>> we don't >>>>>>>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the >>>>>>>>>>>>>>> JVM. >>>>>>>>>>>>>>> The fact >>>>>>>>>>>>>>> >>> that the >>>>>>>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>> thread seems >>>>>>>>>>>>>>> >>> > >>>>>>>> accidental to me - so >>>>>>>>>>>>>>> JVM_SetNativeThreadName is >>>>>>>>>>>>>>> only >>>>>>>>>>>>>>> working by >>>>>>>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and can't be >>>>>>>>>>>>>>> used for the >>>>>>>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the thread >>>>>>>>>>>>>>> inconsistently >>>>>>>>>>>>>>> >>> named at >>>>>>>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the launcher >>>>>>>>>>>>>>> has >>>>>>>>>>>>>>> to be >>>>>>>>>>>>>>> >>> treated like >>>>>>>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. >>>>>>>>>>>>>>> If it >>>>>>>>>>>>>>> wants to >>>>>>>>>>>>>>> name its >>>>>>>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, >>>>>>>>>>>>>>> but I >>>>>>>>>>>>>>> would not be >>>>>>>>>>>>>>> >>> exporting >>>>>>>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it would >>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>> use the OS >>>>>>>>>>>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>>>>>>>>>>> platform-by-platform >>>>>>>>>>>>>>> basis. >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too similar >>>>>>>>>>>>>>> but >>>>>>>>>>>>>>> perform >>>>>>>>>>>>>>> >>> different >>>>>>>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the >>>>>>>>>>>>>>> current >>>>>>>>>>>>>>> thread, the >>>>>>>>>>>>>>> >>> second >>>>>>>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a >>>>>>>>>>>>>>> comment >>>>>>>>>>>>>>> somewhere >>>>>>>>>>>>>>> >>> about >>>>>>>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line 408 >>>>>>>>>>>>>>> casts to >>>>>>>>>>>>>>> (void*) >>>>>>>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>>>> >>> used at >>>>>>>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if possible >>>>>>>>>>>>>>> keep >>>>>>>>>>>>>>> the cast >>>>>>>>>>>>>>> >>> on the >>>>>>>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>>>>> haven't had >>>>>>>>>>>>>>> time to >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>> >>> thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>>>> then my >>>>>>>>>>>>>>> suggestion >>>>>>>>>>>>>>> >>> should >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>>>> in our >>>>>>>>>>>>>>> treatment of >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA b112, >>>>>>>>>>>>>>> and I >>>>>>>>>>>>>>> confirmed >>>>>>>>>>>>>>> >>> native >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) >>>>>>>>>>>>>>> throws >>>>>>>>>>>>>>> Exception{ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>>>>> this. I >>>>>>>>>>>>>>> don't like >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing Kumar's >>>>>>>>>>>>>>> comment. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa Suenaga >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa Suenaga >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> >>> name, and JLI >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to another >>>>>>>>>>>>>>> team so >>>>>>>>>>>>>>> >>> core-libs will >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in particular >>>>>>>>>>>>>>> Kumar) - >>>>>>>>>>>>>>> now cc'd. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>>>>>>> upcall to >>>>>>>>>>>>>>> >>> Thread.setName >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting >>>>>>>>>>>>>>> JVM_SetNativeThreadName. No >>>>>>>>>>>>>>> hotspot changes >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed to use >>>>>>>>>>>>>>> Thread#setName() in >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread >>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not >>>>>>>>>>>>>>> alive, >>>>>>>>>>>>>>> which is >>>>>>>>>>>>>>> >>> why the >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>>>>>>> attached thread. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question which I >>>>>>>>>>>>>>> haven't had >>>>>>>>>>>>>>> time to >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is considered a >>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>> >>> thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>>>> then my >>>>>>>>>>>>>>> suggestion >>>>>>>>>>>>>>> >>> should >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>>>> in our >>>>>>>>>>>>>>> treatment of >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks about >>>>>>>>>>>>>>> this. I >>>>>>>>>>>>>>> don't like >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to provide a >>>>>>>>>>>>>>> function to set >>>>>>>>>>>>>>> >>> native >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original >>>>>>>>>>>>>>> thread as >>>>>>>>>>>>>>> well ... >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug >>>>>>>>>>>>>>> (sorry >>>>>>>>>>>>>>> have >>>>>>>>>>>>>>> been on >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher >>>>>>>>>>>>>>> to be >>>>>>>>>>>>>>> correct >>>>>>>>>>>>>>> as we >>>>>>>>>>>>>>> >>> do not >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via JNI, >>>>>>>>>>>>>>> which >>>>>>>>>>>>>>> includes the >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa >>>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more >>>>>>>>>>>>>>> reviewer >>>>>>>>>>>>>>> :-) >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, Robbin Ehn >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, Yasumasa >>>>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin Ehn >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, Yasumasa >>>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin Ehn" >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>>: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 "Robbin Ehn" >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>> >>>>: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you >>>>>>>>>>>>>>> don't >>>>>>>>>>>>>>> set it: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* >>>>>>>>>>>>>>> main_thread = >>>>>>>>>>>>>>> new >>>>>>>>>>>>>>> >>> JavaThread(); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this before >>>>>>>>>>>>>>> >>> set_active_handles >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I >>>>>>>>>>>>>>> missing >>>>>>>>>>>>>>> something? >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the >>>>>>>>>>>>>>> same >>>>>>>>>>>>>>> to thread >>>>>>>>>>>>>>> >>> name in >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in >>>>>>>>>>>>>>> Thread or >>>>>>>>>>>>>>> setName(). >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new thread in >>>>>>>>>>>>>>> Java >>>>>>>>>>>>>>> app, >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main >>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>> already >>>>>>>>>>>>>>> >>> starte >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is >>>>>>>>>>>>>>> set in >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>>>>>>> setting >>>>>>>>>>>>>>> thrrad name >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But >>>>>>>>>>>>>>> then >>>>>>>>>>>>>>> something like >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>> Tue >>>>>>>>>>>>>>> >>> Mar 29 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>> Wed >>>>>>>>>>>>>>> >>> Mar 30 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial >>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>>>>>>> create_initial_thread(Handle >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>>>>>>> initial_thread_name = >>>>>>>>>>>>>>> >>> "main"; >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle klass >>>>>>>>>>>>>>> (THREAD, k); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle >>>>>>>>>>>>>>> thread_oop = >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>> >>> thread); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue result(T_VOID); >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> JavaCalls::call_special(&result, >>>>>>>>>>>>>>> thread_oop, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new webrev >>>>>>>>>>>>>>> later. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem to name >>>>>>>>>>>>>>> itself >>>>>>>>>>>>>>> 'java' and >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to >>>>>>>>>>>>>>> me. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of >>>>>>>>>>>>>>> the >>>>>>>>>>>>>>> process >>>>>>>>>>>>>>> (and >>>>>>>>>>>>>>> >>> thus >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is >>>>>>>>>>>>>>> 'main'. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in >>>>>>>>>>>>>>> the >>>>>>>>>>>>>>> process >>>>>>>>>>>>>>> is not >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> with >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> set_native_thread_name() is >>>>>>>>>>>>>>> for >>>>>>>>>>>>>>> >>> JavaThread. So I >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for native >>>>>>>>>>>>>>> main >>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can change it >>>>>>>>>>>>>>> anyhow, since >>>>>>>>>>>>>>> >>> we want >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> name >>>>>>>>>>>>>>> might >>>>>>>>>>>>>>> >>> have >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in e.g. >>>>>>>>>>>>>>> /proc. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid >>>>>>>>>>>>>>> comm' >>>>>>>>>>>>>>> | head -4 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with >>>>>>>>>>>>>>> something >>>>>>>>>>>>>>> like >>>>>>>>>>>>>>> 'Java Main >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not >>>>>>>>>>>>>>> be a >>>>>>>>>>>>>>> Java >>>>>>>>>>>>>>> >>> launcher - e.g. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI >>>>>>>>>>>>>>> application, >>>>>>>>>>>>>>> etc. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native >>>>>>>>>>>>>>> main >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> name, >>>>>>>>>>>>>>> >>> I think >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new >>>>>>>>>>>>>>> webrev? >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 PM, >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux will >>>>>>>>>>>>>>> set >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> >>> name via >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>>>>>>> does not >>>>>>>>>>>>>>> have it. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have >>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> name, >>>>>>>>>>>>>>> and main >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, main >>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> should have >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. >>>>>>>>>>>>>>> Could >>>>>>>>>>>>>>> you >>>>>>>>>>>>>>> review it? >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access JPRT. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> > From peter.levart at gmail.com Tue Apr 26 14:42:58 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 26 Apr 2016 16:42:58 +0200 Subject: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe In-Reply-To: <571E147A.3040609@oracle.com> References: <5718FADF.5000601@gmail.com> <5718FE23.3070808@oracle.com> <2CE30172-D616-4C9A-94C7-5F2436979B06@univ-mlv.fr> <57193B06.8040200@oracle.com> <571A2A61.9050908@gmail.com> <571C80D9.5070709@oracle.com> <571DFBE1.3030906@gmail.com> <571E147A.3040609@oracle.com> Message-ID: <571F7E72.9050902@gmail.com> Hi Alan, On 04/25/2016 02:58 PM, Alan Bateman wrote: > On 25/04/2016 12:13, Peter Levart wrote: >> Hi Alan, >> >> I created an issue for this: >> >> JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe >> >> https://bugs.openjdk.java.net/browse/JDK-8155005 >> >> >> I did what you suggested, renamed type parameters to , >> split long line in Module and modified the test so that it now waits >> for entry to be expunged for up to 5 seconds when it is expected to >> be expunged but returns as soon as it detects that the entry is gone >> (usually in 1st 100 ms). It still waits just 500 ms when the entry is >> expected to remain in the map. False negatives should be eliminated >> this way and the test still doesn't waist plenty of execution time. >> >> Here's latest webrev: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.04/ >> > I think using makes it a lot more readable - thanks. > > On gcAndWaitRemoved then I wonder if it would be more robust to have a > variant that polls indefinitely. 5s is a long time but with fastdebug > builds, maybe a looping thread or processes left over from a previous > test runs, virtual machines, then it might be long enough. I increased the timeout to 30 seconds. It is not exactly 30 seconds, but 300 iterations with sleep(100L) + check in each iteration. If the system is really overloaded then this loop should stretch automatically: http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.05/ Are there any other jigsaw-specific tests I should be paying close attention to? I ran the jdk/test/java/lang/reflect/WeakPairMap jdk/test/java/lang/reflect/Module and jdk/test/java/lang/Class tests. Will I need an official blessing to push this to jdk9/dev on the core-libs-dev as we have been discussing this patch only on jigsaw-dev for a while? Regards, Peter > >> >> >> If this is accepted then I would need to know via which repo this >> should be pushed (jdk9/dev or jake). > It should be okay to push this to jdk9/dev and we'll pull the changes > into jake. In general then we will be iterating on the module code for > some time and so will be using the jake sandbox for that. > > -Alan From Roger.Riggs at Oracle.com Tue Apr 26 14:43:38 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 26 Apr 2016 10:43:38 -0400 Subject: UNIXProcess.toString -- include more useful information In-Reply-To: References: Message-ID: Created https://bugs.openjdk.java.net/browse/JDK-8155102 to track the request. On 4/26/2016 10:30 AM, Roger Riggs wrote: > Hi, > > The pid (though os specific) is available from the Process API and so > adding it to toString > does not expose any additional implementation specific information. > > Getting accurate values for exitcode and running status would require > a native call > on windows but might be ok only for debugging. > > $.02, Roger > > > On 4/25/2016 3:49 PM, Martin Buchholz wrote: >> This is a reasonable request. >> >> But if you put platform-specific information into the String, then >> people will start treating that as an API (parsing the string), which >> is undesirable. >> >> On Mon, Apr 25, 2016 at 12:33 PM, Steven Schlansker >> wrote: >>> Hi core-libs-dev, >>> >>> I recently was diagnosing a problem relating to an external program >>> invoked via >>> the ProcessBuilder API. >>> >>> The returned Process is an instance of java.lang.UNIXProcess, which >>> does >>> not have a toString method. >>> >>> While I understand that the concepts of "pid" etc are not >>> cross-platform, >>> it might be useful to operators to have the toString method >>> dump them as diagnostic information. >>> >>> Imagine if instead of >>> >>> "java.lang.UNIXProcess@" >>> >>> you could see >>> >>> "UNIXProcess[running=true, pid=1234]" >>> "UNIXProcess[running=false, exitCode=127]" >>> >>> This seems like it would be a fairly trivial change that could help >>> some >>> operator down the road. >>> >>> Is this a reasonable request? Thanks, >>> Steven >>> > From Alan.Bateman at oracle.com Tue Apr 26 14:56:57 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 26 Apr 2016 15:56:57 +0100 Subject: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe In-Reply-To: <571F7E72.9050902@gmail.com> References: <5718FADF.5000601@gmail.com> <5718FE23.3070808@oracle.com> <2CE30172-D616-4C9A-94C7-5F2436979B06@univ-mlv.fr> <57193B06.8040200@oracle.com> <571A2A61.9050908@gmail.com> <571C80D9.5070709@oracle.com> <571DFBE1.3030906@gmail.com> <571E147A.3040609@oracle.com> <571F7E72.9050902@gmail.com> Message-ID: <571F81B9.3030107@oracle.com> On 26/04/2016 15:42, Peter Levart wrote: > > I increased the timeout to 30 seconds. It is not exactly 30 seconds, > but 300 iterations with sleep(100L) + check in each iteration. If the > system is really overloaded then this loop should stretch automatically: > > http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.05/ > > > Are there any other jigsaw-specific tests I should be paying close > attention to? I ran the jdk/test/java/lang/reflect/WeakPairMap > jdk/test/java/lang/reflect/Module and jdk/test/java/lang/Class tests. > > Will I need an official blessing to push this to jdk9/dev on the > core-libs-dev as we have been discussing this patch only on jigsaw-dev > for a while? I think this version is okay. We'll have to see if 30s is enough as we've hit some very long timeouts in the past due to interference from other things on the system. I realize I suggested jdk9/dev for this now I wonder it might be better to pull this into the jake forest so as to avoid merging + code changes. We are accumulating several module code changes to bring into jdk9/dev in bulk, mostly it is changes that cannot go into jdk9/dev now because they are dependent on changes to jtreg (that is rev'ing in tandem). There are also changes that will need a few iterations before we are ready to bring them to JDK 9. If we are okay with that then I can sponsor it for you. -Alan From sean.mullan at oracle.com Tue Apr 26 15:05:29 2016 From: sean.mullan at oracle.com (Sean Mullan) Date: Tue, 26 Apr 2016 11:05:29 -0400 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5718FEF7.1020807@oracle.com> References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> Message-ID: <571F83B9.2040100@oracle.com> The changes to the security-libs portions look fine to me. --Sean On 04/21/2016 12:25 PM, joe darcy wrote: > Hello, > > After a generally positive reception, please review the webrev to > implement the deprecation of Class.newInstance and the suppression of > the resulting warnings: > > http://cr.openjdk.java.net/~darcy/6850612.0/ > > There are also some changes in the langtools repo; I'll send a separate > review request for those changes to compiler-dev. > > I'll also forward this review request to other areas with affected code. > > Thanks, > > -Joe > > On 4/17/2016 10:31 AM, joe darcy wrote: >> Hello, >> >> With talk of deprecation in the air [1], I thought it would be a fine >> time to examine one of the bugs on my list >> >> JDK-6850612: Deprecate Class.newInstance since it violates the >> checked exception language contract >> >> As the title of the bug implies, The Class.newInstance method >> knowingly violates the checking exception contract. This has long been >> documented in its specification: >> >>> Note that this method propagates any exception thrown by the nullary >>> constructor, including a checked exception. Use of this method >>> effectively bypasses the compile-time exception checking that would >>> otherwise be performed by the compiler. The Constructor.newInstance >>> method avoids this problem by wrapping any exception thrown by the >>> constructor in a (checked) InvocationTargetException. >> >> Roughly, the fix would be to turn the text of this note into the >> @deprecated text and to add a @Deprecated(since="9") annotation to the >> method. There are a few dozen uses of the method in the JDK that would >> have to be @SuppressWarning-ed or otherwise updated. >> >> Thoughts on the appropriateness of deprecating this method at this time? >> >> Comments on the bug have suggested that besides deprecating the >> method, a new method on Class could be introduced, >> newInstanceWithProperExceptionBehavior, that had the same signature >> but wrapped exceptions thrown by the constructor call in the same way >> Constructor.newInstance does. >> >> Thanks, >> >> -Joe >> >> [1] >> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html >> > From aph at redhat.com Tue Apr 26 15:18:49 2016 From: aph at redhat.com (Andrew Haley) Date: Tue, 26 Apr 2016 16:18:49 +0100 Subject: String.equalsIgnoreCase(...) optimization In-Reply-To: <753291461680757@web10h.yandex.ru> References: <753291461680757@web10h.yandex.ru> Message-ID: <571F86D9.2030909@redhat.com> On 04/26/2016 03:25 PM, Andrey wrote: > May be can create optimized regionMatches(...) for use in equalsIgnoreCase(...)? When the HotSpot JVM's just-in-time compiler optimizes this code it inlines all of these tests, realizes that they are constant values, and generates no code for them. All the generated code does is check that the strings have the same coder and are the same length, then it goes into an unrolled loop checking that the characters are the same. If they're different then we have to do some more testing. If you want to optimize any library code its a great idea to make some changes and use JMH (http://openjdk.java.net/projects/code-tools/jmh/) to see if your change makes your test run faster. Andrew. From Alan.Bateman at oracle.com Tue Apr 26 17:00:53 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 26 Apr 2016 18:00:53 +0100 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests In-Reply-To: References: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> <571F330D.6060307@oracle.com> Message-ID: <571F9EC5.8050906@oracle.com> On 26/04/2016 13:50, Felix Yang wrote: > Hi Amy, > > thanks for pointing this out. Updated webrev: > > http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.01/ > This looks okay to me. -Alan From peter.levart at gmail.com Tue Apr 26 17:26:26 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 26 Apr 2016 19:26:26 +0200 Subject: RFR JDK-8155005: java.lang.reflect.Module.WeakSet is not thread-safe In-Reply-To: <571F81B9.3030107@oracle.com> References: <5718FADF.5000601@gmail.com> <5718FE23.3070808@oracle.com> <2CE30172-D616-4C9A-94C7-5F2436979B06@univ-mlv.fr> <57193B06.8040200@oracle.com> <571A2A61.9050908@gmail.com> <571C80D9.5070709@oracle.com> <571DFBE1.3030906@gmail.com> <571E147A.3040609@oracle.com> <571F7E72.9050902@gmail.com> <571F81B9.3030107@oracle.com> Message-ID: <571FA4C2.4050907@gmail.com> On 04/26/2016 04:56 PM, Alan Bateman wrote: > On 26/04/2016 15:42, Peter Levart wrote: >> >> I increased the timeout to 30 seconds. It is not exactly 30 seconds, >> but 300 iterations with sleep(100L) + check in each iteration. If the >> system is really overloaded then this loop should stretch automatically: >> >> http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.WeakSet.multithreadUnsafe/webrev.05/ >> >> >> Are there any other jigsaw-specific tests I should be paying close >> attention to? I ran the jdk/test/java/lang/reflect/WeakPairMap >> jdk/test/java/lang/reflect/Module and jdk/test/java/lang/Class tests. >> >> Will I need an official blessing to push this to jdk9/dev on the >> core-libs-dev as we have been discussing this patch only on >> jigsaw-dev for a while? > I think this version is okay. We'll have to see if 30s is enough as > we've hit some very long timeouts in the past due to interference from > other things on the system. > > I realize I suggested jdk9/dev for this now I wonder it might be > better to pull this into the jake forest so as to avoid merging + code > changes. We are accumulating several module code changes to bring into > jdk9/dev in bulk, mostly it is changes that cannot go into jdk9/dev > now because they are dependent on changes to jtreg (that is rev'ing in > tandem). There are also changes that will need a few iterations before > we are ready to bring them to JDK 9. If we are okay with that then I > can sponsor it for you. > > -Alan Ok, Alan, then I leave it to you to push it at your convenience. Thanks. Regards, Peter From volker.simonis at gmail.com Tue Apr 26 17:33:28 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Tue, 26 Apr 2016 19:33:28 +0200 Subject: RFR(XS): 8155156: Remove remaining sun.misc.* imports from the jdk repo Message-ID: Hi, can I please have a review for this trivial change: http://cr.openjdk.java.net/~simonis/webrevs/2016/8155156/ https://bugs.openjdk.java.net/browse/JDK-8155156 The fix for "8153737: Unsupported Module" moved sun.misc to the jdk.unsupported module and removed sun.misc.* imports. Unfortunately, it forgot to remove the sun.misc.* imports from: src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java which are only used on AIX. Because the base module doesn't require jdk.unsupported, this leads to a build error on AIX. The last remaining sun.misc.* import in src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java isn't required any more as well after "8147544: Remove sun.misc.ManagedLocalsThread from java.desktop" has been pushed. It doesn't lead to a build error because the java.desktop module still requires jdk.unsupported, but as the import isn't necessary any more, I think it's better to remove it as well. I build and smoke tested on Linux, Solaris and AIX. Thank you and best regards, Volker From chris.hegarty at oracle.com Tue Apr 26 17:42:20 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 26 Apr 2016 18:42:20 +0100 Subject: RFR(XS): 8155156: Remove remaining sun.misc.* imports from the jdk repo In-Reply-To: References: Message-ID: On 26 Apr 2016, at 18:33, Volker Simonis wrote: > Hi, > > can I please have a review for this trivial change: > > http://cr.openjdk.java.net/~simonis/webrevs/2016/8155156/ > https://bugs.openjdk.java.net/browse/JDK-8155156 Thank you Volker. Reviewed. -Chris. > The fix for "8153737: Unsupported Module" moved sun.misc to the > jdk.unsupported module and removed sun.misc.* imports. > > Unfortunately, it forgot to remove the sun.misc.* imports from: > > src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java > src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java > > which are only used on AIX. Because the base module doesn't require > jdk.unsupported, this leads to a build error on AIX. > > The last remaining sun.misc.* import in > > src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java > > isn't required any more as well after "8147544: Remove > sun.misc.ManagedLocalsThread from java.desktop" has been pushed. It > doesn't lead to a build error because the java.desktop module still > requires jdk.unsupported, but as the import isn't necessary any more, > I think it's better to remove it as well. > > I build and smoke tested on Linux, Solaris and AIX. > > Thank you and best regards, > Volker From peter.levart at gmail.com Tue Apr 26 18:05:22 2016 From: peter.levart at gmail.com (Peter Levart) Date: Tue, 26 Apr 2016 20:05:22 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <98009039.20160426171056@gmail.com> References: <98009039.20160426171056@gmail.com> Message-ID: <571FADE2.9050703@gmail.com> Hi, If Optional.get() is the method that gets most attention from beginners and learners, then perhaps its javadoc is the place that could be improved by making it a honey pot for advice about Optional use. The assumption that the average programmer starts reading documentation of some new API from the class-level javadocs is perhaps wrong. Quick help (Ctrl-Q in IDEs like IDEA, etc.) is context-sensitive and brings up the method-level javadoc. That's where the story should begin, I think... Regards, Peter On 04/26/2016 01:10 PM, Tagir F. Valeev wrote: > Hello! > > While I'm not a reviewer, I agree with Stephen. While I understand the > rationale, such renaming would cause even more confusion and pain. > Also I think this is not the worst part of Java API, so if we start to > rename things, where should we stop then? > > With best regards, > Tagir Valeev. > > SC> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this > SC> would be painful and add no value. > > SC> While I understand the pain from some developers not understanding the > SC> feature, this is hardly unique in the world of Java. Developers learn > SC> the right way of doing something soon enough. > > SC> And while > > SC> if (opt.isPresent()) { > SC> opt.get() > SC> } > > SC> is sometimes not ideal, in other cases it is the only practical choice > SC> (eg. where the method needs to have a return statement inside the if > SC> statement). > > SC> Changing this to > > SC> if (opt.isPresent()) { > SC> opt.getWhenPresent() > SC> } > > SC> is just noise - I can see the "present" part twice. > > SC> I just don't think I can support the rename (although many of the > SC> webrev tidy-ups are probably good). > > SC> Stephen > > > > SC> On 26 April 2016 at 00:05, Stuart Marks wrote: >>> Hi all, >>> >>> Please review these webrevs that deprecate Optional.get() and to replace it >>> with Optional.getWhenPresent(). The corresponding changes are also applied >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >>> OptionalLong.getAsLong(). >>> >>> Unlike most deprecations, this isn't about the function or the utility of >>> some API, it's about the name. The solution is basically to rename the API. >>> The problem is that "get" shows up as the "obvious" choice in things like >>> IDE code completion, leading to code that mishandles empty Optionals. >>> Typical Stack Overflow discourse runs something like this: >>> >>> Q: what do I do with this Optional thing >>> >>> A: just call get() >>> >>> Q: thanks, it works! >>> >>> Of course, it works until it doesn't. >>> >>> Examining the JDK's use of Optional.get(), I didn't see very many cases that >>> called get() without first checking for the presence of a value. But I did >>> see quite a number of cases like this: >>> >>> if (opt.isPresent()) { >>> doSomething(opt.get()); >>> } else { >>> doSomethingElse(); >>> } >>> >>> In many of these cases, the code could be refactored to use other Optional >>> methods such as filter(), map(), or ifPresent(). >>> >>> In any case this reinforces the contention that use of get() leads to poor >>> code. >>> >>> For this changeset, in just about all cases I've simply replaced the call to >>> get() with a call to getWhenPresent(). In a couple cases I replaced the >>> stream calls >>> >>> .filter(Optional::isPresent).map(Optional::get) >>> >>> with >>> >>> .flatMap(Optional::stream) >>> >>> which I hope will become the new idiom for unwrapping a stream of Optionals. >>> >>> While many cases could be cleaned up further, I didn't change them. The >>> reasons are that I didn't want to spend too much time putting code cleanup >>> into the critical path of this changeset (I'd be happy to help later); doing >>> so would create potential conflicts with code coming in from the Jigsaw >>> forest; and there are non-obvious places where converting from a conditional >>> to one of the lambda-based methods could cause performance problems at >>> startup. >>> >>> There are also a few cases where simplification is prevented because it >>> would end up causing the resulting lambda expressions to throw checked >>> exceptions. :-( >>> >>> Webrevs here: >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >>> >>> Thanks, >>> >>> s'marks From martinrb at google.com Tue Apr 26 18:22:19 2016 From: martinrb at google.com (Martin Buchholz) Date: Tue, 26 Apr 2016 11:22:19 -0700 Subject: Why are manifest files compressed by default? Message-ID: Some of us at Google are having growing doubts about the compression of zip file entries. Compression works best when a lot of data is digested, allowing the compression engine to do "common bit-sequence elimination". But each zip entry is compressed separately, and many zip entries are small. The manifest is special not only because it is likely to be small but because it may be read by many programs that are only interested in zip file metadata (like the java launcher itself!), so its contents are more likely to be read than other entries. I guess the jar command has only one flag -0 to choose compression for all entries, and it would be surprising for the JDK to override the user's choice? Maybe the default behavior should be for the JDK to automatically choose compression only when there's a significant win, e.g. if the entry data is sufficiently large and compressible? Maybe the jar command should grow other compression-related options, and -9 could ask for "maximal overall compression"? From andrey.dyachkov at gmail.com Tue Apr 26 17:45:06 2016 From: andrey.dyachkov at gmail.com (Andrey Dyachkov) Date: Tue, 26 Apr 2016 17:45:06 +0000 Subject: JDK-8155102: Process.toString could include pid, isAlive, exitStatus Message-ID: Hi, I would like to familiarise myself with contributing process. Can I take this bug to fix? -- Thanks, Andrey From stevenschlansker at gmail.com Tue Apr 26 18:28:36 2016 From: stevenschlansker at gmail.com (Steven Schlansker) Date: Tue, 26 Apr 2016 11:28:36 -0700 Subject: UNIXProcess.toString -- include more useful information In-Reply-To: References: Message-ID: Thanks Martin and Roger, hope to see this in Java 9 :) > On Apr 26, 2016, at 7:43 AM, Roger Riggs wrote: > > Created https://bugs.openjdk.java.net/browse/JDK-8155102 to track the request. > > > On 4/26/2016 10:30 AM, Roger Riggs wrote: >> Hi, >> >> The pid (though os specific) is available from the Process API and so adding it to toString >> does not expose any additional implementation specific information. >> >> Getting accurate values for exitcode and running status would require a native call >> on windows but might be ok only for debugging. >> >> $.02, Roger >> >> >> On 4/25/2016 3:49 PM, Martin Buchholz wrote: >>> This is a reasonable request. >>> >>> But if you put platform-specific information into the String, then >>> people will start treating that as an API (parsing the string), which >>> is undesirable. >>> >>> On Mon, Apr 25, 2016 at 12:33 PM, Steven Schlansker >>> wrote: >>>> Hi core-libs-dev, >>>> >>>> I recently was diagnosing a problem relating to an external program invoked via >>>> the ProcessBuilder API. >>>> >>>> The returned Process is an instance of java.lang.UNIXProcess, which does >>>> not have a toString method. >>>> >>>> While I understand that the concepts of "pid" etc are not cross-platform, >>>> it might be useful to operators to have the toString method >>>> dump them as diagnostic information. >>>> >>>> Imagine if instead of >>>> >>>> "java.lang.UNIXProcess@" >>>> >>>> you could see >>>> >>>> "UNIXProcess[running=true, pid=1234]" >>>> "UNIXProcess[running=false, exitCode=127]" >>>> >>>> This seems like it would be a fairly trivial change that could help some >>>> operator down the road. >>>> >>>> Is this a reasonable request? Thanks, >>>> Steven >>>> >> > From forax at univ-mlv.fr Tue Apr 26 18:33:21 2016 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Tue, 26 Apr 2016 18:33:21 +0000 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <571FADE2.9050703@gmail.com> References: <98009039.20160426171056@gmail.com> <571FADE2.9050703@gmail.com> Message-ID: <039D1A6E-B282-4DF5-848E-6C0CEE85D889@univ-mlv.fr> >From my experience, devs in general only read the doc when an exception is thrown so i agree with you. And in the wake of deprecating Optional.get(), I propose to rename RuntimeException to RTFMException :) Remi Le 26 avril 2016 20:05:22 CEST, Peter Levart a ?crit : >Hi, > >If Optional.get() is the method that gets most attention from beginners > >and learners, then perhaps its javadoc is the place that could be >improved by making it a honey pot for advice about Optional use. The >assumption that the average programmer starts reading documentation of >some new API from the class-level javadocs is perhaps wrong. Quick help > >(Ctrl-Q in IDEs like IDEA, etc.) is context-sensitive and brings up the > >method-level javadoc. That's where the story should begin, I think... > >Regards, Peter > >On 04/26/2016 01:10 PM, Tagir F. Valeev wrote: >> Hello! >> >> While I'm not a reviewer, I agree with Stephen. While I understand >the >> rationale, such renaming would cause even more confusion and >pain. >> Also I think this is not the worst part of Java API, so if we start >to >> rename things, where should we stop then? >> >> With best regards, >> Tagir Valeev. >> >> SC> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming >this >> SC> would be painful and add no value. >> >> SC> While I understand the pain from some developers not >understanding the >> SC> feature, this is hardly unique in the world of Java. Developers >learn >> SC> the right way of doing something soon enough. >> >> SC> And while >> >> SC> if (opt.isPresent()) { >> SC> opt.get() >> SC> } >> >> SC> is sometimes not ideal, in other cases it is the only practical >choice >> SC> (eg. where the method needs to have a return statement inside the >if >> SC> statement). >> >> SC> Changing this to >> >> SC> if (opt.isPresent()) { >> SC> opt.getWhenPresent() >> SC> } >> >> SC> is just noise - I can see the "present" part twice. >> >> SC> I just don't think I can support the rename (although many of the >> SC> webrev tidy-ups are probably good). >> >> SC> Stephen >> >> >> >> SC> On 26 April 2016 at 00:05, Stuart Marks >wrote: >>>> Hi all, >>>> >>>> Please review these webrevs that deprecate Optional.get() and to >replace it >>>> with Optional.getWhenPresent(). The corresponding changes are also >applied >>>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >>>> OptionalLong.getAsLong(). >>>> >>>> Unlike most deprecations, this isn't about the function or the >utility of >>>> some API, it's about the name. The solution is basically to rename >the API. >>>> The problem is that "get" shows up as the "obvious" choice in >things like >>>> IDE code completion, leading to code that mishandles empty >Optionals. >>>> Typical Stack Overflow discourse runs something like this: >>>> >>>> Q: what do I do with this Optional thing >>>> >>>> A: just call get() >>>> >>>> Q: thanks, it works! >>>> >>>> Of course, it works until it doesn't. >>>> >>>> Examining the JDK's use of Optional.get(), I didn't see very many >cases that >>>> called get() without first checking for the presence of a value. >But I did >>>> see quite a number of cases like this: >>>> >>>> if (opt.isPresent()) { >>>> doSomething(opt.get()); >>>> } else { >>>> doSomethingElse(); >>>> } >>>> >>>> In many of these cases, the code could be refactored to use other >Optional >>>> methods such as filter(), map(), or ifPresent(). >>>> >>>> In any case this reinforces the contention that use of get() leads >to poor >>>> code. >>>> >>>> For this changeset, in just about all cases I've simply replaced >the call to >>>> get() with a call to getWhenPresent(). In a couple cases I replaced >the >>>> stream calls >>>> >>>> .filter(Optional::isPresent).map(Optional::get) >>>> >>>> with >>>> >>>> .flatMap(Optional::stream) >>>> >>>> which I hope will become the new idiom for unwrapping a stream of >Optionals. >>>> >>>> While many cases could be cleaned up further, I didn't change them. >The >>>> reasons are that I didn't want to spend too much time putting code >cleanup >>>> into the critical path of this changeset (I'd be happy to help >later); doing >>>> so would create potential conflicts with code coming in from the >Jigsaw >>>> forest; and there are non-obvious places where converting from a >conditional >>>> to one of the lambda-based methods could cause performance problems >at >>>> startup. >>>> >>>> There are also a few cases where simplification is prevented >because it >>>> would end up causing the resulting lambda expressions to throw >checked >>>> exceptions. :-( >>>> >>>> Webrevs here: >>>> >>>> >http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >>>> >>>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >>>> >>>> Thanks, >>>> >>>> s'marks From Roger.Riggs at Oracle.com Tue Apr 26 18:47:53 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 26 Apr 2016 14:47:53 -0400 Subject: RFR 9: 8066750 Remove HTTP proxy implementation and tests from RMI Message-ID: <2b513591-a2db-98fc-988f-db445175493d@Oracle.com> The RMI http proxy mechanism was deprecated in Java SE 8. Please review the removal of now dead code for the RMI Http proxy implementation and tests. Webrev: http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ Issue: https://bugs.openjdk.java.net/browse/JDK-8066750 Thanks, Roger From stuart.marks at oracle.com Tue Apr 26 20:41:01 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Tue, 26 Apr 2016 13:41:01 -0700 Subject: RFR 9: 8066750 Remove HTTP proxy implementation and tests from RMI In-Reply-To: <2b513591-a2db-98fc-988f-db445175493d@Oracle.com> References: <2b513591-a2db-98fc-988f-db445175493d@Oracle.com> Message-ID: Hi Roger, Wow, look at all that red! Red is my favorite color. Changes look good. One small item: test/sun/rmi/transport/proxy/EagerHttpFallback.java is one of the tests being removed. Its entry can also be removed from test/ProblemList.txt. Its corresponding bug JDK-7195095 can probably also be closed out. Thanks, s'marks On 4/26/16 11:47 AM, Roger Riggs wrote: > The RMI http proxy mechanism was deprecated in Java SE 8. > Please review the removal of now dead code for the RMI Http proxy implementation > and tests. > > Webrev: > http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ > > Issue: > https://bugs.openjdk.java.net/browse/JDK-8066750 > > Thanks, Roger > From Roger.Riggs at Oracle.com Tue Apr 26 21:40:29 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 26 Apr 2016 17:40:29 -0400 Subject: RFR 9: 8066750 Remove HTTP proxy implementation and tests from RMI In-Reply-To: References: <2b513591-a2db-98fc-988f-db445175493d@Oracle.com> Message-ID: <2f5936d0-a0e7-d159-9592-26c3febf6f91@Oracle.com> Hi Stuart, Good catch, I didn't look in the ProblemList; webrev updated in place. Thanks, Roger On 4/26/2016 4:41 PM, Stuart Marks wrote: > Hi Roger, > > Wow, look at all that red! Red is my favorite color. > > Changes look good. One small item: > > test/sun/rmi/transport/proxy/EagerHttpFallback.java > > is one of the tests being removed. Its entry can also be removed from > test/ProblemList.txt. Its corresponding bug JDK-7195095 can probably > also be closed out. > > Thanks, > > s'marks > > > > On 4/26/16 11:47 AM, Roger Riggs wrote: >> The RMI http proxy mechanism was deprecated in Java SE 8. >> Please review the removal of now dead code for the RMI Http proxy >> implementation >> and tests. >> >> Webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ >> >> Issue: >> https://bugs.openjdk.java.net/browse/JDK-8066750 >> >> Thanks, Roger >> From brian.goetz at oracle.com Tue Apr 26 21:55:59 2016 From: brian.goetz at oracle.com (Brian Goetz) Date: Tue, 26 Apr 2016 17:55:59 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: Message-ID: <571FE3EF.7050001@oracle.com> As the person who chose the original (terrible) name, let me weigh in... I think calling this method "get()" was our biggest API mistake in Java 8. Now, one could argue that, if this is the biggest mistake we made, then we did pretty darn good. Which may be true, but ... make no mistake, it was the wrong name (mea culpa), and experience has borne out that it is widely misused. Subjectively, about half the uses of .get() I see are wrong -- and wrong in the obvious, avoidable way -- they don't consider the optional might be empty. So they've just traded an unexpected NPE for an unexpected NSEE. Its problem is, essentially: it looks harmless, but isn't, but it sure seems like the method you obviously want when you're browsing the autocomplete list / javadoc. It's a hazard both to code writers (pick the wrong method because the name is bad) and to code readers (deceptively harmless looking.) Methods like orElse or ifPresent look harmless, and are; methods like orElseThrow have potentially harmful side-effects but have names that are transparent about what harm they could do. But Optional.get() is neither safe nor transparent -- and yet awfully tempting-looking -- and this leads to frequent misuse. Naming matters, and this one was wrong, and the harm is observable. I wish I'd caught it before 8 shipped. Stepping back a bit ... one of the most frequent complaints we get is "mistakes never get fixed". So, we've decided to be more serious about deprecation -- Dr. Deprecator is suiting up! But that means, for any given item, some people are going to disagree about whether deprecation is suitable, and some will be inconvenienced by the deprecation -- this is unavoidable. Why prioritize this one? In part, because it's a *new* mistake, and has had less time to become entrenched -- and this is the very first opportunity we have to fix it. If we can't fix an API mistake at the very first opportunity, the logical consequence is we can't ever fix anything. And that doesn't seem to be the world we want to retreat to. Similarly, is this the worst mistake in all of Java? Surely not. But its also not reasonable to say "you can't fix X until you've fixed everything worse than X" -- again, that's a recipe for never fixing anything. So, in the context of a deprecation effort, this seems an entirely reasonable candidate. I'd like to see it fixed, and the sooner the better. On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this > would be painful and add no value. > > While I understand the pain from some developers not understanding the > feature, this is hardly unique in the world of Java. Developers learn > the right way of doing something soon enough. > > And while > > if (opt.isPresent()) { > opt.get() > } > > is sometimes not ideal, in other cases it is the only practical choice > (eg. where the method needs to have a return statement inside the if > statement). > > Changing this to > > if (opt.isPresent()) { > opt.getWhenPresent() > } > > is just noise - I can see the "present" part twice. > > I just don't think I can support the rename (although many of the > webrev tidy-ups are probably good). > > Stephen > > > > On 26 April 2016 at 00:05, Stuart Marks wrote: >> Hi all, >> >> Please review these webrevs that deprecate Optional.get() and to replace it >> with Optional.getWhenPresent(). The corresponding changes are also applied >> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >> OptionalLong.getAsLong(). >> >> Unlike most deprecations, this isn't about the function or the utility of >> some API, it's about the name. The solution is basically to rename the API. >> The problem is that "get" shows up as the "obvious" choice in things like >> IDE code completion, leading to code that mishandles empty Optionals. >> Typical Stack Overflow discourse runs something like this: >> >> Q: what do I do with this Optional thing >> >> A: just call get() >> >> Q: thanks, it works! >> >> Of course, it works until it doesn't. >> >> Examining the JDK's use of Optional.get(), I didn't see very many cases that >> called get() without first checking for the presence of a value. But I did >> see quite a number of cases like this: >> >> if (opt.isPresent()) { >> doSomething(opt.get()); >> } else { >> doSomethingElse(); >> } >> >> In many of these cases, the code could be refactored to use other Optional >> methods such as filter(), map(), or ifPresent(). >> >> In any case this reinforces the contention that use of get() leads to poor >> code. >> >> For this changeset, in just about all cases I've simply replaced the call to >> get() with a call to getWhenPresent(). In a couple cases I replaced the >> stream calls >> >> .filter(Optional::isPresent).map(Optional::get) >> >> with >> >> .flatMap(Optional::stream) >> >> which I hope will become the new idiom for unwrapping a stream of Optionals. >> >> While many cases could be cleaned up further, I didn't change them. The >> reasons are that I didn't want to spend too much time putting code cleanup >> into the critical path of this changeset (I'd be happy to help later); doing >> so would create potential conflicts with code coming in from the Jigsaw >> forest; and there are non-obvious places where converting from a conditional >> to one of the lambda-based methods could cause performance problems at >> startup. >> >> There are also a few cases where simplification is prevented because it >> would end up causing the resulting lambda expressions to throw checked >> exceptions. :-( >> >> Webrevs here: >> >> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >> >> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >> >> Thanks, >> >> s'marks From paul.sandoz at oracle.com Tue Apr 26 22:01:57 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 26 Apr 2016 15:01:57 -0700 Subject: RFR 8154447: Exempt classes under java.util.concurrent from MH.Lookup restrictions Message-ID: <8EE8CD59-C958-43CC-8BA7-97CFDCE86334@oracle.com> Hi, Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154447-mh-lookup-restricted-pkgs/webrev/ https://bugs.openjdk.java.net/browse/JDK-8154447 This is a quick fix to allow classes under java.util.concurrent to call MethodHandles.lookup(), and thus unblock the use of such classes using VarHandles. To verify and ensure we don?t regress i included a simple test. These fragile checks will be revisited later under another issue. Paul. From martinrb at google.com Tue Apr 26 22:14:35 2016 From: martinrb at google.com (Martin Buchholz) Date: Tue, 26 Apr 2016 15:14:35 -0700 Subject: RFR 8154447: Exempt classes under java.util.concurrent from MH.Lookup restrictions In-Reply-To: <8EE8CD59-C958-43CC-8BA7-97CFDCE86334@oracle.com> References: <8EE8CD59-C958-43CC-8BA7-97CFDCE86334@oracle.com> Message-ID: Looks good to me. I'd add a TODO comment. On Tue, Apr 26, 2016 at 3:01 PM, Paul Sandoz wrote: > Hi, > > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154447-mh-lookup-restricted-pkgs/webrev/ > https://bugs.openjdk.java.net/browse/JDK-8154447 > > This is a quick fix to allow classes under java.util.concurrent to call MethodHandles.lookup(), and thus unblock the use of such classes using VarHandles. > > To verify and ensure we don?t regress i included a simple test. > > These fragile checks will be revisited later under another issue. > > Paul. From mandy.chung at oracle.com Tue Apr 26 22:18:02 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Tue, 26 Apr 2016 15:18:02 -0700 Subject: RFR 8154447: Exempt classes under java.util.concurrent from MH.Lookup restrictions In-Reply-To: <8EE8CD59-C958-43CC-8BA7-97CFDCE86334@oracle.com> References: <8EE8CD59-C958-43CC-8BA7-97CFDCE86334@oracle.com> Message-ID: <9091A923-685B-4B26-8C73-E14DC299B75D@oracle.com> > On Apr 26, 2016, at 3:01 PM, Paul Sandoz wrote: > > Hi, > > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154447-mh-lookup-restricted-pkgs/webrev/ > https://bugs.openjdk.java.net/browse/JDK-8154447 > > This is a quick fix to allow classes under java.util.concurrent to call MethodHandles.lookup(), and thus unblock the use of such classes using VarHandles. > This quick fix looks okay to me. This big hammer check was intended to be an expedient way to address a past security concern and should be replaced. Mandy From stuart.marks at oracle.com Tue Apr 26 22:19:14 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Tue, 26 Apr 2016 15:19:14 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <571FE3EF.7050001@oracle.com> References: <571FE3EF.7050001@oracle.com> Message-ID: On 4/26/16 2:55 PM, Brian Goetz wrote: > Stepping back a bit ... one of the most frequent complaints we get is "mistakes > never get fixed". So, we've decided to be more serious about deprecation -- Dr. > Deprecator is suiting up! But that means, for any given item, some people are > going to disagree about whether deprecation is suitable, and some will be > inconvenienced by the deprecation -- this is unavoidable. > ... > I'd like to see it fixed, and the sooner the better. Thanks Brian. I should probably offer a mea culpa of my own, which is that I just started pumping out webrevs without providing any context. For some of the previous ones this hasn't been a big deal, but this most recent one has turned into an unpleasant surprise for several of you. JEP 277 (Enhanced Deprecation) is not only about refining the @Deprecated annotation itself, but employing it to deprecate things that have needed to be deprecated for quite a long time. I've been working a list of such things for some time. So what I'll do is set aside the Optional.get() webrev for the moment and start a new thread for discussion of the deprecation list. This should give people a chance to see what we're trying to do, and to assess the impact of deprecating things and how to assess the tradeoffs in doing so, independently of any particular webrev. I'll try to get this out in the next day or so. I'll send it here (core-libs-dev) since all the things on the list so far fall within the core libs area. s'marks From andrey at tweak.su Tue Apr 26 22:21:33 2016 From: andrey at tweak.su (Andrey) Date: Wed, 27 Apr 2016 01:21:33 +0300 Subject: String.equalsIgnoreCase(...) optimization In-Reply-To: <571F86D9.2030909@redhat.com> References: <753291461680757@web10h.yandex.ru> <571F86D9.2030909@redhat.com> Message-ID: <1922171461709293@web27h.yandex.ru> I create simple benchmark (attached). Optimized version more faster: # JMH 1.12 (released 26 days ago) # VM version: JDK 1.8.0_91, VM 25.91-b14 ... # Run complete. Total time: 00:04:02 Benchmark Mode Cnt Score Error Units StringBenchmark.constConst thrpt 20 37935470,179 ? 158354,736 ops/s StringBenchmark.constConstFast thrpt 20 70342038,623 ? 727831,951 ops/s StringBenchmark.newNew thrpt 20 30033885,754 ? 374524,932 ops/s StringBenchmark.newNewFast thrpt 20 69567918,934 ? 196494,474 ops/s StringBenchmark.varVar thrpt 20 36102111,956 ? 364861,774 ops/s StringBenchmark.varVarFast thrpt 20 66743826,698 ? 124162,725 ops/s How I can publish my version equalsIgnoreCase(...) or OpenJDK team check results separately? 26.04.2016, 18:18, "Andrew Haley" : > ?On 04/26/2016 03:25 PM, Andrey wrote: >> ??May be can create optimized regionMatches(...) for use in equalsIgnoreCase(...)? > > ?When the HotSpot JVM's just-in-time compiler optimizes this code it > ?inlines all of these tests, realizes that they are constant values, > ?and generates no code for them. All the generated code does is check > ?that the strings have the same coder and are the same length, then it > ?goes into an unrolled loop checking that the characters are the same. > ?If they're different then we have to do some more testing. > > ?If you want to optimize any library code its a great idea to make some > ?changes and use JMH (http://openjdk.java.net/projects/code-tools/jmh/) > ?to see if your change makes your test run faster. > > ?Andrew. From jonathan.gibbons at oracle.com Tue Apr 26 23:07:27 2016 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Tue, 26 Apr 2016 16:07:27 -0700 Subject: Fwd: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA7ED.4080609@oracle.com> <0cdc0050-8508-2be5-8e25-35fbad98d024@oracle.com> <571EABBE.8040606@oracle.com> Message-ID: <571FF4AF.9090203@oracle.com> So, pop quiz, one question: How many folk use the javac options -Xlint -Werror, and would thus see changes like this as a breaking change in the API? -- Jon On 04/26/2016 02:13 AM, R?mi Forax wrote: > I agree with Jon, Vitaly and Ali, > get is good candidate to @Bikeshed not for @Deprecated. > > R?mi > > > Le 26 avril 2016 08:26:43 CEST, Ali Ebrahimi a ?crit : >> Hi, >> I agree with Jon, Vitaly, >> I think the name Optional completely describe its intents and semantics >> so >> I don't think we need more descriptive method name here. >> Optional === may be have value >> So >> Optional.get === may be return value >> >> Therefore, I think this all effort doesn't add any (or enough) value, >> So >> isn't worth of it (from resource POV). >> Done side: The all current source codes that uses this method when >> compiling with java9 get dozen of warnings. >> >> On Tue, Apr 26, 2016 at 4:13 AM, Jonathan Gibbons < >> jonathan.gibbons at oracle.com> wrote: >> >>> OK. >>> >>> The best I can say is that I disagree with the underlying change (to >>> deprecate Optional.get) but that if the API change is generally >> agreed to, >>> then I reluctantly agree with the edit here. >>> >>> The bug needs a noreg-label. >>> >>> -- jon >>> >>> >>> >>> >>> On 04/25/2016 04:37 PM, Stuart Marks wrote: >>> >>>> >>>> On 4/25/16 4:27 PM, Jonathan Gibbons wrote: >>>> >>>>> Enter.java: >>>>> It's pretty ugly that the recommended usage is to have to add a >>>>> SuppressWarnings >>>>> for a reasonable and valid use of Optional.get. >>>>> >>>>> Are you sure this is the API you want? >>>>> >>>> Ah, I had neglected to explain this one, sorry. >>>> >>>> In the majority cases, uses of get() can be refactored away to use >> one of >>>> the other Optional methods. >>>> >>>> In just about all the remaining cases, the code should use the >>>> replacement method getWhenPresent(), which has the same semantics as >> the >>>> current get() call. This is called for if lambdas should be avoided >> because >>>> of startup performance, or because of checked exceptions, or if it's >>>> provable from context that a value is always present. >>>> >>>> The case of Enter.java is a special one; it gets compiled with the >> boot >>>> libraries (JDK 8) and getWhenPresent() doesn't exist in those. It >> doesn't >>>> generate a warning though. But as you explained to me the other day, >> this >>>> code is later recompiled against the JDK 9 libraries, and in that >> case it >>>> does generate the warning. >>>> >>>> So for this case I think calling get() with @SuppressWarnings is the >> way >>>> to proceed. I opted to extract a local variable and put @SW on it, >> in order >>>> to minimize its scope, but if you prefer an alternative I'd be happy >> to >>>> change it. >>>> >>>> s'marks >>>> >>> From david.holmes at oracle.com Tue Apr 26 23:23:29 2016 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Apr 2016 09:23:29 +1000 Subject: RFR: JDK-8152690: main thread does not have native thread name In-Reply-To: <74485460-c558-0b56-191b-07b7830834b6@gmail.com> References: <56F3F90D.9010408@gmail.com> <5710BF7E.6090206@oracle.com> <5710EA86.6010400@gmail.com> <57116A9E.9070003@oracle.com> <5711CD48.7010403@gmail.com> <5711E587.4050805@oracle.com> <57120600.6090005@gmail.com> <5715BC65.3010302@oracle.com> <571635E6.40601@gmail.com> <5719C5C8.3020705@oracle.com> <571A14ED.10901@gmail.com> <571A381E.9050605@oracle.com> <571A4DE8.8060508@oracle.com> <571B7796.8030905@gmail.com> <571DAF8F.1080305@oracle.com> <571ECF60.4060703@oracle.com> <9111da15-1b9a-a522-c072-475494577cbc@gmail.com> <571EF995.3000109@oracle.com> <571F367B.3010200@oracle.com> <571F684B.9080501@oracle.! com> <571F796F.9010301@oracle.com> <74485460-c558-0b56-191b-07b7830834b6@gmail.com> Message-ID: <571FF871.3010801@oracle.com> On 27/04/2016 12:38 AM, Yasumasa Suenaga wrote: > Hi Kumar, David, > >> simply to set a name which seems to be useful only for folks trying to >> debug >> the VM ??? besides ps and few other OS related utils it >> has no visibility of value to the JRE or the JDK APIs. > > I want to check CPU time through ps command on Linux. > Usually, I get "ps -eLf" and nid in threaddump to check > which thread spends much CPU time. > > If I can get thread name from output of ps command, > I can check it rapidly. If it is the only unnamed thread in the java process then you can infer that it is the "main" thread in one of its two forms. The tid may also give you some indication it is the first thread created by the launcher. > So I want to set "main" name at least. Sorry, but as previously discussed leaving it at "main" after it becomes the DestroyJavaVM thread will be a source of confusion (and bug reports). David ----- > > Thanks, > > Yasumasa > > > On 2016/04/26 23:21, Kumar Srinivasan wrote: >> >> On 4/26/2016 6:08 AM, David Holmes wrote: >>> On 26/04/2016 10:54 PM, Yasumasa Suenaga wrote: >>>> Hi David, >>>> >>>> For this issue, I think we can approach as following: >>>> >>>> >>>> 1. Export new JVM function to set native thread name >>>> It can avoid JNI call and can handle char* value. >>>> However this plan has been rejected. >>>> >>>> 2. Call uncaught exception handler from Launcher >>>> We have to clear (process) any pending exception before >>>> DetachCurrentThread() call. (not documented?) >>>> ------ >>>>> so note that we are potentially calling DetachCurrentThread with an >>>>> exception pending - which is prohibited by JNI** >>>> >>>>> **JNI spec needs to be modified here. >>>> ------ >>>> So we can process pending exception through uncaught >>>> exception handler. >>>> However, this plan has been rejected. >>>> >>>> 3. Do not set DestroyJavaVM name when exception is occurred >>>> It disrupts consistency for native thread name. >>>> >>>> 4. Attach to JVM to set native thread name for DestroyJavaVM >>>> It does not look good. >>>> >>>> >>>> If all of them are not accepted, I guess that it is difficult. >>>> Do you have any other idea? >>> >>> Sorry I don't. The basic idea of having the launcher set the native >>> thread name is fine, but the mechanism to do that has been >>> problematic. The "real" solution (ie one that other applications >>> hosting the jvm would need to use) is for the launcher to duplicate >>> the per-platform logic for os::set_native_thread_name - but that was >>> undesirable. Instead we have tried to avoid that by finding a way to >>> use whatever is already in the JVM - but adding a new JVM interface >>> to expose it directly is not ideal; and hooking into the >>> java.lang.Thread code to avoid that has run into these other >>> problems. I really don't want to take the logic for uncaught >>> exception handling that is in Thread::exit and duplicate it in the >>> launcher. >>> >>> The effort and disruption here really does not justify the "it would >>> be nice to set the native thread name for the main thread" objective. >>> >>> I never expected this to be as problematic as it has turned out. >> >> I agree with Holmes-san, I think this needlessly complicates >> the launcher, more than I would like!, ie simply to set a name >> which seems to be useful only for folks trying to debug >> the VM ??? besides ps and few other OS related utils it >> has no visibility of value to the JRE or the JDK APIs. >> >> Thanks >> >> Kumar >> >>> >>> Sorry. >>> >>> David >>> ----- >>> >>> >>>> >>>> Thanks, >>>> >>>> Yasumasa >>>> >>>> >>>> On 2016/04/26 18:35, David Holmes wrote: >>>>> On 26/04/2016 7:22 PM, Yasumasa Suenaga wrote: >>>>>> Hi David, >>>>>> >>>>>>> I thought about being able to save/restore the original pending >>>>>>> exception but could not see a simple way to restore it - ie just by >>>>>>> poking it back into the thread's pending exception field. The >>>>>>> problem >>>>>>> with using env->Throw is that it acts like the initial throwing >>>>>>> of the >>>>>>> exception and will have a number of side-effects that then get >>>>>>> doubled >>>>>>> up: >>>>>>> - logging statements (UL and Event logging) >>>>>>> - OOM counting >>>>>> >>>>>> Thanks, I understood. >>>>>> >>>>>>>>> so note that we are potentially calling DetachCurrentThread >>>>>>>>> with an >>>>>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>>>>> actually rely on for desired operation as DetachCurrentThread >>>>>>>>> calls >>>>>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>>>>> prints the exception message and stacktrace) and then clears the >>>>>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>>>>> exceptions.) >>>>>> >>>>>> I think we can call uncaught exception handler before calling >>>>>> DestroyJavaVM(). >>>>>> I added it in new webrev for jdk: >>>>>> >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/hotspot/ >>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.08/jdk/ >>>>>> >>>>>> DispatchUncaughtException() in java.c emulates uncaught exception >>>>>> handler >>>>>> call in JavaThread::exit(). >>>>>> I think this patch can provide the solution for our issue. >>>>>> >>>>>> Could you check it? >>>>> >>>>> Sorry - this is getting far too disruptive. I do not support changing >>>>> the way the main thread behaves upon completion, just because we want >>>>> to set a native thread name. >>>>> >>>>> David >>>>> ----- >>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Yasumasa >>>>>> >>>>>> >>>>>> On 2016/04/26 14:16, David Holmes wrote: >>>>>>> On 26/04/2016 1:11 PM, Yasumasa Suenaga wrote: >>>>>>>> Hi David, Kumar, >>>>>>>> >>>>>>>> I think that we should evacuate original exception before >>>>>>>> DestroyJavaVM >>>>>>>> thread name is set. >>>>>>>> >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/hotspot/ >>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.07/jdk/ >>>>>>>> >>>>>>>> I added it to LEAVE macro in new webrev. >>>>>>> >>>>>>> BTW: in the LEAVE macro, stylistically all the code should be in the >>>>>>> do { } while(false); loop. I overlooked that initially. >>>>>>> >>>>>>>> I tested it with following code. It works fine. >>>>>>>> >>>>>>>> ------------- >>>>>>>> public void main(String[] args){ >>>>>>>> throw new RuntimeException("test"); >>>>>>>> } >>>>>>>> ------------- >>>>>>>> >>>>>>>> What do you think about it? >>>>>>> >>>>>>> I thought about being able to save/restore the original pending >>>>>>> exception but could not see a simple way to restore it - ie just by >>>>>>> poking it back into the thread's pending exception field. The >>>>>>> problem >>>>>>> with using env->Throw is that it acts like the initial throwing >>>>>>> of the >>>>>>> exception and will have a number of side-effects that then get >>>>>>> doubled >>>>>>> up: >>>>>>> - logging statements (UL and Event logging) >>>>>>> - OOM counting >>>>>>> >>>>>>> I'm not sure whether that is acceptable or not >>>>>>> >>>>>>> That aside you should check if orig_throwable is non-null before >>>>>>> clearing to avoid an unnecessary JNI call. >>>>>>> >>>>>>> Also "Resume original exception" -> "Restore any original exception" >>>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> >>>>>>>> Yasumasa >>>>>>>> >>>>>>>> >>>>>>>> On 2016/04/26 11:16, David Holmes wrote: >>>>>>>>> Hi Yasumasa, Kumar, >>>>>>>>> >>>>>>>>> Turns out this change breaks the behaviour of the launcher in the >>>>>>>>> case >>>>>>>>> that main() completes by throwing an exception. >>>>>>>>> >>>>>>>>> What we have in the launcher is: >>>>>>>>> >>>>>>>>> (*env)->CallStaticVoidMethod(env, mainClass, mainID, >>>>>>>>> mainArgs); >>>>>>>>> ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; >>>>>>>>> LEAVE(); >>>>>>>>> >>>>>>>>> where LEAVE would have expanded to: >>>>>>>>> >>>>>>>>> if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \ >>>>>>>>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>> ret = 1; \ >>>>>>>>> } \ >>>>>>>>> if (JNI_TRUE) { \ >>>>>>>>> (*vm)->DestroyJavaVM(vm); \ >>>>>>>>> return ret; \ >>>>>>>>> } \ >>>>>>>>> >>>>>>>>> so note that we are potentially calling DetachCurrentThread >>>>>>>>> with an >>>>>>>>> exception pending - which is prohibited by JNI**, but which we >>>>>>>>> actually rely on for desired operation as DetachCurrentThread >>>>>>>>> calls >>>>>>>>> thread->exit() which performs uncaught exception handling (ie it >>>>>>>>> prints the exception message and stacktrace) and then clears the >>>>>>>>> exception! (Hence DestroyJavaVM is not called with any pending >>>>>>>>> exceptions.) >>>>>>>>> >>>>>>>>> **JNI spec needs to be modified here. >>>>>>>>> >>>>>>>>> With the current change we have now inserted the following at the >>>>>>>>> start of LEAVE: >>>>>>>>> >>>>>>>>> SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>> if ((*env)->ExceptionOccurred(env)) { \ >>>>>>>>> (*env)->ExceptionClear(env); \ >>>>>>>>> } \ >>>>>>>>> >>>>>>>>> this has two unintended consequences: >>>>>>>>> >>>>>>>>> 1. SetNativeThreadName itself calls a number of JNI methods, >>>>>>>>> with the >>>>>>>>> exception pending - which is not permitted. So straight away >>>>>>>>> where we >>>>>>>>> have: >>>>>>>>> >>>>>>>>> NULL_CHECK(cls = FindBootStrapClass(env, "java/lang/Thread")); >>>>>>>>> >>>>>>>>> FindBootStrapClass calls JVM_FindClassFromBootLoader, which make >>>>>>>>> calls >>>>>>>>> using the VM's CHECK_NULL macro - which checks for a pending >>>>>>>>> exception >>>>>>>>> (which it finds) and returns NULL. So the jli NULL_CHECK macro >>>>>>>>> then >>>>>>>>> reports a JNI error: >>>>>>>>> >>>>>>>>> Error: A JNI error has occurred, please check your installation >>>>>>>>> and >>>>>>>>> try again >>>>>>>>> >>>>>>>>> >>>>>>>>> 2. There is no longer an exception from main() for >>>>>>>>> DetachCurrentThread >>>>>>>>> to report, so we exit with a return code of 1 as required, but >>>>>>>>> don't >>>>>>>>> report the exception message/stacktrace. >>>>>>>>> >>>>>>>>> I don't see a reasonable solution for this other than >>>>>>>>> abandoning the >>>>>>>>> attempt to change the name from "main" to "DestroyJavaVM" - >>>>>>>>> which if >>>>>>>>> we can't do, I question the utility of setting the name in the >>>>>>>>> first >>>>>>>>> place (while it might be useful in some circumstances [when >>>>>>>>> main() is >>>>>>>>> running] it will cause confusion in others [when main() has >>>>>>>>> exited]). >>>>>>>>> >>>>>>>>> David >>>>>>>>> ----- >>>>>>>>> >>>>>>>>> On 25/04/2016 3:47 PM, David Holmes wrote: >>>>>>>>>> Looks good to me. >>>>>>>>>> >>>>>>>>>> I'll sponsor this "tomorrow". >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> David >>>>>>>>>> >>>>>>>>>> On 23/04/2016 11:24 PM, Yasumasa Suenaga wrote: >>>>>>>>>>> Hi Kumar, >>>>>>>>>>> >>>>>>>>>>> Thank you for your comment! >>>>>>>>>>> I've fixed them and uploaded new webrev. Could you review again? >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/hotspot/ >>>>>>>>>>> >>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.06/jdk/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> Yasumasa >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On 2016/04/23 1:14, Kumar Srinivasan wrote: >>>>>>>>>>>> >>>>>>>>>>>> Also a couple of minor suggestions: >>>>>>>>>>>> >>>>>>>>>>>> - * Set native thread name as possible. >>>>>>>>>>>> + * Set native thread name if possible. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> + /* >>>>>>>>>>>> - * We can clear pending exception because exception >>>>>>>>>>>> at this >>>>>>>>>>>> point >>>>>>>>>>>> - * is not critical. >>>>>>>>>>>> + */ >>>>>>>>>>>> >>>>>>>>>>>> + /* >>>>>>>>>>>> + * Clear non critical pending exceptions at this point. >>>>>>>>>>>> + */ >>>>>>>>>>>> >>>>>>>>>>>> Thanks >>>>>>>>>>>> Kumar >>>>>>>>>>>> >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> This is in the wrong place: >>>>>>>>>>>>> >>>>>>>>>>>>> 1715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>>>> 1716 /* >>>>>>>>>>>>> 1717 * We can clear pending exception because >>>>>>>>>>>>> exception at >>>>>>>>>>>>> this point >>>>>>>>>>>>> 1718 * is not critical. >>>>>>>>>>>>> 1719 */ >>>>>>>>>>>>> 1720 (*env)->ExceptionClear(env); >>>>>>>>>>>>> 1721 } >>>>>>>>>>>>> >>>>>>>>>>>>> This above needs to be after >>>>>>>>>>>>> 391 SetNativeThreadName(env, "main"); >>>>>>>>>>>>> 392 >>>>>>>>>>>>> >>>>>>>>>>>>> Here is why, supposing 1704 through 1711, returns a NULL, >>>>>>>>>>>>> but have also encountered an exception. In which case >>>>>>>>>>>>> the method SetNativeThreadName will return to the caller, as >>>>>>>>>>>>> if nothing has happened, because NULL_CHECK simply checks for >>>>>>>>>>>>> NULL >>>>>>>>>>>>> and returns to the caller. This will cause the caller to enter >>>>>>>>>>>>> the VM with exceptions. >>>>>>>>>>>>> >>>>>>>>>>>>> Kumar >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 4/22/2016 5:11 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>> >>>>>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>>>>> ignore >>>>>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>>>>> continuing. >>>>>>>>>>>>>> >>>>>>>>>>>>>> I've fixed it in new webrev: >>>>>>>>>>>>>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/hotspot/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.05/jdk/ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On 2016/04/22 15:33, David Holmes wrote: >>>>>>>>>>>>>>> On 22/04/2016 1:36 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> Hi all, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I have uploaded webrev.04 as below. >>>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Looks fine. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> As per private email (but repeated here on the record) in >>>>>>>>>>>>>>> java.c: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> 715 if ((*env)->ExceptionOccurred(env)) { >>>>>>>>>>>>>>> 1716 JLI_ReportExceptionDescription(env); >>>>>>>>>>>>>>> 1717 } >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I don't think we need to report the exception, but can just >>>>>>>>>>>>>>> ignore >>>>>>>>>>>>>>> it. Either way we have to clear the exception before >>>>>>>>>>>>>>> continuing. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> David >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> 2016/04/19 22:43 "Yasumasa Suenaga" >>>>>>>>>>>>>>> >: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Hi David, >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Thank you for your comment. >>>>>>>>>>>>>>>> > I uploaded new webrev. Could you review again? >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > - hotspot: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/hotspot/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > - jdk: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.04/jdk/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >> That aside I'm not sure why you do this so late in the >>>>>>>>>>>>>>>> process, I >>>>>>>>>>>>>>>> would have done it immediately after here: >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > I think that native thread name ("main") should be >>>>>>>>>>>>>>>> set just >>>>>>>>>>>>>>>> before >>>>>>>>>>>>>>>> > main method call. >>>>>>>>>>>>>>>> > However, main thread is already started, so I moved it >>>>>>>>>>>>>>>> as you >>>>>>>>>>>>>>>> suggested. >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >> One thing I dislike about the current structure is >>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName >>>>>>>>>>>>>>>> which >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> calls >>>>>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>>>>> to a >>>>>>>>>>>>>>>> char* ! >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > SoI proposed to export new JVM function to set native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> name with >>>>>>>>>>>>>>>> > const char *. >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Thanks, >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > Yasumasa >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > On 2016/04/19 14:04, David Holmes wrote: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Hi Yasumasa, >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Thanks for persevering with this to get it into the >>>>>>>>>>>>>>>> current >>>>>>>>>>>>>>>> form. >>>>>>>>>>>>>>>> Sorry I haven't been able to do a detailed review until >>>>>>>>>>>>>>>> now. >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> On 19/04/2016 9:28 AM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> Hi Gerard, >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> 2016/04/19 3:14 "Gerard Ziemski" >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>> > hi Yasumasa, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>> > Nice work. I have 2 questions: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>> > ======== >>>>>>>>>>>>>>>> >>> > File: java.c >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>> > #1 Shouldn?t we be checking for >>>>>>>>>>>>>>>> ?(*env)->ExceptionOccurred(env)? >>>>>>>>>>>>>>>> >>> after every single JNI call? In this example >>>>>>>>>>>>>>>> instead of >>>>>>>>>>>>>>>> NULL_CHECK, >>>>>>>>>>>>>>>> >>> should we be using CHECK_EXCEPTION_NULL_LEAVE macro? >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> It is not critical if we encounter error at JNI >>>>>>>>>>>>>>>> function >>>>>>>>>>>>>>>> call >>>>>>>>>>>>>>>> because >>>>>>>>>>>>>>>> >>> we cannot set native thread name only. >>>>>>>>>>>>>>>> >>> So I think that we do not need to leave from launcher >>>>>>>>>>>>>>>> process. >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> I agree we do not need to abort if an exception occurs >>>>>>>>>>>>>>>> (and in >>>>>>>>>>>>>>>> fact >>>>>>>>>>>>>>>> I don't think an exception is even possible from this >>>>>>>>>>>>>>>> code), >>>>>>>>>>>>>>>> but we >>>>>>>>>>>>>>>> should ensure any pending exception is cleared before any >>>>>>>>>>>>>>>> futher JNI >>>>>>>>>>>>>>>> calls might be made. Note that NULL_CHECK is already used >>>>>>>>>>>>>>>> extensively >>>>>>>>>>>>>>>> throughout the launcher code - so if this usage is wrong >>>>>>>>>>>>>>>> then it >>>>>>>>>>>>>>>> is all >>>>>>>>>>>>>>>> wrong! More on this code below ... >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Other comments: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> hotspot/src/share/vm/prims/jvm.cpp >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Please add a comment to the method now that you removed >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> internal >>>>>>>>>>>>>>>> comment: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> // Sets the native thread name for a JavaThread. If >>>>>>>>>>>>>>>> specifically >>>>>>>>>>>>>>>> >> // requested JNI-attached threads can also have their >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> name set; >>>>>>>>>>>>>>>> >> // otherwise we do not modify JNI-attached threads as >>>>>>>>>>>>>>>> it may >>>>>>>>>>>>>>>> interfere >>>>>>>>>>>>>>>> >> // with the application that created them. >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> --- >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> jdk/src/java.base/share/classes/java/lang/Thread.java >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Please add the following comments: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> + // Don't modify JNI-attached threads >>>>>>>>>>>>>>>> >> setNativeName(name, false); >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> + // May be called directly via JNI or reflection (when >>>>>>>>>>>>>>>> permitted) to >>>>>>>>>>>>>>>> >> + // allow JNI-attached threads to set their native >>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>> >> private native void setNativeName(String name, >>>>>>>>>>>>>>>> boolean >>>>>>>>>>>>>>>> allowAttachedThread); >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> --- >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> jd/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> 328 #define LEAVE() \ >>>>>>>>>>>>>>>> >> 329 SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> I was going to suggest this be set later, but >>>>>>>>>>>>>>>> realized we >>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>> to be >>>>>>>>>>>>>>>> attached to do this and that happens inside >>>>>>>>>>>>>>>> DestroyJavaVM. :) >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> + /* Set native thread name. */ >>>>>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> The comment is redundant given the name of the method. >>>>>>>>>>>>>>>> That >>>>>>>>>>>>>>>> aside >>>>>>>>>>>>>>>> I'm not sure why you do this so late in the process, I >>>>>>>>>>>>>>>> would >>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>> done >>>>>>>>>>>>>>>> it immediately after here: >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> 386 if (!InitializeJVM(&vm, &env, &ifn)) { >>>>>>>>>>>>>>>> >> 387 JLI_ReportErrorMessage(JVM_ERROR1); >>>>>>>>>>>>>>>> >> 388 exit(1); >>>>>>>>>>>>>>>> >> 389 } >>>>>>>>>>>>>>>> >> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> + /** >>>>>>>>>>>>>>>> >> + * Set native thread name as possible. >>>>>>>>>>>>>>>> >> + */ >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Other than the as->if change I'm unclear where the >>>>>>>>>>>>>>>> "possible" >>>>>>>>>>>>>>>> bit >>>>>>>>>>>>>>>> comes into play - why would it not be possible? >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> 1705 NULL_CHECK(cls = FindBootStrapClass(env, >>>>>>>>>>>>>>>> "java/lang/Thread")); >>>>>>>>>>>>>>>> >> 1706 NULL_CHECK(currentThreadID = >>>>>>>>>>>>>>>> (*env)->GetStaticMethodID(env, >>>>>>>>>>>>>>>> cls, >>>>>>>>>>>>>>>> >> 1707 "currentThread", >>>>>>>>>>>>>>>> "()Ljava/lang/Thread;")); >>>>>>>>>>>>>>>> >> 1708 NULL_CHECK(currentThread = >>>>>>>>>>>>>>>> (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>>>>>>>>> >> 1709 currentThreadID)); >>>>>>>>>>>>>>>> >> 1710 NULL_CHECK(setNativeNameID = >>>>>>>>>>>>>>>> (*env)->GetMethodID(env, >>>>>>>>>>>>>>>> cls, >>>>>>>>>>>>>>>> >> 1711 "setNativeName", >>>>>>>>>>>>>>>> "(Ljava/lang/String;Z)V")); >>>>>>>>>>>>>>>> >> 1712 NULL_CHECK(nameString = >>>>>>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>>>>>> name)); >>>>>>>>>>>>>>>> >> 1713 (*env)->CallVoidMethod(env, currentThread, >>>>>>>>>>>>>>>> setNativeNameID, >>>>>>>>>>>>>>>> >> 1714 nameString, JNI_TRUE); >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> As above NULL_CHECK is fine here, but we should >>>>>>>>>>>>>>>> check for >>>>>>>>>>>>>>>> and >>>>>>>>>>>>>>>> clear >>>>>>>>>>>>>>>> any pending exception after CallVoidMethod. >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> One thing I dislike about the current structure is >>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>> go from char* to java.lang.String to call setNativeName >>>>>>>>>>>>>>>> which >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> calls >>>>>>>>>>>>>>>> JVM_SetNativeThreadName which converts the j.l.String back >>>>>>>>>>>>>>>> to a >>>>>>>>>>>>>>>> char* ! >>>>>>>>>>>>>>>> Overall I wonder about the affect on startup cost. But if >>>>>>>>>>>>>>>> there >>>>>>>>>>>>>>>> is an >>>>>>>>>>>>>>>> issue we can revisit this. >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>> >> David >>>>>>>>>>>>>>>> >> ----- >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > #2 Should the comment for ?SetNativeThreadName? be >>>>>>>>>>>>>>>> ?Set >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> name if possible.? not "Set native thread name as >>>>>>>>>>>>>>>> possible.?? >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> Sorry for my bad English :-) >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> Thanks, >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> Yasumasa >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>> > cheers >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>> > > On Apr 16, 2016, at 4:29 AM, Yasumasa Suenaga >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > Hi David, >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > I uploaded new webrev: >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > - hotspot: >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/hotspot/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > - jdk: >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.03/jdk/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > >> it won't work unless you change the semantics of >>>>>>>>>>>>>>>> setName so I'm >>>>>>>>>>>>>>>> >>> not sure what you were thinking here. To take >>>>>>>>>>>>>>>> advantage >>>>>>>>>>>>>>>> of an >>>>>>>>>>>>>>>> arg >>>>>>>>>>>>>>>> taking >>>>>>>>>>>>>>>> >>> JVM_SetNativThreadName you would need to call it >>>>>>>>>>>>>>>> directly as >>>>>>>>>>>>>>>> no Java >>>>>>>>>>>>>>>> >>> code will call it . ??? >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > I added a flag for setting native thread name to >>>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>> > > This change can set native thread name if main >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> changes to >>>>>>>>>>>>>>>> >>> JNI-attached thread. >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > Thanks, >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > Yasumasa >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > >>>>>>>>>>>>>>>> >>> > > On 2016/04/16 16:11, David Holmes wrote: >>>>>>>>>>>>>>>> >>> > >> On 16/04/2016 3:27 PM, Yasumasa Suenaga wrote: >>>>>>>>>>>>>>>> >>> > >>> Hi David, >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>>>>> could be >>>>>>>>>>>>>>>> considered a >>>>>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> main, even >>>>>>>>>>>>>>>> >>> > >>>> though we never really intended it to work >>>>>>>>>>>>>>>> in the >>>>>>>>>>>>>>>> first place. >>>>>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> I understood. >>>>>>>>>>>>>>>> >>> > >>> Can I send CCC request? >>>>>>>>>>>>>>>> >>> > >>> (I'm jdk 9 commiter, but I'm not employee at >>>>>>>>>>>>>>>> Oracle.) >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >> Sorry you can't file a CCC request, you would >>>>>>>>>>>>>>>> need a >>>>>>>>>>>>>>>> sponsor for >>>>>>>>>>>>>>>> >>> that. But at this stage I don't think I agree with the >>>>>>>>>>>>>>>> proposed change >>>>>>>>>>>>>>>> >>> because of the change in behaviour - there's no way to >>>>>>>>>>>>>>>> restore the >>>>>>>>>>>>>>>> >>> "broken" behaviour. >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >>> I want to continue to discuss about it on >>>>>>>>>>>>>>>> JDK-8154331 >>>>>>>>>>>>>>>> [1]. >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >> Okay we can do that. >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>>> Further, we expect the launcher to use the >>>>>>>>>>>>>>>> supported >>>>>>>>>>>>>>>> JNI >>>>>>>>>>>>>>>> >>> interface (as >>>>>>>>>>>>>>>> >>> > >>>> other processes would), not the internal JVM >>>>>>>>>>>>>>>> interface that >>>>>>>>>>>>>>>> >>> exists for >>>>>>>>>>>>>>>> >>> > >>>> the JDK sources to communicate with the JVM. >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> I think that we do not use JVM interface if we >>>>>>>>>>>>>>>> add new >>>>>>>>>>>>>>>> method in >>>>>>>>>>>>>>>> >>> > >>> LauncherHelper as below: >>>>>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>> --- >>>>>>>>>>>>>>>> a/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>> Wed Apr 13 14:19:30 2016 +0000 >>>>>>>>>>>>>>>> >>> > >>> +++ >>>>>>>>>>>>>>>> b/src/java.base/share/classes/sun/launcher/LauncherHelper.java >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>> Sat Apr 16 11:25:53 2016 +0900 >>>>>>>>>>>>>>>> >>> > >>> @@ -960,4 +960,8 @@ >>>>>>>>>>>>>>>> >>> > >>> else >>>>>>>>>>>>>>>> >>> > >>> return md.toNameAndVersion() + >>>>>>>>>>>>>>>> " (" >>>>>>>>>>>>>>>> + loc >>>>>>>>>>>>>>>> + ")"; >>>>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>>>> >>> > >>> + static void setNativeThreadName(String >>>>>>>>>>>>>>>> name) { >>>>>>>>>>>>>>>> >>> > >>> + Thread.currentThread().setName(name); >>>>>>>>>>>>>>>> >>> > >>> + } >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >> You could also make that call via JNI >>>>>>>>>>>>>>>> directly, so >>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>> sure the >>>>>>>>>>>>>>>> >>> helper adds much here. But it won't work unless you >>>>>>>>>>>>>>>> change >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> semantics >>>>>>>>>>>>>>>> >>> of setName so I'm not sure what you were thinking >>>>>>>>>>>>>>>> here. To >>>>>>>>>>>>>>>> take >>>>>>>>>>>>>>>> >>> advantage of an arg taking JVM_SetNativThreadName you >>>>>>>>>>>>>>>> would >>>>>>>>>>>>>>>> need to >>>>>>>>>>>>>>>> call >>>>>>>>>>>>>>>> >>> it directly as no Java code will call it . ??? >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >> David >>>>>>>>>>>>>>>> >>> > >> ----- >>>>>>>>>>>>>>>> >>> > >> >>>>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>>>> >>> > >>> diff -r f02139a1ac84 >>>>>>>>>>>>>>>> src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>>> >>> > >>> --- a/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>>> Wed >>>>>>>>>>>>>>>> Apr 13 >>>>>>>>>>>>>>>> 14:19:30 >>>>>>>>>>>>>>>> >>> > >>> 2016 +0000 >>>>>>>>>>>>>>>> >>> > >>> +++ b/src/java.base/share/native/libjli/java.c >>>>>>>>>>>>>>>> Sat >>>>>>>>>>>>>>>> Apr 16 >>>>>>>>>>>>>>>> 11:25:53 >>>>>>>>>>>>>>>> >>> > >>> 2016 +0900 >>>>>>>>>>>>>>>> >>> > >>> @@ -125,6 +125,7 @@ >>>>>>>>>>>>>>>> >>> > >>> static void PrintUsage(JNIEnv* env, jboolean >>>>>>>>>>>>>>>> doXUsage); >>>>>>>>>>>>>>>> >>> > >>> static void ShowSettings(JNIEnv* env, char >>>>>>>>>>>>>>>> *optString); >>>>>>>>>>>>>>>> >>> > >>> static void ListModules(JNIEnv* env, char >>>>>>>>>>>>>>>> *optString); >>>>>>>>>>>>>>>> >>> > >>> +static void SetNativeThreadName(JNIEnv* >>>>>>>>>>>>>>>> env, char >>>>>>>>>>>>>>>> *name); >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> static void SetPaths(int argc, char **argv); >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> @@ -325,6 +326,7 @@ >>>>>>>>>>>>>>>> >>> > >>> * mainThread.isAlive() to work as expected. >>>>>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>>>>> >>> > >>> #define LEAVE() \ >>>>>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "DestroyJavaVM"); \ >>>>>>>>>>>>>>>> >>> > >>> do { \ >>>>>>>>>>>>>>>> >>> > >>> if ((*vm)->DetachCurrentThread(vm) != >>>>>>>>>>>>>>>> JNI_OK) >>>>>>>>>>>>>>>> { \ >>>>>>>>>>>>>>>> >>> > >>> JLI_ReportErrorMessage(JVM_ERROR2); \ >>>>>>>>>>>>>>>> >>> > >>> @@ -488,6 +490,9 @@ >>>>>>>>>>>>>>>> >>> > >>> mainArgs = CreateApplicationArgs(env, argv, >>>>>>>>>>>>>>>> argc); >>>>>>>>>>>>>>>> >>> > >>> CHECK_EXCEPTION_NULL_LEAVE(mainArgs); >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> + /* Set native thread name. */ >>>>>>>>>>>>>>>> >>> > >>> + SetNativeThreadName(env, "main"); >>>>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>>>> >>> > >>> /* Invoke main method. */ >>>>>>>>>>>>>>>> >>> > >>> (*env)->CallStaticVoidMethod(env, mainClass, >>>>>>>>>>>>>>>> mainID, >>>>>>>>>>>>>>>> mainArgs); >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> @@ -1686,6 +1691,22 @@ >>>>>>>>>>>>>>>> >>> > >>> joptString); >>>>>>>>>>>>>>>> >>> > >>> } >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> +/** >>>>>>>>>>>>>>>> >>> > >>> + * Set native thread name as possible. >>>>>>>>>>>>>>>> >>> > >>> + */ >>>>>>>>>>>>>>>> >>> > >>> +static void >>>>>>>>>>>>>>>> >>> > >>> +SetNativeThreadName(JNIEnv *env, char *name) >>>>>>>>>>>>>>>> >>> > >>> +{ >>>>>>>>>>>>>>>> >>> > >>> + jmethodID setNativeThreadNameID; >>>>>>>>>>>>>>>> >>> > >>> + jstring nameString; >>>>>>>>>>>>>>>> >>> > >>> + jclass cls = GetLauncherHelperClass(env); >>>>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(cls); >>>>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(setNativeThreadNameID = >>>>>>>>>>>>>>>> >>> (*env)->GetStaticMethodID(env, cls, >>>>>>>>>>>>>>>> >>> > >>> + "setNativeThreadName", >>>>>>>>>>>>>>>> "(Ljava/lang/String;)V")); >>>>>>>>>>>>>>>> >>> > >>> + NULL_CHECK(nameString = >>>>>>>>>>>>>>>> (*env)->NewStringUTF(env, >>>>>>>>>>>>>>>> name)); >>>>>>>>>>>>>>>> >>> > >>> + (*env)->CallStaticVoidMethod(env, cls, >>>>>>>>>>>>>>>> setNativeThreadNameID, >>>>>>>>>>>>>>>> >>> > >>> nameString); >>>>>>>>>>>>>>>> >>> > >>> +} >>>>>>>>>>>>>>>> >>> > >>> + >>>>>>>>>>>>>>>> >>> > >>> /* >>>>>>>>>>>>>>>> >>> > >>> * Prints default usage or the Xusage message, >>>>>>>>>>>>>>>> see >>>>>>>>>>>>>>>> >>> > >>> sun.launcher.LauncherHelper.java >>>>>>>>>>>>>>>> >>> > >>> */ >>>>>>>>>>>>>>>> >>> > >>> ---------------- >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> So I want to add new arg to >>>>>>>>>>>>>>>> JVM_SetNativeThreadName(). >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>>> However this is still a change to the exported >>>>>>>>>>>>>>>> JVM >>>>>>>>>>>>>>>> interface and so >>>>>>>>>>>>>>>> >>> > >>>> has to be approved. >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> Do you mean that this change needs CCC? >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> Thanks, >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> [1] >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2016-April/019034.html >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> >>>>>>>>>>>>>>>> >>> > >>> On 2016/04/16 7:26, David Holmes wrote: >>>>>>>>>>>>>>>> >>> > >>>> On 15/04/2016 11:20 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>> Hi David, >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment >>>>>>>>>>>>>>>> here: >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>>>>> false); // >>>>>>>>>>>>>>>> for main >>>>>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> I filed it to JBS as JDK-8154331. >>>>>>>>>>>>>>>> >>> > >>>>> I will send review request to >>>>>>>>>>>>>>>> hotspot-runtime-dev. >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>>>>> behaviour by >>>>>>>>>>>>>>>> itself as >>>>>>>>>>>>>>>> >>> setName >>>>>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for >>>>>>>>>>>>>>>> the main >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> I know. >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>> That change in behaviour may be a problem, it >>>>>>>>>>>>>>>> could be >>>>>>>>>>>>>>>> considered a >>>>>>>>>>>>>>>> >>> > >>>> regression that setName stops setting the >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> main, even >>>>>>>>>>>>>>>> >>> > >>>> though we never really intended it to work >>>>>>>>>>>>>>>> in the >>>>>>>>>>>>>>>> first place. >>>>>>>>>>>>>>>> >>> :( Such >>>>>>>>>>>>>>>> >>> > >>>> a change needs to go through CCC. >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>>> I checked changeset history. >>>>>>>>>>>>>>>> >>> > >>>>> JVM_SetNativeThreadName() was introduced in >>>>>>>>>>>>>>>> JDK-7098194, >>>>>>>>>>>>>>>> and it is >>>>>>>>>>>>>>>> >>> > >>>>> backported JDK 8. >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>> Yes this all came in as part of the OSX >>>>>>>>>>>>>>>> port in >>>>>>>>>>>>>>>> 7u2. >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>>> However, this function seems to be called >>>>>>>>>>>>>>>> from >>>>>>>>>>>>>>>> >>> Thread#setNativeName() >>>>>>>>>>>>>>>> >>> > >>>>> only. >>>>>>>>>>>>>>>> >>> > >>>>> In addition, Thread#setNativeName() is >>>>>>>>>>>>>>>> private >>>>>>>>>>>>>>>> method. >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> Thus I think that we can add an argument to >>>>>>>>>>>>>>>> >>> JVM_SetNativeThreadName() >>>>>>>>>>>>>>>> >>> > >>>>> for force setting. >>>>>>>>>>>>>>>> >>> > >>>>> (e.g. "bool forced") >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> It makes a change of JVM API. >>>>>>>>>>>>>>>> >>> > >>>>> However, this function is NOT public, so I >>>>>>>>>>>>>>>> think we >>>>>>>>>>>>>>>> can >>>>>>>>>>>>>>>> add one >>>>>>>>>>>>>>>> >>> more >>>>>>>>>>>>>>>> >>> > >>>>> argument. >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> What do you think about this? >>>>>>>>>>>>>>>> >>> > >>>>> If it is accepted, we can set native >>>>>>>>>>>>>>>> thread name >>>>>>>>>>>>>>>> from Java >>>>>>>>>>>>>>>> >>> launcher. >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>> The private/public aspect of the Java API >>>>>>>>>>>>>>>> is not >>>>>>>>>>>>>>>> really at >>>>>>>>>>>>>>>> >>> issue. Yes >>>>>>>>>>>>>>>> >>> > >>>> we would add another arg to the JVM >>>>>>>>>>>>>>>> function to >>>>>>>>>>>>>>>> allow >>>>>>>>>>>>>>>> it to >>>>>>>>>>>>>>>> apply to >>>>>>>>>>>>>>>> >>> > >>>> JNI-attached threads as well (I'd prefer >>>>>>>>>>>>>>>> the arg >>>>>>>>>>>>>>>> reflect that >>>>>>>>>>>>>>>> >>> not just >>>>>>>>>>>>>>>> >>> > >>>> "force"). However this is still a change to >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> exported JVM >>>>>>>>>>>>>>>> >>> interface >>>>>>>>>>>>>>>> >>> > >>>> and so has to be approved. Further, we >>>>>>>>>>>>>>>> expect the >>>>>>>>>>>>>>>> launcher to >>>>>>>>>>>>>>>> >>> use the >>>>>>>>>>>>>>>> >>> > >>>> supported JNI interface (as other processes >>>>>>>>>>>>>>>> would), >>>>>>>>>>>>>>>> not the >>>>>>>>>>>>>>>> internal >>>>>>>>>>>>>>>> >>> > >>>> JVM interface that exists for the JDK >>>>>>>>>>>>>>>> sources to >>>>>>>>>>>>>>>> communicate >>>>>>>>>>>>>>>> >>> with the >>>>>>>>>>>>>>>> >>> > >>>> JVM. >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>> David >>>>>>>>>>>>>>>> >>> > >>>> ----- >>>>>>>>>>>>>>>> >>> > >>>> >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> >>>>>>>>>>>>>>>> >>> > >>>>> On 2016/04/15 19:16, David Holmes wrote: >>>>>>>>>>>>>>>> >>> > >>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> On 15/04/2016 6:53 PM, Yasumasa Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>> Hi David, >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> The fact that the "main" thread is not >>>>>>>>>>>>>>>> tagged as >>>>>>>>>>>>>>>> being a >>>>>>>>>>>>>>>> >>> JNI-attached >>>>>>>>>>>>>>>> >>> > >>>>>>>> thread seems accidental to me >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> Should I file it to JBS? >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> I think it is a bug based on the comment >>>>>>>>>>>>>>>> here: >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> JavaThread(bool is_attaching_via_jni = >>>>>>>>>>>>>>>> false); // >>>>>>>>>>>>>>>> for main >>>>>>>>>>>>>>>> >>> thread and >>>>>>>>>>>>>>>> >>> > >>>>>> JNI attached threads >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> Though that will introduce a change in >>>>>>>>>>>>>>>> behaviour by >>>>>>>>>>>>>>>> itself as >>>>>>>>>>>>>>>> >>> setName >>>>>>>>>>>>>>>> >>> > >>>>>> will no longer set the native name for >>>>>>>>>>>>>>>> the main >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> I think that we can fix as below: >>>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>>> >>> > >>>>>>> diff -r 52aa0ee93b32 >>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/runtime/thread.cpp Fri >>>>>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>>>>> >>> > >>>>>>> @@ -3592,7 +3592,7 @@ >>>>>>>>>>>>>>>> >>> > >>>>>>> #endif // INCLUDE_JVMCI >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> // Attach the main thread to this os >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> > >>>>>>> - JavaThread* main_thread = new >>>>>>>>>>>>>>>> JavaThread(); >>>>>>>>>>>>>>>> >>> > >>>>>>> + JavaThread* main_thread = new >>>>>>>>>>>>>>>> JavaThread(true); >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>> >>> > >>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>> >>> > >>>>>>> // must do this before >>>>>>>>>>>>>>>> set_active_handles >>>>>>>>>>>>>>>> >>> > >>>>>>> @@ -3776,6 +3776,9 @@ >>>>>>>>>>>>>>>> >>> > >>>>>>> // Notify JVMTI agents that VM >>>>>>>>>>>>>>>> initialization >>>>>>>>>>>>>>>> is complete >>>>>>>>>>>>>>>> >>> - nop if >>>>>>>>>>>>>>>> >>> > >>>>>>> no agents. >>>>>>>>>>>>>>>> >>> > >>>>>>> JvmtiExport::post_vm_initialized(); >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> + // Change attach status to "attached" >>>>>>>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>>>>>>> main_thread->set_done_attaching_via_jni(); >>>>>>>>>>>>>>>> >>> > >>>>>>> + >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> I think we can do this straight after the >>>>>>>>>>>>>>>> JavaThread >>>>>>>>>>>>>>>> constructor. >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> if (TRACE_START() != JNI_OK) { >>>>>>>>>>>>>>>> >>> > >>>>>>> vm_exit_during_initialization("Failed to >>>>>>>>>>>>>>>> start >>>>>>>>>>>>>>>> tracing >>>>>>>>>>>>>>>> >>> > >>>>>>> backend."); >>>>>>>>>>>>>>>> >>> > >>>>>>> } >>>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> If it wants to name its native threads >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> it is >>>>>>>>>>>>>>>> free >>>>>>>>>>>>>>>> to do so, >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> Currently, JVM_SetNativeThreadName() cannot >>>>>>>>>>>>>>>> change >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> >>> thread name >>>>>>>>>>>>>>>> >>> > >>>>>>> when the caller thread is JNI-attached >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>> > >>>>>>> However, I think that it should be >>>>>>>>>>>>>>>> changed if >>>>>>>>>>>>>>>> Java >>>>>>>>>>>>>>>> developer >>>>>>>>>>>>>>>> >>> calls >>>>>>>>>>>>>>>> >>> > >>>>>>> Thread#setName() explicitly. >>>>>>>>>>>>>>>> >>> > >>>>>>> It is not the same of changing native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> name at >>>>>>>>>>>>>>>> >>> > >>>>>>> Threads::create_vm(). >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> If it is allowed, I want to fix >>>>>>>>>>>>>>>> SetNativeThreadName() as >>>>>>>>>>>>>>>> below. >>>>>>>>>>>>>>>> >>> > >>>>>>> What do you think about this? >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> The decision to not change the name of >>>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>>> threads was a >>>>>>>>>>>>>>>> >>> > >>>>>> deliberate one** - this functionality >>>>>>>>>>>>>>>> originated >>>>>>>>>>>>>>>> with the OSX >>>>>>>>>>>>>>>> >>> port and >>>>>>>>>>>>>>>> >>> > >>>>>> it was reported that the initial feedback >>>>>>>>>>>>>>>> with >>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>> feature was to >>>>>>>>>>>>>>>> >>> > >>>>>> ensure it didn't mess with thread names that >>>>>>>>>>>>>>>> had >>>>>>>>>>>>>>>> been set by >>>>>>>>>>>>>>>> >>> the host >>>>>>>>>>>>>>>> >>> > >>>>>> process. If we do as you propose then we >>>>>>>>>>>>>>>> will >>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>> have an >>>>>>>>>>>>>>>> >>> > >>>>>> inconsistency for people to complain about: >>>>>>>>>>>>>>>> "why >>>>>>>>>>>>>>>> does my >>>>>>>>>>>>>>>> >>> native thread >>>>>>>>>>>>>>>> >>> > >>>>>> only have a name if I call >>>>>>>>>>>>>>>> cur.setName(cur.getName()) ?" >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> ** If you follow the bugs and related >>>>>>>>>>>>>>>> discussions on >>>>>>>>>>>>>>>> this, the >>>>>>>>>>>>>>>> >>> > >>>>>> semantics and limitations (truncation, >>>>>>>>>>>>>>>> current >>>>>>>>>>>>>>>> thread only, >>>>>>>>>>>>>>>> >>> non-JNI >>>>>>>>>>>>>>>> >>> > >>>>>> threads only) of setting the native >>>>>>>>>>>>>>>> thread name >>>>>>>>>>>>>>>> were supposed >>>>>>>>>>>>>>>> >>> to be >>>>>>>>>>>>>>>> >>> > >>>>>> documented in the release notes - but as far >>>>>>>>>>>>>>>> as I >>>>>>>>>>>>>>>> can see >>>>>>>>>>>>>>>> that >>>>>>>>>>>>>>>> >>> never >>>>>>>>>>>>>>>> >>> > >>>>>> happened. :( >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> My position on this remains that if it is >>>>>>>>>>>>>>>> desirable >>>>>>>>>>>>>>>> for >>>>>>>>>>>>>>>> the main >>>>>>>>>>>>>>>> >>> > >>>>>> thread (and DestroyJavaVM thread) to have >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> names >>>>>>>>>>>>>>>> then the >>>>>>>>>>>>>>>> >>> > >>>>>> launcher needs to be setting them using the >>>>>>>>>>>>>>>> available >>>>>>>>>>>>>>>> platform >>>>>>>>>>>>>>>> >>> APIs. >>>>>>>>>>>>>>>> >>> > >>>>>> Unfortunately this is complicated - as >>>>>>>>>>>>>>>> evidenced by >>>>>>>>>>>>>>>> the VM >>>>>>>>>>>>>>>> >>> code for >>>>>>>>>>>>>>>> >>> > >>>>>> this - due to the need to verify API >>>>>>>>>>>>>>>> availability. >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> Any change in behaviour in relation to >>>>>>>>>>>>>>>> Thread.setName would >>>>>>>>>>>>>>>> >>> have to go >>>>>>>>>>>>>>>> >>> > >>>>>> through our CCC process I think. But a >>>>>>>>>>>>>>>> change in >>>>>>>>>>>>>>>> the launcher >>>>>>>>>>>>>>>> >>> would >>>>>>>>>>>>>>>> >>> > >>>>>> not. >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> Sorry. >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>> David >>>>>>>>>>>>>>>> >>> > >>>>>> ----- >>>>>>>>>>>>>>>> >>> > >>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>>> >>> > >>>>>>> --- a/src/share/vm/prims/jvm.cpp Thu >>>>>>>>>>>>>>>> Apr 14 >>>>>>>>>>>>>>>> 13:31:11 >>>>>>>>>>>>>>>> >>> 2016 +0200 >>>>>>>>>>>>>>>> >>> > >>>>>>> +++ b/src/share/vm/prims/jvm.cpp Fri >>>>>>>>>>>>>>>> Apr 15 >>>>>>>>>>>>>>>> 17:50:10 >>>>>>>>>>>>>>>> >>> 2016 +0900 >>>>>>>>>>>>>>>> >>> > >>>>>>> @@ -3187,7 +3187,7 @@ >>>>>>>>>>>>>>>> >>> > >>>>>>> JavaThread* thr = >>>>>>>>>>>>>>>> java_lang_Thread::thread(java_thread); >>>>>>>>>>>>>>>> >>> > >>>>>>> // Thread naming only supported for the >>>>>>>>>>>>>>>> current >>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>> >>> doesn't >>>>>>>>>>>>>>>> >>> > >>>>>>> work >>>>>>>>>>>>>>>> >>> > >>>>>>> for >>>>>>>>>>>>>>>> >>> > >>>>>>> // target threads. >>>>>>>>>>>>>>>> >>> > >>>>>>> - if (Thread::current() == thr && >>>>>>>>>>>>>>>> >>> !thr->has_attached_via_jni()) { >>>>>>>>>>>>>>>> >>> > >>>>>>> + if (Thread::current() == thr) { >>>>>>>>>>>>>>>> >>> > >>>>>>> // we don't set the name of an >>>>>>>>>>>>>>>> attached >>>>>>>>>>>>>>>> thread to avoid >>>>>>>>>>>>>>>> >>> stepping >>>>>>>>>>>>>>>> >>> > >>>>>>> // on other programs >>>>>>>>>>>>>>>> >>> > >>>>>>> const char *thread_name = >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> --------------- >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>> On 2016/04/15 13:32, David Holmes wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> On 15/04/2016 1:11 AM, Yasumasa Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>> Roger, >>>>>>>>>>>>>>>> >>> > >>>>>>>>> Thanks for your comment! >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> David, >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks >>>>>>>>>>>>>>>> about >>>>>>>>>>>>>>>> this. I >>>>>>>>>>>>>>>> don't like >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> I tried to call Thread#setName() after >>>>>>>>>>>>>>>> initializing VM >>>>>>>>>>>>>>>> (before >>>>>>>>>>>>>>>> >>> > >>>>>>>>> calling >>>>>>>>>>>>>>>> >>> > >>>>>>>>> main method), >>>>>>>>>>>>>>>> >>> > >>>>>>>>> I could set native thread name. >>>>>>>>>>>>>>>> >>> > >>>>>>>>> However, DestroyJavaVM() calls >>>>>>>>>>>>>>>> AttachCurrentThread(). >>>>>>>>>>>>>>>> So we >>>>>>>>>>>>>>>> >>> can't >>>>>>>>>>>>>>>> >>> > >>>>>>>>> set >>>>>>>>>>>>>>>> >>> > >>>>>>>>> native thread name for DestroyJavaVM. >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> Right - I came to the same realization >>>>>>>>>>>>>>>> earlier >>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>> morning. >>>>>>>>>>>>>>>> >>> Which, >>>>>>>>>>>>>>>> >>> > >>>>>>>> unfortunately, takes me back to the basic >>>>>>>>>>>>>>>> premise >>>>>>>>>>>>>>>> here that >>>>>>>>>>>>>>>> >>> we don't >>>>>>>>>>>>>>>> >>> > >>>>>>>> set the name of threads not created by the >>>>>>>>>>>>>>>> JVM. >>>>>>>>>>>>>>>> The fact >>>>>>>>>>>>>>>> >>> that the >>>>>>>>>>>>>>>> >>> > >>>>>>>> "main" thread is not tagged as being a >>>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>>> thread seems >>>>>>>>>>>>>>>> >>> > >>>>>>>> accidental to me - so >>>>>>>>>>>>>>>> JVM_SetNativeThreadName is >>>>>>>>>>>>>>>> only >>>>>>>>>>>>>>>> working by >>>>>>>>>>>>>>>> >>> > >>>>>>>> accident for the initial attach, and >>>>>>>>>>>>>>>> can't be >>>>>>>>>>>>>>>> used for the >>>>>>>>>>>>>>>> >>> > >>>>>>>> DestroyJavaVM part - which leaves the >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> inconsistently >>>>>>>>>>>>>>>> >>> named at >>>>>>>>>>>>>>>> >>> > >>>>>>>> the native level. >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> I'm afraid my view here is that the >>>>>>>>>>>>>>>> launcher >>>>>>>>>>>>>>>> has >>>>>>>>>>>>>>>> to be >>>>>>>>>>>>>>>> >>> treated like >>>>>>>>>>>>>>>> >>> > >>>>>>>> any other process that might host a JVM. >>>>>>>>>>>>>>>> If it >>>>>>>>>>>>>>>> wants to >>>>>>>>>>>>>>>> name its >>>>>>>>>>>>>>>> >>> > >>>>>>>> native threads then it is free to do so, >>>>>>>>>>>>>>>> but I >>>>>>>>>>>>>>>> would not be >>>>>>>>>>>>>>>> >>> exporting >>>>>>>>>>>>>>>> >>> > >>>>>>>> a function from the JVM to do that - it >>>>>>>>>>>>>>>> would >>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>> use the OS >>>>>>>>>>>>>>>> >>> > >>>>>>>> specific API's for that on a >>>>>>>>>>>>>>>> platform-by-platform >>>>>>>>>>>>>>>> basis. >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> Sorry. >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> David >>>>>>>>>>>>>>>> >>> > >>>>>>>> ----- >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>> On 2016/04/14 23:24, Roger Riggs wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> Comments: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> jvm.h: The function names are too >>>>>>>>>>>>>>>> similar >>>>>>>>>>>>>>>> but >>>>>>>>>>>>>>>> perform >>>>>>>>>>>>>>>> >>> different >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> functions: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> -JVM_SetNativeThreadName0 vs >>>>>>>>>>>>>>>> JVM_SetNativeThreadName >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> - The first function applies to the >>>>>>>>>>>>>>>> current >>>>>>>>>>>>>>>> thread, the >>>>>>>>>>>>>>>> >>> second >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> one a >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> specific java thread. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> It would seem useful for there to be a >>>>>>>>>>>>>>>> comment >>>>>>>>>>>>>>>> somewhere >>>>>>>>>>>>>>>> >>> about >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> what >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> the new function does. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> windows/native/libjli/java_md.c: line >>>>>>>>>>>>>>>> 408 >>>>>>>>>>>>>>>> casts to >>>>>>>>>>>>>>>> (void*) >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> instead of >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> (SetNativeThreadName0_t) >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> as is done on unix and mac. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> - macosx/native/libjli/java_md_macosx.c: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> - 737: looks wrong to >>>>>>>>>>>>>>>> overwriteifn->GetCreatedJavaVMs >>>>>>>>>>>>>>>> >>> used at >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> line 730 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> - 738 Incorrect indentation; if >>>>>>>>>>>>>>>> possible >>>>>>>>>>>>>>>> keep >>>>>>>>>>>>>>>> the cast >>>>>>>>>>>>>>>> >>> on the >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> same >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> line as dlsym... >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> $.02, Roger >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> On 4/14/2016 9:32 AM, Yasumasa Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question >>>>>>>>>>>>>>>> which I >>>>>>>>>>>>>>>> haven't had >>>>>>>>>>>>>>>> time to >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is >>>>>>>>>>>>>>>> considered a >>>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>>> >>> thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>>>>> then my >>>>>>>>>>>>>>>> suggestion >>>>>>>>>>>>>>>> >>> should >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>>>>> in our >>>>>>>>>>>>>>>> treatment of >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> I ran following program on JDK 9 EA >>>>>>>>>>>>>>>> b112, >>>>>>>>>>>>>>>> and I >>>>>>>>>>>>>>>> confirmed >>>>>>>>>>>>>>>> >>> native >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> thread name (test) was set. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> public class Sleep{ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> public static void main(String[] args) >>>>>>>>>>>>>>>> throws >>>>>>>>>>>>>>>> Exception{ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.currentThread().setName("test"); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thread.sleep(3600000); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> } >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> --------- >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks >>>>>>>>>>>>>>>> about >>>>>>>>>>>>>>>> this. I >>>>>>>>>>>>>>>> don't like >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> I will update webrev after hearing >>>>>>>>>>>>>>>> Kumar's >>>>>>>>>>>>>>>> comment. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>> On 2016/04/14 21:32, David Holmes >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> On 14/04/2016 1:52 PM, Yasumasa >>>>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> On 2016/04/14 9:34, David Holmes >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> On 14/04/2016 1:28 AM, Yasumasa >>>>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Hi David, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks for your comment. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> I exported new JVM function to set >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> name, and JLI >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> uses it >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> in new webrev. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> First the launcher belongs to >>>>>>>>>>>>>>>> another >>>>>>>>>>>>>>>> team so >>>>>>>>>>>>>>>> >>> core-libs will >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> need to >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> review and approve this (in >>>>>>>>>>>>>>>> particular >>>>>>>>>>>>>>>> Kumar) - >>>>>>>>>>>>>>>> now cc'd. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I'm waiting to review :-) >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Personally I would have used a Java >>>>>>>>>>>>>>>> upcall to >>>>>>>>>>>>>>>> >>> Thread.setName >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> rather >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> than exporting >>>>>>>>>>>>>>>> JVM_SetNativeThreadName. No >>>>>>>>>>>>>>>> hotspot changes >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> needed in >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> that case. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> As I wrote [1] in JBS, I changed >>>>>>>>>>>>>>>> to use >>>>>>>>>>>>>>>> Thread#setName() in >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thread#init(), >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> but I could not change native thread >>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> At Thread.init time the thread is not >>>>>>>>>>>>>>>> alive, >>>>>>>>>>>>>>>> which is >>>>>>>>>>>>>>>> >>> why the >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> native >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> name is not set. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> I guess that caller of main() is JNI >>>>>>>>>>>>>>>> attached thread. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> That is an interesting question >>>>>>>>>>>>>>>> which I >>>>>>>>>>>>>>>> haven't had >>>>>>>>>>>>>>>> time to >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> check - >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> sorry. If the main thread is >>>>>>>>>>>>>>>> considered a >>>>>>>>>>>>>>>> JNI-attached >>>>>>>>>>>>>>>> >>> thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> then >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> my suggestion wont work. If it isn't >>>>>>>>>>>>>>>> then my >>>>>>>>>>>>>>>> suggestion >>>>>>>>>>>>>>>> >>> should >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> work >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> (but it means we have an inconsistency >>>>>>>>>>>>>>>> in our >>>>>>>>>>>>>>>> treatment of >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> JNI-attached threads :( ) >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> I'll wait to see what Kumar thinks >>>>>>>>>>>>>>>> about >>>>>>>>>>>>>>>> this. I >>>>>>>>>>>>>>>> don't like >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> exposing >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> a new JVM function this way. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> David >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> ----- >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thus I think that we have to >>>>>>>>>>>>>>>> provide a >>>>>>>>>>>>>>>> function to set >>>>>>>>>>>>>>>> >>> native >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> thread name. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> [1] >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> https://bugs.openjdk.java.net/browse/JDK-8152690?focusedCommentId=13926851&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13926851 >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Could you review again? >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - hotspot: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/hotspot/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> - jdk: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.02/jdk/ >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>> On 2016/04/13 22:00, David Holmes >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> I'll answer on this original >>>>>>>>>>>>>>>> thread as >>>>>>>>>>>>>>>> well ... >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Hi Yasumasa, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> Please see my updates to the bug >>>>>>>>>>>>>>>> (sorry >>>>>>>>>>>>>>>> have >>>>>>>>>>>>>>>> been on >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> vacation). >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> This >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> needs to be done in the launcher >>>>>>>>>>>>>>>> to be >>>>>>>>>>>>>>>> correct >>>>>>>>>>>>>>>> as we >>>>>>>>>>>>>>>> >>> do not >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> set the >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> name of threads that attach via >>>>>>>>>>>>>>>> JNI, >>>>>>>>>>>>>>>> which >>>>>>>>>>>>>>>> includes the >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> "main" >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> David >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> On 31/03/2016 9:49 AM, Yasumasa >>>>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Thanks Robbin, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> I'm waiting a sponsor and more >>>>>>>>>>>>>>>> reviewer >>>>>>>>>>>>>>>> :-) >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> 2016/03/31 5:58 "Robbin Ehn" >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> FYI: I'm not a Reviewer. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> On 03/30/2016 10:55 PM, >>>>>>>>>>>>>>>> Robbin Ehn >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> Thanks, looks good. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> On 03/30/2016 03:47 PM, >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> I uploaded new webrev. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Could you review it? >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.01/ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> On 2016/03/30 19:10, Robbin >>>>>>>>>>>>>>>> Ehn >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> On 03/30/2016 11:41 AM, >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> Suenaga >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Hi Robbin, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016/03/30 18:22 "Robbin >>>>>>>>>>>>>>>> Ehn" >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>>: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Hi Yasumasa, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > On 03/25/2016 12:48 AM, >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> Suenaga wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Hi Robbin, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> 2016/03/25 1:51 >>>>>>>>>>>>>>>> "Robbin Ehn" >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>> >>>>: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Hi Yasumasa, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > I'm not sure why you >>>>>>>>>>>>>>>> don't >>>>>>>>>>>>>>>> set it: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > diff -r ded6ef79c770 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > --- >>>>>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 13:09:16 2016 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0000 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > +++ >>>>>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp Thu >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Mar 24 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 17:40:09 2016 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0100 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > @@ -3584,6 +3584,7 @@ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > JavaThread* >>>>>>>>>>>>>>>> main_thread = >>>>>>>>>>>>>>>> new >>>>>>>>>>>>>>>> >>> JavaThread(); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> main_thread->set_thread_state(_thread_in_vm); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> main_thread->initialize_thread_current(); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > + >>>>>>>>>>>>>>>> >>> main_thread->set_native_thread_name("main"); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > // must do this >>>>>>>>>>>>>>>> before >>>>>>>>>>>>>>>> >>> set_active_handles >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> main_thread->record_stack_base_and_size(); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> main_thread->set_active_handles(JNIHandleBlock::allocate_block()); >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > here instead? Am I >>>>>>>>>>>>>>>> missing >>>>>>>>>>>>>>>> something? >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Native thread name is the >>>>>>>>>>>>>>>> same >>>>>>>>>>>>>>>> to thread >>>>>>>>>>>>>>>> >>> name in >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> class. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> It is set in c'tor in >>>>>>>>>>>>>>>> Thread or >>>>>>>>>>>>>>>> setName(). >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> If you create new >>>>>>>>>>>>>>>> thread in >>>>>>>>>>>>>>>> Java >>>>>>>>>>>>>>>> app, >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> will be >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> set at >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> startup. However, main >>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>> already >>>>>>>>>>>>>>>> >>> starte >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> in VM. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thread name for "main" is >>>>>>>>>>>>>>>> set in >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> create_initial_thread(). >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> I think that the place of >>>>>>>>>>>>>>>> setting >>>>>>>>>>>>>>>> thrrad name >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> should >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> be the >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> same. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Yes, I see your point. But >>>>>>>>>>>>>>>> then >>>>>>>>>>>>>>>> something like >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this is >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> nicer, no? >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > --- >>>>>>>>>>>>>>>> a/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>> Tue >>>>>>>>>>>>>>>> >>> Mar 29 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 09:43:05 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > +++ >>>>>>>>>>>>>>>> b/src/share/vm/runtime/thread.cpp >>>>>>>>>>>>>>>> Wed >>>>>>>>>>>>>>>> >>> Mar 30 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 10:51:12 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 2016 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> +0200 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -981,6 +981,7 @@ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > // Creates the initial >>>>>>>>>>>>>>>> Thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > static oop >>>>>>>>>>>>>>>> create_initial_thread(Handle >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread_group, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread* >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > TRAPS) { >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + static const char* >>>>>>>>>>>>>>>> initial_thread_name = >>>>>>>>>>>>>>>> >>> "main"; >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Klass* k = >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> true, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceKlassHandle >>>>>>>>>>>>>>>> klass >>>>>>>>>>>>>>>> (THREAD, k); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > instanceHandle >>>>>>>>>>>>>>>> thread_oop = >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> klass->allocate_instance_handle(CHECK_NULL); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > @@ -988,8 +989,10 @@ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> java_lang_Thread::set_thread(thread_oop(), >>>>>>>>>>>>>>>> >>> thread); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> java_lang_Thread::set_priority(thread_oop(), >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> NormPriority); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> thread->set_threadObj(thread_oop()); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > - Handle string = >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> java_lang_String::create_from_str("main", >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> thread->set_native_thread_name(initial_thread_name); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > + Handle string = >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> java_lang_String::create_from_str(initial_thread_name, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> CHECK_NULL); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > JavaValue >>>>>>>>>>>>>>>> result(T_VOID); >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> JavaCalls::call_special(&result, >>>>>>>>>>>>>>>> thread_oop, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Okay, I will upload new >>>>>>>>>>>>>>>> webrev >>>>>>>>>>>>>>>> later. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks! >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > The launcher seem >>>>>>>>>>>>>>>> to name >>>>>>>>>>>>>>>> itself >>>>>>>>>>>>>>>> 'java' and >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> naming >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> this >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> just >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > 'main' is confusing to >>>>>>>>>>>>>>>> me. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > E.g. so main thread of >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> process >>>>>>>>>>>>>>>> (and >>>>>>>>>>>>>>>> >>> thus >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> process) is >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> 'java' but >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > first JavaThread is >>>>>>>>>>>>>>>> 'main'. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> The native main thread in >>>>>>>>>>>>>>>> the >>>>>>>>>>>>>>>> process >>>>>>>>>>>>>>>> is not >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> It is >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> waiting >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> for ending of Java main >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> with >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_join(). >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> set_native_thread_name() is >>>>>>>>>>>>>>>> for >>>>>>>>>>>>>>>> >>> JavaThread. So I >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> think that >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> we do >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> not >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> need to call it for >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> main >>>>>>>>>>>>>>>> thread. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Not sure if we can >>>>>>>>>>>>>>>> change it >>>>>>>>>>>>>>>> anyhow, since >>>>>>>>>>>>>>>> >>> we want >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> java and >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name to be the same and java >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> name >>>>>>>>>>>>>>>> might >>>>>>>>>>>>>>>> >>> have >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> some >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> dependents. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > The name is visible in >>>>>>>>>>>>>>>> e.g. >>>>>>>>>>>>>>>> /proc. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > $ ps H -C java -o 'pid tid >>>>>>>>>>>>>>>> comm' >>>>>>>>>>>>>>>> | head -4 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > PID TID COMMAND >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6423 java >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6424 main >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > 6423 6425 GC Thread#0 >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > It would be nice with >>>>>>>>>>>>>>>> something >>>>>>>>>>>>>>>> like >>>>>>>>>>>>>>>> 'Java Main >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thread'. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> I do not think so. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Native main thread might not >>>>>>>>>>>>>>>> be a >>>>>>>>>>>>>>>> Java >>>>>>>>>>>>>>>> >>> launcher - e.g. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Apache >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> commons-daemon, JNI >>>>>>>>>>>>>>>> application, >>>>>>>>>>>>>>>> etc. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> If you want to change native >>>>>>>>>>>>>>>> main >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> name, >>>>>>>>>>>>>>>> >>> I think >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> that we >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> have to >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> change Java launcher code. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Should I include it in new >>>>>>>>>>>>>>>> webrev? >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> No >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> Thanks again! >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> /Robbin >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > Thanks >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > /Robbin >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > Thanks! >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > /Robbin >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > On 03/24/2016 03:26 >>>>>>>>>>>>>>>> PM, >>>>>>>>>>>>>>>> Yasumasa >>>>>>>>>>>>>>>> >>> Suenaga wrote: >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Hi all, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > HotSpot for Linux >>>>>>>>>>>>>>>> will >>>>>>>>>>>>>>>> set >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> name via >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> pthread_setname_np(). >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > However, main thread >>>>>>>>>>>>>>>> does not >>>>>>>>>>>>>>>> have it. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > All JavaThread have >>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> name, >>>>>>>>>>>>>>>> and main >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread is >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> JavaThread. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > For consistency, >>>>>>>>>>>>>>>> main >>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> should have >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> native >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> thread >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> name. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I uploaded a webrev. >>>>>>>>>>>>>>>> Could >>>>>>>>>>>>>>>> you >>>>>>>>>>>>>>>> review it? >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8152690/webrev.00/ >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > I cannot access >>>>>>>>>>>>>>>> JPRT. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > So I need a sponsor. >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Thanks, >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > Yasumasa >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> > > >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>> >>>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>> >>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>> >> From vitalyd at gmail.com Tue Apr 26 23:38:36 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Tue, 26 Apr 2016 19:38:36 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <571FE3EF.7050001@oracle.com> References: <571FE3EF.7050001@oracle.com> Message-ID: I've yet to hear one supporter on this thread besides yourself and Stuart. Is there some usability survey or something that actually indicates a significant sample of people don't like the name? Guava Optional behaves and is named the same way, and I've not heard anyone complain about that (I and many people I know used it for years). I think the conversation would be *maybe* different if picking a name for a new thing, but the deprecation churn here adds no value, IMO, and is going to be viewed as an annoyance by a large swath of people. On Tuesday, April 26, 2016, Brian Goetz wrote: > As the person who chose the original (terrible) name, let me weigh in... > > I think calling this method "get()" was our biggest API mistake in Java > 8. Now, one could argue that, if this is the biggest mistake we made, then > we did pretty darn good. Which may be true, but ... make no mistake, it > was the wrong name (mea culpa), and experience has borne out that it is > widely misused. Subjectively, about half the uses of .get() I see are > wrong -- and wrong in the obvious, avoidable way -- they don't consider the > optional might be empty. So they've just traded an unexpected NPE for an > unexpected NSEE. > > Its problem is, essentially: it looks harmless, but isn't, but it sure > seems like the method you obviously want when you're browsing the > autocomplete list / javadoc. It's a hazard both to code writers (pick the > wrong method because the name is bad) and to code readers (deceptively > harmless looking.) > > Methods like orElse or ifPresent look harmless, and are; methods like > orElseThrow have potentially harmful side-effects but have names that are > transparent about what harm they could do. But Optional.get() is neither > safe nor transparent -- and yet awfully tempting-looking -- and this leads > to frequent misuse. Naming matters, and this one was wrong, and the harm > is observable. I wish I'd caught it before 8 shipped. > > Stepping back a bit ... one of the most frequent complaints we get is > "mistakes never get fixed". So, we've decided to be more serious about > deprecation -- Dr. Deprecator is suiting up! But that means, for any given > item, some people are going to disagree about whether deprecation is > suitable, and some will be inconvenienced by the deprecation -- this is > unavoidable. > > Why prioritize this one? In part, because it's a *new* mistake, and has > had less time to become entrenched -- and this is the very first > opportunity we have to fix it. If we can't fix an API mistake at the very > first opportunity, the logical consequence is we can't ever fix anything. > And that doesn't seem to be the world we want to retreat to. > > Similarly, is this the worst mistake in all of Java? Surely not. But its > also not reasonable to say "you can't fix X until you've fixed everything > worse than X" -- again, that's a recipe for never fixing anything. So, in > the context of a deprecation effort, this seems an entirely reasonable > candidate. > > I'd like to see it fixed, and the sooner the better. > > > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this >> would be painful and add no value. >> >> While I understand the pain from some developers not understanding the >> feature, this is hardly unique in the world of Java. Developers learn >> the right way of doing something soon enough. >> >> And while >> >> if (opt.isPresent()) { >> opt.get() >> } >> >> is sometimes not ideal, in other cases it is the only practical choice >> (eg. where the method needs to have a return statement inside the if >> statement). >> >> Changing this to >> >> if (opt.isPresent()) { >> opt.getWhenPresent() >> } >> >> is just noise - I can see the "present" part twice. >> >> I just don't think I can support the rename (although many of the >> webrev tidy-ups are probably good). >> >> Stephen >> >> >> >> On 26 April 2016 at 00:05, Stuart Marks wrote: >> >>> Hi all, >>> >>> Please review these webrevs that deprecate Optional.get() and to replace >>> it >>> with Optional.getWhenPresent(). The corresponding changes are also >>> applied >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >>> OptionalLong.getAsLong(). >>> >>> Unlike most deprecations, this isn't about the function or the utility of >>> some API, it's about the name. The solution is basically to rename the >>> API. >>> The problem is that "get" shows up as the "obvious" choice in things like >>> IDE code completion, leading to code that mishandles empty Optionals. >>> Typical Stack Overflow discourse runs something like this: >>> >>> Q: what do I do with this Optional thing >>> >>> A: just call get() >>> >>> Q: thanks, it works! >>> >>> Of course, it works until it doesn't. >>> >>> Examining the JDK's use of Optional.get(), I didn't see very many cases >>> that >>> called get() without first checking for the presence of a value. But I >>> did >>> see quite a number of cases like this: >>> >>> if (opt.isPresent()) { >>> doSomething(opt.get()); >>> } else { >>> doSomethingElse(); >>> } >>> >>> In many of these cases, the code could be refactored to use other >>> Optional >>> methods such as filter(), map(), or ifPresent(). >>> >>> In any case this reinforces the contention that use of get() leads to >>> poor >>> code. >>> >>> For this changeset, in just about all cases I've simply replaced the >>> call to >>> get() with a call to getWhenPresent(). In a couple cases I replaced the >>> stream calls >>> >>> .filter(Optional::isPresent).map(Optional::get) >>> >>> with >>> >>> .flatMap(Optional::stream) >>> >>> which I hope will become the new idiom for unwrapping a stream of >>> Optionals. >>> >>> While many cases could be cleaned up further, I didn't change them. The >>> reasons are that I didn't want to spend too much time putting code >>> cleanup >>> into the critical path of this changeset (I'd be happy to help later); >>> doing >>> so would create potential conflicts with code coming in from the Jigsaw >>> forest; and there are non-obvious places where converting from a >>> conditional >>> to one of the lambda-based methods could cause performance problems at >>> startup. >>> >>> There are also a few cases where simplification is prevented because it >>> would end up causing the resulting lambda expressions to throw checked >>> exceptions. :-( >>> >>> Webrevs here: >>> >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >>> >>> Thanks, >>> >>> s'marks >>> >> > -- Sent from my phone From pbenedict at apache.org Wed Apr 27 00:05:27 2016 From: pbenedict at apache.org (Paul Benedict) Date: Tue, 26 Apr 2016 19:05:27 -0500 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: Are you asking Brian to set up another survey monkey for the masses? I expect a happy silent majority and a raucous minority.... just based on past results. :-) On Apr 26, 2016 6:38 PM, "Vitaly Davidovich" wrote: I've yet to hear one supporter on this thread besides yourself and Stuart. Is there some usability survey or something that actually indicates a significant sample of people don't like the name? Guava Optional behaves and is named the same way, and I've not heard anyone complain about that (I and many people I know used it for years). I think the conversation would be *maybe* different if picking a name for a new thing, but the deprecation churn here adds no value, IMO, and is going to be viewed as an annoyance by a large swath of people. On Tuesday, April 26, 2016, Brian Goetz wrote: > As the person who chose the original (terrible) name, let me weigh in... > > I think calling this method "get()" was our biggest API mistake in Java > 8. Now, one could argue that, if this is the biggest mistake we made, then > we did pretty darn good. Which may be true, but ... make no mistake, it > was the wrong name (mea culpa), and experience has borne out that it is > widely misused. Subjectively, about half the uses of .get() I see are > wrong -- and wrong in the obvious, avoidable way -- they don't consider the > optional might be empty. So they've just traded an unexpected NPE for an > unexpected NSEE. > > Its problem is, essentially: it looks harmless, but isn't, but it sure > seems like the method you obviously want when you're browsing the > autocomplete list / javadoc. It's a hazard both to code writers (pick the > wrong method because the name is bad) and to code readers (deceptively > harmless looking.) > > Methods like orElse or ifPresent look harmless, and are; methods like > orElseThrow have potentially harmful side-effects but have names that are > transparent about what harm they could do. But Optional.get() is neither > safe nor transparent -- and yet awfully tempting-looking -- and this leads > to frequent misuse. Naming matters, and this one was wrong, and the harm > is observable. I wish I'd caught it before 8 shipped. > > Stepping back a bit ... one of the most frequent complaints we get is > "mistakes never get fixed". So, we've decided to be more serious about > deprecation -- Dr. Deprecator is suiting up! But that means, for any given > item, some people are going to disagree about whether deprecation is > suitable, and some will be inconvenienced by the deprecation -- this is > unavoidable. > > Why prioritize this one? In part, because it's a *new* mistake, and has > had less time to become entrenched -- and this is the very first > opportunity we have to fix it. If we can't fix an API mistake at the very > first opportunity, the logical consequence is we can't ever fix anything. > And that doesn't seem to be the world we want to retreat to. > > Similarly, is this the worst mistake in all of Java? Surely not. But its > also not reasonable to say "you can't fix X until you've fixed everything > worse than X" -- again, that's a recipe for never fixing anything. So, in > the context of a deprecation effort, this seems an entirely reasonable > candidate. > > I'd like to see it fixed, and the sooner the better. > > > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this >> would be painful and add no value. >> >> While I understand the pain from some developers not understanding the >> feature, this is hardly unique in the world of Java. Developers learn >> the right way of doing something soon enough. >> >> And while >> >> if (opt.isPresent()) { >> opt.get() >> } >> >> is sometimes not ideal, in other cases it is the only practical choice >> (eg. where the method needs to have a return statement inside the if >> statement). >> >> Changing this to >> >> if (opt.isPresent()) { >> opt.getWhenPresent() >> } >> >> is just noise - I can see the "present" part twice. >> >> I just don't think I can support the rename (although many of the >> webrev tidy-ups are probably good). >> >> Stephen >> >> >> >> On 26 April 2016 at 00:05, Stuart Marks wrote: >> >>> Hi all, >>> >>> Please review these webrevs that deprecate Optional.get() and to replace >>> it >>> with Optional.getWhenPresent(). The corresponding changes are also >>> applied >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >>> OptionalLong.getAsLong(). >>> >>> Unlike most deprecations, this isn't about the function or the utility of >>> some API, it's about the name. The solution is basically to rename the >>> API. >>> The problem is that "get" shows up as the "obvious" choice in things like >>> IDE code completion, leading to code that mishandles empty Optionals. >>> Typical Stack Overflow discourse runs something like this: >>> >>> Q: what do I do with this Optional thing >>> >>> A: just call get() >>> >>> Q: thanks, it works! >>> >>> Of course, it works until it doesn't. >>> >>> Examining the JDK's use of Optional.get(), I didn't see very many cases >>> that >>> called get() without first checking for the presence of a value. But I >>> did >>> see quite a number of cases like this: >>> >>> if (opt.isPresent()) { >>> doSomething(opt.get()); >>> } else { >>> doSomethingElse(); >>> } >>> >>> In many of these cases, the code could be refactored to use other >>> Optional >>> methods such as filter(), map(), or ifPresent(). >>> >>> In any case this reinforces the contention that use of get() leads to >>> poor >>> code. >>> >>> For this changeset, in just about all cases I've simply replaced the >>> call to >>> get() with a call to getWhenPresent(). In a couple cases I replaced the >>> stream calls >>> >>> .filter(Optional::isPresent).map(Optional::get) >>> >>> with >>> >>> .flatMap(Optional::stream) >>> >>> which I hope will become the new idiom for unwrapping a stream of >>> Optionals. >>> >>> While many cases could be cleaned up further, I didn't change them. The >>> reasons are that I didn't want to spend too much time putting code >>> cleanup >>> into the critical path of this changeset (I'd be happy to help later); >>> doing >>> so would create potential conflicts with code coming in from the Jigsaw >>> forest; and there are non-obvious places where converting from a >>> conditional >>> to one of the lambda-based methods could cause performance problems at >>> startup. >>> >>> There are also a few cases where simplification is prevented because it >>> would end up causing the resulting lambda expressions to throw checked >>> exceptions. :-( >>> >>> Webrevs here: >>> >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >>> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >>> >>> Thanks, >>> >>> s'marks >>> >> > -- Sent from my phone From vitalyd at gmail.com Wed Apr 27 00:16:01 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Tue, 26 Apr 2016 20:16:01 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: I'm really grasping at straws here and asking for something quantitative to substantiate this deprecation plan. As it stands, there is hearsay and some stackoverflow links - surely going through with this (and inflicting some level of pain on folks who don't care for this) deserves something a bit better? Brian mentioned that one criticism often heard is mistakes aren't corrected - I fully believe that's true. But this may end up being one of those "they want to correct mistakes and THIS is what they chose??!" things. I understand the appeal in "correcting" this given it's a relatively new addition, but I don't think it'll go over well. On Tuesday, April 26, 2016, Paul Benedict wrote: > Are you asking Brian to set up another survey monkey for the masses? I > expect a happy silent majority and a raucous minority.... just based on > past results. :-) > On Apr 26, 2016 6:38 PM, "Vitaly Davidovich" > wrote: > > I've yet to hear one supporter on this thread besides yourself and Stuart. > Is there some usability survey or something that actually indicates a > significant sample of people don't like the name? Guava Optional behaves > and is named the same way, and I've not heard anyone complain about that (I > and many people I know used it for years). > > I think the conversation would be *maybe* different if picking a name for a > new thing, but the deprecation churn here adds no value, IMO, and is going > to be viewed as an annoyance by a large swath of people. > > On Tuesday, April 26, 2016, Brian Goetz > wrote: > > > As the person who chose the original (terrible) name, let me weigh in... > > > > I think calling this method "get()" was our biggest API mistake in Java > > 8. Now, one could argue that, if this is the biggest mistake we made, > then > > we did pretty darn good. Which may be true, but ... make no mistake, it > > was the wrong name (mea culpa), and experience has borne out that it is > > widely misused. Subjectively, about half the uses of .get() I see are > > wrong -- and wrong in the obvious, avoidable way -- they don't consider > the > > optional might be empty. So they've just traded an unexpected NPE for an > > unexpected NSEE. > > > > Its problem is, essentially: it looks harmless, but isn't, but it sure > > seems like the method you obviously want when you're browsing the > > autocomplete list / javadoc. It's a hazard both to code writers (pick > the > > wrong method because the name is bad) and to code readers (deceptively > > harmless looking.) > > > > Methods like orElse or ifPresent look harmless, and are; methods like > > orElseThrow have potentially harmful side-effects but have names that are > > transparent about what harm they could do. But Optional.get() is neither > > safe nor transparent -- and yet awfully tempting-looking -- and this > leads > > to frequent misuse. Naming matters, and this one was wrong, and the harm > > is observable. I wish I'd caught it before 8 shipped. > > > > Stepping back a bit ... one of the most frequent complaints we get is > > "mistakes never get fixed". So, we've decided to be more serious about > > deprecation -- Dr. Deprecator is suiting up! But that means, for any > given > > item, some people are going to disagree about whether deprecation is > > suitable, and some will be inconvenienced by the deprecation -- this is > > unavoidable. > > > > Why prioritize this one? In part, because it's a *new* mistake, and has > > had less time to become entrenched -- and this is the very first > > opportunity we have to fix it. If we can't fix an API mistake at the > very > > first opportunity, the logical consequence is we can't ever fix anything. > > And that doesn't seem to be the world we want to retreat to. > > > > Similarly, is this the worst mistake in all of Java? Surely not. But its > > also not reasonable to say "you can't fix X until you've fixed everything > > worse than X" -- again, that's a recipe for never fixing anything. So, > in > > the context of a deprecation effort, this seems an entirely reasonable > > candidate. > > > > I'd like to see it fixed, and the sooner the better. > > > > > > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > > > >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this > >> would be painful and add no value. > >> > >> While I understand the pain from some developers not understanding the > >> feature, this is hardly unique in the world of Java. Developers learn > >> the right way of doing something soon enough. > >> > >> And while > >> > >> if (opt.isPresent()) { > >> opt.get() > >> } > >> > >> is sometimes not ideal, in other cases it is the only practical choice > >> (eg. where the method needs to have a return statement inside the if > >> statement). > >> > >> Changing this to > >> > >> if (opt.isPresent()) { > >> opt.getWhenPresent() > >> } > >> > >> is just noise - I can see the "present" part twice. > >> > >> I just don't think I can support the rename (although many of the > >> webrev tidy-ups are probably good). > >> > >> Stephen > >> > >> > >> > >> On 26 April 2016 at 00:05, Stuart Marks > wrote: > >> > >>> Hi all, > >>> > >>> Please review these webrevs that deprecate Optional.get() and to > replace > >>> it > >>> with Optional.getWhenPresent(). The corresponding changes are also > >>> applied > >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and > >>> OptionalLong.getAsLong(). > >>> > >>> Unlike most deprecations, this isn't about the function or the utility > of > >>> some API, it's about the name. The solution is basically to rename the > >>> API. > >>> The problem is that "get" shows up as the "obvious" choice in things > like > >>> IDE code completion, leading to code that mishandles empty Optionals. > >>> Typical Stack Overflow discourse runs something like this: > >>> > >>> Q: what do I do with this Optional thing > >>> > >>> A: just call get() > >>> > >>> Q: thanks, it works! > >>> > >>> Of course, it works until it doesn't. > >>> > >>> Examining the JDK's use of Optional.get(), I didn't see very many cases > >>> that > >>> called get() without first checking for the presence of a value. But I > >>> did > >>> see quite a number of cases like this: > >>> > >>> if (opt.isPresent()) { > >>> doSomething(opt.get()); > >>> } else { > >>> doSomethingElse(); > >>> } > >>> > >>> In many of these cases, the code could be refactored to use other > >>> Optional > >>> methods such as filter(), map(), or ifPresent(). > >>> > >>> In any case this reinforces the contention that use of get() leads to > >>> poor > >>> code. > >>> > >>> For this changeset, in just about all cases I've simply replaced the > >>> call to > >>> get() with a call to getWhenPresent(). In a couple cases I replaced the > >>> stream calls > >>> > >>> .filter(Optional::isPresent).map(Optional::get) > >>> > >>> with > >>> > >>> .flatMap(Optional::stream) > >>> > >>> which I hope will become the new idiom for unwrapping a stream of > >>> Optionals. > >>> > >>> While many cases could be cleaned up further, I didn't change them. The > >>> reasons are that I didn't want to spend too much time putting code > >>> cleanup > >>> into the critical path of this changeset (I'd be happy to help later); > >>> doing > >>> so would create potential conflicts with code coming in from the Jigsaw > >>> forest; and there are non-obvious places where converting from a > >>> conditional > >>> to one of the lambda-based methods could cause performance problems at > >>> startup. > >>> > >>> There are also a few cases where simplification is prevented because it > >>> would end up causing the resulting lambda expressions to throw checked > >>> exceptions. :-( > >>> > >>> Webrevs here: > >>> > >>> > >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > >>> > >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ > >>> > >>> Thanks, > >>> > >>> s'marks > >>> > >> > > > > -- > Sent from my phone > > -- Sent from my phone From paul.sandoz at oracle.com Wed Apr 27 00:52:26 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 26 Apr 2016 17:52:26 -0700 Subject: RFR 8154447: Exempt classes under java.util.concurrent from MH.Lookup restrictions In-Reply-To: References: <8EE8CD59-C958-43CC-8BA7-97CFDCE86334@oracle.com> Message-ID: > On 26 Apr 2016, at 15:14, Martin Buchholz wrote: > > Looks good to me. I'd add a TODO comment. > Thanks. I have changed the comment to: // For caller-sensitive MethodHandles.lookup() disallow lookup from // restricted packages. This a fragile and blunt approach. // TODO replace with a more formal and less fragile mechanism // that does not bluntly restrict packages within java.base from // looking up MethodHandles or VarHandles. Paul. > On Tue, Apr 26, 2016 at 3:01 PM, Paul Sandoz wrote: >> Hi, >> >> Please review: >> >> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154447-mh-lookup-restricted-pkgs/webrev/ >> https://bugs.openjdk.java.net/browse/JDK-8154447 >> >> This is a quick fix to allow classes under java.util.concurrent to call MethodHandles.lookup(), and thus unblock the use of such classes using VarHandles. >> >> To verify and ensure we don?t regress i included a simple test. >> >> These fragile checks will be revisited later under another issue. >> >> Paul. From roger.riggs at oracle.com Wed Apr 27 01:14:22 2016 From: roger.riggs at oracle.com (Roger Riggs) Date: Tue, 26 Apr 2016 21:14:22 -0400 Subject: RFR 9: 8066750 broke jdk9 builds; backup the changeset Message-ID: Please review the backout of the change for 8806750 which broke some builds that have not yet removed a dependency. Webrev: http://cr.openjdk.java.net/~rriggs/webrev-backout-8155182/ After the dependencies are cleared, I'll send a new review for the original removal. Sorry for the hassle, Roger [1] 88066750 webrev: http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ From joe.darcy at oracle.com Wed Apr 27 01:16:20 2016 From: joe.darcy at oracle.com (Joseph D. Darcy) Date: Tue, 26 Apr 2016 18:16:20 -0700 Subject: RFR 9: 8066750 broke jdk9 builds; backup the changeset In-Reply-To: References: Message-ID: <572012E4.3030407@oracle.com> +1 if it is just applying an anti-delta to the earlier change. Thanks, -Joe On 4/26/2016 6:14 PM, Roger Riggs wrote: > Please review the backout of the change for 8806750 which broke some > builds > that have not yet removed a dependency. > > Webrev: > http://cr.openjdk.java.net/~rriggs/webrev-backout-8155182/ > > After the dependencies are cleared, I'll send a new review for the > original removal. > > Sorry for the hassle, > Roger > > > [1] 88066750 webrev: > http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ From lance.andersen at oracle.com Wed Apr 27 01:19:10 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Tue, 26 Apr 2016 21:19:10 -0400 Subject: RFR 9: 8066750 broke jdk9 builds; backup the changeset In-Reply-To: <572012E4.3030407@oracle.com> References: <572012E4.3030407@oracle.com> Message-ID: <92CD0EAE-C147-41E5-BBA6-FC7AB9D1A457@oracle.com> +1? > On Apr 26, 2016, at 9:16 PM, Joseph D. Darcy wrote: > > +1 if it is just applying an anti-delta to the earlier change. > > Thanks, > > -Joe > > On 4/26/2016 6:14 PM, Roger Riggs wrote: >> Please review the backout of the change for 8806750 which broke some builds >> that have not yet removed a dependency. >> >> Webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-backout-8155182/ >> >> After the dependencies are cleared, I'll send a new review for the original removal. >> >> Sorry for the hassle, >> Roger >> >> >> [1] 88066750 webrev: http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From roger.riggs at oracle.com Wed Apr 27 01:19:16 2016 From: roger.riggs at oracle.com (Roger Riggs) Date: Tue, 26 Apr 2016 21:19:16 -0400 Subject: RFR 9: 8066750 broke jdk9 builds; backup the changeset In-Reply-To: <572012E4.3030407@oracle.com> References: <572012E4.3030407@oracle.com> Message-ID: <867f0776-e70d-cae8-a918-b5fb6d4345f3@oracle.com> Yes, just the result of hg backout. Do I need to run a jprt build job or can I push and let Mach5 proof it? Thanks, Roger On 4/26/16 9:16 PM, Joseph D. Darcy wrote: > +1 if it is just applying an anti-delta to the earlier change. > > Thanks, > > -Joe > > On 4/26/2016 6:14 PM, Roger Riggs wrote: >> Please review the backout of the change for 8806750 which broke some >> builds >> that have not yet removed a dependency. >> >> Webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-backout-8155182/ >> >> After the dependencies are cleared, I'll send a new review for the >> original removal. >> >> Sorry for the hassle, >> Roger >> >> >> [1] 88066750 webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-httpproxy-8066750/ > From kevinb at google.com Wed Apr 27 04:20:47 2016 From: kevinb at google.com (Kevin Bourrillion) Date: Tue, 26 Apr 2016 21:20:47 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: Guava owner here, and yes, I've never heard such a complaint about our Optional.get() method. This class has about a quarter of a million usages inside Google alone (I'm not kidding), and people seem quite happy with it. We have been planning to migrate these usages from our Optional class to yours (sounds crazy, but this is how we roll). Threads like this one -- and the threat of changing Optional in-place incompatibly to become a value type as part of Valhalla -- are making us, for the first time, seriously question whether that is such a good idea. Please don't rename this method. On Tue, Apr 26, 2016 at 4:38 PM, Vitaly Davidovich wrote: > I've yet to hear one supporter on this thread besides yourself and Stuart. > Is there some usability survey or something that actually indicates a > significant sample of people don't like the name? Guava Optional behaves > and is named the same way, and I've not heard anyone complain about that (I > and many people I know used it for years). > > I think the conversation would be *maybe* different if picking a name for a > new thing, but the deprecation churn here adds no value, IMO, and is going > to be viewed as an annoyance by a large swath of people. > > On Tuesday, April 26, 2016, Brian Goetz wrote: > > > As the person who chose the original (terrible) name, let me weigh in... > > > > I think calling this method "get()" was our biggest API mistake in Java > > 8. Now, one could argue that, if this is the biggest mistake we made, > then > > we did pretty darn good. Which may be true, but ... make no mistake, it > > was the wrong name (mea culpa), and experience has borne out that it is > > widely misused. Subjectively, about half the uses of .get() I see are > > wrong -- and wrong in the obvious, avoidable way -- they don't consider > the > > optional might be empty. So they've just traded an unexpected NPE for an > > unexpected NSEE. > > > > Its problem is, essentially: it looks harmless, but isn't, but it sure > > seems like the method you obviously want when you're browsing the > > autocomplete list / javadoc. It's a hazard both to code writers (pick > the > > wrong method because the name is bad) and to code readers (deceptively > > harmless looking.) > > > > Methods like orElse or ifPresent look harmless, and are; methods like > > orElseThrow have potentially harmful side-effects but have names that are > > transparent about what harm they could do. But Optional.get() is neither > > safe nor transparent -- and yet awfully tempting-looking -- and this > leads > > to frequent misuse. Naming matters, and this one was wrong, and the harm > > is observable. I wish I'd caught it before 8 shipped. > > > > Stepping back a bit ... one of the most frequent complaints we get is > > "mistakes never get fixed". So, we've decided to be more serious about > > deprecation -- Dr. Deprecator is suiting up! But that means, for any > given > > item, some people are going to disagree about whether deprecation is > > suitable, and some will be inconvenienced by the deprecation -- this is > > unavoidable. > > > > Why prioritize this one? In part, because it's a *new* mistake, and has > > had less time to become entrenched -- and this is the very first > > opportunity we have to fix it. If we can't fix an API mistake at the > very > > first opportunity, the logical consequence is we can't ever fix anything. > > And that doesn't seem to be the world we want to retreat to. > > > > Similarly, is this the worst mistake in all of Java? Surely not. But its > > also not reasonable to say "you can't fix X until you've fixed everything > > worse than X" -- again, that's a recipe for never fixing anything. So, > in > > the context of a deprecation effort, this seems an entirely reasonable > > candidate. > > > > I'd like to see it fixed, and the sooner the better. > > > > > > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > > > >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this > >> would be painful and add no value. > >> > >> While I understand the pain from some developers not understanding the > >> feature, this is hardly unique in the world of Java. Developers learn > >> the right way of doing something soon enough. > >> > >> And while > >> > >> if (opt.isPresent()) { > >> opt.get() > >> } > >> > >> is sometimes not ideal, in other cases it is the only practical choice > >> (eg. where the method needs to have a return statement inside the if > >> statement). > >> > >> Changing this to > >> > >> if (opt.isPresent()) { > >> opt.getWhenPresent() > >> } > >> > >> is just noise - I can see the "present" part twice. > >> > >> I just don't think I can support the rename (although many of the > >> webrev tidy-ups are probably good). > >> > >> Stephen > >> > >> > >> > >> On 26 April 2016 at 00:05, Stuart Marks > wrote: > >> > >>> Hi all, > >>> > >>> Please review these webrevs that deprecate Optional.get() and to > replace > >>> it > >>> with Optional.getWhenPresent(). The corresponding changes are also > >>> applied > >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and > >>> OptionalLong.getAsLong(). > >>> > >>> Unlike most deprecations, this isn't about the function or the utility > of > >>> some API, it's about the name. The solution is basically to rename the > >>> API. > >>> The problem is that "get" shows up as the "obvious" choice in things > like > >>> IDE code completion, leading to code that mishandles empty Optionals. > >>> Typical Stack Overflow discourse runs something like this: > >>> > >>> Q: what do I do with this Optional thing > >>> > >>> A: just call get() > >>> > >>> Q: thanks, it works! > >>> > >>> Of course, it works until it doesn't. > >>> > >>> Examining the JDK's use of Optional.get(), I didn't see very many cases > >>> that > >>> called get() without first checking for the presence of a value. But I > >>> did > >>> see quite a number of cases like this: > >>> > >>> if (opt.isPresent()) { > >>> doSomething(opt.get()); > >>> } else { > >>> doSomethingElse(); > >>> } > >>> > >>> In many of these cases, the code could be refactored to use other > >>> Optional > >>> methods such as filter(), map(), or ifPresent(). > >>> > >>> In any case this reinforces the contention that use of get() leads to > >>> poor > >>> code. > >>> > >>> For this changeset, in just about all cases I've simply replaced the > >>> call to > >>> get() with a call to getWhenPresent(). In a couple cases I replaced the > >>> stream calls > >>> > >>> .filter(Optional::isPresent).map(Optional::get) > >>> > >>> with > >>> > >>> .flatMap(Optional::stream) > >>> > >>> which I hope will become the new idiom for unwrapping a stream of > >>> Optionals. > >>> > >>> While many cases could be cleaned up further, I didn't change them. The > >>> reasons are that I didn't want to spend too much time putting code > >>> cleanup > >>> into the critical path of this changeset (I'd be happy to help later); > >>> doing > >>> so would create potential conflicts with code coming in from the Jigsaw > >>> forest; and there are non-obvious places where converting from a > >>> conditional > >>> to one of the lambda-based methods could cause performance problems at > >>> startup. > >>> > >>> There are also a few cases where simplification is prevented because it > >>> would end up causing the resulting lambda expressions to throw checked > >>> exceptions. :-( > >>> > >>> Webrevs here: > >>> > >>> > >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > >>> > >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ > >>> > >>> Thanks, > >>> > >>> s'marks > >>> > >> > > > > -- > Sent from my phone > -- Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com From amy.lu at oracle.com Wed Apr 27 05:18:57 2016 From: amy.lu at oracle.com (Amy Lu) Date: Wed, 27 Apr 2016 13:18:57 +0800 Subject: RFR 8154733, Fix module dependencies missed in java.rmi tests In-Reply-To: <571F9EC5.8050906@oracle.com> References: <8c5eb416-ca8b-21aa-6654-7a3133c2d6a1@oracle.com> <571F330D.6060307@oracle.com> <571F9EC5.8050906@oracle.com> Message-ID: <57204BC1.6000504@oracle.com> On 4/27/16 1:00 AM, Alan Bateman wrote: > > > On 26/04/2016 13:50, Felix Yang wrote: >> Hi Amy, >> >> thanks for pointing this out. Updated webrev: >> >> http://cr.openjdk.java.net/~xiaofeya/8154733/webrev.01/ >> > This looks okay to me. > > -Alan Thank you Alan! Felix, I'll sponsor this change for you. Thanks, Amy From stuart.marks at oracle.com Wed Apr 27 05:37:12 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Tue, 26 Apr 2016 22:37:12 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: <57b34f7b-9008-6a4c-cf06-24baab31b1f3@oracle.com> On 4/26/16 9:20 PM, Kevin Bourrillion wrote: > Guava owner here, and yes, I've never heard such a complaint about our > Optional.get() method. This class has about a quarter of a million usages > inside Google alone (I'm not kidding), and people seem quite happy with it. Hi Kevin, thanks for your comments. Interesting to hear yours (and Google's) experience with Guava's Optional.get(). How does Google avoid misusing it? Better programmers, better reviews, ability to refactor globally, or something else? Based on some of the code I've seen in the JDK and on grepcode.com (posted upthread), perhaps 50% or more of the uses of the JDK's Optional.get() are bad or suspect. Usually issues like this can be mitigated with Stack Overflow answers, blog articles, conference talks, better documentation, etc. But when the rate of misuse is this high, maybe it means that there's something wrong with the API itself. Now it may be the case that a particular proposal to fix the problem creates more pain than is worthwhile. I'm sympathetic to this, and I'm willing to discuss variations on or alternatives to proposals that reduce the pain. And I'm also prepared to accept, after exploring alternatives, that there might not be any that are sufficiently pain-free to proceed. But I'm also hearing that "Optional.get() isn't a problem." I'm really surprised by this. After looking at a bunch of code that uses Optional.get() it really looks like a problem to me. But maybe somebody can explain to me why it isn't. > We have been planning to migrate these usages from our Optional class to > yours (sounds crazy, but this is how we roll). Threads like this one -- and > the threat of changing Optional in-place incompatibly to become a value > type as part of Valhalla -- are making us, for the first time, seriously > question whether that is such a good idea. > > Please don't rename this method. I'll set aside the issue of value types for this discussion. We're not proposing to rename the method, strictly speaking. (I did use the word "rename" in my initial message on this thread. This was imprecise. If this misled anyone, I apologize.) A rename is strictly the addition of method and the removal of the old one. This is source and binary incompatible. We're not proposing that. We're also not proposing some temporary overlap of the old and the new for a few releases, after which the old would be removed. If we were to do that, we'd annotate the old method with @Deprecated(forRemoval=true). But the proposal is to deprecate with forRemoval=false (which is the default value, so it's elided). Instead, the proposal is to deprecate the old method, adjust the documentation to refer to the new method (and other Optional methods) and to leave the old method there indefinitely. This changes the behavior of IDEs and the way compilers issue warning messages, but otherwise it's source and binary compatible. Does this still make you reluctant to migrate to the JDK's Optional? If so, I'd like to understand this better, in order to improve the proposal. s'marks From stuart.marks at oracle.com Wed Apr 27 05:42:07 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Tue, 26 Apr 2016 22:42:07 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: Message-ID: <94b56926-06ec-2ea9-7f7a-9a20fd5a2833@oracle.com> On 4/26/16 3:43 AM, Stephen Colebourne wrote: > In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this > would be painful and add no value. Hi Stephen, I just sent a reply [1] to Kevin B, wherein I clarified "rename." Briefly, it strictly isn't a rename. The old method would be deprecated not-for-removal, and would be left in place indefinitely. Does this still create pain? If so, is there some way the proposal can be modified to reduce it? s'marks From ecki at zusammenkunft.net Wed Apr 27 07:56:05 2016 From: ecki at zusammenkunft.net (ecki at zusammenkunft.net) Date: Wed, 27 Apr 2016 09:56:05 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: <8b8d15a8-ad93-4746-9b07-b56d393b0563.maildroid@localhost> Hello, I agree, using the isPresent()/get() is fine, especially for code which interfaces between Optional-using APIs and null/default using APIs. Especially if you do not want/should use streams or lambda. And as I recall the "do not use Optional everywhere" motto is repeatet from Oracle as well, so those Interfaces are to be expected. Optional<> res = calculateOptionalResult(); If (res.isPresent()) doSomething(res.get()); // at this location 'orThrow' would be highly disturbing the reading flow // else // doSomething(); So the major problem with that is, it makes it obvious it has not much advantage over null (and the language needs a ?. Operator ,) Gruss Bernd -- http://bernd.eckenfels.net -----Original Message----- From: Kevin Bourrillion To: Vitaly Davidovich Cc: core-libs-dev Sent: Mi., 27 Apr. 2016 7:51 Subject: Re: RFR(m): 8140281 deprecate Optional.get() Guava owner here, and yes, I've never heard such a complaint about our Optional.get() method. This class has about a quarter of a million usages inside Google alone (I'm not kidding), and people seem quite happy with it. We have been planning to migrate these usages from our Optional class to yours (sounds crazy, but this is how we roll). Threads like this one -- and the threat of changing Optional in-place incompatibly to become a value type as part of Valhalla -- are making us, for the first time, seriously question whether that is such a good idea. Please don't rename this method. On Tue, Apr 26, 2016 at 4:38 PM, Vitaly Davidovich wrote: > I've yet to hear one supporter on this thread besides yourself and Stuart. > Is there some usability survey or something that actually indicates a > significant sample of people don't like the name? Guava Optional behaves > and is named the same way, and I've not heard anyone complain about that (I > and many people I know used it for years). > > I think the conversation would be *maybe* different if picking a name for a > new thing, but the deprecation churn here adds no value, IMO, and is going > to be viewed as an annoyance by a large swath of people. > > On Tuesday, April 26, 2016, Brian Goetz wrote: > > > As the person who chose the original (terrible) name, let me weigh in... > > > > I think calling this method "get()" was our biggest API mistake in Java > > 8. Now, one could argue that, if this is the biggest mistake we made, > then > > we did pretty darn good. Which may be true, but ... make no mistake, it > > was the wrong name (mea culpa), and experience has borne out that it is > > widely misused. Subjectively, about half the uses of .get() I see are > > wrong -- and wrong in the obvious, avoidable way -- they don't consider > the > > optional might be empty. So they've just traded an unexpected NPE for an > > unexpected NSEE. > > > > Its problem is, essentially: it looks harmless, but isn't, but it sure > > seems like the method you obviously want when you're browsing the > > autocomplete list / javadoc. It's a hazard both to code writers (pick > the > > wrong method because the name is bad) and to code readers (deceptively > > harmless looking.) > > > > Methods like orElse or ifPresent look harmless, and are; methods like > > orElseThrow have potentially harmful side-effects but have names that are > > transparent about what harm they could do. But Optional.get() is neither > > safe nor transparent -- and yet awfully tempting-looking -- and this > leads > > to frequent misuse. Naming matters, and this one was wrong, and the harm > > is observable. I wish I'd caught it before 8 shipped. > > > > Stepping back a bit ... one of the most frequent complaints we get is > > "mistakes never get fixed". So, we've decided to be more serious about > > deprecation -- Dr. Deprecator is suiting up! But that means, for any > given > > item, some people are going to disagree about whether deprecation is > > suitable, and some will be inconvenienced by the deprecation -- this is > > unavoidable. > > > > Why prioritize this one? In part, because it's a *new* mistake, and has > > had less time to become entrenched -- and this is the very first > > opportunity we have to fix it. If we can't fix an API mistake at the > very > > first opportunity, the logical consequence is we can't ever fix anything. > > And that doesn't seem to be the world we want to retreat to. > > > > Similarly, is this the worst mistake in all of Java? Surely not. But its > > also not reasonable to say "you can't fix X until you've fixed everything > > worse than X" -- again, that's a recipe for never fixing anything. So, > in > > the context of a deprecation effort, this seems an entirely reasonable > > candidate. > > > > I'd like to see it fixed, and the sooner the better. > > > > > > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > > > >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this > >> would be painful and add no value. > >> > >> While I understand the pain from some developers not understanding the > >> feature, this is hardly unique in the world of Java. Developers learn > >> the right way of doing something soon enough. > >> > >> And while > >> > >> if (opt.isPresent()) { > >> opt.get() > >> } > >> > >> is sometimes not ideal, in other cases it is the only practical choice > >> (eg. where the method needs to have a return statement inside the if > >> statement). > >> > >> Changing this to > >> > >> if (opt.isPresent()) { > >> opt.getWhenPresent() > >> } > >> > >> is just noise - I can see the "present" part twice. > >> > >> I just don't think I can support the rename (although many of the > >> webrev tidy-ups are probably good). > >> > >> Stephen > >> > >> > >> > >> On 26 April 2016 at 00:05, Stuart Marks > wrote: > >> > >>> Hi all, > >>> > >>> Please review these webrevs that deprecate Optional.get() and to > replace > >>> it > >>> with Optional.getWhenPresent(). The corresponding changes are also > >>> applied > >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and > >>> OptionalLong.getAsLong(). > >>> > >>> Unlike most deprecations, this isn't about the function or the utility > of > >>> some API, it's about the name. The solution is basically to rename the > >>> API. > >>> The problem is that "get" shows up as the "obvious" choice in things > like > >>> IDE code completion, leading to code that mishandles empty Optionals. > >>> Typical Stack Overflow discourse runs something like this: > >>> > >>> Q: what do I do with this Optional thing > >>> > >>> A: just call get() > >>> > >>> Q: thanks, it works! > >>> > >>> Of course, it works until it doesn't. > >>> > >>> Examining the JDK's use of Optional.get(), I didn't see very many cases > >>> that > >>> called get() without first checking for the presence of a value. But I > >>> did > >>> see quite a number of cases like this: > >>> > >>> if (opt.isPresent()) { > >>> doSomething(opt.get()); > >>> } else { > >>> doSomethingElse(); > >>> } > >>> > >>> In many of these cases, the code could be refactored to use other > >>> Optional > >>> methods such as filter(), map(), or ifPresent(). > >>> > >>> In any case this reinforces the contention that use of get() leads to > >>> poor > >>> code. > >>> > >>> For this changeset, in just about all cases I've simply replaced the > >>> call to > >>> get() with a call to getWhenPresent(). In a couple cases I replaced the > >>> stream calls > >>> > >>> .filter(Optional::isPresent).map(Optional::get) > >>> > >>> with > >>> > >>> .flatMap(Optional::stream) > >>> > >>> which I hope will become the new idiom for unwrapping a stream of > >>> Optionals. > >>> > >>> While many cases could be cleaned up further, I didn't change them. The > >>> reasons are that I didn't want to spend too much time putting code > >>> cleanup > >>> into the critical path of this changeset (I'd be happy to help later); > >>> doing > >>> so would create potential conflicts with code coming in from the Jigsaw > >>> forest; and there are non-obvious places where converting from a > >>> conditional > >>> to one of the lambda-based methods could cause performance problems at > >>> startup. > >>> > >>> There are also a few cases where simplification is prevented because it > >>> would end up causing the resulting lambda expressions to throw checked > >>> exceptions. :-( > >>> > >>> Webrevs here: > >>> > >>> > >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > >>> > >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ > >>> > >>> Thanks, > >>> > >>> s'marks > >>> > >> > > > > -- > Sent from my phone > -- Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com From volker.simonis at gmail.com Wed Apr 27 08:28:11 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Wed, 27 Apr 2016 10:28:11 +0200 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: Message-ID: Ping - shouldn't we fix this issue before JDK 9 Feature Complete? Could you please also comment on my remarks regarding the relation of java.lang.Package.getSpecificationVersion() to JEP and 223 and and my question why the Version class is not in a standard java package. Thank you and best regards, Volker On Thu, Apr 7, 2016 at 12:11 PM, Volker Simonis wrote: > On Wed, Apr 6, 2016 at 8:28 PM, Iris Clark wrote: >> Hi, Volker. >> >> Sorry for the delay. I agree that the old implementation isn't quite correct. I can't see us potentially having a JCP MR for a security or patch release (9.0.0.X and 9.0.X respectively). >> >> I could see a MR for an very unusual minor release (9.X). If we had an MR there's no guarantee that we'd need to change the java.specification.version system property. However, in the event that we did need to change the java.specification.version, it should match that release's $MAJOR.$MINOR, even if it meant that we had a sequence of specification version numbers with gaps. >> >> As an example, let's say that JDK 9 is released via umbrella JSR with java.specification.value of "9". The system property would remain at "9" for all releases regardless of type until we choose to have a MR. Should that MR occur while we're working on minor release 9.3.X and there is a need to change the value of java.specification.value, it would become "9.3" and would remain so in every release until the next MR. >> >> While we haven't changed the system property recently, I think that we need to future-proof ourselves a little bit for MRs as described above. >> >> Assuming that we change the syntax of java.specification.version to $MAJOR.$MINOR (zeros truncated, value dependent on JCP) then we need to make a similar change to the syntax of java.vm.specification.version. [ Note that in the current implementation, I believe that the values of java.specification.version and java.vm.specification.version are tied to each other. ] >> >> Changing the syntax of java{.vm}?specification.version requires a CCC which I will file once we have agreement on the necessary changes. >> > > Hi Iris, > > thanks for your comments. I don't think that using $MAJOR.$MINOR for > java.specification.version is a good solution. As far as I understand, > JEP 223 (i.e. the new version scheme) is an Oracle/OpenJDK > implementation detail. There is no JSR for this and it won't be > enforced trough a JCK/TCK test (please correct me if I'm wrong). The > new versioning schema references the JCP in that is says that the > $MAJOR number corresponds to the "Java SE Platform Specification" > number as specified by the JCP in the corresponding JSR. But not vice > versa - i.e. there's no JSR referencing JEP 223. > > JEP 223 also says that the $MINOR number will be increased if this is > mandated by a Maintenance Release of the relevant Platform > Specification (by the JCP). But as you correctly noticed, in reality, > $MINOR is expected to be increased frequently compared to the number > of Java SE Maintenance Releases (if there will be any at all). So if > the JCP should decide to publish a Maintenance Release, why should it > name if after the then actual $MINOR update release number of the > Oracle/OpenJDK. I think a natural choice for such a MR would be "9.1", > no difference at which update release version Oracle/OpenJDK will be > at that time. > > So I think it would be best to decouple java.specification.version > from the Java versioning schema. We can start with > java.specification.version == $MAJOR. If there should be a MR > sometimes in the future, we can just set java.specification.version to > the version number of that MR, whatever that will be. That's exactly > what this change is about. > > Regarding the value of java.vm.specification.version I'm not sure what > it actually means at all. Until Java 1.6, > java.vm.specification.version has always been "1.0", while > java.specification.version has changed from 1.4, to 1.5 and 1.6 > (notice that java.specification.version has never been changed to > 1.4.2, it was 1.4 for Java 1.4.0 as well as for 1.4.2). Starting with > Java 7, java.vm.specification.version is the same like > java.specification.version (i.e. 1.7 and 1.8) but I'm not sure if that > is mandated by JCP and if it will be possible that these numbers will > diverge for a Java release. I.e. will it be possible to have a new > Java version (say Java 10) where the VM specification (and thus > java.vm.specification.version) will remain unchanged (say "9")? From > my understanding, that should be possible. Especially for a MR, it > seems highly probable to me that the java.specification.version will > be increased, but the VM specification (and thus > java.vm.specification.version) will remain unchanged. > > So again, I think we shouldn't tie java.vm.specification.version to > java.specification.version and simply start with > java.vm.specification.version == $MAJOR. The current implementation > already does this correctly. While the java.specification.version > property comes from VERSION_SPECIFICATION in > common/autoconf/spec.gmk.in and it is being set in > jdk/src/java.base/share/native/libjava/System.c the > java.vm.specification.version property is set being in > hotspot/src/share/vm/runtime/arguments.cpp directly to the major Java > version number. Because of this difference, there are currently no > problems with the java.vm.specification.version property caused by the > new versioning schema. > > As a side note: while I wrote all this down, I realized that we have > java.lang.Package.getSpecificationVersion() in the class library which > returns the specification version of a specific package. But this API > is not mentioned anywhere in JEP 223. Shouldn't the output of > java.lang.Package.getSpecificationVersion() be aligned with JEP 223 > and java.vm.specification.version as well? > > And a final question. Why did we put jdk.Version into the jdk package? > As far as I know, jdk is not a standard Java package and thus not > enforced by the Java standard (please correct me if I'm wrong). > Shouldn't the Version class be in a standard Java package such that > it's implementation will be mandatory for all Java implementations? > > Regards, > Volker > >> Regards, >> Iris >> >> -----Original Message----- >> From: Volker Simonis [mailto:volker.simonis at gmail.com] >> Sent: Tuesday, April 05, 2016 10:26 AM >> To: Java Core Libs >> Cc: verona-dev at openjdk.java.net >> Subject: Re: RFR(XXS): 8149519: Investigate implementation of java.specification.version >> >> Hi, >> >> can somebody please review this trivial change? >> >> Regards, >> Volker >> >> >> On Mon, Apr 4, 2016 at 6:47 PM, Volker Simonis wrote: >>> Hi, >>> >>> can I please have a review for this small fix: >>> >>> http://cr.openjdk.java.net/~simonis/webrevs/2016/8149519 >>> https://bugs.openjdk.java.net/browse/JDK-8149519 >>> >>> Currently the value of the java.specification.version property comes >>> from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in. It is >>> currently set to VERSION_NUMBER which is the same value which is also >>> used for the java.version property. >>> >>> This is a bad idea, because VERSION_NUMBER is a dot separated sequence >>> of numbers (e.g. 9.0.1) which is expected to change frequently (i.e. >>> for every build and/or update version). If we are configuring with >>> "--with-version-patch=1" for example, VERSION_NUMBER and java.version >>> will be "9.0.0.1". But it makes no sense that VERSION_SPECIFICATION >>> and java.specification.version have the same, dotted value. And it >>> breaks a lot of legacy applications which parse >>> java.specification.version as a float number. That code would still >>> work if java.specification.version would be a concrete number (e.g. >>> '9' or '10'). >>> >>> I suggest to set VERSION_SPECIFICATION to VERSION_MAJOR in >>> common/autoconf/spec.gmk.in. This should be the "right value" until we >>> get a specification change during a major release which hasn't >>> happened for quite some time now. >>> >>> Regards, >>> Volker From aph at redhat.com Wed Apr 27 08:31:03 2016 From: aph at redhat.com (Andrew Haley) Date: Wed, 27 Apr 2016 09:31:03 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: <572078C7.9070102@redhat.com> On 27/04/16 00:38, Vitaly Davidovich wrote: > I've yet to hear one supporter on this thread besides yourself and Stuart. Do you really want to turn this discussion into even more of a bikeshed discussion? Count me in as in favour of deprecation, but let's not get into +1s and -1s. I'm perfectly happy to let Stuart and Brian explain themselves ? what they say makes sense to me. Andrew. From aleksey.shipilev at oracle.com Wed Apr 27 08:56:53 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Wed, 27 Apr 2016 11:56:53 +0300 Subject: [jmm-dev] RFR 8154755: Add a VarHandle weakCompareAndSet with volatile semantics In-Reply-To: <07EE4695-9AF3-4F50-ACAE-831BD508B657@oracle.com> References: <07EE4695-9AF3-4F50-ACAE-831BD508B657@oracle.com> Message-ID: <57207ED5.8000007@oracle.com> On 04/21/2016 07:21 PM, Paul Sandoz wrote: > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154755-weak-cas-volatile/webrev/ Looks okay to me. -Aleksey From Alan.Bateman at oracle.com Wed Apr 27 09:15:17 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 27 Apr 2016 10:15:17 +0100 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: Message-ID: <57208325.6080907@oracle.com> On 27/04/2016 09:28, Volker Simonis wrote: > Ping - shouldn't we fix this issue before JDK 9 Feature Complete? > > Could you please also comment on my remarks regarding the relation of > java.lang.Package.getSpecificationVersion() to JEP and 223 and and my > question why the Version class is not in a standard java package. > One thing to be aware of is that specification for legacy java.lang.Package has been significantly overhauled as part of updating the platform to support modules. The javadoc to read is the updated class description where it specifies the properties of Packages automatically created for types in named modules, also the API note in the 8-parameter ClassLoader.definePackage method. The TL;DR summary is that getSpecificationVersion() will return null when invoking on Package objects for any types in any of the system module (or any of the modules on the module path too). So I don't think JEP 223 needs to be concerned with it. JDK-8144062 is tracking the replacement of jdk.Version with a standard API. -Alan. From volker.simonis at gmail.com Wed Apr 27 09:54:05 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Wed, 27 Apr 2016 11:54:05 +0200 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: <57208325.6080907@oracle.com> References: <57208325.6080907@oracle.com> Message-ID: On Wed, Apr 27, 2016 at 11:15 AM, Alan Bateman wrote: > > On 27/04/2016 09:28, Volker Simonis wrote: >> >> Ping - shouldn't we fix this issue before JDK 9 Feature Complete? >> >> Could you please also comment on my remarks regarding the relation of >> java.lang.Package.getSpecificationVersion() to JEP and 223 and and my >> question why the Version class is not in a standard java package. >> > One thing to be aware of is that specification for legacy java.lang.Package > has been significantly overhauled as part of updating the platform to > support modules. The javadoc to read is the updated class description where > it specifies the properties of Packages automatically created for types in > named modules, also the API note in the 8-parameter > ClassLoader.definePackage method. The TL;DR summary is that > getSpecificationVersion() will return null when invoking on Package objects > for any types in any of the system module (or any of the modules on the > module path too). So I don't think JEP 223 needs to be concerned with it. > Thanks for the clarification. As far as I can see, this updated javadoc is still only in the jigsaw repo so I didn't read it before. > JDK-8144062 is tracking the replacement of jdk.Version with a standard API. > Thanks for providing the link. I wasn't aware of it. Yet another bug to follow on JBS :) Volker > -Alan. From andrey at tweak.su Wed Apr 27 09:57:11 2016 From: andrey at tweak.su (Andrey) Date: Wed, 27 Apr 2016 12:57:11 +0300 Subject: String.equalsIgnoreCase(...) optimization In-Reply-To: <1922171461709293@web27h.yandex.ru> References: <753291461680757@web10h.yandex.ru> <571F86D9.2030909@redhat.com> <1922171461709293@web27h.yandex.ru> Message-ID: <4179981461751031@web2g.yandex.ru> I publish my JMH benchmark at github https://github.com/volodin-aa/openjdk-benchmark 27.04.2016, 01:23, "Andrey" : > I create simple benchmark (attached). Optimized version more faster: > > # JMH 1.12 (released 26 days ago) > # VM version: JDK 1.8.0_91, VM 25.91-b14 > .. > # Run complete. Total time: 00:04:02 > > Benchmark Mode Cnt Score Error Units > StringBenchmark.constConst thrpt 20 37935470,179 ? 158354,736 ops/s > StringBenchmark.constConstFast thrpt 20 70342038,623 ? 727831,951 ops/s > StringBenchmark.newNew thrpt 20 30033885,754 ? 374524,932 ops/s > StringBenchmark.newNewFast thrpt 20 69567918,934 ? 196494,474 ops/s > StringBenchmark.varVar thrpt 20 36102111,956 ? 364861,774 ops/s > StringBenchmark.varVarFast thrpt 20 66743826,698 ? 124162,725 ops/s > > How I can publish my version equalsIgnoreCase(...) or OpenJDK team check results separately? > > 26.04.2016, 18:18, "Andrew Haley" : >> ??On 04/26/2016 03:25 PM, Andrey wrote: >>> ???May be can create optimized regionMatches(...) for use in equalsIgnoreCase(...)? >> >> ??When the HotSpot JVM's just-in-time compiler optimizes this code it >> ??inlines all of these tests, realizes that they are constant values, >> ??and generates no code for them. All the generated code does is check >> ??that the strings have the same coder and are the same length, then it >> ??goes into an unrolled loop checking that the characters are the same From Alan.Bateman at oracle.com Wed Apr 27 10:01:42 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 27 Apr 2016 11:01:42 +0100 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: <57208325.6080907@oracle.com> Message-ID: <57208E06.2060809@oracle.com> On 27/04/2016 10:54, Volker Simonis wrote: > : > Thanks for the clarification. As far as I can see, this updated > javadoc is still only in the jigsaw repo so I didn't read it before. > It's in JDK 9 since jdk-9+111. I just checked the online/browsable docs [1] and it's there. -Alan [1] http://download.java.net/java/jdk9/docs/api/index.html From aph at redhat.com Wed Apr 27 10:17:50 2016 From: aph at redhat.com (Andrew Haley) Date: Wed, 27 Apr 2016 11:17:50 +0100 Subject: String.equalsIgnoreCase(...) optimization In-Reply-To: <4179981461751031@web2g.yandex.ru> References: <753291461680757@web10h.yandex.ru> <571F86D9.2030909@redhat.com> <1922171461709293@web27h.yandex.ru> <4179981461751031@web2g.yandex.ru> Message-ID: <572091CE.2080700@redhat.com> On 27/04/16 10:57, Andrey wrote: > I publish my JMH benchmark at github > https://github.com/volodin-aa/openjdk-benchmark This test needs to be better. Always comparing "String" and "string" doesn't tell us much. These strings are extremely short, and a few more cases would be useful. Please change your units to something more sensible. I suggest nanoseconds. Thanks, Andrew. From aleksey.shipilev at oracle.com Wed Apr 27 10:33:04 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Wed, 27 Apr 2016 13:33:04 +0300 Subject: RFR (XS) 8155215: java.lang.String concatenation spec is unnecessarily strong Message-ID: <57209560.6040206@oracle.com> Hi, Please review this tiny spec improvement that syncs up JLS and java.lang.String Javadoc. java.lang.String Javadoc unnecessarily locks down the implementation details for String concat (e.g. usage of StringBuilder): http://cr.openjdk.java.net/~shade/8155215/webrev.00/ I'll submit CCC as soon as we agree on wording. Thanks, -Aleksey From andrey at tweak.su Wed Apr 27 10:37:45 2016 From: andrey at tweak.su (Andrey) Date: Wed, 27 Apr 2016 13:37:45 +0300 Subject: String.equalsIgnoreCase(...) optimization In-Reply-To: <572091CE.2080700@redhat.com> References: <753291461680757@web10h.yandex.ru> <571F86D9.2030909@redhat.com> <1922171461709293@web27h.yandex.ru> <4179981461751031@web2g.yandex.ru> <572091CE.2080700@redhat.com> Message-ID: <217511461753465@web20m.yandex.ru> Results for long strings ????private static final String _STRING = "This test needs to be better. Always comparing String and string doesn't tell us much. These strings are extremely short, and a few more cases would be useful. Please change your units to something more sensible. I suggest nanoseconds. Thanks, Andrew."; ????private static final String STRING = "THIS TEST NEEDS TO BE BETTER. ALWAYS COMPARING STRING AND STRING DOESN'T TELL US MUCH. THESE STRINGS ARE EXTREMELY SHORT, AND A FEW MORE CASES WOULD BE USEFUL. PLEASE CHANGE YOUR UNITS TO SOMETHING MORE SENSIBLE. I SUGGEST NANOSECONDS. THANKS, ANDREW."; # Run complete. Total time: 00:04:01 Benchmark Mode Cnt Score Error Units StringBenchmark.constConst thrpt 20 931938,920 ? 1703,527 ops/s StringBenchmark.constConstFast thrpt 20 1290645,530 ? 10855,059 ops/s StringBenchmark.newNew thrpt 20 604461,665 ? 17613,802 ops/s StringBenchmark.newNewFast thrpt 20 962488,540 ? 15299,433 ops/s StringBenchmark.varVar thrpt 20 849925,016 ? 1933,533 ops/s StringBenchmark.varVarFast thrpt 20 1306144,917 ? 15554,201 ops/s For not equal strings algorithm has performance as standard String.equalsIgnoreCase(...) . 27.04.2016, 13:17, "Andrew Haley" : > ?On 27/04/16 10:57, Andrey wrote: > >> ??I publish my JMH benchmark at github >> ??https://github.com/volodin-aa/openjdk-benchmark > > ?This test needs to be better. Always comparing "String" and "string" > ?doesn't tell us much. These strings are extremely short, and a few > ?more cases would be useful. > > ?Please change your units to something more sensible. I suggest > ?nanoseconds. > > ?Thanks, > > ?Andrew. From vitalyd at gmail.com Wed Apr 27 10:51:44 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Wed, 27 Apr 2016 06:51:44 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <572078C7.9070102@redhat.com> References: <571FE3EF.7050001@oracle.com> <572078C7.9070102@redhat.com> Message-ID: On Wednesday, April 27, 2016, Andrew Haley wrote: > On 27/04/16 00:38, Vitaly Davidovich wrote: > > I've yet to hear one supporter on this thread besides yourself and > Stuart. > > Do you really want to turn this discussion into even more of a > bikeshed discussion? Not at all. Simply saying I find this proposal odd, and I didn't get the feeling I'm alone by reading the other responses here. > Count me in as in favour of deprecation, > but let's not get into +1s and -1s. I'm perfectly happy to > let Stuart and Brian explain themselves ? what they say makes > sense to me. > > Andrew. > > -- Sent from my phone From aph at redhat.com Wed Apr 27 10:55:21 2016 From: aph at redhat.com (Andrew Haley) Date: Wed, 27 Apr 2016 11:55:21 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> <572078C7.9070102@redhat.com> Message-ID: <57209A99.2010104@redhat.com> On 27/04/16 11:51, Vitaly Davidovich wrote: > On Wednesday, April 27, 2016, Andrew Haley wrote: > >> On 27/04/16 00:38, Vitaly Davidovich wrote: >>> I've yet to hear one supporter on this thread besides yourself and >> Stuart. >> >> Do you really want to turn this discussion into even more of a >> bikeshed discussion? > > Not at all. Simply saying I find this proposal odd, and I didn't get the > feeling I'm alone by reading the other responses here. You're not alone, but not everyone should chime in. Now that I'm here I have to say that deprecating bad names is an excellent thing to do, and what enhanced deprecation should be doing. Andrew. From scolebourne at joda.org Wed Apr 27 11:08:55 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Wed, 27 Apr 2016 12:08:55 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <571FE3EF.7050001@oracle.com> References: <571FE3EF.7050001@oracle.com> Message-ID: On 26 April 2016 at 22:55, Brian Goetz wrote: > As the person who chose the original (terrible) name, let me weigh in... We start from a different premise - I do not think that get() is a terrible name. Nor was it the biggest API mistake in Java 8 (I've come to believe parallelStream() was that). FWIW, if I agreed that it was a terrible name, I would be in favour of the rename at the earliest opportunity. How about Duration.getNano( which should have been getNanos() ? Kevin has already outlined the key reason for the name get() - that Guava uses it and has done for many years. It is therefore the accepted name for the method. More broadly, it is used in association with isPresent() and as such seeing "getWhenPresent" repeats "present" and is far too much in your face. Ultimately, Optional is a class that requires a degree of learning. That learning is not hard and will happen with time. Where things went wrong IMO was adding Optional without tackling null-management in the language, but thats a separate debate. My experience is certainly not that 50% of users use it wrong. I do accept that many will not use orElse() or map() when they should, but that is fine - so long as they use isPresent() before get(), the rest can come later. To be clear, a lot of the claimed justification for this from Stuart's earlier message is that people are using get() instead of orElse(), orElseThrow(), filter(), map() etc. _but I don't care about that at all_. Overuse of isPresent() is rife but fine. The only case that matters is use of get() without any check. On 27 April 2016 at 06:42, Stuart Marks wrote: > Briefly, it strictly isn't a rename. The old method would be deprecated > not-for-removal, and would be left in place indefinitely. > Does this still create pain? If so, is there some way the proposal can be > modified to reduce it? We keep our code free of all deprecations. As such, this will require change when we adopt Java 9. So, this is a rename in practical terms. The replacement being significantly longer will also cause line-length issues and reformatting in places. TLDR, we view Optoinal as a new core API added in Java 8 that was have relied on and used widely. It is fine as is, and does not need any alteration. Stephen > I think calling this method "get()" was our biggest API mistake in Java 8. > Now, one could argue that, if this is the biggest mistake we made, then we > did pretty darn good. Which may be true, but ... make no mistake, it was > the wrong name (mea culpa), and experience has borne out that it is widely > misused. Subjectively, about half the uses of .get() I see are wrong -- and > wrong in the obvious, avoidable way -- they don't consider the optional > might be empty. So they've just traded an unexpected NPE for an unexpected > NSEE. > > Its problem is, essentially: it looks harmless, but isn't, but it sure seems > like the method you obviously want when you're browsing the autocomplete > list / javadoc. It's a hazard both to code writers (pick the wrong method > because the name is bad) and to code readers (deceptively harmless looking.) > > Methods like orElse or ifPresent look harmless, and are; methods like > orElseThrow have potentially harmful side-effects but have names that are > transparent about what harm they could do. But Optional.get() is neither > safe nor transparent -- and yet awfully tempting-looking -- and this leads > to frequent misuse. Naming matters, and this one was wrong, and the harm is > observable. I wish I'd caught it before 8 shipped. > > Stepping back a bit ... one of the most frequent complaints we get is > "mistakes never get fixed". So, we've decided to be more serious about > deprecation -- Dr. Deprecator is suiting up! But that means, for any given > item, some people are going to disagree about whether deprecation is > suitable, and some will be inconvenienced by the deprecation -- this is > unavoidable. > > Why prioritize this one? In part, because it's a *new* mistake, and has had > less time to become entrenched -- and this is the very first opportunity we > have to fix it. If we can't fix an API mistake at the very first > opportunity, the logical consequence is we can't ever fix anything. And > that doesn't seem to be the world we want to retreat to. > > Similarly, is this the worst mistake in all of Java? Surely not. But its > also not reasonable to say "you can't fix X until you've fixed everything > worse than X" -- again, that's a recipe for never fixing anything. So, in > the context of a deprecation effort, this seems an entirely reasonable > candidate. > > I'd like to see it fixed, and the sooner the better. > From vitalyd at gmail.com Wed Apr 27 11:20:38 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Wed, 27 Apr 2016 07:20:38 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <57209A99.2010104@redhat.com> References: <571FE3EF.7050001@oracle.com> <572078C7.9070102@redhat.com> <57209A99.2010104@redhat.com> Message-ID: On Wednesday, April 27, 2016, Andrew Haley wrote: > On 27/04/16 11:51, Vitaly Davidovich wrote: > > On Wednesday, April 27, 2016, Andrew Haley > wrote: > > > >> On 27/04/16 00:38, Vitaly Davidovich wrote: > >>> I've yet to hear one supporter on this thread besides yourself and > >> Stuart. > >> > >> Do you really want to turn this discussion into even more of a > >> bikeshed discussion? > > > > Not at all. Simply saying I find this proposal odd, and I didn't get the > > feeling I'm alone by reading the other responses here. > > You're not alone, but not everyone should chime in. Now that I'm > here I have to say that deprecating bad names is an excellent > thing to do, and what enhanced deprecation should be doing. Sure, but there's no agreement it's a bad name to begin with. It's a fine name, with precedent, and avoids visual noise when used as intended. Optional has something like a dozen methods with very simple javadoc - if a developer misused it, they'll learn and move on. There's really no issue here at all, as far as I'm concerned. I understand Brian and Stuart's thinking, but it's not addressing any real issue, IMO. > > Andrew. > > -- Sent from my phone From martinrb at google.com Wed Apr 27 11:26:25 2016 From: martinrb at google.com (Martin Buchholz) Date: Wed, 27 Apr 2016 04:26:25 -0700 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: <57208E06.2060809@oracle.com> References: <57208325.6080907@oracle.com> <57208E06.2060809@oracle.com> Message-ID: I think the jdk9 docs have moved (again, grrrr - I complain about this sort of thing every release) and so a google search for "package class se 9" only finds the old one +104 at http://download.java.net/jdk9/docs/api/java/lang/Package.html Why can't there be a redirect instead of leaving the old docs in place? On Wed, Apr 27, 2016 at 3:01 AM, Alan Bateman wrote: > On 27/04/2016 10:54, Volker Simonis wrote: >> >> : >> Thanks for the clarification. As far as I can see, this updated >> javadoc is still only in the jigsaw repo so I didn't read it before. >> > It's in JDK 9 since jdk-9+111. I just checked the online/browsable docs [1] > and it's there. > > -Alan > > [1] http://download.java.net/java/jdk9/docs/api/index.html From aleksey.shipilev at oracle.com Wed Apr 27 11:37:54 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Wed, 27 Apr 2016 14:37:54 +0300 Subject: String.equalsIgnoreCase(...) optimization In-Reply-To: <4179981461751031@web2g.yandex.ru> References: <753291461680757@web10h.yandex.ru> <571F86D9.2030909@redhat.com> <1922171461709293@web27h.yandex.ru> <4179981461751031@web2g.yandex.ru> Message-ID: <5720A492.7070102@oracle.com> Hi Andrey, On 04/27/2016 12:57 PM, Andrey wrote: > I publish my JMH benchmark at github https://github.com/volodin-aa/openjdk-benchmark Please note that you really should compete with JDK 9 String, not with JDK 8. String.equalsIgnoreCase is different in JDK 9, and the obvious improvement one can do there is: diff -r 5a6df35b0f97 src/java.base/share/classes/java/lang/StringLatin1.java --- a/src/java.base/share/classes/java/lang/StringLatin1.java Wed Apr 27 09:13:51 2016 +0200 +++ b/src/java.base/share/classes/java/lang/StringLatin1.java Wed Apr 27 14:16:14 2016 +0300 @@ -315,11 +315,14 @@ byte[] other, int ooffset, int len) { int last = toffset + len; while (toffset < last) { - char c1 = (char)(value[toffset++] & 0xff); - char c2 = (char)(other[ooffset++] & 0xff); - if (c1 == c2) { + byte b1 = value[toffset++]; + byte b2 = other[ooffset++]; + if (b1 == b2) { continue; } + char c1 = (char)(b1 & 0xff); + char c2 = (char)(b2 & 0xff); + char u1 = Character.toUpperCase(c1); char u2 = Character.toUpperCase(c2); if (u1 == u2) { ...which improves performance even on short Strings. Maybe specializing Character.toUpperCase for Latin1 strings would pay off more. Maybe specializing regionMatches for complete Strings would worth the increased complexity too, but that should be tried on JDK code first. To make a good justification for the change, the benchmark should really test: a) Different lengths; b) Different starting mismatch offset; c) Different Latin1/UTF16 pairs. Note well: these optimizations would require studying the generated code looking for the compiler quirks, and as such would require much more time than anyone thinks it would take (even after taking Hofstadter's Law into account). Thanks, -Aleksey From michael.haupt at oracle.com Wed Apr 27 11:58:02 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 27 Apr 2016 13:58:02 +0200 Subject: RFR(XS): 8155214: java/lang/invoke/PermuteArgsTest.java fails due to exhausted code cache Message-ID: Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8155214 Webrev: http://cr.openjdk.java.net/~mhaupt/8155214/webrev.00/ The failing test, unlike several other tests in the method handles area, was not safeguarded against code cache overflows. Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From Alan.Bateman at oracle.com Wed Apr 27 12:16:27 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 27 Apr 2016 13:16:27 +0100 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: <57208325.6080907@oracle.com> <57208E06.2060809@oracle.com> Message-ID: <5720AD9B.8070708@oracle.com> On 27/04/2016 12:26, Martin Buchholz wrote: > I think the jdk9 docs have moved (again, grrrr - I complain about this > sort of thing every release) and so a google search for "package class > se 9" only finds the old one +104 at > http://download.java.net/jdk9/docs/api/java/lang/Package.html > Why can't there be a redirect instead of leaving the old docs in place? > Yeah, a number of us noticed that recently too. Chasing the folks that publish these builds to get this fixed ... -Alan From volker.simonis at gmail.com Wed Apr 27 12:23:08 2016 From: volker.simonis at gmail.com (Volker Simonis) Date: Wed, 27 Apr 2016 14:23:08 +0200 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: <57208325.6080907@oracle.com> <57208E06.2060809@oracle.com> Message-ID: Yes, this was the version I've looked to as well. Thanks for pointing this out. On Wed, Apr 27, 2016 at 1:26 PM, Martin Buchholz wrote: > I think the jdk9 docs have moved (again, grrrr - I complain about this > sort of thing every release) and so a google search for "package class > se 9" only finds the old one +104 at > http://download.java.net/jdk9/docs/api/java/lang/Package.html > Why can't there be a redirect instead of leaving the old docs in place? > > On Wed, Apr 27, 2016 at 3:01 AM, Alan Bateman wrote: >> On 27/04/2016 10:54, Volker Simonis wrote: >>> >>> : >>> Thanks for the clarification. As far as I can see, this updated >>> javadoc is still only in the jigsaw repo so I didn't read it before. >>> >> It's in JDK 9 since jdk-9+111. I just checked the online/browsable docs [1] >> and it's there. >> >> -Alan >> >> [1] http://download.java.net/java/jdk9/docs/api/index.html From michael.haupt at oracle.com Wed Apr 27 12:38:25 2016 From: michael.haupt at oracle.com (Michael Haupt) Date: Wed, 27 Apr 2016 14:38:25 +0200 Subject: RFR(S): 8155106: MHs.Lookup.findConstructor returns handles for array classes Message-ID: <2078A840-5E12-49A2-8B85-5A993D78E802@oracle.com> Dear all, please review this change. Bug: https://bugs.openjdk.java.net/browse/JDK-8155106 Webrev: http://cr.openjdk.java.net/~mhaupt/8155106/webrev.00/ Thanks, Michael -- Dr. Michael Haupt | Principal Member of Technical Staff Phone: +49 331 200 7277 | Fax: +49 331 200 7561 Oracle Java Platform Group | LangTools Team | Nashorn Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstra?e 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From aleksey.shipilev at oracle.com Wed Apr 27 12:49:39 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Wed, 27 Apr 2016 15:49:39 +0300 Subject: RFR(S): 8155106: MHs.Lookup.findConstructor returns handles for array classes In-Reply-To: <2078A840-5E12-49A2-8B85-5A993D78E802@oracle.com> References: <2078A840-5E12-49A2-8B85-5A993D78E802@oracle.com> Message-ID: <5720B563.9010300@oracle.com> On 04/27/2016 03:38 PM, Michael Haupt wrote: > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8155106 > Webrev: http://cr.openjdk.java.net/~mhaupt/8155106/webrev.00/ Looks okay. -Aleksey From sundararajan.athijegannathan at oracle.com Wed Apr 27 12:54:49 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Wed, 27 Apr 2016 18:24:49 +0530 Subject: RFR(S): 8155106: MHs.Lookup.findConstructor returns handles for array classes In-Reply-To: <2078A840-5E12-49A2-8B85-5A993D78E802@oracle.com> References: <2078A840-5E12-49A2-8B85-5A993D78E802@oracle.com> Message-ID: <64df913b-42aa-3718-b144-2eb06d405c2b@oracle.com> +1 -Sundar On 4/27/2016 6:08 PM, Michael Haupt wrote: > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8155106 > Webrev: http://cr.openjdk.java.net/~mhaupt/8155106/webrev.00/ > > Thanks, > > Michael > From sundararajan.athijegannathan at oracle.com Wed Apr 27 12:57:36 2016 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Wed, 27 Apr 2016 18:27:36 +0530 Subject: RFR(XS): 8155214: java/lang/invoke/PermuteArgsTest.java fails due to exhausted code cache In-Reply-To: References: Message-ID: +1 -Sundar On 4/27/2016 5:28 PM, Michael Haupt wrote: > Dear all, > > please review this change. > Bug: https://bugs.openjdk.java.net/browse/JDK-8155214 > Webrev: http://cr.openjdk.java.net/~mhaupt/8155214/webrev.00/ > > The failing test, unlike several other tests in the method handles area, was not safeguarded against code cache overflows. > > Thanks, > > Michael > From brian.goetz at oracle.com Wed Apr 27 13:42:38 2016 From: brian.goetz at oracle.com (Brian Goetz) Date: Wed, 27 Apr 2016 09:42:38 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <571FE3EF.7050001@oracle.com> Message-ID: <5720C1CE.2000301@oracle.com> Not that you'll find an additional voice compelling, but here's some additional anecdotal evidence from another channel: https://twitter.com/jeffreymaxwell/status/725313986053427200 On 4/26/2016 8:16 PM, Vitaly Davidovich wrote: > I'm really grasping at straws here and asking for something > quantitative to substantiate this deprecation plan. As it stands, > there is hearsay and some stackoverflow links - surely going through > with this (and inflicting some level of pain on folks who don't care > for this) deserves something a bit better? Brian mentioned that one > criticism often heard is mistakes aren't corrected - I fully believe > that's true. But this may end up being one of those "they want to > correct mistakes and THIS is what they chose??!" things. I understand > the appeal in "correcting" this given it's a relatively new addition, > but I don't think it'll go over well. > > On Tuesday, April 26, 2016, Paul Benedict > wrote: > > Are you asking Brian to set up another survey monkey for the > masses? I expect a happy silent majority and a raucous > minority.... just based on past results. :-) > > On Apr 26, 2016 6:38 PM, "Vitaly Davidovich" > wrote: > > I've yet to hear one supporter on this thread besides yourself > and Stuart. > Is there some usability survey or something that actually > indicates a > significant sample of people don't like the name? Guava > Optional behaves > and is named the same way, and I've not heard anyone complain > about that (I > and many people I know used it for years). > > I think the conversation would be *maybe* different if picking > a name for a > new thing, but the deprecation churn here adds no value, IMO, > and is going > to be viewed as an annoyance by a large swath of people. > > On Tuesday, April 26, 2016, Brian Goetz > > wrote: > > > As the person who chose the original (terrible) name, let me > weigh in... > > > > I think calling this method "get()" was our biggest API > mistake in Java > > 8. Now, one could argue that, if this is the biggest > mistake we made, then > > we did pretty darn good. Which may be true, but ... make no > mistake, it > > was the wrong name (mea culpa), and experience has borne out > that it is > > widely misused. Subjectively, about half the uses of .get() > I see are > > wrong -- and wrong in the obvious, avoidable way -- they > don't consider the > > optional might be empty. So they've just traded an > unexpected NPE for an > > unexpected NSEE. > > > > Its problem is, essentially: it looks harmless, but isn't, > but it sure > > seems like the method you obviously want when you're > browsing the > > autocomplete list / javadoc. It's a hazard both to code > writers (pick the > > wrong method because the name is bad) and to code readers > (deceptively > > harmless looking.) > > > > Methods like orElse or ifPresent look harmless, and are; > methods like > > orElseThrow have potentially harmful side-effects but have > names that are > > transparent about what harm they could do. But > Optional.get() is neither > > safe nor transparent -- and yet awfully tempting-looking -- > and this leads > > to frequent misuse. Naming matters, and this one was wrong, > and the harm > > is observable. I wish I'd caught it before 8 shipped. > > > > Stepping back a bit ... one of the most frequent complaints > we get is > > "mistakes never get fixed". So, we've decided to be more > serious about > > deprecation -- Dr. Deprecator is suiting up! But that > means, for any given > > item, some people are going to disagree about whether > deprecation is > > suitable, and some will be inconvenienced by the deprecation > -- this is > > unavoidable. > > > > Why prioritize this one? In part, because it's a *new* > mistake, and has > > had less time to become entrenched -- and this is the very first > > opportunity we have to fix it. If we can't fix an API > mistake at the very > > first opportunity, the logical consequence is we can't ever > fix anything. > > And that doesn't seem to be the world we want to retreat to. > > > > Similarly, is this the worst mistake in all of Java? Surely > not. But its > > also not reasonable to say "you can't fix X until you've > fixed everything > > worse than X" -- again, that's a recipe for never fixing > anything. So, in > > the context of a deprecation effort, this seems an entirely > reasonable > > candidate. > > > > I'd like to see it fixed, and the sooner the better. > > > > > > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: > > > >> In OpenGamma Strata we have 546 uses of Optional.get(). > Renaming this > >> would be painful and add no value. > >> > >> While I understand the pain from some developers not > understanding the > >> feature, this is hardly unique in the world of Java. > Developers learn > >> the right way of doing something soon enough. > >> > >> And while > >> > >> if (opt.isPresent()) { > >> opt.get() > >> } > >> > >> is sometimes not ideal, in other cases it is the only > practical choice > >> (eg. where the method needs to have a return statement > inside the if > >> statement). > >> > >> Changing this to > >> > >> if (opt.isPresent()) { > >> opt.getWhenPresent() > >> } > >> > >> is just noise - I can see the "present" part twice. > >> > >> I just don't think I can support the rename (although many > of the > >> webrev tidy-ups are probably good). > >> > >> Stephen > >> > >> > >> > >> On 26 April 2016 at 00:05, Stuart Marks > > wrote: > >> > >>> Hi all, > >>> > >>> Please review these webrevs that deprecate Optional.get() > and to replace > >>> it > >>> with Optional.getWhenPresent(). The corresponding changes > are also > >>> applied > >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and > >>> OptionalLong.getAsLong(). > >>> > >>> Unlike most deprecations, this isn't about the function or > the utility of > >>> some API, it's about the name. The solution is basically > to rename the > >>> API. > >>> The problem is that "get" shows up as the "obvious" choice > in things like > >>> IDE code completion, leading to code that mishandles empty > Optionals. > >>> Typical Stack Overflow discourse runs something like this: > >>> > >>> Q: what do I do with this Optional thing > >>> > >>> A: just call get() > >>> > >>> Q: thanks, it works! > >>> > >>> Of course, it works until it doesn't. > >>> > >>> Examining the JDK's use of Optional.get(), I didn't see > very many cases > >>> that > >>> called get() without first checking for the presence of a > value. But I > >>> did > >>> see quite a number of cases like this: > >>> > >>> if (opt.isPresent()) { > >>> doSomething(opt.get()); > >>> } else { > >>> doSomethingElse(); > >>> } > >>> > >>> In many of these cases, the code could be refactored to > use other > >>> Optional > >>> methods such as filter(), map(), or ifPresent(). > >>> > >>> In any case this reinforces the contention that use of > get() leads to > >>> poor > >>> code. > >>> > >>> For this changeset, in just about all cases I've simply > replaced the > >>> call to > >>> get() with a call to getWhenPresent(). In a couple cases I > replaced the > >>> stream calls > >>> > >>> .filter(Optional::isPresent).map(Optional::get) > >>> > >>> with > >>> > >>> .flatMap(Optional::stream) > >>> > >>> which I hope will become the new idiom for unwrapping a > stream of > >>> Optionals. > >>> > >>> While many cases could be cleaned up further, I didn't > change them. The > >>> reasons are that I didn't want to spend too much time > putting code > >>> cleanup > >>> into the critical path of this changeset (I'd be happy to > help later); > >>> doing > >>> so would create potential conflicts with code coming in > from the Jigsaw > >>> forest; and there are non-obvious places where converting > from a > >>> conditional > >>> to one of the lambda-based methods could cause performance > problems at > >>> startup. > >>> > >>> There are also a few cases where simplification is > prevented because it > >>> would end up causing the resulting lambda expressions to > throw checked > >>> exceptions. :-( > >>> > >>> Webrevs here: > >>> > >>> > >>> > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ > > >>> > >>> > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ > > >>> > >>> Thanks, > >>> > >>> s'marks > >>> > >> > > > > -- > Sent from my phone > > > > -- > Sent from my phone From vitalyd at gmail.com Wed Apr 27 13:51:52 2016 From: vitalyd at gmail.com (Vitaly Davidovich) Date: Wed, 27 Apr 2016 09:51:52 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <5720C1CE.2000301@oracle.com> References: <571FE3EF.7050001@oracle.com> <5720C1CE.2000301@oracle.com> Message-ID: I really don't know what to say -- "near 100% use error rate"? I don't know that person nor whom he's representing when he says "our", but that's appalling. This has nothing to do with "ivory tower cranks", as he put it. Did you ask him why he thinks their use error rate is so high? On Wed, Apr 27, 2016 at 9:42 AM, Brian Goetz wrote: > Not that you'll find an additional voice compelling, but here's some > additional anecdotal evidence from another channel: > https://twitter.com/jeffreymaxwell/status/725313986053427200 > > > > On 4/26/2016 8:16 PM, Vitaly Davidovich wrote: > > I'm really grasping at straws here and asking for something quantitative > to substantiate this deprecation plan. As it stands, there is hearsay and > some stackoverflow links - surely going through with this (and inflicting > some level of pain on folks who don't care for this) deserves something a > bit better? Brian mentioned that one criticism often heard is mistakes > aren't corrected - I fully believe that's true. But this may end up being > one of those "they want to correct mistakes and THIS is what they chose??!" > things. I understand the appeal in "correcting" this given it's a > relatively new addition, but I don't think it'll go over well. > > On Tuesday, April 26, 2016, Paul Benedict < > pbenedict at apache.org> wrote: > >> Are you asking Brian to set up another survey monkey for the masses? I >> expect a happy silent majority and a raucous minority.... just based on >> past results. :-) >> On Apr 26, 2016 6:38 PM, "Vitaly Davidovich" wrote: >> >> I've yet to hear one supporter on this thread besides yourself and Stuart. >> Is there some usability survey or something that actually indicates a >> significant sample of people don't like the name? Guava Optional behaves >> and is named the same way, and I've not heard anyone complain about that >> (I >> and many people I know used it for years). >> >> I think the conversation would be *maybe* different if picking a name for >> a >> new thing, but the deprecation churn here adds no value, IMO, and is going >> to be viewed as an annoyance by a large swath of people. >> >> On Tuesday, April 26, 2016, Brian Goetz wrote: >> >> > As the person who chose the original (terrible) name, let me weigh in... >> > >> > I think calling this method "get()" was our biggest API mistake in Java >> > 8. Now, one could argue that, if this is the biggest mistake we made, >> then >> > we did pretty darn good. Which may be true, but ... make no mistake, it >> > was the wrong name (mea culpa), and experience has borne out that it is >> > widely misused. Subjectively, about half the uses of .get() I see are >> > wrong -- and wrong in the obvious, avoidable way -- they don't consider >> the >> > optional might be empty. So they've just traded an unexpected NPE for an >> > unexpected NSEE. >> > >> > Its problem is, essentially: it looks harmless, but isn't, but it sure >> > seems like the method you obviously want when you're browsing the >> > autocomplete list / javadoc. It's a hazard both to code writers (pick >> the >> > wrong method because the name is bad) and to code readers (deceptively >> > harmless looking.) >> > >> > Methods like orElse or ifPresent look harmless, and are; methods like >> > orElseThrow have potentially harmful side-effects but have names that >> are >> > transparent about what harm they could do. But Optional.get() is >> neither >> > safe nor transparent -- and yet awfully tempting-looking -- and this >> leads >> > to frequent misuse. Naming matters, and this one was wrong, and the >> harm >> > is observable. I wish I'd caught it before 8 shipped. >> > >> > Stepping back a bit ... one of the most frequent complaints we get is >> > "mistakes never get fixed". So, we've decided to be more serious about >> > deprecation -- Dr. Deprecator is suiting up! But that means, for any >> given >> > item, some people are going to disagree about whether deprecation is >> > suitable, and some will be inconvenienced by the deprecation -- this is >> > unavoidable. >> > >> > Why prioritize this one? In part, because it's a *new* mistake, and has >> > had less time to become entrenched -- and this is the very first >> > opportunity we have to fix it. If we can't fix an API mistake at the >> very >> > first opportunity, the logical consequence is we can't ever fix >> anything. >> > And that doesn't seem to be the world we want to retreat to. >> > >> > Similarly, is this the worst mistake in all of Java? Surely not. But >> its >> > also not reasonable to say "you can't fix X until you've fixed >> everything >> > worse than X" -- again, that's a recipe for never fixing anything. So, >> in >> > the context of a deprecation effort, this seems an entirely reasonable >> > candidate. >> > >> > I'd like to see it fixed, and the sooner the better. >> > >> > >> > On 4/26/2016 6:43 AM, Stephen Colebourne wrote: >> > >> >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this >> >> would be painful and add no value. >> >> >> >> While I understand the pain from some developers not understanding the >> >> feature, this is hardly unique in the world of Java. Developers learn >> >> the right way of doing something soon enough. >> >> >> >> And while >> >> >> >> if (opt.isPresent()) { >> >> opt.get() >> >> } >> >> >> >> is sometimes not ideal, in other cases it is the only practical choice >> >> (eg. where the method needs to have a return statement inside the if >> >> statement). >> >> >> >> Changing this to >> >> >> >> if (opt.isPresent()) { >> >> opt.getWhenPresent() >> >> } >> >> >> >> is just noise - I can see the "present" part twice. >> >> >> >> I just don't think I can support the rename (although many of the >> >> webrev tidy-ups are probably good). >> >> >> >> Stephen >> >> >> >> >> >> >> >> On 26 April 2016 at 00:05, Stuart Marks >> wrote: >> >> >> >>> Hi all, >> >>> >> >>> Please review these webrevs that deprecate Optional.get() and to >> replace >> >>> it >> >>> with Optional.getWhenPresent(). The corresponding changes are also >> >>> applied >> >>> to OptionalDouble.getAsDouble(), OptionalInt.getAsInt(), and >> >>> OptionalLong.getAsLong(). >> >>> >> >>> Unlike most deprecations, this isn't about the function or the >> utility of >> >>> some API, it's about the name. The solution is basically to rename the >> >>> API. >> >>> The problem is that "get" shows up as the "obvious" choice in things >> like >> >>> IDE code completion, leading to code that mishandles empty Optionals. >> >>> Typical Stack Overflow discourse runs something like this: >> >>> >> >>> Q: what do I do with this Optional thing >> >>> >> >>> A: just call get() >> >>> >> >>> Q: thanks, it works! >> >>> >> >>> Of course, it works until it doesn't. >> >>> >> >>> Examining the JDK's use of Optional.get(), I didn't see very many >> cases >> >>> that >> >>> called get() without first checking for the presence of a value. But I >> >>> did >> >>> see quite a number of cases like this: >> >>> >> >>> if (opt.isPresent()) { >> >>> doSomething(opt.get()); >> >>> } else { >> >>> doSomethingElse(); >> >>> } >> >>> >> >>> In many of these cases, the code could be refactored to use other >> >>> Optional >> >>> methods such as filter(), map(), or ifPresent(). >> >>> >> >>> In any case this reinforces the contention that use of get() leads to >> >>> poor >> >>> code. >> >>> >> >>> For this changeset, in just about all cases I've simply replaced the >> >>> call to >> >>> get() with a call to getWhenPresent(). In a couple cases I replaced >> the >> >>> stream calls >> >>> >> >>> .filter(Optional::isPresent).map(Optional::get) >> >>> >> >>> with >> >>> >> >>> .flatMap(Optional::stream) >> >>> >> >>> which I hope will become the new idiom for unwrapping a stream of >> >>> Optionals. >> >>> >> >>> While many cases could be cleaned up further, I didn't change them. >> The >> >>> reasons are that I didn't want to spend too much time putting code >> >>> cleanup >> >>> into the critical path of this changeset (I'd be happy to help later); >> >>> doing >> >>> so would create potential conflicts with code coming in from the >> Jigsaw >> >>> forest; and there are non-obvious places where converting from a >> >>> conditional >> >>> to one of the lambda-based methods could cause performance problems at >> >>> startup. >> >>> >> >>> There are also a few cases where simplification is prevented because >> it >> >>> would end up causing the resulting lambda expressions to throw checked >> >>> exceptions. :-( >> >>> >> >>> Webrevs here: >> >>> >> >>> >> >>> >> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/ >> >>> >> >>> http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/ >> >>> >> >>> Thanks, >> >>> >> >>> s'marks >> >>> >> >> >> > >> >> -- >> Sent from my phone >> >> > > -- > Sent from my phone > > > From daniel.fuchs at oracle.com Wed Apr 27 14:20:58 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Wed, 27 Apr 2016 16:20:58 +0200 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <5718FEF7.1020807@oracle.com> References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> Message-ID: <869dbebf-3aea-adcc-6cee-e1d3a8e66ec6@oracle.com> Hi Joe, Changes in java.util.logging and java.management look good. I glanced at the rest and spotted one issue here: http://cr.openjdk.java.net/~darcy/6850612.0/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java.frames.html 615 Object o = Class.forName("javax.swing.text.html.parser.ParserDelegator"); 616 defaultParser = (Parser) o; The call to newInstance() is missing at line 615 best regards, -- daniel On 21/04/16 18:25, joe darcy wrote: > Hello, > > After a generally positive reception, please review the webrev to > implement the deprecation of Class.newInstance and the suppression of > the resulting warnings: > > http://cr.openjdk.java.net/~darcy/6850612.0/ > > There are also some changes in the langtools repo; I'll send a separate > review request for those changes to compiler-dev. > > I'll also forward this review request to other areas with affected code. > > Thanks, > > -Joe > > On 4/17/2016 10:31 AM, joe darcy wrote: >> Hello, >> >> With talk of deprecation in the air [1], I thought it would be a fine >> time to examine one of the bugs on my list >> >> JDK-6850612: Deprecate Class.newInstance since it violates the >> checked exception language contract >> >> As the title of the bug implies, The Class.newInstance method >> knowingly violates the checking exception contract. This has long been >> documented in its specification: >> >>> Note that this method propagates any exception thrown by the nullary >>> constructor, including a checked exception. Use of this method >>> effectively bypasses the compile-time exception checking that would >>> otherwise be performed by the compiler. The Constructor.newInstance >>> method avoids this problem by wrapping any exception thrown by the >>> constructor in a (checked) InvocationTargetException. >> >> Roughly, the fix would be to turn the text of this note into the >> @deprecated text and to add a @Deprecated(since="9") annotation to the >> method. There are a few dozen uses of the method in the JDK that would >> have to be @SuppressWarning-ed or otherwise updated. >> >> Thoughts on the appropriateness of deprecating this method at this time? >> >> Comments on the bug have suggested that besides deprecating the >> method, a new method on Class could be introduced, >> newInstanceWithProperExceptionBehavior, that had the same signature >> but wrapped exceptions thrown by the constructor call in the same way >> Constructor.newInstance does. >> >> Thanks, >> >> -Joe >> >> [1] >> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html >> > From Roger.Riggs at Oracle.com Wed Apr 27 14:38:09 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 27 Apr 2016 10:38:09 -0400 Subject: JDK-8155102: Process.toString could include pid, isAlive, exitStatus In-Reply-To: References: Message-ID: <1dfb33a9-fd8b-9ce5-5916-65782b9222c1@Oracle.com> Hi Andrey, Take a look at the OpenJDK processes, there are a few things you can read about how to contribute [1] and the developers guide [2]. The changes would be localized to the ProcessImpl classes for unix and windows. Roger [1] http://openjdk.java.net/contribute/ [2] http://openjdk.java.net/guide/ On 4/26/2016 1:45 PM, Andrey Dyachkov wrote: > Hi, > > I would like to familiarise myself with contributing process. > Can I take this bug to fix? From brian.goetz at oracle.com Wed Apr 27 14:48:32 2016 From: brian.goetz at oracle.com (Brian Goetz) Date: Wed, 27 Apr 2016 10:48:32 -0400 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <94b56926-06ec-2ea9-7f7a-9a20fd5a2833@oracle.com> References: <94b56926-06ec-2ea9-7f7a-9a20fd5a2833@oracle.com> Message-ID: <5720D140.1050101@oracle.com> So far, this thread has been mostly "I DON'T LIKE THIS CHANGE." But let's talk about a real underlying issue instead, mkay? While no one has actually said this (I guess everyone was too busy slinging rhetoric and raising strawman objections) there is at least one real issue here, which is: - I have a library - I want it to be free of deprecation warnings - I want it to compile cleanly on platform versions N...N+k, where something is deprecated with an alternative in M>N, and the alternative does not exist in N. That leaves the hypothetical library provider above (which I assume is Stephen's situation, though it was left unsaid) with some bad choices: - @SuppressWarnings the use everywhere - Compile without deprecation warnings - Have multiple sourcebases I think the real issue is that @SuppressWarnings is too blunt a tool to be useful in this situation, so deprecation causes collateral pain for library developers. If we can make the deprecation more painless for this class of developers (the ones disproportionately affeted), then I think much of the noise goes away. On 4/27/2016 1:42 AM, Stuart Marks wrote: > On 4/26/16 3:43 AM, Stephen Colebourne wrote: >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this >> would be painful and add no value. > > Hi Stephen, > > I just sent a reply [1] to Kevin B, wherein I clarified "rename." > > Briefly, it strictly isn't a rename. The old method would be > deprecated not-for-removal, and would be left in place indefinitely. > > Does this still create pain? If so, is there some way the proposal can > be modified to reduce it? > > s'marks From scolebourne at joda.org Wed Apr 27 15:44:31 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Wed, 27 Apr 2016 16:44:31 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <5720D140.1050101@oracle.com> References: <94b56926-06ec-2ea9-7f7a-9a20fd5a2833@oracle.com> <5720D140.1050101@oracle.com> Message-ID: Better suppress warnings would be nice, and the problem statement below is reasonable, what concerns me more is the impact on clients of the Strata API. Strata uses Optional heavily - we have "done the right thing" and do not return null from any public methods. As such, a *lot* of methods return Optional. If this change happens, then everyone who adopts Strata today and codes against our API (legitimately using isPresent() followed by get() ) will suffer when Java 9 is released. I don't see how a better SuppressWarnings helps those clients. FWIW, I will have to consider migrating to Guava Optional if I can't rely on a core API like JDK Optional remaining stable. I propose that we deprecate List.get(int). To compensate, we should add a new method getButPleaseCheckListSizeFirst(int) The rationale is that lots of developers call get(int) without correctly checking the list size. I estimate that 69.3724% of all developers misuse the method. If I thought the method needed renaming, I'd go along with this. I'm am accepting the demise of Class.newInstance() for example, although I think even that is a very marginal deprecation. If it seems to Kevin that get() is the right name, and others like me agree, perhaps its worth considering whether the change is actually appropriate? FWIW, the best example in JSR-310 of a design mistake is TemporalAmount.get(TemporalUnit): http://stackoverflow.com/questions/24491243/why-cant-i-get-a-duration-in-minutes-or-hours-in-java-time/24500045#24500045 Renaming that method to unitValue(TemporalUnit) or similar would actually be a useful change (as it is a framework method and almost all uses of that method in application code are wrong). Stephen On 27 April 2016 at 15:48, Brian Goetz wrote: > So far, this thread has been mostly "I DON'T LIKE THIS CHANGE." But let's > talk about a real underlying issue instead, mkay? > > While no one has actually said this (I guess everyone was too busy slinging > rhetoric and raising strawman objections) there is at least one real issue > here, which is: > > - I have a library > - I want it to be free of deprecation warnings > - I want it to compile cleanly on platform versions N...N+k, where > something is deprecated with an alternative in M>N, and the alternative does > not exist in N. > > That leaves the hypothetical library provider above (which I assume is > Stephen's situation, though it was left unsaid) with some bad choices: > - @SuppressWarnings the use everywhere > - Compile without deprecation warnings > - Have multiple sourcebases > > I think the real issue is that @SuppressWarnings is too blunt a tool to be > useful in this situation, so deprecation causes collateral pain for library > developers. If we can make the deprecation more painless for this class of > developers (the ones disproportionately affeted), then I think much of the > noise goes away. > > > On 4/27/2016 1:42 AM, Stuart Marks wrote: >> >> On 4/26/16 3:43 AM, Stephen Colebourne wrote: >>> >>> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this >>> would be painful and add no value. >> >> >> Hi Stephen, >> >> I just sent a reply [1] to Kevin B, wherein I clarified "rename." >> >> Briefly, it strictly isn't a rename. The old method would be deprecated >> not-for-removal, and would be left in place indefinitely. >> >> Does this still create pain? If so, is there some way the proposal can be >> modified to reduce it? >> >> s'marks > > From joe.darcy at oracle.com Wed Apr 27 15:53:34 2016 From: joe.darcy at oracle.com (joe darcy) Date: Wed, 27 Apr 2016 08:53:34 -0700 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <869dbebf-3aea-adcc-6cee-e1d3a8e66ec6@oracle.com> References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> <869dbebf-3aea-adcc-6cee-e1d3a8e66ec6@oracle.com> Message-ID: <67fbb0b9-392d-5603-d2c0-381af0ea85b9@oracle.com> Hi Daniel, Good catch! I've fixed that in my working copy of the changes. Thanks for the careful review, -Joe On 4/27/2016 7:20 AM, Daniel Fuchs wrote: > Hi Joe, > > Changes in java.util.logging and java.management look good. > > I glanced at the rest and spotted one issue here: > > http://cr.openjdk.java.net/~darcy/6850612.0/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java.frames.html > > > 615 Object o = > Class.forName("javax.swing.text.html.parser.ParserDelegator"); > 616 defaultParser = (Parser) o; > > The call to newInstance() is missing at line 615 > > best regards, > > -- daniel > > On 21/04/16 18:25, joe darcy wrote: >> Hello, >> >> After a generally positive reception, please review the webrev to >> implement the deprecation of Class.newInstance and the suppression of >> the resulting warnings: >> >> http://cr.openjdk.java.net/~darcy/6850612.0/ >> >> There are also some changes in the langtools repo; I'll send a separate >> review request for those changes to compiler-dev. >> >> I'll also forward this review request to other areas with affected code. >> >> Thanks, >> >> -Joe >> >> On 4/17/2016 10:31 AM, joe darcy wrote: >>> Hello, >>> >>> With talk of deprecation in the air [1], I thought it would be a fine >>> time to examine one of the bugs on my list >>> >>> JDK-6850612: Deprecate Class.newInstance since it violates the >>> checked exception language contract >>> >>> As the title of the bug implies, The Class.newInstance method >>> knowingly violates the checking exception contract. This has long been >>> documented in its specification: >>> >>>> Note that this method propagates any exception thrown by the nullary >>>> constructor, including a checked exception. Use of this method >>>> effectively bypasses the compile-time exception checking that would >>>> otherwise be performed by the compiler. The Constructor.newInstance >>>> method avoids this problem by wrapping any exception thrown by the >>>> constructor in a (checked) InvocationTargetException. >>> >>> Roughly, the fix would be to turn the text of this note into the >>> @deprecated text and to add a @Deprecated(since="9") annotation to the >>> method. There are a few dozen uses of the method in the JDK that would >>> have to be @SuppressWarning-ed or otherwise updated. >>> >>> Thoughts on the appropriateness of deprecating this method at this >>> time? >>> >>> Comments on the bug have suggested that besides deprecating the >>> method, a new method on Class could be introduced, >>> newInstanceWithProperExceptionBehavior, that had the same signature >>> but wrapped exceptions thrown by the constructor call in the same way >>> Constructor.newInstance does. >>> >>> Thanks, >>> >>> -Joe >>> >>> [1] >>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html >>> >>> >> > From xueming.shen at oracle.com Wed Apr 27 16:18:05 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Wed, 27 Apr 2016 09:18:05 -0700 Subject: RFR (XS) 8155215: java.lang.String concatenation spec is unnecessarily strong In-Reply-To: <57209560.6040206@oracle.com> References: <57209560.6040206@oracle.com> Message-ID: <5720E63D.7080402@oracle.com> On 4/27/16 3:33 AM, Aleksey Shipilev wrote: > Hi, > > Please review this tiny spec improvement that syncs up JLS and > java.lang.String Javadoc. java.lang.String Javadoc unnecessarily locks > down the implementation details for String concat (e.g. usage of > StringBuilder): > http://cr.openjdk.java.net/~shade/8155215/webrev.00/ > > I'll submit CCC as soon as we agree on wording. > > Thanks, > -Aleksey > looks good. From aph at redhat.com Wed Apr 27 16:58:27 2016 From: aph at redhat.com (Andrew Haley) Date: Wed, 27 Apr 2016 17:58:27 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <94b56926-06ec-2ea9-7f7a-9a20fd5a2833@oracle.com> <5720D140.1050101@oracle.com> Message-ID: <5720EFB3.3020204@redhat.com> On 04/27/2016 04:44 PM, Stephen Colebourne wrote: > Better suppress warnings would be nice, and the problem statement > below is reasonable, what concerns me more is the impact on clients > of the Strata API. Strata uses Optional heavily - we have "done the > right thing" and do not return null from any public methods. As > such, a *lot* of methods return Optional. If this change happens, > then everyone who adopts Strata today and codes against our API > (legitimately using isPresent() followed by get() ) will suffer when > Java 9 is released. I don't see how a better SuppressWarnings helps > those clients. Sure, but almost all of the uses of Optional.get() will be in the future. This rather reminds me of the early UNIX bug report about make syntax. The bug was that make(1) treated tab characters and spaces differently. This bug could have been fixed but there were about 20 users of make already, and they would have had to change their makefiles. And probably everyone reading this mail has suffered because of that bug. Andrew. From maurizio.cimadamore at oracle.com Wed Apr 27 17:43:26 2016 From: maurizio.cimadamore at oracle.com (Maurizio Cimadamore) Date: Wed, 27 Apr 2016 18:43:26 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <572078C7.9070102@redhat.com> References: <571FE3EF.7050001@oracle.com> <572078C7.9070102@redhat.com> Message-ID: <5720FA3E.3080509@oracle.com> On 27/04/16 09:31, Andrew Haley wrote: > what they say makes > sense to me It makes sense to me to. Having an innocently-named get() method throwing an exception is not something you see everyday. And in this case it's doubly confusing because one could imagine also a different behavior (i.e. return null if no object is there). So I'm in favor for making things clearer by choosing a more explicit name (whether the proposed one or a better one). Cheers Maurizio From timo.kinnunen at gmail.com Wed Apr 27 17:47:20 2016 From: timo.kinnunen at gmail.com (Timo Kinnunen) Date: Wed, 27 Apr 2016 19:47:20 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <5720D140.1050101@oracle.com> References: <94b56926-06ec-2ea9-7f7a-9a20fd5a2833@oracle.com> <5720D140.1050101@oracle.com> Message-ID: <5720fb31.aaf0c20a.d8e6f.ffff9cce@mx.google.com> Hi, Looking at real problems is good, and in this case there?s quite a few layers of issues underlying issues indeed. First the problem of the ?get? method underlain by the deprecation issue. As mentioned, the name ?get? is a good, proper name for a method. There are no problems with the name itself. The problem is with the implementation backing this name not matching what it should obviously-from-just-reading-the-name be really doing. A misbehaving implementation is nothing new and is a relatively easy problem to fix. First, not throwing a previously thrown exception should not break too many consumers. Likewise returning a previously not returned value won?t deprive consumers of any values they are relying on getting. Still, some consumers might be broken. On balance, if the evidence presented earlier the thread holds true then many (perhaps quite a few more!) consumers -- currently silently broken -- would get silently mended. As a bonus, returning null and not throwing a NSEE doesn?t disqualify Optional from becoming a value type in future nor prevent it from containing a future value type. The solution to how this is to be done is left as an exercise for the reader. ?? But yeah, there is a solution. Against this backdrop the suggestion to deprecate the get-method without changing its implementation in essence changes the thrown NoSuchElementException into a quasi-checked exception via creative (ab)use of the deprecation mechanism. That leaves the class with just as many methods with problems as there were in the beginning. If the get-method is then recreated under a different name with all the problems in the implementation left unfixed, Optional ends up with 1 more method with problems than what it started with. This way of ?fixing? the problem seems to me like a workaround to deeper issues with the language. -- Have a nice day, Timo Sent from Mail for Windows 10 From: Brian Goetz Sent: Wednesday, April 27, 2016 16:49 To: Stuart Marks; Stephen Colebourne Cc: core-libs-dev Subject: Re: RFR(m): 8140281 deprecate Optional.get() So far, this thread has been mostly "I DON'T LIKE THIS CHANGE." But let's talk about a real underlying issue instead, mkay? While no one has actually said this (I guess everyone was too busy slinging rhetoric and raising strawman objections) there is at least one real issue here, which is: - I have a library - I want it to be free of deprecation warnings - I want it to compile cleanly on platform versions N...N+k, where something is deprecated with an alternative in M>N, and the alternative does not exist in N. That leaves the hypothetical library provider above (which I assume is Stephen's situation, though it was left unsaid) with some bad choices: - @SuppressWarnings the use everywhere - Compile without deprecation warnings - Have multiple sourcebases I think the real issue is that @SuppressWarnings is too blunt a tool to be useful in this situation, so deprecation causes collateral pain for library developers. If we can make the deprecation more painless for this class of developers (the ones disproportionately affeted), then I think much of the noise goes away. On 4/27/2016 1:42 AM, Stuart Marks wrote: > On 4/26/16 3:43 AM, Stephen Colebourne wrote: >> In OpenGamma Strata we have 546 uses of Optional.get(). Renaming this >> would be painful and add no value. > > Hi Stephen, > > I just sent a reply [1] to Kevin B, wherein I clarified "rename." > > Briefly, it strictly isn't a rename. The old method would be > deprecated not-for-removal, and would be left in place indefinitely. > > Does this still create pain? If so, is there some way the proposal can > be modified to reduce it? > > s'marks From neugens.limasoftware at gmail.com Wed Apr 27 17:49:43 2016 From: neugens.limasoftware at gmail.com (Mario Torre) Date: Wed, 27 Apr 2016 19:49:43 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <5720FA3E.3080509@oracle.com> References: <571FE3EF.7050001@oracle.com> <572078C7.9070102@redhat.com> <5720FA3E.3080509@oracle.com> Message-ID: 2016-04-27 19:43 GMT+02:00 Maurizio Cimadamore : > > > On 27/04/16 09:31, Andrew Haley wrote: >> >> what they say makes >> sense to me > > It makes sense to me to. Having an innocently-named get() method throwing an > exception is not something you see everyday. And in this case it's doubly > confusing because one could imagine also a different behavior (i.e. return > null if no object is there). So I'm in favor for making things clearer by > choosing a more explicit name (whether the proposed one or a better one). This thread looks funny, so I chime in too. +1 for the change overall, I really do like when methods are self explanatory and I don't need to read the manual ;) But please consider the getWhenPresent sounds to me like it's trying to suggest that the method would block and returns *when* the value is present, not sure if it's just me and the fact that I'm not native english speaker though. Cheers, Mario -- pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF Java Champion - Blog: http://neugens.wordpress.com - Twitter: @neugens Proud GNU Classpath developer: http://www.classpath.org/ OpenJDK: http://openjdk.java.net/projects/caciocavallo/ Please, support open standards: http://endsoftpatents.org/ From chris.hegarty at oracle.com Wed Apr 27 18:04:37 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 27 Apr 2016 19:04:37 +0100 Subject: RFR (XS) 8155215: java.lang.String concatenation spec is unnecessarily strong In-Reply-To: <57209560.6040206@oracle.com> References: <57209560.6040206@oracle.com> Message-ID: <86F0FAB3-EC76-4A32-89D1-D8F16E553927@oracle.com> On 27 Apr 2016, at 11:33, Aleksey Shipilev wrote: > Hi, > > Please review this tiny spec improvement that syncs up JLS and > java.lang.String Javadoc. java.lang.String Javadoc unnecessarily locks > down the implementation details for String concat (e.g. usage of > StringBuilder): > http://cr.openjdk.java.net/~shade/8155215/webrev.00/ This looks good. Should is say ?Java SE? API rather than ?JDK API? ? -Chris. From mandy.chung at oracle.com Wed Apr 27 18:31:13 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Wed, 27 Apr 2016 11:31:13 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> Message-ID: <66A0640B-408C-4276-BB79-CCFDEFFDC24B@oracle.com> Updated webrev: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.01/index.html I added a new StackFrame::getByteCodeIndex method to return bci and updatedgetFileName and getLineNumber to have the same returned type as in StackTraceElement. From usage perspective, the caller has to prepare and handle the information is unavailable and I think it would typically log some token to represent the unavailable case and might well use null and negative value. This patch would save the creation of short-lived Optional object that might help logging filename/linenumber case. I?m working on a new test to verify bci and line number to be included in the next revision. Mandy > On Apr 11, 2016, at 2:22 PM, Mandy Chung wrote: > > Webrev at: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html > > StackFrame::getFileName and StackFrame::getLineNumber are originally proposed with the view of any stack walking code can migrate to the StackWalker API without the use of StackTraceElement. > > File name and line number are useful for debugging and troubleshooting purpose. It has additional overhead to map from a method and BCI to look up the file name and line number. > > StackFrame::toStackTraceElement method returns StackTraceElement that includes the file name and line number. There is no particular benefit to duplicate getFileName and getLineNumber methods in StackFrame. It is equivalently convenient to call StackFrame.toStackTraceElement().getFileName() (or getLineNumber). > > This patch proposes to remove StackFrame::getFileName and StackFrame::getLineNumber methods since such information can be obtained from StackFrame.toStackTraceElement(). > > Mandy From huizhe.wang at oracle.com Wed Apr 27 19:06:23 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Wed, 27 Apr 2016 12:06:23 -0700 Subject: RFR (JAXP) 8154220 : Semi-colon delimited list of catalog files in System property is throwing IllegalArgumentException Message-ID: <57210DAF.4070504@oracle.com> Hi, Please review the following issue and fix: JBS: https://bugs.openjdk.java.net/browse/JDK-8154220 webrev: http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ Thanks, Joe From cushon at google.com Wed Apr 27 19:19:00 2016 From: cushon at google.com (Liam Miller-Cushon) Date: Wed, 27 Apr 2016 12:19:00 -0700 Subject: RFR 7183985: Class.getAnnotation() throws an ArrayStoreException when the annotation class not present In-Reply-To: References: Message-ID: Hi, I finally have an update - We've been using the patch internally for about six weeks, and it hasn't caused any problems. The compatibility impact still appears to be minimal. I've attached an updated version of the patch with the improvements to the test coverage you suggested. Are you still willing to help get the compatibility review started? Thanks, Liam On Tue, Feb 16, 2016 at 9:48 AM, Joel Borggr?n-Franck < joel.borggren.franck at gmail.com> wrote: > Hi Liam, > > Sorry for the delay, > > On Sat, 30 Jan 2016 at 04:45 Liam Miller-Cushon wrote: > >> On Thu, Jan 28, 2016 at 11:50 AM, Joel Borggr?n-Franck < >> joel.borggren.franck at gmail.com> wrote: >> >> But, the reason we didn't fix this the last two times we looked at it >>> (that I am aware of) is the compatibility story. In order to fix his >>> you need to figure out two things: >>> >>> - Is this is a spec change, that is, can we get away with throwing an >>> AnnotationFormatError where we would now do? Should we clarify the >>> spec? >>> >> >> Can you clarify which parts of the spec might need to be updated? I can't >> find anything relevant in the jls or jvms. The javadoc for AnnotatedElement >> mentions some conditions under which TypeNotPresentException is thrown: >> >> "If an annotation returned by a method in this interface contains >> (directly or indirectly) a Class-valued member referring to a class that is >> not accessible in this VM, attempting to read the class by calling the >> relevant Class-returning method on the returned annotation will result in a >> TypeNotPresentException." >> >> So throwing TypeNotPresentException when an array-valued annotation >> indirectly references an inaccessible class sounds like the right >> behaviour, and is consistent with how the implementation currently handles >> similar cases. >> > > I think you answered my concerns. By the spec I meant either the Java > Language Specification or the normative parts of the javadoc. This seems to > be in line with what is currently specified. > > >> - Since this is a behaviorally incompatible change, how big is the >>> impact? This is of course a hard question to answer, but if one could >>> do a corpus analysis over a large code base and look for catches of >>> ArrayStoreExceptions when reflecting over annotations, that could be >>> useful. If it turns out that "a lot" of users have adopted to this >>> bug, perhaps it isn't worth fixing? On the other hand I can imagine >>> that this is so uncommon that no one catches either type of error. >>> >> >> I'm working on evaluating the impact. A review of our code base showed >> that handling ArrayStoreException is fairly uncommon. Of the instances I >> found, none of them were in code that was inspecting annotations. >> >> The next step is to start using the patch internally and see if anything >> breaks. I'll update the thread when I have results on that. >> > > Great, if the experiment works out I'll help formulate a change request > for compatibility review. > > cheers > /Joel > -------------- next part -------------- A non-text attachment was scrubbed... Name: 7183985.3.patch Type: text/x-patch Size: 19441 bytes Desc: not available URL: From lance.andersen at oracle.com Wed Apr 27 19:42:29 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Wed, 27 Apr 2016 15:42:29 -0400 Subject: RFR (JAXP) 8154220 : Semi-colon delimited list of catalog files in System property is throwing IllegalArgumentException In-Reply-To: <57210DAF.4070504@oracle.com> References: <57210DAF.4070504@oracle.com> Message-ID: Hi Joe, Overall it is OK. I might have considered using @Beforeclass vs a static block in the test. Also, once you check the property, you could then set your offset and avoid the extra check and need for the isWindows boolean. That is more of a style choice though. I am OK either way, I just try to leverage the testng annotations when I can. Best Lance > On Apr 27, 2016, at 3:06 PM, huizhe wang wrote: > > Hi, > > Please review the following issue and fix: > > JBS: https://bugs.openjdk.java.net/browse/JDK-8154220 > webrev: http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ > > Thanks, > Joe > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From stevenschlansker at gmail.com Wed Apr 27 20:18:04 2016 From: stevenschlansker at gmail.com (Steven Schlansker) Date: Wed, 27 Apr 2016 13:18:04 -0700 Subject: JEP 118 Parameter Names by default Message-ID: Hi core-libs-dev, Apologies in advance if this is the wrong list, I was torn between this one and compiler-dev, but I'm already subscribed here so we'll try this first :) I am trying to understand why the javac '-parameters' option is not enabled by default. Normally it would not be too onerous, but due to some limitations in e.g. Maven it is surprisingly difficult to configure correctly in a world where you must build code that both targets e.g. 1.8 and 1.7 (and soon 1.9): http://mail-archives.apache.org/mod_mbox/maven-dev/201604.mbox/browser While I am happy to work with the Maven project to improve their support for sending compiler arguments more flexibly, I did wonder -- why is this feature not on by default? I did some brief searching and was unable to come up with any downside, but maybe I missed something obvious? Can we turn it on by default for Java 9? Thanks for humoring me, Steven From ropalka at redhat.com Wed Apr 27 21:23:01 2016 From: ropalka at redhat.com (Richard Opalka) Date: Wed, 27 Apr 2016 23:23:01 +0200 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <13C89E01-3396-4EFE-BC35-C289E59DBEED@oracle.com> <5707CFBB.8020809@oracle.com> Message-ID: We are missing sun/reflect/ReflectionFactory$GetReflectionFactoryAction inner class in jdk.unsupported module: java.lang.NoClassDefFoundError: sun/reflect/ReflectionFactory$GetReflectionFactoryAction at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base at 9-internal/BuiltinClassLoader.java:366) at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base at 9-internal/ClassLoaders.java:184) at java.lang.ClassLoader.loadClass(java.base at 9-internal/ClassLoader.java:419) at org.jboss.marshalling.reflect.SerializableClass.(SerializableClass.java:47) Rio On 04/08/2016 05:48 PM, Mandy Chung wrote: >> On Apr 8, 2016, at 8:35 AM, Chris Hegarty wrote: >> >> >> I moved the tests from a directory named 'jdk.unsupported' to >> unsupported', as other tests, in test/tools/jdeps/module, use >> test/tools/jdeps as a test library, and the directory/test lib >> name is conflicting with the module name. jtreg fails immediately. >> The updates I made check that jdeps identifies both jdk.internal.misc >> and sun.misc Unsafe as internal APIs. > Thanks for explaining why you did the rename. Your change now makes sense to me. I may reorganize the jdeps tests to avoid the module name you ran into in the future. > > All looks good. > > Mandy From peter.levart at gmail.com Wed Apr 27 21:46:46 2016 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 27 Apr 2016 23:46:46 +0200 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: <571A639B.1000606@oracle.com> References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> <571A4439.6090001@Oracle.com> <571A639B.1000606@oracle.com> Message-ID: Hi Joe, On 04/22/2016 07:47 PM, joe darcy wrote: > Hi Roger, > > Per other discussion in the thread, no new method will be introduced. > > The area owners will need to cleanup this usage of this method since > it may involve restructuring of catch blocks, etc., since the > recommended approach has different exception behavior. The functionality of Class.newInstance() might have a logical replacement in existing API (getConstructor().newInstance()) but this replacement is not equivalent performance-wise. As mentioned, Class.newInstance() has a special cache for constructor and caller that speeds up repeated invocations from the same caller by skipping access checks. Suppose there exist a public API like the following: public T instantiateAndSetup(Class clazz) { ... } ...that uses clazz.newInstance() inside the implementation to construct new instances of passed-in classes. Suppose such API is widely used and is performance sensitive. What is the maintainer of that API supposed to do when Class.newInstance() is deprecated and later removed with no replacement? He has the following choices: - deprecate his API and provide a replacement taking a Constructor object instead of a Class object and leave the responsibility of Constructor(s) caching to the user of the API. - maintain an internal cache of Class -> Constructor in his implementation of the API. Such cache is not trivial as it must weakly reference Class and Constructor objects or ClassLoader leaks are possible and it has its own overhead. Wouldn't it be possible to just change the specification of the method to wrap checked exceptions with an unchecked exception (such as UdeclaredThrowableException)? I think this would have a minimal impact on existing code as constructors usually don't throw checked exceptions - in particular the no-argument constructors. Is there any evidence that such no-argument constructors exist at all, let alone that they are invoked via Class.newInstance() ? Regards, Peter > > Thanks, > > -Joe > > On 4/22/2016 8:33 AM, Roger Riggs wrote: >> Hi Joe, >> >> Wouldn't it be less make work to introduce the new method, replace >> the current one where appropriate >> and then deprecate the existing method? As it is, you/someone is >> going to make a second pass >> over all the same files. >> >> Roger >> >> >> On 4/21/2016 12:25 PM, joe darcy wrote: >>> Hello, >>> >>> After a generally positive reception, please review the webrev to >>> implement the deprecation of Class.newInstance and the suppression >>> of the resulting warnings: >>> >>> http://cr.openjdk.java.net/~darcy/6850612.0/ >>> >>> There are also some changes in the langtools repo; I'll send a >>> separate review request for those changes to compiler-dev. >>> >>> I'll also forward this review request to other areas with affected >>> code. >>> >>> Thanks, >>> >>> -Joe >>> >>> On 4/17/2016 10:31 AM, joe darcy wrote: >>>> Hello, >>>> >>>> With talk of deprecation in the air [1], I thought it would be a >>>> fine time to examine one of the bugs on my list >>>> >>>> JDK-6850612: Deprecate Class.newInstance since it violates the >>>> checked exception language contract >>>> >>>> As the title of the bug implies, The Class.newInstance method >>>> knowingly violates the checking exception contract. This has long >>>> been documented in its specification: >>>> >>>>> Note that this method propagates any exception thrown by the >>>>> nullary constructor, including a checked exception. Use of this >>>>> method effectively bypasses the compile-time exception checking >>>>> that would otherwise be performed by the compiler. The >>>>> Constructor.newInstance method avoids this problem by wrapping any >>>>> exception thrown by the constructor in a (checked) >>>>> InvocationTargetException. >>>> >>>> Roughly, the fix would be to turn the text of this note into the >>>> @deprecated text and to add a @Deprecated(since="9") annotation to >>>> the method. There are a few dozen uses of the method in the JDK >>>> that would have to be @SuppressWarning-ed or otherwise updated. >>>> >>>> Thoughts on the appropriateness of deprecating this method at this >>>> time? >>>> >>>> Comments on the bug have suggested that besides deprecating the >>>> method, a new method on Class could be introduced, >>>> newInstanceWithProperExceptionBehavior, that had the same signature >>>> but wrapped exceptions thrown by the constructor call in the same >>>> way Constructor.newInstance does. >>>> >>>> Thanks, >>>> >>>> -Joe >>>> >>>> [1] >>>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-April/040192.html >>> >> > From chris.hegarty at oracle.com Wed Apr 27 21:54:04 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Wed, 27 Apr 2016 22:54:04 +0100 Subject: RFR [9] 8153737: Unsupported Module In-Reply-To: References: <34E89289-EC26-4368-8258-697EA864D439@oracle.com> <13C89E01-3396-4EFE-BC35-C289E59DBEED@oracle.com> <5707CFBB.8020809@oracle.com> Message-ID: <5028AF86-C8DD-431E-8499-0022B8D90C85@oracle.com> Hi Rio, > We are missing sun/reflect/ReflectionFactory$GetReflectionFactoryAction inner class > > in jdk.unsupported module: > > java.lang.NoClassDefFoundError: sun/reflect/ReflectionFactory$GetReflectionFactoryAction > at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base at 9-internal/BuiltinClassLoader.java:366) > at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base at 9-internal/ClassLoaders.java:184) > at java.lang.ClassLoader.loadClass(java.base at 9-internal/ClassLoader.java:419) > at org.jboss.marshalling.reflect.SerializableClass.(SerializableClass.java:47) GetReflectionFactoryAction is a convenience class for acquiring the capability to instantiate reflective objects. It?s code is: As part of JEP 260, we retained the single getReflectionFactory accessor. You can replace your usage with the following: PrivilegedAction pa = new PrivilegedAction() { @Override public ReflectionFactory run() { return ReflectionFactory.getReflectionFactory(); } }; -Chris. From steve.drach at oracle.com Wed Apr 27 21:58:21 2016 From: steve.drach at oracle.com (Steve Drach) Date: Wed, 27 Apr 2016 14:58:21 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them Message-ID: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev/ This changeset causes the URL returned from a ClassLoader.getResource(name) invocation to be reified, that is the URL is a direct pointer to either a versioned or unversioned entry in the jar file. The patch also assures that jar URL?s are always processed by the URLClassPath.JarLoader. The MultiReleaseJarURLConnection test was enhanced to demonstrate that reified URLs are returned. The SimpleHttpServer test helper class was moved into it?s own file. From john.r.rose at oracle.com Wed Apr 27 22:26:08 2016 From: john.r.rose at oracle.com (John Rose) Date: Wed, 27 Apr 2016 15:26:08 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> Message-ID: <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> Diction Note: Reified X means X wasn't real (in some sense) until now. As in non-reified types, which are not real at runtime because the static compiler discarded them. In this case it appears you are simply exposing a translated name, not making it real for the first time. If this is true, I think you want to say "true name" or "real name" or "translated name", not "reified name". ? John > On Apr 27, 2016, at 2:58 PM, Steve Drach wrote: > > > Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 > > Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev/ > > This changeset causes the URL returned from a ClassLoader.getResource(name) invocation to be reified, that is the URL is a direct pointer to either a versioned or unversioned entry in the jar file. The patch also assures that jar URL?s are always processed by the URLClassPath.JarLoader. The MultiReleaseJarURLConnection test was enhanced to demonstrate that reified URLs are returned. The SimpleHttpServer test helper class was moved into it?s own file. From huizhe.wang at oracle.com Wed Apr 27 22:45:43 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Wed, 27 Apr 2016 15:45:43 -0700 Subject: RFR (JAXP) 8154220 : Semi-colon delimited list of catalog files in System property is throwing IllegalArgumentException In-Reply-To: References: <57210DAF.4070504@oracle.com> Message-ID: <57214117.4030002@oracle.com> On 4/27/2016 12:42 PM, Lance Andersen wrote: > Hi Joe, > > Overall it is OK. > > I might have considered using @Beforeclass vs a static block in the > test. Also, once you check the property, you could then set your > offset and avoid the extra check and need for the isWindows boolean. > That is more of a style choice though. Thanks Lance. Updated using @Beforeclass to set up a filepath field. http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ > > I am OK either way, I just try to leverage the testng annotations > when I can. Yeah, make sense. Best, Joe > > Best > Lance >> On Apr 27, 2016, at 3:06 PM, huizhe wang > > wrote: >> >> Hi, >> >> Please review the following issue and fix: >> >> JBS: https://bugs.openjdk.java.net/browse/JDK-8154220 >> webrev: http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ >> >> >> Thanks, >> Joe >> > > > > Lance > Andersen| Principal Member of Technical Staff | +1.781.442.2037 > Oracle Java Engineering > 1 Network Drive > Burlington, MA 01803 > Lance.Andersen at oracle.com > > > From lance.andersen at oracle.com Wed Apr 27 22:51:35 2016 From: lance.andersen at oracle.com (Lance Andersen) Date: Wed, 27 Apr 2016 18:51:35 -0400 Subject: RFR (JAXP) 8154220 : Semi-colon delimited list of catalog files in System property is throwing IllegalArgumentException In-Reply-To: <57214117.4030002@oracle.com> References: <57210DAF.4070504@oracle.com> <57214117.4030002@oracle.com> Message-ID: Looks better joe Best Lance > On Apr 27, 2016, at 6:45 PM, huizhe wang wrote: > > > On 4/27/2016 12:42 PM, Lance Andersen wrote: >> Hi Joe, >> >> Overall it is OK. >> >> I might have considered using @Beforeclass vs a static block in the test. Also, once you check the property, you could then set your offset and avoid the extra check and need for the isWindows boolean. That is more of a style choice though. > > Thanks Lance. Updated using @Beforeclass to set up a filepath field. > > http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ > >> >> I am OK either way, I just try to leverage the testng annotations when I can. > > Yeah, make sense. > > Best, > Joe > >> >> Best >> Lance >>> On Apr 27, 2016, at 3:06 PM, huizhe wang > wrote: >>> >>> Hi, >>> >>> Please review the following issue and fix: >>> >>> JBS: https://bugs.openjdk.java.net/browse/JDK-8154220 >>> webrev: http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ >>> >>> Thanks, >>> Joe >>> >> >> >> >> Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 >> Oracle Java Engineering >> 1 Network Drive >> Burlington, MA 01803 >> Lance.Andersen at oracle.com >> >> >> > Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037 Oracle Java Engineering 1 Network Drive Burlington, MA 01803 Lance.Andersen at oracle.com From huizhe.wang at oracle.com Wed Apr 27 23:07:26 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Wed, 27 Apr 2016 16:07:26 -0700 Subject: RFR (JAXP) 8154220 : Semi-colon delimited list of catalog files in System property is throwing IllegalArgumentException In-Reply-To: References: <57210DAF.4070504@oracle.com> <57214117.4030002@oracle.com> Message-ID: <5721462E.6030201@oracle.com> Thanks! Best, Joe On 4/27/2016 3:51 PM, Lance Andersen wrote: > Looks better joe > > Best > Lance >> On Apr 27, 2016, at 6:45 PM, huizhe wang > > wrote: >> >> >> On 4/27/2016 12:42 PM, Lance Andersen wrote: >>> Hi Joe, >>> >>> Overall it is OK. >>> >>> I might have considered using @Beforeclass vs a static block in the >>> test. Also, once you check the property, you could then set your >>> offset and avoid the extra check and need for the isWindows boolean. >>> That is more of a style choice though. >> >> Thanks Lance. Updated using @Beforeclass to set up a filepath field. >> >> http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ >> >>> >>> I am OK either way, I just try to leverage the testng annotations >>> when I can. >> >> Yeah, make sense. >> >> Best, >> Joe >> >>> >>> Best >>> Lance >>>> On Apr 27, 2016, at 3:06 PM, huizhe wang >>> > wrote: >>>> >>>> Hi, >>>> >>>> Please review the following issue and fix: >>>> >>>> JBS: https://bugs.openjdk.java.net/browse/JDK-8154220 >>>> webrev: http://cr.openjdk.java.net/~joehw/jdk9/8154220/webrev/ >>>> >>>> >>>> Thanks, >>>> Joe >>>> >>> >>> >>> >>> >>> Lance >>> Andersen| Principal Member of Technical Staff | +1.781.442.2037 >>> Oracle Java Engineering >>> 1 Network Drive >>> Burlington, MA 01803 >>> Lance.Andersen at oracle.com >>> >>> >>> >> > > > > Lance > Andersen| Principal Member of Technical Staff | +1.781.442.2037 > Oracle Java Engineering > 1 Network Drive > Burlington, MA 01803 > Lance.Andersen at oracle.com > > > From paul.sandoz at oracle.com Wed Apr 27 23:20:15 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 27 Apr 2016 16:20:15 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> Message-ID: <865CEDEB-2977-4A40-AF1A-643F7CC67BE3@oracle.com> > On 27 Apr 2016, at 15:26, John Rose wrote: > > Diction Note: Reified X means X wasn't real (in some sense) until now. As in non-reified types, which are not real at runtime because the static compiler discarded them. > I suggested reified because i thought it fit with the notion of making something abstract more concrete, but perhaps this just confuses matters? > In this case it appears you are simply exposing a translated name, not making it real for the first time. > > If this is true, I think you want to say "true name" or "real name" or "translated name", not "reified name?. or ?versioned name" would work for me. Paul. From john.r.rose at oracle.com Thu Apr 28 00:10:26 2016 From: john.r.rose at oracle.com (John Rose) Date: Wed, 27 Apr 2016 17:10:26 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <865CEDEB-2977-4A40-AF1A-643F7CC67BE3@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> <865CEDEB-2977-4A40-AF1A-643F7CC67BE3@oracle.com> Message-ID: On Apr 27, 2016, at 4:20 PM, Paul Sandoz wrote: > > >> On 27 Apr 2016, at 15:26, John Rose wrote: >> >> Diction Note: Reified X means X wasn't real (in some sense) until now. As in non-reified types, which are not real at runtime because the static compiler discarded them. >> > > I suggested reified because i thought it fit with the notion of making something abstract more concrete, but perhaps this just confuses matters? It's the real name, but since it already exists (because that's how it is stored) it isn't really reified, it's just revealed. This API uses the term "real name" for an almost identical phenomenon (target of a sym-link in a file system): https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toRealPath-java.nio.file.LinkOption...- In a versioned jar, the logical names are sometimes mapped to other names under which the elements are actually stored. Thus, they behave like sym-links. (But with a bit of control context thrown in, the active version.) On old-fashioned file systems with real version numbers, the Common Lisp function TRUENAME does exactly what you are trying to do here. http://www.mathcs.duq.edu/simon/Gcl/gcl_1141.html (And in some way, we are sliding down the slope toward re-inventing those file systems, aren't we?) The older pre-nio API for File calls it "getCanonicalPath", but I think "true name" is better than "canonical name", since "canonical" means "follows the rules", rather than what we need in this case, which is "where it really is stored". http://docs.oracle.com/javase/8/docs/api/java/io/File.html#getCanonicalPath-- > >> In this case it appears you are simply exposing a translated name, not making it real for the first time. >> >> If this is true, I think you want to say "true name" or "real name" or "translated name", not "reified name?. > > or ?versioned name" would work for me. I'm just whinging about the term "reified" which doesn't seem to work, logically. "Versioned name" would work for me too. But "true name" has the two good precedents cited above. ? John From michael.hixson at gmail.com Thu Apr 28 02:19:37 2016 From: michael.hixson at gmail.com (Michael Hixson) Date: Wed, 27 Apr 2016 19:19:37 -0700 Subject: JEP 118 Parameter Names by default In-Reply-To: References: Message-ID: I found this old email reply to someone who asked a similar question. Maybe the same reasoning still applies: http://mail.openjdk.java.net/pipermail/enhanced-metadata-spec-discuss/2013-May/000201.html -Michael On Wed, Apr 27, 2016 at 1:18 PM, Steven Schlansker wrote: > Hi core-libs-dev, > > Apologies in advance if this is the wrong list, I was torn between this > one and compiler-dev, but I'm already subscribed here so we'll try this first :) > > I am trying to understand why the javac '-parameters' option is not enabled by > default. > > Normally it would not be too onerous, but due to some limitations in e.g. Maven > it is surprisingly difficult to configure correctly in a world where you must > build code that both targets e.g. 1.8 and 1.7 (and soon 1.9): > http://mail-archives.apache.org/mod_mbox/maven-dev/201604.mbox/browser > > While I am happy to work with the Maven project to improve their support > for sending compiler arguments more flexibly, I did wonder -- why is > this feature not on by default? > > I did some brief searching and was unable to come up with any downside, > but maybe I missed something obvious? Can we turn it on by default for Java 9? > > Thanks for humoring me, > Steven > > From stuart.marks at oracle.com Thu Apr 28 02:49:43 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Wed, 27 Apr 2016 19:49:43 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <57207AD8.6000204@javaspecialists.eu> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> Message-ID: On 4/27/16 1:39 AM, Dr Heinz M. Kabutz wrote: > thanks for these excellent examples of where Optional.get() is being used > incorrectly in the JDK. I would like to publish a Java Specialists' > Newsletter about this topic and hopefully educate at least a part of the Java > proletariat on how to do it correctly. To my embarassment, this is the first > time that I've /seen/ Optional.ifPresent(), so I include myself amongst the > proles. I think it was just too close to Optional.isPresent() and I just > overlooked it. However, the longer, clumsier name would not IMHO make any > difference. I would rather ask the IDE vendors to build in autofix mechanisms > to transform the code in these examples to what it should look like. You're welcome. I'm also a bit embarrassed at finding this code in the JDK. I guess we need to do some more internal education. On the name, I'd be happy to find a less clumsy name that conveys the programmer's assertion that a value is always present. I also think it's reasonable, independently of any deprecation/renaming, for IDE vendors to add rule checkers that attempt to detect unsafe uses of Optional. I'm a bit skeptical of whether it's possible for there to be automatic fixes, but detection would be a good step forward. > Now a code style question. Let's say that I get back an Optional > and I currently do the following with it: > > Optional prime = ... > if (prime.isPresent()) { > System.out.println("Prime is " + prime.get()); > } else { > System.out.println("Prime not found"); > } Assuming the Optional came from a method called findPrime(), I'd rewrite this code as follows: System.out.println(findPrime().map(p -> "Prime is " + p) .orElse("Prime not found")); > Is there a better way of doing this? We'd almost need a > ifPresentElse(Consumer consumer, Runnable action) method I guess. Close. In JDK 9 we added ifPresentOrElse(Consumer action, Runnable emptyAction) This is useful if you really need to perform separate actions in the different cases, instead of just substituting or transforming values. > Now, another question, do I have your permission to reference the examples of > incorrect usage below and quote you on how it should be done in my newsletter? Sure, I'd love to see your writeup on this. This is all open source and open email logs, so there aren't any secrets here. There are a couple caveats though: 1) There are places in the JDK code where special conditions apply. For example, early in startup, we avoid using lambdas because it drags in all the lambda support code prematurely. In such cases my suggested changes wouldn't be appropriate. I think this kind of issue doesn't apply to most applications and libraries, though. 2) I don't claim to have the final word on the "right" way to use Optional. It is, unfortunately, all too easy to find examples of poor usage of Optional.get(). I've suggested some fixes that I like, but others might prefer different approaches that are equally valid. s'marks From iris.clark at oracle.com Thu Apr 28 04:34:11 2016 From: iris.clark at oracle.com (Iris Clark) Date: Wed, 27 Apr 2016 21:34:11 -0700 (PDT) Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: Message-ID: Hi, Volker. Sorry for the delay. > Ping - shouldn't we fix this issue before JDK 9 Feature Complete? Ideally, yes. I am hoping to get this resolved in the next few weeks. My first priority for Verona is JDK-8144062 which moves jdk.Version into a standard API (Alan mentioned this bugid earlier in this thread). That absolutely must be completed before Feature Complete next month. Thanks, iris -----Original Message----- From: Volker Simonis [mailto:volker.simonis at gmail.com] Sent: Wednesday, April 27, 2016 1:28 AM To: Iris Clark Cc: Java Core Libs; verona-dev at openjdk.java.net; Alex Buckley; Kumar Srinivasan; Marvin Ma Subject: Re: RFR(XXS): 8149519: Investigate implementation of java.specification.version Ping - shouldn't we fix this issue before JDK 9 Feature Complete? Could you please also comment on my remarks regarding the relation of java.lang.Package.getSpecificationVersion() to JEP and 223 and and my question why the Version class is not in a standard java package. Thank you and best regards, Volker On Thu, Apr 7, 2016 at 12:11 PM, Volker Simonis wrote: > On Wed, Apr 6, 2016 at 8:28 PM, Iris Clark wrote: >> Hi, Volker. >> >> Sorry for the delay. I agree that the old implementation isn't quite correct. I can't see us potentially having a JCP MR for a security or patch release (9.0.0.X and 9.0.X respectively). >> >> I could see a MR for an very unusual minor release (9.X). If we had an MR there's no guarantee that we'd need to change the java.specification.version system property. However, in the event that we did need to change the java.specification.version, it should match that release's $MAJOR.$MINOR, even if it meant that we had a sequence of specification version numbers with gaps. >> >> As an example, let's say that JDK 9 is released via umbrella JSR with java.specification.value of "9". The system property would remain at "9" for all releases regardless of type until we choose to have a MR. Should that MR occur while we're working on minor release 9.3.X and there is a need to change the value of java.specification.value, it would become "9.3" and would remain so in every release until the next MR. >> >> While we haven't changed the system property recently, I think that we need to future-proof ourselves a little bit for MRs as described above. >> >> Assuming that we change the syntax of java.specification.version to >> $MAJOR.$MINOR (zeros truncated, value dependent on JCP) then we need >> to make a similar change to the syntax of >> java.vm.specification.version. [ Note that in the current >> implementation, I believe that the values of >> java.specification.version and java.vm.specification.version are tied >> to each other. ] >> >> Changing the syntax of java{.vm}?specification.version requires a CCC which I will file once we have agreement on the necessary changes. >> > > Hi Iris, > > thanks for your comments. I don't think that using $MAJOR.$MINOR for > java.specification.version is a good solution. As far as I understand, > JEP 223 (i.e. the new version scheme) is an Oracle/OpenJDK > implementation detail. There is no JSR for this and it won't be > enforced trough a JCK/TCK test (please correct me if I'm wrong). The > new versioning schema references the JCP in that is says that the > $MAJOR number corresponds to the "Java SE Platform Specification" > number as specified by the JCP in the corresponding JSR. But not vice > versa - i.e. there's no JSR referencing JEP 223. > > JEP 223 also says that the $MINOR number will be increased if this is > mandated by a Maintenance Release of the relevant Platform > Specification (by the JCP). But as you correctly noticed, in reality, > $MINOR is expected to be increased frequently compared to the number > of Java SE Maintenance Releases (if there will be any at all). So if > the JCP should decide to publish a Maintenance Release, why should it > name if after the then actual $MINOR update release number of the > Oracle/OpenJDK. I think a natural choice for such a MR would be "9.1", > no difference at which update release version Oracle/OpenJDK will be > at that time. > > So I think it would be best to decouple java.specification.version > from the Java versioning schema. We can start with > java.specification.version == $MAJOR. If there should be a MR > sometimes in the future, we can just set java.specification.version to > the version number of that MR, whatever that will be. That's exactly > what this change is about. > > Regarding the value of java.vm.specification.version I'm not sure what > it actually means at all. Until Java 1.6, > java.vm.specification.version has always been "1.0", while > java.specification.version has changed from 1.4, to 1.5 and 1.6 > (notice that java.specification.version has never been changed to > 1.4.2, it was 1.4 for Java 1.4.0 as well as for 1.4.2). Starting with > Java 7, java.vm.specification.version is the same like > java.specification.version (i.e. 1.7 and 1.8) but I'm not sure if that > is mandated by JCP and if it will be possible that these numbers will > diverge for a Java release. I.e. will it be possible to have a new > Java version (say Java 10) where the VM specification (and thus > java.vm.specification.version) will remain unchanged (say "9")? From > my understanding, that should be possible. Especially for a MR, it > seems highly probable to me that the java.specification.version will > be increased, but the VM specification (and thus > java.vm.specification.version) will remain unchanged. > > So again, I think we shouldn't tie java.vm.specification.version to > java.specification.version and simply start with > java.vm.specification.version == $MAJOR. The current implementation > already does this correctly. While the java.specification.version > property comes from VERSION_SPECIFICATION in > common/autoconf/spec.gmk.in and it is being set in > jdk/src/java.base/share/native/libjava/System.c the > java.vm.specification.version property is set being in > hotspot/src/share/vm/runtime/arguments.cpp directly to the major Java > version number. Because of this difference, there are currently no > problems with the java.vm.specification.version property caused by the > new versioning schema. > > As a side note: while I wrote all this down, I realized that we have > java.lang.Package.getSpecificationVersion() in the class library which > returns the specification version of a specific package. But this API > is not mentioned anywhere in JEP 223. Shouldn't the output of > java.lang.Package.getSpecificationVersion() be aligned with JEP 223 > and java.vm.specification.version as well? > > And a final question. Why did we put jdk.Version into the jdk package? > As far as I know, jdk is not a standard Java package and thus not > enforced by the Java standard (please correct me if I'm wrong). > Shouldn't the Version class be in a standard Java package such that > it's implementation will be mandatory for all Java implementations? > > Regards, > Volker > >> Regards, >> Iris >> >> -----Original Message----- >> From: Volker Simonis [mailto:volker.simonis at gmail.com] >> Sent: Tuesday, April 05, 2016 10:26 AM >> To: Java Core Libs >> Cc: verona-dev at openjdk.java.net >> Subject: Re: RFR(XXS): 8149519: Investigate implementation of >> java.specification.version >> >> Hi, >> >> can somebody please review this trivial change? >> >> Regards, >> Volker >> >> >> On Mon, Apr 4, 2016 at 6:47 PM, Volker Simonis wrote: >>> Hi, >>> >>> can I please have a review for this small fix: >>> >>> http://cr.openjdk.java.net/~simonis/webrevs/2016/8149519 >>> https://bugs.openjdk.java.net/browse/JDK-8149519 >>> >>> Currently the value of the java.specification.version property comes >>> from VERSION_SPECIFICATION in common/autoconf/spec.gmk.in. It is >>> currently set to VERSION_NUMBER which is the same value which is >>> also used for the java.version property. >>> >>> This is a bad idea, because VERSION_NUMBER is a dot separated >>> sequence of numbers (e.g. 9.0.1) which is expected to change frequently (i.e. >>> for every build and/or update version). If we are configuring with >>> "--with-version-patch=1" for example, VERSION_NUMBER and >>> java.version will be "9.0.0.1". But it makes no sense that >>> VERSION_SPECIFICATION and java.specification.version have the same, >>> dotted value. And it breaks a lot of legacy applications which parse >>> java.specification.version as a float number. That code would still >>> work if java.specification.version would be a concrete number (e.g. >>> '9' or '10'). >>> >>> I suggest to set VERSION_SPECIFICATION to VERSION_MAJOR in >>> common/autoconf/spec.gmk.in. This should be the "right value" until >>> we get a specification change during a major release which hasn't >>> happened for quite some time now. >>> >>> Regards, >>> Volker From amaembo at gmail.com Thu Apr 28 07:37:10 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Thu, 28 Apr 2016 13:37:10 +0600 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() Message-ID: <1733186081.20160428133710@gmail.com> Hello! Please review and sponsor the following patch: https://bugs.openjdk.java.net/browse/JDK-8155600 http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r1/ It appears that custom implementation of Arrays.asList().iterator() is noticeably more performant than the AbstractList implementation used currently. Here's JMH test which illustrates this: http://cr.openjdk.java.net/~tvaleev/webrev/8155600/jmh/ @Benchmark public int sumList() { return sum(list); } @Benchmark public int sumArray() { return sum(Arrays.asList(arr)); } public static int sum(Iterable data) { int sum = 0; for (int item : data) sum+=item; return sum; } Here's summary result on my Intel x64 machine: JDK 9ea+115: Benchmark (limit) Mode Cnt Score Error Units ArrayTest.sumArray 0 avgt 50 6,371 ? 0,009 ns/op ArrayTest.sumArray 1 avgt 50 8,020 ? 0,100 ns/op ArrayTest.sumArray 10 avgt 50 14,424 ? 0,060 ns/op ArrayTest.sumArray 100 avgt 50 88,684 ? 3,261 ns/op ArrayTest.sumArray 1000 avgt 50 677,048 ? 1,050 ns/op ArrayTest.sumArray 10000 avgt 50 8038,224 ? 59,678 ns/op ArrayTest.sumList 0 avgt 50 3,395 ? 0,003 ns/op ArrayTest.sumList 1 avgt 50 5,613 ? 0,061 ns/op ArrayTest.sumList 10 avgt 50 13,448 ? 0,076 ns/op ArrayTest.sumList 100 avgt 50 97,242 ? 0,105 ns/op ArrayTest.sumList 1000 avgt 50 664,342 ? 0,704 ns/op ArrayTest.sumList 10000 avgt 50 7971,230 ? 61,344 ns/op JDK 9ea+115 patched: Benchmark (limit) Mode Cnt Score Error Units ArrayTest.sumArray 0 avgt 50 2,932 ? 0,011 ns/op ArrayTest.sumArray 1 avgt 50 5,000 ? 0,062 ns/op ArrayTest.sumArray 10 avgt 50 9,421 ? 0,219 ns/op ArrayTest.sumArray 100 avgt 50 43,848 ? 0,187 ns/op ArrayTest.sumArray 1000 avgt 50 383,619 ? 1,019 ns/op ArrayTest.sumArray 10000 avgt 50 6860,087 ? 13,022 ns/op ArrayTest.sumList 0 avgt 50 3,400 ? 0,008 ns/op ArrayTest.sumList 1 avgt 50 6,142 ? 0,047 ns/op ArrayTest.sumList 10 avgt 50 12,488 ? 0,084 ns/op ArrayTest.sumList 100 avgt 50 83,029 ? 0,078 ns/op ArrayTest.sumList 1000 avgt 50 605,651 ? 0,992 ns/op ArrayTest.sumList 10000 avgt 50 7649,681 ? 16,355 ns/op AbstractList.iterator() makes unnecessary bookkeeping like modCount tracking which reduces the performance. Also it seems that having implicit this$0 field in AbstractList.iterator() makes impossible to avoid allocation of short-lived Arrays.ArrayList object in sumArray() test. Launching JMH -prof gc confirms that non-patched sumArray() test allocates 24 bytes per invocation while patched sumArray() does not allocate anything. What do you think? Is it reasonable change? Should I check some tests or add new ones for this optimization? With best regards, Tagir Valeev. From Alan.Bateman at oracle.com Thu Apr 28 08:11:24 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 28 Apr 2016 09:11:24 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> Message-ID: <5721C5AC.6010707@oracle.com> On 27/04/2016 22:58, Steve Drach wrote: > Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 > > Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev/ > > This changeset causes the URL returned from a ClassLoader.getResource(name) invocation to be reified, that is the URL is a direct pointer to either a versioned or unversioned entry in the jar file. The patch also assures that jar URL?s are always processed by the URLClassPath.JarLoader. The MultiReleaseJarURLConnection test was enhanced to demonstrate that reified URLs are returned. The SimpleHttpServer test helper class was moved into it?s own file. I was happy to see John's note on diction so I assume the method will be renamed. Have you considered making it public so that tools and libraries outside of the JDK can use this? One question on URLClassPath getLoader as it's not immediately obvious that this is needed. URLClassLoader specifies that any URL ending with "/" is assumed to be a directory. Are you planning to update java.net.JarURLConnection as that has special handling for #runtime that will need to be replaced. -Alan From frank.yuan at oracle.com Thu Apr 28 08:11:46 2016 From: frank.yuan at oracle.com (Frank Yuan) Date: Thu, 28 Apr 2016 16:11:46 +0800 Subject: RFR: 8155600: jaxp.library.TestPolicy should extend the default security policy Message-ID: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> Hi Mandy, Joe and all Would you like to review the fix for bug https://bugs.openjdk.java.net/browse/JDK-8155514? The webrev is at: http://cr.openjdk.java.net/~fyuan/8155514/webrev.00/. It's verified with the source bundle in http://scaaa637.us.oracle.com/archive/2016/04/2016-04-26-045641.mlchung.jdk9-deprivilege Thanks, Frank From chris.hegarty at oracle.com Thu Apr 28 08:17:37 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 28 Apr 2016 09:17:37 +0100 Subject: RFR [9] 8155578: OpenJDK build failed after JDK-8044773 Message-ID: <6CC58124-16DF-40E9-A685-0B7435793EE8@oracle.com> This is a review for a trivial, but build-fatal, addition of a qualified export to the jdk.net module, that was mistakenly omitted from the changes for 8044773. $ hg diff -U 11 diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -158,22 +158,23 @@ exports jdk.internal.misc to java.corba, java.desktop, java.logging, java.management, java.naming, java.rmi, java.security.jgss, java.sql, java.xml, jdk.charsets, + jdk.net, jdk.scripting.nashorn, jdk.unsupported, jdk.vm.ci; exports jdk.internal.perf to java.desktop, java.management, jdk.jvmstat; exports jdk.internal.ref to java.desktop; exports jdk.internal.reflect to java.corba, -Chris. From Alan.Bateman at oracle.com Thu Apr 28 08:20:40 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 28 Apr 2016 09:20:40 +0100 Subject: RFR [9] 8155578: OpenJDK build failed after JDK-8044773 In-Reply-To: <6CC58124-16DF-40E9-A685-0B7435793EE8@oracle.com> References: <6CC58124-16DF-40E9-A685-0B7435793EE8@oracle.com> Message-ID: <5721C7D8.7040801@oracle.com> On 28/04/2016 09:17, Chris Hegarty wrote: > This is a review for a trivial, but build-fatal, addition of a qualified export > to the jdk.net module, that was mistakenly omitted from the changes > for 8044773. > > This looks fine. From peter.levart at gmail.com Thu Apr 28 08:29:47 2016 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 28 Apr 2016 10:29:47 +0200 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <1733186081.20160428133710@gmail.com> References: <1733186081.20160428133710@gmail.com> Message-ID: Hi Tagir, I think this is a nice optimization. I like the part that allows EA to optimize-away the Arrays.ArrayList allocation when used in foreach loop. Regards, Peter On 04/28/2016 09:37 AM, Tagir F. Valeev wrote: > Hello! > > Please review and sponsor the following patch: > https://bugs.openjdk.java.net/browse/JDK-8155600 > http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r1/ > > It appears that custom implementation of Arrays.asList().iterator() is > noticeably more performant than the AbstractList implementation used > currently. Here's JMH test which illustrates this: > > http://cr.openjdk.java.net/~tvaleev/webrev/8155600/jmh/ > > @Benchmark > public int sumList() { > return sum(list); > } > > @Benchmark > public int sumArray() { > return sum(Arrays.asList(arr)); > } > > public static int sum(Iterable data) { > int sum = 0; > for (int item : data) sum+=item; > return sum; > } > > Here's summary result on my Intel x64 machine: > > JDK 9ea+115: > Benchmark (limit) Mode Cnt Score Error Units > ArrayTest.sumArray 0 avgt 50 6,371 ? 0,009 ns/op > ArrayTest.sumArray 1 avgt 50 8,020 ? 0,100 ns/op > ArrayTest.sumArray 10 avgt 50 14,424 ? 0,060 ns/op > ArrayTest.sumArray 100 avgt 50 88,684 ? 3,261 ns/op > ArrayTest.sumArray 1000 avgt 50 677,048 ? 1,050 ns/op > ArrayTest.sumArray 10000 avgt 50 8038,224 ? 59,678 ns/op > ArrayTest.sumList 0 avgt 50 3,395 ? 0,003 ns/op > ArrayTest.sumList 1 avgt 50 5,613 ? 0,061 ns/op > ArrayTest.sumList 10 avgt 50 13,448 ? 0,076 ns/op > ArrayTest.sumList 100 avgt 50 97,242 ? 0,105 ns/op > ArrayTest.sumList 1000 avgt 50 664,342 ? 0,704 ns/op > ArrayTest.sumList 10000 avgt 50 7971,230 ? 61,344 ns/op > > JDK 9ea+115 patched: > Benchmark (limit) Mode Cnt Score Error Units > ArrayTest.sumArray 0 avgt 50 2,932 ? 0,011 ns/op > ArrayTest.sumArray 1 avgt 50 5,000 ? 0,062 ns/op > ArrayTest.sumArray 10 avgt 50 9,421 ? 0,219 ns/op > ArrayTest.sumArray 100 avgt 50 43,848 ? 0,187 ns/op > ArrayTest.sumArray 1000 avgt 50 383,619 ? 1,019 ns/op > ArrayTest.sumArray 10000 avgt 50 6860,087 ? 13,022 ns/op > ArrayTest.sumList 0 avgt 50 3,400 ? 0,008 ns/op > ArrayTest.sumList 1 avgt 50 6,142 ? 0,047 ns/op > ArrayTest.sumList 10 avgt 50 12,488 ? 0,084 ns/op > ArrayTest.sumList 100 avgt 50 83,029 ? 0,078 ns/op > ArrayTest.sumList 1000 avgt 50 605,651 ? 0,992 ns/op > ArrayTest.sumList 10000 avgt 50 7649,681 ? 16,355 ns/op > > AbstractList.iterator() makes unnecessary bookkeeping like modCount > tracking which reduces the performance. Also it seems that having > implicit this$0 field in AbstractList.iterator() makes impossible to > avoid allocation of short-lived Arrays.ArrayList object in sumArray() > test. Launching JMH -prof gc confirms that non-patched sumArray() test > allocates 24 bytes per invocation while patched sumArray() does not > allocate anything. > > What do you think? Is it reasonable change? Should I check some tests > or add new ones for this optimization? > > With best regards, > Tagir Valeev. > From victor2 at ukr.net Thu Apr 28 09:26:17 2016 From: victor2 at ukr.net (Victor Polischuk) Date: Thu, 28 Apr 2016 12:26:17 +0300 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> Message-ID: <1461835180.388878317.8g41wld0@frv39.fwdcdn.com> I am sorry if my comment would be inappropriate, but is there a reason not to introduce "Optional ifAbsent(Runnable emptyAction)" and change signature of ifPresent to "Optional ifPresent(Consumer consumer)"? In that case method chaining would be more natural and it will give a decent way to have more than one simple action assigned to Optional without creating messy java block. --- Original message --- From: "Stuart Marks" Date: 28 April 2016, 05:50:45 > > Is there a better way of doing this? We'd almost need a > > ifPresentElse(Consumer consumer, Runnable action) method I guess. > Close. In JDK 9 we added > > ifPresentOrElse(Consumer action, Runnable emptyAction) > > s'marks From chris.hegarty at oracle.com Thu Apr 28 10:55:45 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Thu, 28 Apr 2016 11:55:45 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5721C5AC.6010707@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <5721C5AC.6010707@oracle.com> Message-ID: <90D204F3-E067-4491-9C5D-02BAAE105646@oracle.com> On 28 Apr 2016, at 09:11, Alan Bateman wrote: > > On 27/04/2016 22:58, Steve Drach wrote: >> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 >> >> Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev/ >> >> This changeset causes the URL returned from a ClassLoader.getResource(name) invocation to be reified, that is the URL is a direct pointer to either a versioned or unversioned entry in the jar file. The patch also assures that jar URL?s are always processed by the URLClassPath.JarLoader. The MultiReleaseJarURLConnection test was enhanced to demonstrate that reified URLs are returned. The SimpleHttpServer test helper class was moved into it?s own file. > I was happy to see John's note on diction so I assume the method will be renamed. Have you considered making it public so that tools and libraries outside of the JDK can use this? It sounds reasonable for this to be a public API, and if so, does it make sense to move it to JarEntry ( rather than JarFile )? So it would be JarEntry::getTrueName, or similar. -Chris. From baiduzhyi.devel at gmail.com Thu Apr 28 11:05:51 2016 From: baiduzhyi.devel at gmail.com (Stanislav Baiduzhyi) Date: Thu, 28 Apr 2016 13:05:51 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> Message-ID: Stuart, Those examples are amazing. Would it be possible to expand Optional class javadoc with some of those examples? First, second, and the last one are the most descriptive in my opinion. I frowned at Optional for so long, you just showed me that I was not using it properly. On 26 April 2016 at 08:06, Stuart Marks wrote: > > > On 4/25/16 5:46 PM, Vitaly Davidovich wrote: >> >> We've introduced Optional to avoid this. The problem is that the >> obvious >> thing to do is to get() the value out of the Optional, but this buys >> us >> right back into the what-if-the-value-is-missing case that we had with >> nulls. >> >> Why is this the "obvious" thing? Because a few stackoverflow threads went >> like >> that? > > > Well, the Stack Overflow exchange was a caricature. But without looking too > hard, I found this code: [2] > > return stringList.stream().filter(...).findFirst().get() != null; > > [2] http://stackoverflow.com/q/36346409/1441122 > > The person, presumably new to Java 8, was able to determine that findFirst() > returned an Optional instead of the desired value, and was able to figure > out enough to call get(), and even thought enough about the possibly-absent > case to check it against null. But the person had to ask on Stack Overflow > about how to solve the problem. > > Now I obviously don't know the exact thought process that went on, but get() > has among the shortest of name of the Optional methods, and has no > arguments, so it seems like it ought to be called more more frequently > compared to more specialized methods like ifPresentOrElse() or > orElseThrow(). > > There are other items on Stack Overflow such as these: [3] [4]. But these > probably aren't what you're looking for. :-) > > [3] http://stackoverflow.com/a/26328555/1441122 > > [4] http://stackoverflow.com/a/23464794/1441122 > > >> It's not clear it returns an Optional - it could be returning some other >> type >> that happens to have a getWhenPresent. What would be clear it's an >> Optional is >> to have a local of that type and assign find(pk) to it. > > > Of course there's always a possibility that there's some other API that has > getWhenPresent() on it. There isn't one in the JDK, and I've been unable to > find one elsewhere. So "getWhenPresent" should be different enough to > trigger a different thought pattern, as opposed to a plain "get" which fades > into the background. > > The Optional API was designed to be chained, so you don't want to pull it > into a local variable. > >> Descriptive names are good, but like Jon, I'm not buying this change. Is >> it >> really wrong to tell people to read the javadoc? And is that worth the >> deprecation churn? It's going to be needlessly verbose (esp in existing >> code >> that already checked isPresent) for no strong benefit. If someone is >> mindlessly >> having their IDE write code for them, this isn't going to prevent poor >> code. >> For code review purposes, if it's important to call out that something is >> Optional then use the type somewhere explicitly. > > > Personally I'm generally skeptical of simple name changes, but after having > gone through a bunch of examples of the use of get(), my skepticism melted > away. It really does seem to be misused a significant fraction of the time, > possibly even a majority of the time. > > Beginners and Java 8 learners will probably fall into the trap of forgetting > to check. But JDK programmers, who are decidedly not beginners, are writing > code that uses get() unnecessarily: > > ======================================== > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java.sdiff.html > > 206 if (source.isPresent()) { > 207 executor.runTask(source.get(), deque); > 208 } > > could be rewritten as > > source.ifPresent(archive -> executor.runTask(archive, deque)); > > ======================================== > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java.sdiff.html > > 476 Optional req = options.requires.stream() > 477 .filter(mn -> !modules.containsKey(mn)) > 478 .findFirst(); > 479 if (req.isPresent()) { > 480 throw new BadArgs("err.module.not.found", req.get()); > 481 } > > could be rewritten as > > options.requires.stream() > .filter(mn -> !modules.containsKey(mn)) > .findFirst() > .ifPresent(s -> throw new BadArgs("err.module.not.found", > s)); > > ======================================== > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java.sdiff.html > > 1203 String hist = replayableHistory > 1204 .subList(first + 1, replayableHistory.size()) > 1205 .stream() > 1206 .reduce( (a, b) -> a + RECORD_SEPARATOR + b) > 1207 .get(); > > could be rewritten as > > String hist = String.join(RECORD_SEPARATOR, > replayableHistory.subList(first + 1, replayableHistory.size())); > > (It's also not clear to me that the sublist is guaranteed to be nonempty, so > the first snippet might fail in get().) > > ======================================== > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.base/share/classes/java/lang/module/Resolver.java.sdiff.html > > 100 if (mref.location().isPresent()) > 101 trace(" (%s)", mref.location().get()); > > could be rewritten as > > mref.location().ifPresent(loc -> trace(" (%s)", loc); > > ======================================== > > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/java.base/share/classes/java/lang/reflect/Layer.java.sdiff.html > > 364 Optional oparent = cf.parent(); > 365 if (!oparent.isPresent() || oparent.get() != > this.configuration()) { > 366 throw new IllegalArgumentException( > 367 "Parent of configuration != configuration of this > Layer"); > > could be rewritten as > > cf.parent() > .filter(cfg -> cfg == this.configuration()) > .orElseThrow(() -> throw new IllegalArgumentException( > "Parent of configuration != configuration of this Layer")); > > ======================================== > > If you go to grepcode.com, find the source for Optional.get() -- I used > 8u40-b25 -- and then click the little arrow next to get(), you can find a > bunch of uses of Optional.get(). A startlingly large fraction of them can be > simplified in a similar manner to the JDK examples I showed above, bypassing > the need to call get(). (I did a quick check of the first ten examples, and > I think about seven could be improved, depending on how you count.) > > It really does look to me like get() is a bad API. It's not people > "mindlessly" having their IDE write code. The problem is that get() is > deceptively attractive. Even people remember to check it, they put the > checking around the get(), instead of looking at Optional's other methods. > This is what results in the needlessly verbose code. > > A minority of the cases are justified in using get(). If this is renamed to > getWhenPresent(), it becomes slightly more verbose, but it also specifically > states that the programmer is making an assertion about the presence of a > value -- a worthwhile improvement. > > Is it worth the churn? Well, the problem is only going to get worse. I > believe that if we don't deprecate get() now, a few years down the road, the > problem will be so bad, we'll say "I wish we had deprecated it back in JDK 9 > when we were talking about it then." Just like right now we're saying, "I > wish we had fixed it before JDK 8 shipped." > > s'marks From nadeesh.tv at oracle.com Thu Apr 28 13:10:34 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Thu, 28 Apr 2016 18:40:34 +0530 Subject: RFR:JDK-8079628:java.time: DateTimeFormatter containing "DD" fails on 3-digit day-of-year value In-Reply-To: References: <571F558F.9090008@oracle.com> Message-ID: <57220BCA.5000608@oracle.com> Hi all, Thanks Stephen for the comments. Please see the updated webrev http://cr.openjdk.java.net/~ntv/8079628/webrev.01/ Regards, Nadeesh TV On 4/26/2016 5:42 PM, Stephen Colebourne wrote: > This change introduces inconsistencies and problems. For example, it > will parse up to 19 digits for "D" but only up to 2 digits for "d". > The following would be better: > > * D 1 appendValue(ChronoField.DAY_OF_YEAR) > * DD 2 appendValue(ChronoField.DAY_OF_YEAR, 2, 3, > SignStyle.NORMAL) > * DDD 3 appendValue(ChronoField.DAY_OF_YEAR, 3) > > This limits the accepted input to 3 digits, which is quite sufficient > here. It is also clearer for the common "D" and "DDD" cases. > > Note that a test case needs to cover adjacent value parsing for > day-of-year. This pattern "yyyyDDD" should be tested and work. With > the webrev changes, it will not work as adjacent value parsing mode > will not be triggered. > > (The change will alter the meaning of "yyyyDD" but no-one should be > using that anyway as it is broken, only working for the first 99 days > of the year.) > > The code in TCKDateTimeFormatterBuilder needs a blank line after the > new methods. > > Stephen > > > On 26 April 2016 at 12:48, nadeesh tv wrote: >> Hi all, >> >> Please review a fix for >> >> Bug ID - https://bugs.openjdk.java.net/browse/JDK-8079628 >> >> Issue - Pattern 'D' is not implemented as intended by CLDR >> >> Solution - Changed the definition of 'D' to D..D 1..3 >> appendValue(ChronoField.DAY_OF_YEAR, n, 19, SignStyle.NORMAL) >> >> Webrev - http://cr.openjdk.java.net/~ntv/8079628/webrev.00/ >> >> -- >> Thanks and Regards, >> Nadeesh TV >> -- Thanks and Regards, Nadeesh TV From nadeesh.tv at oracle.com Thu Apr 28 13:12:50 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Thu, 28 Apr 2016 18:42:50 +0530 Subject: RFR:JDK-8148949:DateTimeFormatter pattern letters 'A','n','N' In-Reply-To: <571E2C01.6050407@oracle.com> References: <571E2C01.6050407@oracle.com> Message-ID: <57220C52.5030609@oracle.com> Hi all, Please see the updated webrev http://cr.openjdk.java.net/~ntv/8148949/webrev.01/ Regards, Nadeesh TV On 4/25/2016 8:08 PM, nadeesh tv wrote: > HI all, > Please review a fix for > Bug ID - https://bugs.openjdk.java.net/browse/JDK-8148949 > > Issue - Pattern letters 'A' does not match the intent of LDML/CLDR > > Solution - Changed the definition of pattern letters 'A','n','N' > > Webrev - http://cr.openjdk.java.net/~ntv/8148949/webrev.00/ > > -- Thanks and Regards, Nadeesh TV From aleksey.shipilev at oracle.com Thu Apr 28 13:52:56 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Thu, 28 Apr 2016 16:52:56 +0300 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <1733186081.20160428133710@gmail.com> References: <1733186081.20160428133710@gmail.com> Message-ID: <572215B8.1070709@oracle.com> On 04/28/2016 10:37 AM, Tagir F. Valeev wrote: > Hello! > > Please review and sponsor the following patch: > https://bugs.openjdk.java.net/browse/JDK-8155600 > http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r1/ I like the motivation and the patch. Nitpicks: *) Does EA break if you make ArrayItr inner class to gain the access to E[] a? *) next(): Missing braces in throw new NSEE() block; *) next(): Why loading this.a into local? > What do you think? Is it reasonable change? Should I check some tests > or add new ones for this optimization? I think Arrays.asList is frequently used in tests already. But, a quick boundary jtreg test would be nice to have, given now we have a special iterator. Thanks, -Aleksey From szegedia at gmail.com Thu Apr 28 14:08:47 2016 From: szegedia at gmail.com (Attila Szegedi) Date: Thu, 28 Apr 2016 16:08:47 +0200 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <572215B8.1070709@oracle.com> References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> Message-ID: On Thu, Apr 28, 2016 at 3:52 PM, Aleksey Shipilev < aleksey.shipilev at oracle.com> wrote: > *) next(): Missing braces in throw new NSEE() block; > *) next(): Why loading this.a into local? I agree with Aleksey but I'd go as far as to say that not only this.a is unnecessary, but i as well. The body of next() looks too elaborate. This seems equivalent and concise: if (cursor >= a.length) { throw new NoSuchElementException(); } return a[cursor++]; Attila. From peter.levart at gmail.com Thu Apr 28 14:14:02 2016 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 28 Apr 2016 16:14:02 +0200 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> Message-ID: <5d618858-a724-bf28-ed2e-da1f1d0c95ad@gmail.com> On 04/28/2016 04:08 PM, Attila Szegedi wrote: > On Thu, Apr 28, 2016 at 3:52 PM, Aleksey Shipilev < > aleksey.shipilev at oracle.com> wrote: > >> *) next(): Missing braces in throw new NSEE() block; >> *) next(): Why loading this.a into local? > > I agree with Aleksey but I'd go as far as to say that not only this.a is > unnecessary, but i as well. The body of next() looks too elaborate. This > seems equivalent and concise: > > if (cursor >= a.length) { > throw new NoSuchElementException(); > } > return a[cursor++]; > > Attila. ...except that your variant can throw ArrayIndexOutOfBoundsException (if used inappropriately) and Tagir's can't. (this.a is final and doesn't need to be loaded into local). Regards, Peter From scolebourne at joda.org Thu Apr 28 14:28:09 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Thu, 28 Apr 2016 15:28:09 +0100 Subject: RFR:JDK-8148949:DateTimeFormatter pattern letters 'A','n','N' In-Reply-To: <57220C52.5030609@oracle.com> References: <571E2C01.6050407@oracle.com> <57220C52.5030609@oracle.com> Message-ID: I'd like to see the test cases in test_secondsPattern() check the result of the parse (by passing more arguments from data_secondsPattern) Otherwise looks good. Stephen On 28 April 2016 at 14:12, nadeesh tv wrote: > Hi all, > Please see the updated webrev > http://cr.openjdk.java.net/~ntv/8148949/webrev.01/ > > Regards, > Nadeesh TV > > On 4/25/2016 8:08 PM, nadeesh tv wrote: >> >> HI all, >> Please review a fix for >> Bug ID - https://bugs.openjdk.java.net/browse/JDK-8148949 >> >> Issue - Pattern letters 'A' does not match the intent of LDML/CLDR >> >> Solution - Changed the definition of pattern letters 'A','n','N' >> >> Webrev - http://cr.openjdk.java.net/~ntv/8148949/webrev.00/ >> >> > > -- > Thanks and Regards, > Nadeesh TV > From scolebourne at joda.org Thu Apr 28 14:47:02 2016 From: scolebourne at joda.org (Stephen Colebourne) Date: Thu, 28 Apr 2016 15:47:02 +0100 Subject: RFR:JDK-8079628:java.time: DateTimeFormatter containing "DD" fails on 3-digit day-of-year value In-Reply-To: <57220BCA.5000608@oracle.com> References: <571F558F.9090008@oracle.com> <57220BCA.5000608@oracle.com> Message-ID: My mistake on the spec for "DD". It should be SignStyle.NOT_NEGATIVE, not NORMAL. I'd like to see a test that checks adjacent value parsing works correctly for "DDD". ie. yyyyDDDHHmm should be able to parse into a LocalDateTime where the date-time value can be checked against the input string. I think this will be a good fix once complete. thanks Stephen On 28 April 2016 at 14:10, nadeesh tv wrote: > > Hi all, > > Thanks Stephen for the comments. > > Please see the updated webrev > http://cr.openjdk.java.net/~ntv/8079628/webrev.01/ > > Regards, > Nadeesh TV > > On 4/26/2016 5:42 PM, Stephen Colebourne wrote: >> >> This change introduces inconsistencies and problems. For example, it >> will parse up to 19 digits for "D" but only up to 2 digits for "d". >> The following would be better: >> >> * D 1 appendValue(ChronoField.DAY_OF_YEAR) >> * DD 2 appendValue(ChronoField.DAY_OF_YEAR, 2, 3, >> SignStyle.NORMAL) >> * DDD 3 appendValue(ChronoField.DAY_OF_YEAR, 3) >> >> This limits the accepted input to 3 digits, which is quite sufficient >> here. It is also clearer for the common "D" and "DDD" cases. >> >> Note that a test case needs to cover adjacent value parsing for >> day-of-year. This pattern "yyyyDDD" should be tested and work. With >> the webrev changes, it will not work as adjacent value parsing mode >> will not be triggered. >> >> (The change will alter the meaning of "yyyyDD" but no-one should be >> using that anyway as it is broken, only working for the first 99 days >> of the year.) >> >> The code in TCKDateTimeFormatterBuilder needs a blank line after the >> new methods. >> >> Stephen >> >> >> On 26 April 2016 at 12:48, nadeesh tv wrote: >>> >>> Hi all, >>> >>> Please review a fix for >>> >>> Bug ID - https://bugs.openjdk.java.net/browse/JDK-8079628 >>> >>> Issue - Pattern 'D' is not implemented as intended by CLDR >>> >>> Solution - Changed the definition of 'D' to D..D 1..3 >>> appendValue(ChronoField.DAY_OF_YEAR, n, 19, SignStyle.NORMAL) >>> >>> Webrev - http://cr.openjdk.java.net/~ntv/8079628/webrev.00/ >>> >>> -- >>> Thanks and Regards, >>> Nadeesh TV >>> > > -- > Thanks and Regards, > Nadeesh TV > From huizhe.wang at oracle.com Thu Apr 28 16:14:55 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Thu, 28 Apr 2016 09:14:55 -0700 Subject: RFR: 8155600: jaxp.library.TestPolicy should extend the default security policy In-Reply-To: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> References: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> Message-ID: <572236FF.8010908@oracle.com> Hi Frank, Thanks for the quick fix. The change looks good. -Joe On 4/28/2016 1:11 AM, Frank Yuan wrote: > > Hi Mandy, Joe and all > > Would you like to review the fix for bug > https://bugs.openjdk.java.net/browse/JDK-8155514? > > The webrev is at: http://cr.openjdk.java.net/~fyuan/8155514/webrev.00/ > . > > It's verified with the source bundle in > http://scaaa637.us.oracle.com/archive/2016/04/2016-04-26-045641.mlchung.jdk9-deprivilege > > > Thanks, > > Frank > From huizhe.wang at oracle.com Thu Apr 28 16:05:42 2016 From: huizhe.wang at oracle.com (huizhe wang) Date: Thu, 28 Apr 2016 09:05:42 -0700 Subject: RFR: 8155600: jaxp.library.TestPolicy should extend the default security policy In-Reply-To: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> References: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> Message-ID: <572234D6.7090508@oracle.com> Hi Frank, The change looks good. Thanks! Joe On 4/28/2016 1:11 AM, Frank Yuan wrote: > > Hi Mandy, Joe and all > > Would you like to review the fix for bug > https://bugs.openjdk.java.net/browse/JDK-8155514? > > The webrev is at: http://cr.openjdk.java.net/~fyuan/8155514/webrev.00/ > . > > It's verified with the source bundle in > http://scaaa637.us.oracle.com/archive/2016/04/2016-04-26-045641.mlchung.jdk9-deprivilege > > > Thanks, > > Frank > From paul.sandoz at oracle.com Thu Apr 28 17:37:16 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 28 Apr 2016 10:37:16 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> <865CEDEB-2977-4A40-AF1A-643F7CC67BE3@oracle.com> Message-ID: <0039A8A7-E585-409E-8745-2AD0D13F13EA@oracle.com> > On 27 Apr 2016, at 17:10, John Rose wrote: > > On Apr 27, 2016, at 4:20 PM, Paul Sandoz wrote: >> >> >>> On 27 Apr 2016, at 15:26, John Rose wrote: >>> >>> Diction Note: Reified X means X wasn't real (in some sense) until now. As in non-reified types, which are not real at runtime because the static compiler discarded them. >>> >> >> I suggested reified because i thought it fit with the notion of making something abstract more concrete, but perhaps this just confuses matters? > > It's the real name, but since it already exists (because that's how it is stored) it isn't really reified, it's just revealed. > > This API uses the term "real name" for an almost identical phenomenon (target of a sym-link in a file system): > > https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toRealPath-java.nio.file.LinkOption...- > > In a versioned jar, the logical names are sometimes mapped to other names under which the elements are actually stored. > Thus, they behave like sym-links. (But with a bit of control context thrown in, the active version.) > Yes, they behave like sym links in a virtual overlay (with a version) but there is no directly explicit information encoded in the zip file to express those links. > On old-fashioned file systems with real version numbers, the Common Lisp function TRUENAME does exactly what you are trying to do here. > > http://www.mathcs.duq.edu/simon/Gcl/gcl_1141.html > Touche, i should know better than to spar with you on language, and i know when i am beat when you play the Lisp card :-) > (And in some way, we are sliding down the slope toward re-inventing those file systems, aren't we?) > > The older pre-nio API for File calls it "getCanonicalPath", but I think "true name" is better than > "canonical name", since "canonical" means "follows the rules", rather than what we need in this case, > which is "where it really is stored". > > http://docs.oracle.com/javase/8/docs/api/java/io/File.html#getCanonicalPath-- > >> >>> In this case it appears you are simply exposing a translated name, not making it real for the first time. >>> >>> If this is true, I think you want to say "true name" or "real name" or "translated name", not "reified name?. >> >> or ?versioned name" would work for me. > > I'm just whinging about the term "reified" which doesn't seem to work, logically. > > "Versioned name" would work for me too. But "true name" has the two good precedents cited above. Agreed. Paul. From nadeesh.tv at oracle.com Thu Apr 28 18:04:18 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Thu, 28 Apr 2016 23:34:18 +0530 Subject: RFR:JDK-8079628:java.time: DateTimeFormatter containing "DD" fails on 3-digit day-of-year value In-Reply-To: References: <571F558F.9090008@oracle.com> <57220BCA.5000608@oracle.com> Message-ID: <572250A2.8030709@oracle.com> Hi all, Please see the updated webrev http://cr.openjdk.java.net/~ntv/8079628/webrev.02/ Thanks and Regards, Nadeesh TV On 4/28/2016 8:17 PM, Stephen Colebourne wrote: > My mistake on the spec for "DD". It should be SignStyle.NOT_NEGATIVE, > not NORMAL. > > I'd like to see a test that checks adjacent value parsing works > correctly for "DDD". ie. yyyyDDDHHmm should be able to parse into a > LocalDateTime where the date-time value can be checked against the > input string. > > I think this will be a good fix once complete. > thanks > Stephen > > On 28 April 2016 at 14:10, nadeesh tv wrote: >> Hi all, >> >> Thanks Stephen for the comments. >> >> Please see the updated webrev >> http://cr.openjdk.java.net/~ntv/8079628/webrev.01/ >> >> Regards, >> Nadeesh TV >> >> On 4/26/2016 5:42 PM, Stephen Colebourne wrote: >>> This change introduces inconsistencies and problems. For example, it >>> will parse up to 19 digits for "D" but only up to 2 digits for "d". >>> The following would be better: >>> >>> * D 1 appendValue(ChronoField.DAY_OF_YEAR) >>> * DD 2 appendValue(ChronoField.DAY_OF_YEAR, 2, 3, >>> SignStyle.NORMAL) >>> * DDD 3 appendValue(ChronoField.DAY_OF_YEAR, 3) >>> >>> This limits the accepted input to 3 digits, which is quite sufficient >>> here. It is also clearer for the common "D" and "DDD" cases. >>> >>> Note that a test case needs to cover adjacent value parsing for >>> day-of-year. This pattern "yyyyDDD" should be tested and work. With >>> the webrev changes, it will not work as adjacent value parsing mode >>> will not be triggered. >>> >>> (The change will alter the meaning of "yyyyDD" but no-one should be >>> using that anyway as it is broken, only working for the first 99 days >>> of the year.) >>> >>> The code in TCKDateTimeFormatterBuilder needs a blank line after the >>> new methods. >>> >>> Stephen >>> >>> >>> On 26 April 2016 at 12:48, nadeesh tv wrote: >>>> Hi all, >>>> >>>> Please review a fix for >>>> >>>> Bug ID - https://bugs.openjdk.java.net/browse/JDK-8079628 >>>> >>>> Issue - Pattern 'D' is not implemented as intended by CLDR >>>> >>>> Solution - Changed the definition of 'D' to D..D 1..3 >>>> appendValue(ChronoField.DAY_OF_YEAR, n, 19, SignStyle.NORMAL) >>>> >>>> Webrev - http://cr.openjdk.java.net/~ntv/8079628/webrev.00/ >>>> >>>> -- >>>> Thanks and Regards, >>>> Nadeesh TV >>>> >> -- >> Thanks and Regards, >> Nadeesh TV >> -- Thanks and Regards, Nadeesh TV From steve.drach at oracle.com Thu Apr 28 18:26:36 2016 From: steve.drach at oracle.com (Steve Drach) Date: Thu, 28 Apr 2016 11:26:36 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> <865CEDEB-2977-4A40-AF1A-643F7CC67BE3@oracle.com> Message-ID: <50CFC7C1-5338-440C-B53F-7BA2F067E46D@oracle.com> Keeping with the path precedent, is it acceptable to change ?getReifiedName? to ?getRealName?? >>> >>> Diction Note: Reified X means X wasn't real (in some sense) until now. As in non-reified types, which are not real at runtime because the static compiler discarded them. >>> >> >> I suggested reified because i thought it fit with the notion of making something abstract more concrete, but perhaps this just confuses matters? > > It's the real name, but since it already exists (because that's how it is stored) it isn't really reified, it's just revealed. > > This API uses the term "real name" for an almost identical phenomenon (target of a sym-link in a file system): > > https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toRealPath-java.nio.file.LinkOption...- > > In a versioned jar, the logical names are sometimes mapped to other names under which the elements are actually stored. > Thus, they behave like sym-links. (But with a bit of control context thrown in, the active version.) > > On old-fashioned file systems with real version numbers, the Common Lisp function TRUENAME does exactly what you are trying to do here. > > http://www.mathcs.duq.edu/simon/Gcl/gcl_1141.html > > (And in some way, we are sliding down the slope toward re-inventing those file systems, aren't we?) > > The older pre-nio API for File calls it "getCanonicalPath", but I think "true name" is better than > "canonical name", since "canonical" means "follows the rules", rather than what we need in this case, > which is "where it really is stored". > > http://docs.oracle.com/javase/8/docs/api/java/io/File.html#getCanonicalPath-- > >> >>> In this case it appears you are simply exposing a translated name, not making it real for the first time. >>> >>> If this is true, I think you want to say "true name" or "real name" or "translated name", not "reified name?. >> >> or ?versioned name" would work for me. > > I'm just whinging about the term "reified" which doesn't seem to work, logically. > > "Versioned name" would work for me too. But "true name" has the two good precedents cited above. > > ? John From brent.christian at oracle.com Thu Apr 28 18:37:14 2016 From: brent.christian at oracle.com (Brent Christian) Date: Thu, 28 Apr 2016 11:37:14 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: <66A0640B-408C-4276-BB79-CCFDEFFDC24B@oracle.com> References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <66A0640B-408C-4276-BB79-CCFDEFFDC24B@oracle.com> Message-ID: <5722585A.4060408@oracle.com> Hi, Mandy It looks good to me. A few minor things: StackFrameInfo.java: Should getByteCodeIndex() be final ? StackWalker.java, line 136: * change ';' to ',' JavaLangInvokeAccess.java, line 40: For the isNative() docs, I would prefer "Returns true if..." to "Tests if..." Some test code for getByteCodeIndex() would be good - sounds like you plan to add that. Thanks, -Brent On 04/27/2016 11:31 AM, Mandy Chung wrote: > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.01/index.html > > I added a new StackFrame::getByteCodeIndex method to return bci and updatedgetFileName and getLineNumber to have the same returned type as in StackTraceElement. From usage perspective, the caller has to prepare and handle the information is unavailable and I think it would typically log some token to represent the unavailable case and might well use null and negative value. This patch would save the creation of short-lived Optional object that might help logging filename/linenumber case. > > I?m working on a new test to verify bci and line number to be included in the next revision. > > Mandy > >> On Apr 11, 2016, at 2:22 PM, Mandy Chung wrote: >> >> Webrev at: >> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >> >> StackFrame::getFileName and StackFrame::getLineNumber are originally proposed with the view of any stack walking code can migrate to the StackWalker API without the use of StackTraceElement. >> >> File name and line number are useful for debugging and troubleshooting purpose. It has additional overhead to map from a method and BCI to look up the file name and line number. >> >> StackFrame::toStackTraceElement method returns StackTraceElement that includes the file name and line number. There is no particular benefit to duplicate getFileName and getLineNumber methods in StackFrame. It is equivalently convenient to call StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >> >> This patch proposes to remove StackFrame::getFileName and StackFrame::getLineNumber methods since such information can be obtained from StackFrame.toStackTraceElement(). >> >> Mandy > From steve.drach at oracle.com Thu Apr 28 18:53:36 2016 From: steve.drach at oracle.com (Steve Drach) Date: Thu, 28 Apr 2016 11:53:36 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5721C5AC.6010707@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <5721C5AC.6010707@oracle.com> Message-ID: >> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 >> >> Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev/ >> >> This changeset causes the URL returned from a ClassLoader.getResource(name) invocation to be reified, that is the URL is a direct pointer to either a versioned or unversioned entry in the jar file. The patch also assures that jar URL?s are always processed by the URLClassPath.JarLoader. The MultiReleaseJarURLConnection test was enhanced to demonstrate that reified URLs are returned. The SimpleHttpServer test helper class was moved into it?s own file. > I was happy to see John's note on diction so I assume the method will be renamed. Have you considered making it public so that tools and libraries outside of the JDK can use this? I opened an issue to track this ? JDK-8155657. We?d like to get this changeset, including the name change for getReifieidName, integrated as soon as we can. > > One question on URLClassPath getLoader as it's not immediately obvious that this is needed. URLClassLoader specifies that any URL ending with "/" is assumed to be a directory. Yes, and for regular jar files, that worked fine, but when we tried it with a multi-release jar we found it by passed the part of JarLoader where we open the jar file as a runtime jar, so, for example, this code fails to retrieve the correct versioned entry, returning instead the base entry. URL[] urls = { new URL(?jar:file:/foo/multi-release.jar!/?) }; URLClassLoader cldr = new URLClassLoader(urls); Class vcls = cldr.loadClass("version.Version?); The change just corrects the logic when working with a ?jar:?..!/? URL. > Are you planning to update java.net.JarURLConnection as that has special handling for #runtime that will need to be replaced. No, we are not. Appending the #runtime fragment in URLClassPath is the way we communicate to URLJarFile that the jar should be opened as a runtime versioned JarFile. All this changeset does is assure that the internal implementation details are not leaked to the outside world. > > -Alan From steve.drach at oracle.com Thu Apr 28 18:59:48 2016 From: steve.drach at oracle.com (Steve Drach) Date: Thu, 28 Apr 2016 11:59:48 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <90D204F3-E067-4491-9C5D-02BAAE105646@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <5721C5AC.6010707@oracle.com> <90D204F3-E067-4491-9C5D-02BAAE105646@oracle.com> Message-ID: >>> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 >>> >>> Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev/ >>> >>> This changeset causes the URL returned from a ClassLoader.getResource(name) invocation to be reified, that is the URL is a direct pointer to either a versioned or unversioned entry in the jar file. The patch also assures that jar URL?s are always processed by the URLClassPath.JarLoader. The MultiReleaseJarURLConnection test was enhanced to demonstrate that reified URLs are returned. The SimpleHttpServer test helper class was moved into it?s own file. >> I was happy to see John's note on diction so I assume the method will be renamed. Have you considered making it public so that tools and libraries outside of the JDK can use this? > > It sounds reasonable for this to be a public API, I opened JDK-8155657 to track that. > and if so, does it make sense to > move it to JarEntry ( rather than JarFile )? So it would be JarEntry::getTrueName, > or similar. The part of JarFile that knows all about versioning is a subclass of JarEntry, JarFileEntry. JarEntry knows nothing about versioning, nor about JarFileEntry. Only JarFile knows about JarFileEntry. From Alan.Bateman at oracle.com Thu Apr 28 19:03:17 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 28 Apr 2016 20:03:17 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <5721C5AC.6010707@oracle.com> Message-ID: <57225E75.3040303@oracle.com> On 28/04/2016 19:53, Steve Drach wrote: > : > Yes, and for regular jar files, that worked fine, but when we tried it with a multi-release jar we found it by passed the part of JarLoader where we open the jar file as a runtime jar, so, for example, this code fails to retrieve the correct versioned entry, returning instead the base entry. > > URL[] urls = { new URL(?jar:file:/foo/multi-release.jar!/?) }; > URLClassLoader cldr = new URLClassLoader(urls); > Class vcls = cldr.loadClass("version.Version?); > > The change just corrects the logic when working with a ?jar:?..!/? URL. > > Can you double check the URLClassLoader spec? Also I assume the URL you are want here is "file:/foo/multi-release.jar" as "jar:file:/foo/multi-release.jar!/" is the URL to the top-level directory in the JAR file. -Alan From jason_mehrens at hotmail.com Thu Apr 28 19:06:28 2016 From: jason_mehrens at hotmail.com (Jason Mehrens) Date: Thu, 28 Apr 2016 19:06:28 +0000 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> <571A4439.6090001@Oracle.com> <571A639B.1000606@oracle.com>, Message-ID: Hi Peter, >As mentioned, Class.newInstance() has a special cache for constructor >and caller that speeds up repeated invocations from the same caller by >skipping access checks. I'm sure I'm missing something obvious related to performance or security but, couldn't the exact same 'cachedConstructor' field be used for caching Class.getConstructor(new Class[0]) as long as a constructor copy is returned? That way the recommended workaround is near the same performance. Jason From steve.drach at oracle.com Thu Apr 28 19:20:35 2016 From: steve.drach at oracle.com (Steve Drach) Date: Thu, 28 Apr 2016 12:20:35 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <57225E75.3040303@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <5721C5AC.6010707@oracle.com> <57225E75.3040303@oracle.com> Message-ID: > On Apr 28, 2016, at 12:03 PM, Alan Bateman wrote: > > > > On 28/04/2016 19:53, Steve Drach wrote: >> : >> Yes, and for regular jar files, that worked fine, but when we tried it with a multi-release jar we found it by passed the part of JarLoader where we open the jar file as a runtime jar, so, for example, this code fails to retrieve the correct versioned entry, returning instead the base entry. >> >> URL[] urls = { new URL(?jar:file:/foo/multi-release.jar!/?) }; >> URLClassLoader cldr = new URLClassLoader(urls); >> Class vcls = cldr.loadClass("version.Version?); >> >> The change just corrects the logic when working with a ?jar:?..!/? URL. >> >> > Can you double check the URLClassLoader spec? We discussed it. It seems the spec might be deficit with respect to "jar:file:/foo/multi-release.jar!/? type URLs, but it didn?t matter when it referred to a legacy jar file. > > Also I assume the URL you are want here is "file:/foo/multi-release.jar? No, that one is correct and still works as it did before. > as "jar:file:/foo/multi-release.jar!/" is the URL to the top-level directory in the JAR file. The spec for JarURLconnections says "If the entry name is omitted, the URL refers to the whole JAR file: jar:http://www.foo.com/bar/baz.jar!/? that?s the way we are using it, as the location of a jar file. I?ve ran this through jprt with test core and found no errors/failures with this change. > > -Alan From mandy.chung at oracle.com Thu Apr 28 19:42:36 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 28 Apr 2016 12:42:36 -0700 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: <5722585A.4060408@oracle.com> References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <66A0640B-408C-4276-BB79-CCFDEFFDC24B@oracle.com> <5722585A.4060408@oracle.com> Message-ID: > On Apr 28, 2016, at 11:37 AM, Brent Christian wrote: > > Hi, Mandy > > It looks good to me. A few minor things: > > StackFrameInfo.java: > > Should getByteCodeIndex() be final ? > It?s a package-private class and so no subclass outside this package anyway. So it doesn?t really matter. I didn?t catch the inconsistency there - some methods in this class are final and some are not. I may clean them up. > > StackWalker.java, line 136: > * change ';' to ?,' > ok. > > JavaLangInvokeAccess.java, line 40: > > For the isNative() docs, I would prefer "Returns true if..." to "Tests if..." > > Both conventions are used. I can change that. > Some test code for getByteCodeIndex() would be good - sounds like you plan to add that. yes. Will send out for review next. thanks for the review. Mandy > > Thanks, > -Brent > On 04/27/2016 11:31 AM, Mandy Chung wrote: >> Updated webrev: >> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.01/index.html >> >> I added a new StackFrame::getByteCodeIndex method to return bci and updatedgetFileName and getLineNumber to have the same returned type as in StackTraceElement. From usage perspective, the caller has to prepare and handle the information is unavailable and I think it would typically log some token to represent the unavailable case and might well use null and negative value. This patch would save the creation of short-lived Optional object that might help logging filename/linenumber case. >> >> I?m working on a new test to verify bci and line number to be included in the next revision. >> >> Mandy >> >>> On Apr 11, 2016, at 2:22 PM, Mandy Chung wrote: >>> >>> Webrev at: >>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >>> >>> StackFrame::getFileName and StackFrame::getLineNumber are originally proposed with the view of any stack walking code can migrate to the StackWalker API without the use of StackTraceElement. >>> >>> File name and line number are useful for debugging and troubleshooting purpose. It has additional overhead to map from a method and BCI to look up the file name and line number. >>> >>> StackFrame::toStackTraceElement method returns StackTraceElement that includes the file name and line number. There is no particular benefit to duplicate getFileName and getLineNumber methods in StackFrame. It is equivalently convenient to call StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >>> >>> This patch proposes to remove StackFrame::getFileName and StackFrame::getLineNumber methods since such information can be obtained from StackFrame.toStackTraceElement(). >>> >>> Mandy >> > From mandy.chung at oracle.com Thu Apr 28 19:59:46 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Thu, 28 Apr 2016 12:59:46 -0700 Subject: RFR: 8155600: jaxp.library.TestPolicy should extend the default security policy In-Reply-To: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> References: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> Message-ID: <07BE02D4-5911-4C8A-A1E9-030698DFD7FE@oracle.com> Hi Frank, The fix looks fine. Thanks for verifying it with my patch to deprivilege jdk.charasets. Mandy > On Apr 28, 2016, at 1:11 AM, Frank Yuan wrote: > > Hi Mandy, Joe and all > > Would you like to review the fix for bug https://bugs.openjdk.java.net/browse/JDK-8155514? > > The webrev is at: http://cr.openjdk.java.net/~fyuan/8155514/webrev.00/. > > It?s verified with the source bundle in http://scaaa637.us.oracle.com/archive/2016/04/2016-04-26-045641.mlchung.jdk9-deprivilege > > > Thanks, > > Frank From nadeesh.tv at oracle.com Thu Apr 28 20:04:39 2016 From: nadeesh.tv at oracle.com (nadeesh tv) Date: Fri, 29 Apr 2016 01:34:39 +0530 Subject: RFR:JDK-8148949:DateTimeFormatter pattern letters 'A','n','N' In-Reply-To: References: <571E2C01.6050407@oracle.com> <57220C52.5030609@oracle.com> Message-ID: <57226CD7.1060907@oracle.com> Hi all, Thanks Stephen for the comments. Please see the updated webrev http://cr.openjdk.java.net/~ntv/8148949/webrev.02/ Regards, Nadeesh On 4/28/2016 7:58 PM, Stephen Colebourne wrote: > I'd like to see the test cases in test_secondsPattern() check the > result of the parse (by passing more arguments from > data_secondsPattern) > > Otherwise looks good. > Stephen > > On 28 April 2016 at 14:12, nadeesh tv wrote: >> Hi all, >> Please see the updated webrev >> http://cr.openjdk.java.net/~ntv/8148949/webrev.01/ >> >> Regards, >> Nadeesh TV >> >> On 4/25/2016 8:08 PM, nadeesh tv wrote: >>> HI all, >>> Please review a fix for >>> Bug ID - https://bugs.openjdk.java.net/browse/JDK-8148949 >>> >>> Issue - Pattern letters 'A' does not match the intent of LDML/CLDR >>> >>> Solution - Changed the definition of pattern letters 'A','n','N' >>> >>> Webrev - http://cr.openjdk.java.net/~ntv/8148949/webrev.00/ >>> >>> >> -- >> Thanks and Regards, >> Nadeesh TV >> -- Thanks and Regards, Nadeesh TV From aleksey.shipilev at oracle.com Thu Apr 28 20:10:28 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Thu, 28 Apr 2016 23:10:28 +0300 Subject: RFR (XS) 8155090: String concatenation fails with a custom SecurityManager that uses concatenation Message-ID: <57226E34.3080909@oracle.com> Hi, Please review the fix for a shady bootstrapping issue, when a custom SecurityManager is using string concatenation: https://bugs.openjdk.java.net/browse/JDK-8155090 The essence of the issue is that during StringConcatFactory::, we are reading the system properties via the privileged calls. When user SecurityManager that uses string concatenation is set, we are trying to produce a string concatenation stub in order to proceed, and double-back on SCF. There, we try to run SCF methods without fully complete : the existing test fails with uninitialized static final Strategy field. The cleanest (yet subtle) solution here is to make sure the default SCF settings are good to run with, which allows transient operations to complete normally: http://cr.openjdk.java.net/~shade/8155090/webrev.00/ Testing: offending test; java/lang/String jtregs Thanks, -Aleksey From aleksey.shipilev at oracle.com Thu Apr 28 20:21:35 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Thu, 28 Apr 2016 23:21:35 +0300 Subject: RFR (XS) 8155215: java.lang.String concatenation spec is unnecessarily strong In-Reply-To: <57209560.6040206@oracle.com> References: <57209560.6040206@oracle.com> Message-ID: <572270CF.1060207@oracle.com> On 04/27/2016 01:33 PM, Aleksey Shipilev wrote: > Please review this tiny spec improvement that syncs up JLS and > java.lang.String Javadoc. java.lang.String Javadoc unnecessarily locks > down the implementation details for String concat (e.g. usage of > StringBuilder): > http://cr.openjdk.java.net/~shade/8155215/webrev.00/ > > I'll submit CCC as soon as we agree on wording. Thanks for on-list and off-list reviews! Under Alex Buckley's guidance, we have arrived to this version, moving more to @implNote: http://cr.openjdk.java.net/~shade/8155215/webrev.02/ Cheers, -Aleksey From paul.sandoz at oracle.com Thu Apr 28 20:21:52 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 28 Apr 2016 13:21:52 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <5721C5AC.6010707@oracle.com> <57225E75.3040303@oracle.com> Message-ID: <10845DFE-C1F0-4B3D-A160-C418666D6488@oracle.com> > On 28 Apr 2016, at 12:20, Steve Drach wrote: > > >> On Apr 28, 2016, at 12:03 PM, Alan Bateman wrote: >> >> >> >> On 28/04/2016 19:53, Steve Drach wrote: >>> : >>> Yes, and for regular jar files, that worked fine, but when we tried it with a multi-release jar we found it by passed the part of JarLoader where we open the jar file as a runtime jar, so, for example, this code fails to retrieve the correct versioned entry, returning instead the base entry. >>> >>> URL[] urls = { new URL(?jar:file:/foo/multi-release.jar!/?) }; >>> URLClassLoader cldr = new URLClassLoader(urls); >>> Class vcls = cldr.loadClass("version.Version?); >>> >>> The change just corrects the logic when working with a ?jar:?..!/? URL. >>> >>> >> Can you double check the URLClassLoader spec? > > We discussed it. It seems the spec might be deficit with respect to "jar:file:/foo/multi-release.jar!/? type URLs, but it didn?t matter when it referred to a legacy jar file. > It appears to be an undocumented ?feature" that URLClassLoader can accept base jar-scheme URLs such as: jar:file/?.!/ jar:http/?.!/ by virtue of those URLs being passed to URLClassPath, which is contrary to what is stated on URLClassLoader: "Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which will be opened as needed.? The above only reliably applies to file-scheme URLs. Here is the original logic: String file = url.getFile(); if (file != null && file.endsWith("/")) { if ("file".equals(url.getProtocol())) { return new FileLoader(url); References: <57226E34.3080909@oracle.com> Message-ID: <5722787B.8090807@oracle.com> Hi Aleksey, On 2016-04-28 22:10, Aleksey Shipilev wrote: > Hi, > > Please review the fix for a shady bootstrapping issue, when a custom > SecurityManager is using string concatenation: > https://bugs.openjdk.java.net/browse/JDK-8155090 > > The essence of the issue is that during StringConcatFactory::, > we are reading the system properties via the privileged calls. When > user SecurityManager that uses string concatenation is set, we are > trying to produce a string concatenation stub in order to proceed, and > double-back on SCF. There, we try to run SCF methods without fully > complete : the existing test fails with uninitialized static > final Strategy field. > > The cleanest (yet subtle) solution here is to make sure the default SCF > settings are good to run with, which allows transient > operations to complete normally: > http://cr.openjdk.java.net/~shade/8155090/webrev.00/ looks good to me! While a subtle fix indeed, the comment well explains the need for doing this, and alternatives like ensuring there are no calls back into the SecurityManager from SCF would be very fragile in comparison. Nits: the the -> the, (onto -> into?) no need for a re-review if you choose to fix these. Thanks! /Claes > > Testing: offending test; java/lang/String jtregs > > Thanks, > -Aleksey > From steve.drach at oracle.com Thu Apr 28 21:18:15 2016 From: steve.drach at oracle.com (Steve Drach) Date: Thu, 28 Apr 2016 14:18:15 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them Message-ID: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> I?ve updated the webrev to change all instances of the word ?reified? to ?real? as in getRealName(). Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev.01/ From peter.levart at gmail.com Thu Apr 28 21:20:15 2016 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 28 Apr 2016 23:20:15 +0200 Subject: JDK 9 pre-review of JDK-6850612: Deprecate Class.newInstance since it violates the checked exception language contract In-Reply-To: References: <5713C871.1080407@oracle.com> <5718FEF7.1020807@oracle.com> <571A4439.6090001@Oracle.com> <571A639B.1000606@oracle.com> Message-ID: On 04/28/2016 09:06 PM, Jason Mehrens wrote: > Hi Peter, > >> As mentioned, Class.newInstance() has a special cache for constructor >> and caller that speeds up repeated invocations from the same caller by >> skipping access checks. > I'm sure I'm missing something obvious related to performance or security but, couldn't the exact same 'cachedConstructor' field be used for caching Class.getConstructor(new Class[0]) as long as a constructor copy is returned? > That way the recommended workaround is near the same performance. This would only speed up the lookup part (optimization for looking up no-arg constructor - perhaps this could be a special field in Class.ReflectionData), but returning a copy would force re-evaluation of access checks which can now be skipped if the caller remains the same in consecutive invocations to Class.newInstance(). Regards, Peter From david.holmes at oracle.com Thu Apr 28 23:09:57 2016 From: david.holmes at oracle.com (David Holmes) Date: Fri, 29 Apr 2016 09:09:57 +1000 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's Message-ID: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> bug: https://bugs.openjdk.java.net/browse/JDK-8154710 webrev: http://cr.openjdk.java.net/~dholmes/8154710/webrev/ This change is small in nature but somewhat broad in scope. It "affects" the implementation of System.currentTimeMillis() in the Java space, and os::javaTimeMillis() in the VM. But on Solaris only. I say "affects" but the change will be unobservable other than in terms of performance. As of Solaris 11.3.6 a new in-memory timestamp has been made available (not unlike what has always existed on Windows). There are actually 3 different timestamps exported but the one we are interested in is get_nsecs_fromepoch - which is of course elapsed nanoseconds since the epoch - which is exactly what javaTimeMillis() is, but expressed in milliseconds. The in-memory timestamps have an update accuracy of 1ms, so are not suitable for any other API's that want the time-of-day, but at a greater accuracy. Microbenchmark shows the in-memory access is approx 45% faster (19ns on my test system) compared to the gettimeofday call (35ns). Thanks, David From stuart.marks at oracle.com Thu Apr 28 23:41:48 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 28 Apr 2016 16:41:48 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <1461835180.388878317.8g41wld0@frv39.fwdcdn.com> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> <1461835180.388878317.8g41wld0@frv39.fwdcdn.com> Message-ID: <80b376b3-ab06-1f5b-6581-374513fda89e@oracle.com> On 4/28/16 2:26 AM, Victor Polischuk wrote: > I am sorry if my comment would be inappropriate, but is there a reason not to > introduce "Optional ifAbsent(Runnable emptyAction)" and change signature > of ifPresent to "Optional ifPresent(Consumer consumer)"? > > In that case method chaining would be more natural and it will give a decent > way to have more than one simple action assigned to Optional without creating > messy java block. Yes, this is starting to veer off topic from Optional.get(). I'll just say that a few methods have been added to Optional in Java 9: ifPresentOrElse(), or(), and stream(). It seems pretty complete now. Please see the Java 9 early access docs for details: http://download.java.net/java/jdk9/docs/api/java/util/Optional.html s'marks From stuart.marks at oracle.com Thu Apr 28 23:55:49 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 28 Apr 2016 16:55:49 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> Message-ID: <5dad068b-038e-591c-49a1-ffcc22ffebb8@oracle.com> On 4/28/16 4:05 AM, Stanislav Baiduzhyi wrote: > Those examples are amazing. Would it be possible to expand Optional > class javadoc with some of those examples? First, second, and the last > one are the most descriptive in my opinion. I frowned at Optional for > so long, you just showed me that I was not using it properly. Yes, this is a good point, independent of deprecation of get() and addition of new/replacement methods such as getWhenPresent(). It does seem really hard to look at the API docs for Optional and to figure out how they're intended to be used. While the javadocs aren't the right place for a tutorial, it's certainly reasonable to have a few small examples in key places. I've filed JDK-8155693 to track this. s'marks From frank.yuan at oracle.com Fri Apr 29 02:13:59 2016 From: frank.yuan at oracle.com (Frank Yuan) Date: Fri, 29 Apr 2016 10:13:59 +0800 Subject: RFR: 8155600: jaxp.library.TestPolicy should extend the default security policy In-Reply-To: <07BE02D4-5911-4C8A-A1E9-030698DFD7FE@oracle.com> References: <06b201d1a125$9d5af1e0$d810d5a0$@oracle.com> <07BE02D4-5911-4C8A-A1E9-030698DFD7FE@oracle.com> Message-ID: <013801d1a1bc$cc2ba130$6482e390$@oracle.com> Thank you! Pushed. Best Regards Frank -----Original Message----- From: Mandy Chung [mailto:mandy.chung at oracle.com] Sent: Friday, April 29, 2016 4:00 AM To: Frank Yuan Cc: core-libs-dev ; huizhe wang ; Xueming Shen Subject: Re: RFR: 8155600: jaxp.library.TestPolicy should extend the default security policy Hi Frank, The fix looks fine. Thanks for verifying it with my patch to deprivilege jdk.charasets. Mandy > On Apr 28, 2016, at 1:11 AM, Frank Yuan wrote: > > Hi Mandy, Joe and all > > Would you like to review the fix for bug > https://bugs.openjdk.java.net/browse/JDK-8155514? > > The webrev is at: http://cr.openjdk.java.net/~fyuan/8155514/webrev.00/. > > It?s verified with the source bundle in > http://scaaa637.us.oracle.com/archive/2016/04/2016-04-26-045641.mlchun > g.jdk9-deprivilege > > > Thanks, > > Frank From felix.yang at oracle.com Fri Apr 29 02:16:19 2016 From: felix.yang at oracle.com (Felix Yang) Date: Fri, 29 Apr 2016 10:16:19 +0800 Subject: RFR 8155088, Fix module dependencies in java/sql/* and javax/* tests Message-ID: <8a466652-c0da-1f0c-8272-d1b51bea6c73@oracle.com> Hi there, please review the changes to explicitly declare module dependencies for "java/sql/*" and "javax/*" tests; Bug: https://bugs.openjdk.java.net/browse/JDK-8155088 Webrev: http://cr.openjdk.java.net/~xiaofeya/8155088/webrev.00/ Thanks, Felix From martinrb at google.com Fri Apr 29 02:23:05 2016 From: martinrb at google.com (Martin Buchholz) Date: Thu, 28 Apr 2016 19:23:05 -0700 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <5dad068b-038e-591c-49a1-ffcc22ffebb8@oracle.com> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <5dad068b-038e-591c-49a1-ffcc22ffebb8@oracle.com> Message-ID: No opinion on Optional.get() itself, but here's an opinion on the high cost of deprecation. If you deprecate the API today, and I have a library that is already using the API, then I should add a @SuppressWarning("deprecation") today and keep it there until the number of people using pre-jdk9 is insignificant, when I can finally rename it. How long is that? These days, I estimate at least 10 years. But even 20 years is quite possible. From chris.hegarty at oracle.com Fri Apr 29 07:09:27 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Fri, 29 Apr 2016 08:09:27 +0100 Subject: RFR (XS) 8155090: String concatenation fails with a custom SecurityManager that uses concatenation In-Reply-To: <5722787B.8090807@oracle.com> References: <57226E34.3080909@oracle.com> <5722787B.8090807@oracle.com> Message-ID: > On 28 Apr 2016, at 21:54, Claes Redestad wrote: > > Hi Aleksey, > > On 2016-04-28 22:10, Aleksey Shipilev wrote: >> Hi, >> >> Please review the fix for a shady bootstrapping issue, when a custom >> SecurityManager is using string concatenation: >> https://bugs.openjdk.java.net/browse/JDK-8155090 >> >> The essence of the issue is that during StringConcatFactory::, >> we are reading the system properties via the privileged calls. When >> user SecurityManager that uses string concatenation is set, we are >> trying to produce a string concatenation stub in order to proceed, and >> double-back on SCF. There, we try to run SCF methods without fully >> complete : the existing test fails with uninitialized static >> final Strategy field. >> >> The cleanest (yet subtle) solution here is to make sure the default SCF >> settings are good to run with, which allows transient >> operations to complete normally: >> http://cr.openjdk.java.net/~shade/8155090/webrev.00/ > > looks good to me! +1. I?ve seen a few similar, but not the same, issues like this in the core area before. -Chris. > While a subtle fix indeed, the comment well explains the need > for doing this, and alternatives like ensuring there are no calls > back into the SecurityManager from SCF would be very fragile > in comparison. > > Nits: the the -> the, (onto -> into?) no need for a re-review if > you choose to fix these. > > Thanks! > > /Claes > >> >> Testing: offending test; java/lang/String jtregs >> >> Thanks, >> -Aleksey From Alan.Bateman at oracle.com Fri Apr 29 07:25:22 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 08:25:22 +0100 Subject: RFR 8155088, Fix module dependencies in java/sql/* and javax/* tests In-Reply-To: <8a466652-c0da-1f0c-8272-d1b51bea6c73@oracle.com> References: <8a466652-c0da-1f0c-8272-d1b51bea6c73@oracle.com> Message-ID: <57230C62.7010607@oracle.com> On 29/04/2016 03:16, Felix Yang wrote: > Hi there, > > please review the changes to explicitly declare module > dependencies for "java/sql/*" and "javax/*" tests; > > Bug: https://bugs.openjdk.java.net/browse/JDK-8155088 > > Webrev: http://cr.openjdk.java.net/~xiaofeya/8155088/webrev.00/ Felix - would it be disruptive to you if I asked to hold off on this until we get the changes in jake pushed to jdk9/dev (next week). The reason is that this we've changed most of these tests in jake to use -addmods. We've also replaced the TEST.properties for the javax.transaction tests so that they are run with a driver class instead. This is also related to the policy for root modules which impacts the tests that we have for the EE modules in the jdk repo. -Alan From felix.yang at oracle.com Fri Apr 29 07:37:37 2016 From: felix.yang at oracle.com (Felix Yang) Date: Fri, 29 Apr 2016 15:37:37 +0800 Subject: RFR 8155088, Fix module dependencies in java/sql/* and javax/* tests In-Reply-To: <57230C62.7010607@oracle.com> References: <8a466652-c0da-1f0c-8272-d1b51bea6c73@oracle.com> <57230C62.7010607@oracle.com> Message-ID: <0a1e247d-33b4-abaf-92e7-51abb0f86801@oracle.com> On 2016/4/29 15:25, Alan Bateman wrote: > On 29/04/2016 03:16, Felix Yang wrote: >> Hi there, >> >> please review the changes to explicitly declare module >> dependencies for "java/sql/*" and "javax/*" tests; >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8155088 >> >> Webrev: http://cr.openjdk.java.net/~xiaofeya/8155088/webrev.00/ > Felix - would it be disruptive to you if I asked to hold off on this > until we get the changes in jake pushed to jdk9/dev (next week). The > reason is that this we've changed most of these tests in jake to use > -addmods. We've also replaced the TEST.properties for the > javax.transaction tests so that they are run with a driver class > instead. This is also related to the policy for root modules which > impacts the tests that we have for the EE modules in the jdk repo. Alan, it is OK. Libs SQE will hold off to wait the changes in. Thanks for the info, Felix > > -Alan From Alan.Bateman at oracle.com Fri Apr 29 08:57:05 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 09:57:05 +0100 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: <57208325.6080907@oracle.com> <57208E06.2060809@oracle.com> Message-ID: <572321E1.2030702@oracle.com> On 27/04/2016 12:26, Martin Buchholz wrote: > I think the jdk9 docs have moved (again, grrrr - I complain about this > sort of thing every release) and so a google search for "package class > se 9" only finds the old one +104 at > http://download.java.net/jdk9/docs/api/java/lang/Package.html > Why can't there be a redirect instead of leaving the old docs in place? > The infrastructure that publishes the builds and docs on java.net is several steps removed from most of us here but from what I understand, the stale docs have been purged and a redirect from the old location to the new location is in place. When I search for "jdk 9 docs" now then Google serves up this link http://download.java.net/jdk9/docs/api/index.html?help-doc.html and I get redirected to the docs at: http://download.java.net/java/jdk9/docs/api/index.html -Alan From andrej.golovnin at gmail.com Fri Apr 29 09:23:14 2016 From: andrej.golovnin at gmail.com (Andrej Golovnin) Date: Fri, 29 Apr 2016 11:23:14 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> Message-ID: Hi Stuart, > I also think it's reasonable, independently of any deprecation/renaming, for IDE vendors to > add rule checkers that attempt to detect unsafe uses of Optional. I'm a bit > skeptical of whether it's possible for there to be automatic fixes, but > detection would be a good step forward. IntelliJ IDEA already warns you when you use Optional.get() without Optional.isPresent(). Just use the right IDE! ;-) I understand that you must use Optional.get() in the bootstrap code of Java Runtime to avoid usage of lambdas. But in the most other cases (I would say in 99.9%) you don't need the #get() method at all. At this place I would like to quote the user raimille1 from the discussion https://news.ycombinator.com/item?id=11588927 about your change: "There are many Java 8 developers using streams() and optionals with an imperative programming mindset still." And here is an example from JDK. Take look at the code http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java-.html : 397 cf.modules().forEach(m -> { 398 ModuleReference mref = m.reference(); 399 map.put(mref.descriptor().name(), mref); 400 }); 401 402 // set of modules that are observable 403 Set mrefs = new HashSet<>(map.values()); 404 405 // add the other modules 406 for (String mod : otherMods) { 407 Optional omref = finder.find(mod); 408 if (omref.isPresent()) { 409 ModuleReference mref = omref.get(); 410 map.putIfAbsent(mod, mref); 411 mrefs.add(mref); 412 } else { 413 // no need to fail 414 } 415 } It is a mix of imperative and functional programming. But you can rewrite it in a more functional style. The lines 397-400 can be rewritten as: cf.modules() .stream() .map(ResolvedModule::reference) .forEach(mref -> map.put(mref.descriptor().name(), mref)); The lines 406-415 can be rewritten as: otherMods .stream() .map(finder::find) // After this step you can filter out all empty Optionals. // But I don't think it is really needed. .forEach( o -> o.ifPresent(mref -> { map.putIfAbsent(mref.descriptor().name(), ref); mrefs.add(mref); } ); As you see there is no need for the stupid else-clause in the lines 412-414 and there is no need to call Optional.get(). Scala's Option class has also the #get()-method. But I have never seen that someone asked to deprecate it and to add a new one. And in my Scala projects I have never used it. And like others I have also some wishes: 1. I think Optional should implement Iterable interface. You can use then Optional everywhere where you can use Iterable today. And you will get the #forEach()-method which I miss sometimes after using Scala's Option class. 2. Please add Optional#isEmpty() method. The #isEmpty()-method is useful when you want to filter out empty Optionals from a stream. Today I have to write the lambda o -> !o.isPresen(). With the new Optional#isEmpty() method I can use the method reference Optional::isEmpty. 3. Please add Option#orNull() method. It is easier to read than Optional.orElse(null). 4. I think Optional should implement Serializable interface. Currently the JEE developers cannot use it as return and parameter types of methods of the session bean's remote interface. This is what we have to write today: public Whatever getBestMatch(String someCriteria) { return someOtherSrvice .findAll(someCriteria) .stream() .map(...) .filter(...) .sorted(MyComparator::new) .findFirst() .orElse(null); } Personally I would like to omit orElse(null) and just return the Optional returned by #findFirst(). But because this method can be called by a remote client using RMI and RMI requires that all objects must be Serializable, I cannot use Optional. We have now this new cool API in JDK and we cannot use it in JEE applications. How stupid is that? One off-topic wish: Please integrate Tagir's StreamEx library (or at least some parts of it) into JDK's Stream API. After adding his library to our product I see that developers move away from JDK's Stream API because his library is more useful than the standard Stream API. @Tagir: Thank you very much for StreamEx! Great job! :-) As an average Java developer and an user of the Stream API and the Optional class, I vote against deprecating of the Optional.get()-method. (We have a democracy here, haven't we? :-D) Best regards, Andrej Golovnin From Alan.Bateman at oracle.com Fri Apr 29 09:49:50 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 10:49:50 +0100 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> Message-ID: <57232E3E.6060808@oracle.com> On 29/04/2016 10:23, Andrej Golovnin wrote: > : > > "There are many Java 8 developers using streams() and optionals > with an imperative programming mindset still." > > And here is an example from JDK. Take look at the code > http://cr.openjdk.java.net/~smarks/reviews/8140281/webrev.0.jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java-.html > : > > 397 cf.modules().forEach(m -> { > 398 ModuleReference mref = m.reference(); > 399 map.put(mref.descriptor().name(), mref); > 400 }); > 401 > 402 // set of modules that are observable > 403 Set mrefs = new HashSet<>(map.values()); > 404 > 405 // add the other modules > 406 for (String mod : otherMods) { > 407 Optional omref = finder.find(mod); > 408 if (omref.isPresent()) { > 409 ModuleReference mref = omref.get(); > 410 map.putIfAbsent(mod, mref); > 411 mrefs.add(mref); > 412 } else { > 413 // no need to fail > 414 } > 415 } > > It is a mix of imperative and functional programming. > But you can rewrite it in a more functional style. > The lines 397-400 can be rewritten as: > > cf.modules() > .stream() > .map(ResolvedModule::reference) > .forEach(mref -> map.put(mref.descriptor().name(), mref)); > > which btw is exactly how it is implemented elsewhere. However it was not possible to write it this way before refactoring of the API a few weeks ago and it's just that the jlink code wasn't cleaned up much during the refactoring. In general then we have lots of code in the JDK that could be refactored and cleaned up. Some of the new code (such as jlink) has had to go through many iterations and refactoring and very easy to end up with mixes of functional and imperative. I expect there will be a lot of churn in this code over the coming months (not features work and just improving and iterating on the current implementation) and hopefully in better shape then. -Alan. From aleksey.shipilev at oracle.com Fri Apr 29 09:50:33 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 29 Apr 2016 12:50:33 +0300 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> Message-ID: <57232E69.20800@oracle.com> On 04/29/2016 02:09 AM, David Holmes wrote: > bug: https://bugs.openjdk.java.net/browse/JDK-8154710 > webrev: http://cr.openjdk.java.net/~dholmes/8154710/webrev/ Looks good. Is hrtime_t always integral, so you can "(hrtime_t)now / NANOSECS_PER_MILLISEC" it? > This change is small in nature but somewhat broad in scope. It "affects" > the implementation of System.currentTimeMillis() in the Java space, and > os::javaTimeMillis() in the VM. But on Solaris only. > > I say "affects" but the change will be unobservable other than in terms > of performance. Observable enough to me. Thanks, -Aleksey From daniel.fuchs at oracle.com Fri Apr 29 09:53:29 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Fri, 29 Apr 2016 11:53:29 +0200 Subject: Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed In-Reply-To: References: <5D245EC6-47C6-4BF1-A505-89934731A814@oracle.com> <66A0640B-408C-4276-BB79-CCFDEFFDC24B@oracle.com> <5722585A.4060408@oracle.com> Message-ID: Hi Mandy, This looks good to me. Regarding final methods, I believe it might be prudent to make toStackTraceElement() final - and possibly also all the getters that call it. It would be imprudent to try to override any of these methods in a subclass without looking at the implementation in the superclass. Making these methods final will ensure that future maintainers will at least need to look at the implementation in StackFrameInfo before they override any of them. best regards, -- daniel On 28/04/16 21:42, Mandy Chung wrote: > >> On Apr 28, 2016, at 11:37 AM, Brent Christian wrote: >> >> Hi, Mandy >> >> It looks good to me. A few minor things: >> >> StackFrameInfo.java: >> >> Should getByteCodeIndex() be final ? >> > > It?s a package-private class and so no subclass outside this package anyway. So it doesn?t really matter. I didn?t catch the inconsistency there - some methods in this class are final and some are not. I may clean them up. > > >> >> StackWalker.java, line 136: >> * change ';' to ?,' >> > > ok. > >> >> JavaLangInvokeAccess.java, line 40: >> >> For the isNative() docs, I would prefer "Returns true if..." to "Tests if..." >> >> > > Both conventions are used. I can change that. > >> Some test code for getByteCodeIndex() would be good - sounds like you plan to add that. > > yes. Will send out for review next. > > thanks for the review. > Mandy > >> >> Thanks, >> -Brent >> On 04/27/2016 11:31 AM, Mandy Chung wrote: >>> Updated webrev: >>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.01/index.html >>> >>> I added a new StackFrame::getByteCodeIndex method to return bci and updatedgetFileName and getLineNumber to have the same returned type as in StackTraceElement. From usage perspective, the caller has to prepare and handle the information is unavailable and I think it would typically log some token to represent the unavailable case and might well use null and negative value. This patch would save the creation of short-lived Optional object that might help logging filename/linenumber case. >>> >>> I?m working on a new test to verify bci and line number to be included in the next revision. >>> >>> Mandy >>> >>>> On Apr 11, 2016, at 2:22 PM, Mandy Chung wrote: >>>> >>>> Webrev at: >>>> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8153912/webrev.00/index.html >>>> >>>> StackFrame::getFileName and StackFrame::getLineNumber are originally proposed with the view of any stack walking code can migrate to the StackWalker API without the use of StackTraceElement. >>>> >>>> File name and line number are useful for debugging and troubleshooting purpose. It has additional overhead to map from a method and BCI to look up the file name and line number. >>>> >>>> StackFrame::toStackTraceElement method returns StackTraceElement that includes the file name and line number. There is no particular benefit to duplicate getFileName and getLineNumber methods in StackFrame. It is equivalently convenient to call StackFrame.toStackTraceElement().getFileName() (or getLineNumber). >>>> >>>> This patch proposes to remove StackFrame::getFileName and StackFrame::getLineNumber methods since such information can be obtained from StackFrame.toStackTraceElement(). >>>> >>>> Mandy >>> >> > From david.holmes at oracle.com Fri Apr 29 10:05:24 2016 From: david.holmes at oracle.com (David Holmes) Date: Fri, 29 Apr 2016 20:05:24 +1000 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <57232E69.20800@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> Message-ID: On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: > On 04/29/2016 02:09 AM, David Holmes wrote: >> bug: https://bugs.openjdk.java.net/browse/JDK-8154710 >> webrev: http://cr.openjdk.java.net/~dholmes/8154710/webrev/ > > Looks good. > > Is hrtime_t always integral, so you can "(hrtime_t)now / > NANOSECS_PER_MILLISEC" it? Yes it is a 64-bit (long long) signed integer. >> This change is small in nature but somewhat broad in scope. It "affects" >> the implementation of System.currentTimeMillis() in the Java space, and >> os::javaTimeMillis() in the VM. But on Solaris only. >> >> I say "affects" but the change will be unobservable other than in terms >> of performance. > > Observable enough to me. :) Any apps you can think of that might show benefit from this? Thanks, David > Thanks, > -Aleksey > From aleksey.shipilev at oracle.com Fri Apr 29 10:12:46 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 29 Apr 2016 13:12:46 +0300 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> Message-ID: <5723339E.306@oracle.com> On 04/29/2016 01:05 PM, David Holmes wrote: > On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: >> On 04/29/2016 02:09 AM, David Holmes wrote: >>> This change is small in nature but somewhat broad in scope. It "affects" >>> the implementation of System.currentTimeMillis() in the Java space, and >>> os::javaTimeMillis() in the VM. But on Solaris only. >>> >>> I say "affects" but the change will be unobservable other than in terms >>> of performance. >> >> Observable enough to me. > > :) Any apps you can think of that might show benefit from this? Theoretically, this might affect heavily logging apps. IIRC, SPECjbb2000 was affected by currentTimeMillis performance. But, I see no reason in trying to justify the change, apart from the targeted microbenchmark. -Aleksey From aleksey.shipilev at oracle.com Fri Apr 29 10:29:08 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 29 Apr 2016 13:29:08 +0300 Subject: RFR (XS) 8155090: String concatenation fails with a custom SecurityManager that uses concatenation In-Reply-To: References: <57226E34.3080909@oracle.com> <5722787B.8090807@oracle.com> Message-ID: <57233774.6020603@oracle.com> On 04/29/2016 10:09 AM, Chris Hegarty wrote: >> On 28 Apr 2016, at 21:54, Claes Redestad > > wrote: >>> The cleanest (yet subtle) solution here is to make sure the default SCF >>> settings are good to run with, which allows transient >>> operations to complete normally: >>> http://cr.openjdk.java.net/~shade/8155090/webrev.00/ >>> >> >> looks good to me! > > +1. Thanks, pushed. -Aleksey From peter.levart at gmail.com Fri Apr 29 11:11:24 2016 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Apr 2016 13:11:24 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> Message-ID: <81e28d81-0642-13f6-eb95-f120638edbe2@gmail.com> On 04/29/2016 11:23 AM, Andrej Golovnin wrote: > The lines 406-415 can be rewritten as: > > otherMods > .stream() > .map(finder::find) // After this step you can filter out all > // empty Optionals. > // But I don't think it is really needed. > .forEach( > o -> o.ifPresent(mref -> { > map.putIfAbsent(mref.descriptor().name(), ref); > mrefs.add(mref); > } > ); ...even more Stream-y (with JDK 9 changes to Optional): otherMods .stream() .flatMap(mod -> finder.find(mod).stream()) .forEach(mref -> ...); Yes, it takes some time for people to get used to new tools before they use them optimally. This is a normal learning process. So I wonder whether it is only the method name that is to blame for the observed percentage of wrong or sub-optimal usages of Optional or would it be more-or-less the same with a more descriptive name at this time. But the argument that getWhenPresent() is easier to spot than get() when reading code is on spot so at least some bugs would get spotted more quickly if the method stood out. Regards, Peter From jaroslav at kamenik.cz Fri Apr 29 11:36:36 2016 From: jaroslav at kamenik.cz (=?UTF-8?Q?Jaroslav_Kamen=C3=ADk?=) Date: Fri, 29 Apr 2016 13:36:36 +0200 Subject: Integer/Long reverse bits optimization Message-ID: Hello! I have a small patch to Integer and Long classes, which is speeding up bit reversion significantly. Last two/three steps of bit reversion are doing byte reversion, so there is possibility to use intrinsified method reverseBytes. Java implementation of reverseBytes is similar to those steps, so it should give similar performance when intrinsics are not available. Here I have result of few performance tests (thank for hints, Aleksej:) : old code: # VM options: -server ReverseInt.reverse 1 avgt 5 8,766 ? 0,214 ns/op ReverseLong.reverse 1 avgt 5 9,992 ? 0,165 ns/op # VM options: -client ReverseInt.reverse 1 avgt 5 9,168 ? 0,268 ns/op ReverseLong.reverse 1 avgt 5 9,988 ? 0,123 ns/op patched: # VM options: -server ReverseInt.reverse 1 avgt 5 6,411 ? 0,046 ns/op ReverseLong.reverse 1 avgt 5 6,299 ? 0,158 ns/op # VM options: -client ReverseInt.reverse 1 avgt 5 6,430 ? 0,022 ns/op ReverseLong.reverse 1 avgt 5 6,301 ? 0,097 ns/op patched, intrinsics disabled: # VM options: -server -XX:DisableIntrinsic=_reverseBytes_i,_reverseBytes_l ReverseInt.reverse 1 avgt 5 9,597 ? 0,206 ns/op ReverseLong.reverse 1 avgt 5 9,966 ? 0,151 ns/op # VM options: -client -XX:DisableIntrinsic=_reverseBytes_i,_reverseBytes_l ReverseInt.reverse 1 avgt 5 9,609 ? 0,069 ns/op ReverseLong.reverse 1 avgt 5 9,968 ? 0,075 ns/op You can see, there is little slowdown in integer case with intrinsics disabled. It seems to be caused by different 'shape' of byte reverting code in Integer.reverse and Integer.reverseByte. I tried to replace reverseByte code with piece of reverse method, and it is as fast as not patched case: ReverseInt.reverse 1 avgt 5 9,184 ? 0,255 ns/op Diffs from jdk9: Integer.java: @@ -1779,9 +1805,8 @@ i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555; i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333; i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f; - i = (i << 24) | ((i & 0xff00) << 8) | - ((i >>> 8) & 0xff00) | (i >>> 24); - return i; + + return reverseBytes(i); Long.java: @@ -1940,10 +1997,8 @@ i = (i & 0x5555555555555555L) << 1 | (i >>> 1) & 0x5555555555555555L; i = (i & 0x3333333333333333L) << 2 | (i >>> 2) & 0x3333333333333333L; i = (i & 0x0f0f0f0f0f0f0f0fL) << 4 | (i >>> 4) & 0x0f0f0f0f0f0f0f0fL; - i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL; - i = (i << 48) | ((i & 0xffff0000L) << 16) | - ((i >>> 16) & 0xffff0000L) | (i >>> 48); - return i; + + return reverseBytes(i); Jaroslav From amaembo at gmail.com Fri Apr 29 12:40:41 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Fri, 29 Apr 2016 18:40:41 +0600 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> Message-ID: <498505705.20160429184041@gmail.com> Thank you for reviews! Here's updated webrev: http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r2/ AS> *) Does EA break if you make ArrayItr inner class to gain the access to AS> E[] a? No, I checked, it still allocates. AS> *) next(): Missing braces in throw new NSEE() block; Fixed AS> *) next(): Why loading this.a into local? Removed local a. Seems that this change does not affect the performance. AS> I agree with Aleksey but I'd go as far as to say that not only AS> this.a is unnecessary, but i as well. The body of next() looks too AS> elaborate. This seems equivalent and concise: AS> ? if (cursor >= a.length) { AS> ? ? ? throw new NoSuchElementException(); AS> ? } AS> ? return a[cursor++]; I tried to mimic java.util.ArrayList.iterator() implementation. Here I would agree with Peter Levart and leave local variable. AS> I think Arrays.asList is frequently used in tests already. But, a quick AS> boundary jtreg test would be nice to have, given now we have a special AS> iterator. Simple test is implemented. I did not find proper class to put it, so I created new class instead (test/java/util/Arrays/AsList.java). Please check. With best regards, Tagir Valeev. From claes.redestad at oracle.com Fri Apr 29 12:33:59 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 29 Apr 2016 14:33:59 +0200 Subject: Integer/Long reverse bits optimization In-Reply-To: References: Message-ID: <572354B7.7070005@oracle.com> Hi, On 2016-04-29 13:36, Jaroslav Kamen?k wrote: > Hello! > > I have a small patch to Integer and Long classes, which is speeding up bit > reversion significantly. > > Last two/three steps of bit reversion are doing byte reversion, so there is > possibility to use > intrinsified method reverseBytes. Java implementation of reverseBytes is > similar to those > steps, so it should give similar performance when intrinsics are not > available. Here I have > result of few performance tests (thank for hints, Aleksej:) : > > > old code: > > # VM options: -server > ReverseInt.reverse 1 avgt 5 8,766 ? 0,214 ns/op > ReverseLong.reverse 1 avgt 5 9,992 ? 0,165 ns/op > > # VM options: -client > ReverseInt.reverse 1 avgt 5 9,168 ? 0,268 ns/op > ReverseLong.reverse 1 avgt 5 9,988 ? 0,123 ns/op > > > patched: > > # VM options: -server > ReverseInt.reverse 1 avgt 5 6,411 ? 0,046 ns/op > ReverseLong.reverse 1 avgt 5 6,299 ? 0,158 ns/op > > # VM options: -client > ReverseInt.reverse 1 avgt 5 6,430 ? 0,022 ns/op > ReverseLong.reverse 1 avgt 5 6,301 ? 0,097 ns/op > > > patched, intrinsics disabled: > > # VM options: -server -XX:DisableIntrinsic=_reverseBytes_i,_reverseBytes_l > ReverseInt.reverse 1 avgt 5 9,597 ? 0,206 ns/op > ReverseLong.reverse 1 avgt 5 9,966 ? 0,151 ns/op > > # VM options: -client -XX:DisableIntrinsic=_reverseBytes_i,_reverseBytes_l > ReverseInt.reverse 1 avgt 5 9,609 ? 0,069 ns/op > ReverseLong.reverse 1 avgt 5 9,968 ? 0,075 ns/op > > > > You can see, there is little slowdown in integer case with intrinsics > disabled. > It seems to be caused by different 'shape' of byte reverting code in > Integer.reverse and Integer.reverseByte. I tried to replace reverseByte code > with piece of reverse method, and it is as fast as not patched case: > > > ReverseInt.reverse 1 avgt 5 9,184 ? 0,255 ns/op > > > Diffs from jdk9: > > Integer.java: > > @@ -1779,9 +1805,8 @@ > i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555; > i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333; > i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f; > - i = (i << 24) | ((i & 0xff00) << 8) | > - ((i >>> 8) & 0xff00) | (i >>> 24); > - return i; > + > + return reverseBytes(i); > > Long.java: > > @@ -1940,10 +1997,8 @@ > i = (i & 0x5555555555555555L) << 1 | (i >>> 1) & > 0x5555555555555555L; > i = (i & 0x3333333333333333L) << 2 | (i >>> 2) & > 0x3333333333333333L; > i = (i & 0x0f0f0f0f0f0f0f0fL) << 4 | (i >>> 4) & > 0x0f0f0f0f0f0f0f0fL; > - i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & > 0x00ff00ff00ff00ffL; > - i = (i << 48) | ((i & 0xffff0000L) << 16) | > - ((i >>> 16) & 0xffff0000L) | (i >>> 48); > - return i; > + > + return reverseBytes(i); reduces code duplication, improves performance... what's the catch!? :-) Updating Integer.reverseByte to have the same 'shape' as in Integer.reverseByte seems reasonable in this case. I can sponsor this if you've signed the OCA etc. Thanks! /Claes From vladimir.x.ivanov at oracle.com Fri Apr 29 12:36:29 2016 From: vladimir.x.ivanov at oracle.com (Vladimir Ivanov) Date: Fri, 29 Apr 2016 15:36:29 +0300 Subject: RFR 8154755: Add a VarHandle weakCompareAndSet with volatile semantics In-Reply-To: <07EE4695-9AF3-4F50-ACAE-831BD508B657@oracle.com> References: <07EE4695-9AF3-4F50-ACAE-831BD508B657@oracle.com> Message-ID: <5723554D.9030508@oracle.com> Looks good. Best regards, Vladimir Ivanov On 4/21/16 7:21 PM, Paul Sandoz wrote: > Hi, > > Please review: > > http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8154755-weak-cas-volatile/webrev/ > > This webrev adds a new VarHandle access mode method, weakCompareAndSetVolatile [*]. (I also fixed some doc errors regarding AccessMode enum names that i forgot to update in a previous issue). > > Aleksey noticed a discrepancy with the current set of weak CAS methods when comparing with C++ atomics. > > On hardware that supports LL/SC (e.g. ARM) the weak volatile variant may be more performant than the strong volatile variant (compareAndSet) when the CAS is performed in a loop. > > See the thread on the jmm-dev list for more details: > > http://mail.openjdk.java.net/pipermail/jmm-dev/2016-April/000239.html > > > Implementations currently defer to the strong volatile Unsafe CAS. We will follow up with changes to Unsafe, hotspot, and updating the VH implementations as separate issues. > > Thanks, > Paul. > > [*] > /** > * Possibly atomically sets the value of a variable to the {@code newValue} > * with the memory semantics of {@link #setVolatile} if the variable's > * current value, referred to as the witness value, {@code ==} the > * {@code expectedValue}, as accessed with the memory semantics of > * {@link #getVolatile}. > * > *

      This operation may fail spuriously (typically, due to memory > * contention) even if the witness value does match the expected value. > * > ... > */ > public final native > @MethodHandle.PolymorphicSignature > @HotSpotIntrinsicCandidate > boolean weakCompareAndSetVolatile(Object... args); > > > > > > Paul. > From aleksey.shipilev at oracle.com Fri Apr 29 12:49:04 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 29 Apr 2016 15:49:04 +0300 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <498505705.20160429184041@gmail.com> References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> <498505705.20160429184041@gmail.com> Message-ID: <57235840.6020904@oracle.com> On 04/29/2016 03:40 PM, Tagir F. Valeev wrote: > http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r2/ JDK part looks good to me. Test: *) Formatting: "i=0", "i AS> *) Does EA break if you make ArrayItr inner class to gain the access to > AS> E[] a? > > No, I checked, it still allocates. Yeah, this seems to be an issue with EA, investigating... We can push this iterator in current form meanwhile. Thanks, -Aleksey From charlie.hunt at oracle.com Fri Apr 29 12:57:37 2016 From: charlie.hunt at oracle.com (charlie hunt) Date: Fri, 29 Apr 2016 07:57:37 -0500 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <5723339E.306@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> <5723339E.306@oracle.com> Message-ID: > On Apr 29, 2016, at 5:12 AM, Aleksey Shipilev wrote: > >> On 04/29/2016 01:05 PM, David Holmes wrote: >>> On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: >>>> On 04/29/2016 02:09 AM, David Holmes wrote: >>>> This change is small in nature but somewhat broad in scope. It "affects" >>>> the implementation of System.currentTimeMillis() in the Java space, and >>>> os::javaTimeMillis() in the VM. But on Solaris only. >>>> >>>> I say "affects" but the change will be unobservable other than in terms >>>> of performance. >>> >>> Observable enough to me. >> >> :) Any apps you can think of that might show benefit from this? > > Theoretically, this might affect heavily logging apps. IIRC, SPECjbb2000 > was affected by currentTimeMillis performance. But, I see no reason in > trying to justify the change, apart from the targeted microbenchmark. > > -Aleksey Fwiw, "back in the day" there was a slight gap in perf between Solaris and Windows on SPECjbb2005. That slight gap was attributed to differences in currentTimeMillis overhead. Charlie From amaembo at gmail.com Fri Apr 29 13:31:27 2016 From: amaembo at gmail.com (Tagir F. Valeev) Date: Fri, 29 Apr 2016 19:31:27 +0600 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <57235840.6020904@oracle.com> References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> <498505705.20160429184041@gmail.com> <57235840.6020904@oracle.com> Message-ID: <1910629449.20160429193127@gmail.com> Hello! Thank you for comments. Update: http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r3/ AS> Test: AS> *) Formatting: "i=0", "i *) Formatting: "} catch (NSEE ex)" should be on the same line; Done. AS> *) What does the "for (int i=0; i<3; i++) {" thing test? It tests the idempotence of final iterator state: it returns false from hasNext() and throws from next() no matter how many times you launch these methods. Sometimes poorly written iterators throw NSEE only once, then change state somehow and subsequent hasNext()/next() calls behave differently which violates the contract. For example, something like this would fail my test: if (cursor++ == a.length) throw new NoSuchElementException(); AS> *) No need for "parallel = true", should be fine with sequential; Done. AS> *) The idiom for exception testing is more self-contained: AS> try { AS> itr.next(); AS> fail("Should have thrown NSEE"); AS> } catch (NSEE ex) { AS> // expected AS> } Done. AS> *) Probably need to add these cases too, to boundary-test the null AS> handling: AS> {null} AS> {null, 1} AS> {1, null} AS> {null, null} AS> {null, 1, 2} AS> {1, null, 2} AS> {1, 2, null} AS> {null, null, null} Done. With best regards, Tagir Valeev. From daniel.fuchs at oracle.com Fri Apr 29 13:35:44 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Fri, 29 Apr 2016 15:35:44 +0200 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <5723339E.306@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> <5723339E.306@oracle.com> Message-ID: <6f257e7e-d6b8-e489-86d3-6948af564e0f@oracle.com> Hi Aleksey, On 29/04/16 12:12, Aleksey Shipilev wrote: > On 04/29/2016 01:05 PM, David Holmes wrote: >> On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: >>> On 04/29/2016 02:09 AM, David Holmes wrote: >>>> This change is small in nature but somewhat broad in scope. It "affects" >>>> the implementation of System.currentTimeMillis() in the Java space, and >>>> os::javaTimeMillis() in the VM. But on Solaris only. >>>> >>>> I say "affects" but the change will be unobservable other than in terms >>>> of performance. >>> >>> Observable enough to me. >> >> :) Any apps you can think of that might show benefit from this? > > Theoretically, this might affect heavily logging apps. IIRC, SPECjbb2000 > was affected by currentTimeMillis performance. But, I see no reason in > trying to justify the change, apart from the targeted microbenchmark. If by "logging" you mean java.util.logging then this should have no effect as logging now calls os::javaTimeSystemUTC (through java.time), to get more precise time stamps. best regards, -- daniel > > -Aleksey > From claes.redestad at oracle.com Fri Apr 29 13:38:48 2016 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 29 Apr 2016 15:38:48 +0200 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <1910629449.20160429193127@gmail.com> References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> <498505705.20160429184041@gmail.com> <57235840.6020904@oracle.com> <1910629449.20160429193127@gmail.com> Message-ID: <572363E8.4010102@oracle.com> On 2016-04-29 15:31, Tagir F. Valeev wrote: > Hello! > > Thank you for comments. Update: > http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r3/ Looks good. Thanks! /Claes From aleksey.shipilev at oracle.com Fri Apr 29 13:41:30 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Fri, 29 Apr 2016 16:41:30 +0300 Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <572363E8.4010102@oracle.com> References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> <498505705.20160429184041@gmail.com> <57235840.6020904@oracle.com> <1910629449.20160429193127@gmail.com> <572363E8.4010102@oracle.com> Message-ID: <5723648A.2070908@oracle.com> On 04/29/2016 04:38 PM, Claes Redestad wrote: > On 2016-04-29 15:31, Tagir F. Valeev wrote: >> Hello! >> >> Thank you for comments. Update: >> http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r3/ > > Looks good. Okay, good! I'll sponsor. Thanks, -Aleksey From charlie.hunt at oracle.com Fri Apr 29 13:46:31 2016 From: charlie.hunt at oracle.com (charlie hunt) Date: Fri, 29 Apr 2016 08:46:31 -0500 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <6f257e7e-d6b8-e489-86d3-6948af564e0f@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> <5723339E.306@oracle.com> <6f257e7e-d6b8-e489-86d3-6948af564e0f@oracle.com> Message-ID: <64C391E3-9FFC-4101-BD86-9F0936860677@oracle.com> > On Apr 29, 2016, at 8:35 AM, Daniel Fuchs wrote: > > Hi Aleksey, > > On 29/04/16 12:12, Aleksey Shipilev wrote: >> On 04/29/2016 01:05 PM, David Holmes wrote: >>> On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: >>>> On 04/29/2016 02:09 AM, David Holmes wrote: >>>>> This change is small in nature but somewhat broad in scope. It "affects" >>>>> the implementation of System.currentTimeMillis() in the Java space, and >>>>> os::javaTimeMillis() in the VM. But on Solaris only. >>>>> >>>>> I say "affects" but the change will be unobservable other than in terms >>>>> of performance. >>>> >>>> Observable enough to me. >>> >>> :) Any apps you can think of that might show benefit from this? >> >> Theoretically, this might affect heavily logging apps. IIRC, SPECjbb2000 >> was affected by currentTimeMillis performance. But, I see no reason in >> trying to justify the change, apart from the targeted microbenchmark. > > If by "logging" you mean java.util.logging then this should have no > effect as logging now calls os::javaTimeSystemUTC (through java.time), > to get more precise time stamps. > > best regards, > > ? daniel I think Alexey means getting timestamps via System.currentTimeMillis() and internal JVM?s os::javaTimeMillis(), (which could have included logging). That was the intention with my comment wrt SPECjbb2005, (of which was of similar flavor as SPECjbb2000). The good news (to me anyway) is SPECjbb2000 and SPECjbb2005 have been retired in favor of SPECjbb2015. hths, charlie > >> >> -Aleksey From Roger.Riggs at Oracle.com Fri Apr 29 14:19:36 2016 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 29 Apr 2016 10:19:36 -0400 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <64C391E3-9FFC-4101-BD86-9F0936860677@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> <5723339E.306@oracle.com> <6f257e7e-d6b8-e489-86d3-6948af564e0f@oracle.com> <64C391E3-9FFC-4101-BD86-9F0936860677@oracle.com> Message-ID: <45182d6e-34d0-d93b-c28a-5c99fc260cb6@Oracle.com> Hi, This change seems fine to me; though barely observable only in a microcosm. (I was going to make the same comment as Daniel, logging now uses higher resolution timestamps). Roger On 4/29/2016 9:46 AM, charlie hunt wrote: >> On Apr 29, 2016, at 8:35 AM, Daniel Fuchs wrote: >> >> Hi Aleksey, >> >> On 29/04/16 12:12, Aleksey Shipilev wrote: >>> On 04/29/2016 01:05 PM, David Holmes wrote: >>>> On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: >>>>> On 04/29/2016 02:09 AM, David Holmes wrote: >>>>>> This change is small in nature but somewhat broad in scope. It "affects" >>>>>> the implementation of System.currentTimeMillis() in the Java space, and >>>>>> os::javaTimeMillis() in the VM. But on Solaris only. >>>>>> >>>>>> I say "affects" but the change will be unobservable other than in terms >>>>>> of performance. >>>>> Observable enough to me. >>>> :) Any apps you can think of that might show benefit from this? >>> Theoretically, this might affect heavily logging apps. IIRC, SPECjbb2000 >>> was affected by currentTimeMillis performance. But, I see no reason in >>> trying to justify the change, apart from the targeted microbenchmark. >> If by "logging" you mean java.util.logging then this should have no >> effect as logging now calls os::javaTimeSystemUTC (through java.time), >> to get more precise time stamps. >> >> best regards, >> >> ? daniel > I think Alexey means getting timestamps via System.currentTimeMillis() and internal JVM?s os::javaTimeMillis(), (which could have included logging). That was the intention with my comment wrt SPECjbb2005, (of which was of similar flavor as SPECjbb2000). The good news (to me anyway) is SPECjbb2000 and SPECjbb2005 have been retired in favor of SPECjbb2015. > > hths, > > charlie > >>> -Aleksey From forax at univ-mlv.fr Fri Apr 29 14:20:57 2016 From: forax at univ-mlv.fr (Remi Forax) Date: Fri, 29 Apr 2016 16:20:57 +0200 (CEST) Subject: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() In-Reply-To: <572363E8.4010102@oracle.com> References: <1733186081.20160428133710@gmail.com> <572215B8.1070709@oracle.com> <498505705.20160429184041@gmail.com> <57235840.6020904@oracle.com> <1910629449.20160429193127@gmail.com> <572363E8.4010102@oracle.com> Message-ID: <1897648696.4681238.1461939657977.JavaMail.zimbra@u-pem.fr> Hi all, Just nitpicking, i wonder if it's not better to use the Doug Lea's convention in next() i.e. rename i to cursor to shadow the field cursor public E next() { int cursor = this.cursor; if (cursor >= a.length) { throw new NoSuchElementException(); } this.cursor = cursor + 1; return a[cursor]; } also ArrayItr should be marked final. regards, R?mi ----- Mail original ----- > De: "Claes Redestad" > ?: "Tagir F. Valeev" , "Aleksey Shipilev" > Cc: "core-libs-dev" > Envoy?: Vendredi 29 Avril 2016 15:38:48 > Objet: Re: RFR: 8155600 - Performance optimization of Arrays.asList().iterator() > > On 2016-04-29 15:31, Tagir F. Valeev wrote: > > Hello! > > > > Thank you for comments. Update: > > http://cr.openjdk.java.net/~tvaleev/webrev/8155600/r3/ > > Looks good. > > Thanks! > > /Claes > From Alan.Bateman at oracle.com Fri Apr 29 14:32:20 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 15:32:20 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> Message-ID: <57237074.6050608@oracle.com> On 28/04/2016 22:18, Steve Drach wrote: > I?ve updated the webrev to change all instances of the word ?reified? > to ?real? as in getRealName(). > > Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 > > Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev.01/ > > The src changes looks okay but did we come to a conclusion on URLClassLoader spec? If not, can we revert the change to URLClassPath getLoader and deal with it separately? -Alan From daniel.fuchs at oracle.com Fri Apr 29 15:08:09 2016 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Fri, 29 Apr 2016 17:08:09 +0200 Subject: RFR: 8139982 Re-examine java.management dependency on java.util.logging.LoggingMXBean Message-ID: Hi, Please find below a patch [2] that eliminates a static dependency of java.lang.management on java.util.logging.LoggingMXBean. When JDK-6876135 was fixed, it introduced the PlatformLoggingMXBean interface, and recommended using PlatformLoggingMXBean over LoggingMXBean. However, it left a static dependency on java.util.logging.LoggingMXBean in java.lang.management: The MBean registered in the MBeanServer was a private class in ManagementFactoryHelper implementing a non standard interface that extended both PlatformLoggingMXBean and LoggingMXBean. (sun.management.ManagementFactoryHelper$LoggingMXBean) (see https://bugs.openjdk.java.net/browse/JDK-6876135) This patch proposes to relax the constraint on the PlatformLoggingMXBean implementation - by no longer forcing it to implement LoggingMXBean. This will allow to get rid of the non standard interface, and make the MBean declare "java.lang.management.PlatformLoggingMXBean" as its MXBean interface. To make it clear that PlatformLoggingMXBean should be used instead of LoggingMXBean we also propose to deprecate the java.util.logging.LoggingMXBean interface as well as the LogManager.getLoggingMXBean() method (since it returns a deprecated type). As of yet, there no intention of removing any of these. Backward Compatibility considerations: -------------------------------------- 1. Local clients which obtain an instance of the logging MXBean by calling ManagementFactory.getPlatformMXBean( "java.util.logging:type=Logging", PlatformLoggingMXBean.class) will no longer be able to cast the result on java.util.logging.LoggingMXBean. [There should be few, given that PlatformLoggingMXBean already has all the methods defined in LoggingMXBean] 2. ManagementFactory.getPlatformMBeanServer().isInstanceOf( ObjectName, "java.util.logging.LoggingMXBean") will now return 'false' instead of 'true'. 3. The Logging MXBean MBeanInfo will now report that its management interface is "java.lang.management.PlatformLoggingMXBean" instead of "sun.management.ManagementFactoryHelper$LoggingMXBean". 4. Calls to ManagementFactory.newPlatformMXBeanProxy( MBeanServerConnection, ObjectName, java.util.logging.LoggingMXBean.class); and JMX.newMXBeanProxy(MBeanServerConnection, ObjectName, java.util.logging.LoggingMXBean.class) will continue to work as before. 5. Remote clients running previous version of the JDK should see no changes, except for the interface name in MBeanInfo, and the change in isInstanceOf reported in 2. [1] JBS issue: https://bugs.openjdk.java.net/browse/JDK-8139982 [2] webrev: http://cr.openjdk.java.net/~dfuchs/8139982_webrev/webrev.06/index.html best regards, -- daniel From andrej.golovnin at gmail.com Fri Apr 29 15:30:06 2016 From: andrej.golovnin at gmail.com (Andrej Golovnin) Date: Fri, 29 Apr 2016 17:30:06 +0200 Subject: RFR(m): 8140281 deprecate Optional.get() In-Reply-To: <81e28d81-0642-13f6-eb95-f120638edbe2@gmail.com> References: <1282fc0c-2d92-be13-d95e-9486cd556146@oracle.com> <571EA9D8.3010702@oracle.com> <57207AD8.6000204@javaspecialists.eu> <81e28d81-0642-13f6-eb95-f120638edbe2@gmail.com> Message-ID: Hi Peter, > ...even more Stream-y (with JDK 9 changes to Optional): > > otherMods > .stream() > .flatMap(mod -> finder.find(mod).stream()) > .forEach(mref -> ...); > > > Yes, it takes some time for people to get used to new tools before they use them optimally. This is a normal learning process. So I wonder whether it is only the method name that is to blame for the observed percentage of wrong or sub-optimal usages of Optional or would it be more-or-less the same with a more descriptive name at this time. > > But the argument that getWhenPresent() is easier to spot than get() when reading code is on spot so at least some bugs would get spotted more quickly if the method stood out. Even when you call this new method Optional.dudeCallIsPresentBeforeCallingMe() it won't help. Against the stupidity, the inability to read JavaDocs and the laziness helps only a compiler error. Therefore when you really want to help developers to avoid bugs due to wrong usage of Optional.get(), then you must change the compiler to recognize the usage of Optional.get() without the isPresent()-check and to raise an error in such cases. I mean if IntelliJ is able to give you a hint that you use Optional.get() without the isPresent()-check, then the Java compiler should be able to do it too. Just my two cents. Best regards, Andrej Golovnin From steve.drach at oracle.com Fri Apr 29 15:55:43 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 08:55:43 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <57237074.6050608@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> Message-ID: <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> >> I?ve updated the webrev to change all instances of the word ?reified? to ?real? as in getRealName(). >> >> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 >> >> Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev.01/ >> > The src changes looks okay but did we come to a conclusion on URLClassLoader spec? If not, can we revert the change to URLClassPath getLoader and deal with it separately? If we revert the change to URLClassPath, then we can?t read multi-release jars referenced by the ?jar:{file,http}:/some/path/mr.jar!/? form of a URL. These jars would be treated as non-versioned. That would mean that a jar referenced by the URL jar:file:/some/path/mr.jar!/ and one referenced by the URL file:/some/path/mr.jar could supply different classes for the same requested entry. Is that what we want? From jaroslav at kamenik.cz Fri Apr 29 16:17:08 2016 From: jaroslav at kamenik.cz (=?UTF-8?Q?Jaroslav_Kamen=C3=ADk?=) Date: Fri, 29 Apr 2016 18:17:08 +0200 Subject: Integer/Long reverse bits optimization In-Reply-To: <572354B7.7070005@oracle.com> References: <572354B7.7070005@oracle.com> Message-ID: Hi, thank you:) I have OCA signed and processed. I have changed Integer.reverseBytes, and added two small checks to BitTwiddle tests for Integer and Long, patch is attached. Jaroslav 2016-04-29 14:33 GMT+02:00 Claes Redestad : > Hi, > > > On 2016-04-29 13:36, Jaroslav Kamen?k wrote: > >> Hello! >> >> I have a small patch to Integer and Long classes, which is speeding up bit >> reversion significantly. >> >> Last two/three steps of bit reversion are doing byte reversion, so there >> is >> possibility to use >> intrinsified method reverseBytes. Java implementation of reverseBytes is >> similar to those >> steps, so it should give similar performance when intrinsics are not >> available. Here I have >> result of few performance tests (thank for hints, Aleksej:) : >> >> >> old code: >> >> # VM options: -server >> ReverseInt.reverse 1 avgt 5 8,766 ? 0,214 ns/op >> ReverseLong.reverse 1 avgt 5 9,992 ? 0,165 ns/op >> >> # VM options: -client >> ReverseInt.reverse 1 avgt 5 9,168 ? 0,268 ns/op >> ReverseLong.reverse 1 avgt 5 9,988 ? 0,123 ns/op >> >> >> patched: >> >> # VM options: -server >> ReverseInt.reverse 1 avgt 5 6,411 ? 0,046 ns/op >> ReverseLong.reverse 1 avgt 5 6,299 ? 0,158 ns/op >> >> # VM options: -client >> ReverseInt.reverse 1 avgt 5 6,430 ? 0,022 ns/op >> ReverseLong.reverse 1 avgt 5 6,301 ? 0,097 ns/op >> >> >> patched, intrinsics disabled: >> >> # VM options: -server -XX:DisableIntrinsic=_reverseBytes_i,_reverseBytes_l >> ReverseInt.reverse 1 avgt 5 9,597 ? 0,206 ns/op >> ReverseLong.reverse 1 avgt 5 9,966 ? 0,151 ns/op >> >> # VM options: -client -XX:DisableIntrinsic=_reverseBytes_i,_reverseBytes_l >> ReverseInt.reverse 1 avgt 5 9,609 ? 0,069 ns/op >> ReverseLong.reverse 1 avgt 5 9,968 ? 0,075 ns/op >> >> >> >> You can see, there is little slowdown in integer case with intrinsics >> disabled. >> It seems to be caused by different 'shape' of byte reverting code in >> Integer.reverse and Integer.reverseByte. I tried to replace reverseByte >> code >> with piece of reverse method, and it is as fast as not patched case: >> >> >> ReverseInt.reverse 1 avgt 5 9,184 ? 0,255 ns/op >> >> >> Diffs from jdk9: >> >> Integer.java: >> >> @@ -1779,9 +1805,8 @@ >> i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555; >> i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333; >> i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f; >> - i = (i << 24) | ((i & 0xff00) << 8) | >> - ((i >>> 8) & 0xff00) | (i >>> 24); >> - return i; >> + >> + return reverseBytes(i); >> >> Long.java: >> >> @@ -1940,10 +1997,8 @@ >> i = (i & 0x5555555555555555L) << 1 | (i >>> 1) & >> 0x5555555555555555L; >> i = (i & 0x3333333333333333L) << 2 | (i >>> 2) & >> 0x3333333333333333L; >> i = (i & 0x0f0f0f0f0f0f0f0fL) << 4 | (i >>> 4) & >> 0x0f0f0f0f0f0f0f0fL; >> - i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & >> 0x00ff00ff00ff00ffL; >> - i = (i << 48) | ((i & 0xffff0000L) << 16) | >> - ((i >>> 16) & 0xffff0000L) | (i >>> 48); >> - return i; >> + >> + return reverseBytes(i); >> > > reduces code duplication, improves performance... what's the catch!? :-) > > Updating Integer.reverseByte to have the same 'shape' as in > Integer.reverseByte seems reasonable in this case. > > I can sponsor this if you've signed the OCA etc. > > Thanks! > > /Claes > -------------- next part -------------- A non-text attachment was scrubbed... Name: reverse.patch Type: text/x-patch Size: 2807 bytes Desc: not available URL: From paul.sandoz at oracle.com Fri Apr 29 16:52:48 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 29 Apr 2016 09:52:48 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <57237074.6050608@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> Message-ID: <18598F75-5683-4FBE-9618-B05AC5BFD82D@oracle.com> > On 29 Apr 2016, at 07:32, Alan Bateman wrote: > > > > On 28/04/2016 22:18, Steve Drach wrote: >> I?ve updated the webrev to change all instances of the word ?reified? to ?real? as in getRealName(). >> >> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 >> >> Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev.01/ >> > The src changes looks okay but did we come to a conclusion on URLClassLoader spec? If not, can we revert the change to URLClassPath getLoader and deal with it separately? > AFAICT this fix does not really change the existing implementation behaviour of URLClassLoader and URLClassPath. The patch redirects the processing of ?jar:?/!? from the more general URLClassPath.Loader to the URLClassPath.JarLoader. But i think the cracking of the URL within the jar URL can be made more robust. It probably should use file.indexOf(?!/?) to check there is just one occurrence at the end. Separately the spec of URLClassLoader could be clarified as to the current implementation behaviour. Paul. From Alan.Bateman at oracle.com Fri Apr 29 17:00:09 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 18:00:09 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> Message-ID: <57239319.1060901@oracle.com> On 29/04/2016 16:55, Steve Drach wrote: >>> I?ve updated the webrev to change all instances of the word >>> ?reified? to ?real? as in getRealName(). >>> >>> Issue: https://bugs.openjdk.java.net/browse/JDK-8151542 >>> >>> Webrev: http://cr.openjdk.java.net/~sdrach/8151542/webrev.01/ >>> >>> >> The src changes looks okay but did we come to a conclusion on >> URLClassLoader spec? If not, can we revert the change to URLClassPath >> getLoader and deal with it separately? > > If we revert the change to URLClassPath, then we can?t read > multi-release jars referenced by the > ?jar:{file,http}:/some/path/mr.jar!/? form of a URL. These jars would > be treated as non-versioned. That would mean that a jar referenced by > the URL jar:file:/some/path/mr.jar!/ and one referenced by the URL > file:/some/path/mr.jar could supply different classes for the same > requested entry. Is that what we want? > So you are planning to eventually change the URLClassLoader spec to allow this or not? -Alan. From steve.drach at oracle.com Fri Apr 29 18:36:45 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 11:36:45 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <57239319.1060901@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> Message-ID: <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> I put a new webrev out with the change suggested by Paul, using file.indexOf(?!/?) instead of file.endsWith(?!/?). http://cr.openjdk.java.net/~sdrach/8151542/webrev.02/index.html > So you are planning to eventually change the URLClassLoader spec to allow this or not? I think we should push this changeset since URLClassLoader has always accepted the jar:?!/ URL and all this changeset does is enable it to support multi-release jars. And create an issue to track the change to the URLClassLoader api. From mandy.chung at oracle.com Fri Apr 29 19:55:22 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 29 Apr 2016 12:55:22 -0700 Subject: RFR: 8139982 Re-examine java.management dependency on java.util.logging.LoggingMXBean In-Reply-To: References: Message-ID: <63AA09C6-F10E-46A8-B207-AF22BE3D50B1@oracle.com> Hi Daniel, > On Apr 29, 2016, at 8:08 AM, Daniel Fuchs wrote: > > Hi, > > Please find below a patch [2] that eliminates a static > dependency of java.lang.management on java.util.logging.LoggingMXBean. > > When JDK-6876135 was fixed, it introduced the PlatformLoggingMXBean > interface, and recommended using PlatformLoggingMXBean over > LoggingMXBean. Adding to this, JDK-6876135 prepared the JDK for modularization and PlatformLoggingMXBean was introduced that can be replaced with existing usage of LoggingMXBean. With this change, java.management dependency on java.logging will become implementation details for logging purpose and can be eliminated completely in the future. About the deprecation, to be specific, LoggingMXBean will no longer be a platform MXBean and an instance of LoggingMXBean will not register in the platform MBeanServer. This is a revised wording for the deprecation note for LoggingMXBean: @deprecated {@code LoggingMXBean} is no longer a {@link java.lang.management.PlatformManagedObject platform MXBean} and replaced with {@link java.lang.management.PlatformLoggingMXBean}. It will not register in the platform MBeanServer. Use {@code ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)} instead. One question about: ManagementFactory::getPlatformMXBean(MBeanServerConnection, PlatformLoggingMXBean.class) - what would happen if this method is called from an image with java.logging module present and connect to a VM with no java.logging module? Should the ManagementFactory::getPlatformMXBean spec or PlatformLoggingMXBean spec be clarified? ManagementFactoryHelper.java 191 if (result != null) { 192 LoggingMXBeanSupport.class.getModule().addReads(m); 193 } Reflection access assumes readability now: http://openjdk.java.net/projects/jigsaw/spec/issues/#ReflectionWithoutReadability So this addReads is not needed. 252 final Map methods = AccessController.doPrivileged( 253 new PrivilegedAction<>() { 254 @Override 255 public Map run() { 256 return initMethodMap(impl); 257 } 258 }); I believe this doPrivileged is not necessary and so do the other getMethod calls. Probably you are thinking ahead what if java.management may one day be defined by a child loader of the defining loader of java.logging. Then you can move doPrivileged to initMethodMap. 217 // skip - better to throw InternalError since it expects all methods are used? 273 throw new SecurityException(ex); - should not reach here. SecurityException may cause confusion since this will be thrown even without security manager. could simply throw InternalException 296 private PlatformLoggingImpl(LoggingMXBeanSupport support) { - perhaps renaming LoggingMXBeanSupport to LoggingProxy to better represent it. > > Backward Compatibility considerations: > -------------------------------------- > > 1. Local clients which obtain an instance of the logging > MXBean by calling ManagementFactory.getPlatformMXBean( > "java.util.logging:type=Logging", > PlatformLoggingMXBean.class) > will no longer be able to cast the result on > java.util.logging.LoggingMXBean. > [There should be few, given that PlatformLoggingMXBean > already has all the methods defined in LoggingMXBean] > I expect this would be really rare too. > 2. ManagementFactory.getPlatformMBeanServer().isInstanceOf( > ObjectName, "java.util.logging.LoggingMXBean") > will now return 'false' instead of 'true'. > > 3. The Logging MXBean MBeanInfo will now report that its > management interface is "java.lang.management.PlatformLoggingMXBean" > instead of "sun.management.ManagementFactoryHelper$LoggingMXBean?. Any impact to permission confiugred in security policy? Should also document that. > 4. Calls to ManagementFactory.newPlatformMXBeanProxy( > MBeanServerConnection, ObjectName, > java.util.logging.LoggingMXBean.class); and > JMX.newMXBeanProxy(MBeanServerConnection, ObjectName, > java.util.logging.LoggingMXBean.class) > will continue to work as before. > > 5. Remote clients running previous version of the JDK > should see no changes, except for the interface > name in MBeanInfo, and the change in isInstanceOf > reported in 2. This is good. The incompatibility risk for this change is rather low. Mandy From john.r.rose at oracle.com Fri Apr 29 19:56:24 2016 From: john.r.rose at oracle.com (John Rose) Date: Fri, 29 Apr 2016 12:56:24 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <50CFC7C1-5338-440C-B53F-7BA2F067E46D@oracle.com> References: <2DE15C5A-53F3-4E41-BA1A-9DB5715BC42B@oracle.com> <8673E85F-3774-45E8-9DE8-602003411884@oracle.com> <865CEDEB-2977-4A40-AF1A-643F7CC67BE3@oracle.com> <50CFC7C1-5338-440C-B53F-7BA2F067E46D@oracle.com> Message-ID: On Apr 28, 2016, at 11:26 AM, Steve Drach wrote: > > Keeping with the path precedent, is it acceptable to change ?getReifiedName? to ?getRealName?? For me, in this setting, "true" and "real" are equally good. (Perhaps they differ metaphysically, but that's too many for me.) So, yes, nio.Path says "real", and I'm happy with that. Thanks, ? John > >>>> >>>> Diction Note: Reified X means X wasn't real (in some sense) until now. As in non-reified types, which are not real at runtime because the static compiler discarded them. >>>> >>> >>> I suggested reified because i thought it fit with the notion of making something abstract more concrete, but perhaps this just confuses matters? >> >> It's the real name, but since it already exists (because that's how it is stored) it isn't really reified, it's just revealed. >> >> This API uses the term "real name" for an almost identical phenomenon (target of a sym-link in a file system): >> >> https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toRealPath-java.nio.file.LinkOption...- >> >> In a versioned jar, the logical names are sometimes mapped to other names under which the elements are actually stored. >> Thus, they behave like sym-links. (But with a bit of control context thrown in, the active version.) >> >> On old-fashioned file systems with real version numbers, the Common Lisp function TRUENAME does exactly what you are trying to do here. >> >> http://www.mathcs.duq.edu/simon/Gcl/gcl_1141.html >> >> (And in some way, we are sliding down the slope toward re-inventing those file systems, aren't we?) >> >> The older pre-nio API for File calls it "getCanonicalPath", but I think "true name" is better than >> "canonical name", since "canonical" means "follows the rules", rather than what we need in this case, >> which is "where it really is stored". >> >> http://docs.oracle.com/javase/8/docs/api/java/io/File.html#getCanonicalPath-- >> >>> >>>> In this case it appears you are simply exposing a translated name, not making it real for the first time. >>>> >>>> If this is true, I think you want to say "true name" or "real name" or "translated name", not "reified name?. >>> >>> or ?versioned name" would work for me. >> >> I'm just whinging about the term "reified" which doesn't seem to work, logically. >> >> "Versioned name" would work for me too. But "true name" has the two good precedents cited above. >> >> ? John > From martinrb at google.com Fri Apr 29 20:03:44 2016 From: martinrb at google.com (Martin Buchholz) Date: Fri, 29 Apr 2016 13:03:44 -0700 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: <572321E1.2030702@oracle.com> References: <57208325.6080907@oracle.com> <57208E06.2060809@oracle.com> <572321E1.2030702@oracle.com> Message-ID: Today, I tried google-searching for "LinkedList se 9" which sent me to http://download.java.net/jdk9/docs/api/java/util/LinkedList.html?is-external=true which gives me 404. That's an improvement on the stale +104 docs, and should prod Google's engine into learning about better docs, but it may still take a while. Redirection could be improved. I tried "binging" "LinkedList se 9" and it gave me the same result. Like I always say, populate the final jdk 9 docs directory from the very first EA build! On Fri, Apr 29, 2016 at 1:57 AM, Alan Bateman wrote: > > On 27/04/2016 12:26, Martin Buchholz wrote: >> >> I think the jdk9 docs have moved (again, grrrr - I complain about this >> sort of thing every release) and so a google search for "package class >> se 9" only finds the old one +104 at >> http://download.java.net/jdk9/docs/api/java/lang/Package.html >> Why can't there be a redirect instead of leaving the old docs in place? >> > The infrastructure that publishes the builds and docs on java.net is several > steps removed from most of us here but from what I understand, the stale > docs have been purged and a redirect from the old location to the new > location is in place. > > When I search for "jdk 9 docs" now then Google serves up this link > http://download.java.net/jdk9/docs/api/index.html?help-doc.html > > and I get redirected to the docs at: > http://download.java.net/java/jdk9/docs/api/index.html > > -Alan From xueming.shen at oracle.com Fri Apr 29 20:37:58 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 29 Apr 2016 13:37:58 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> Message-ID: <5723C626.3020201@oracle.com> JarFile.getRealName() invokes e.realEntry().getName() to get the "realname", which may create a new JarFileEntry() if the names are different. Shouldn't the realname just be the "super.getName()" ? sherman On 04/29/2016 11:36 AM, Steve Drach wrote: > I put a new webrev out with the change suggested by Paul, using file.indexOf(?!/?) instead of file.endsWith(?!/?). > > http://cr.openjdk.java.net/~sdrach/8151542/webrev.02/index.html > >> So you are planning to eventually change the URLClassLoader spec to allow this or not? > I think we should push this changeset since URLClassLoader has always accepted the jar:?!/ URL and all this changeset does is enable it to support multi-release jars. And create an issue to track the change to the URLClassLoader api. > From Alan.Bateman at oracle.com Fri Apr 29 20:46:48 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 21:46:48 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> Message-ID: <5723C838.3010804@oracle.com> On 29/04/2016 19:36, Steve Drach wrote: > I put a new webrev out with the change suggested by Paul, using > file.indexOf(?!/?) instead of file.endsWith(?!/?). > > http://cr.openjdk.java.net/~sdrach/8151542/webrev.02/index.html > This still needs to be fixed to compare the URL protocol without regard to case (yes, some of the old code isn't right but best not to make it worss). > >> So you are planning to eventually change the URLClassLoader spec to >> allow this or not? > > I think we should push this changeset since URLClassLoader has always > accepted the jar:?!/ URL and all this changeset does is enable it to > support multi-release jars. And create an issue to track the change > to the URLClassLoader api. > There shouldn't be any urgency with this change going in but if you are doing it this way then please create a high priority bug to get the spec and implementation aligned. -Alan From steve.drach at oracle.com Fri Apr 29 21:12:33 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 14:12:33 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5723C838.3010804@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> Message-ID: <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> >> I put a new webrev out with the change suggested by Paul, using file.indexOf(?!/?) instead of file.endsWith(?!/?). >> >> http://cr.openjdk.java.net/~sdrach/8151542/webrev.02/index.html This still needs to be fixed to compare the URL protocol without regard to case (yes, some of the old code isn't right but best not to make it worss). Okay. > >> >>> So you are planning to eventually change the URLClassLoader spec to allow this or not? >> >> I think we should push this changeset since URLClassLoader has always accepted the jar:?!/ URL and all this changeset does is enable it to support multi-release jars. And create an issue to track the change to the URLClassLoader api. >> > There shouldn't be any urgency with this change going in but if you are doing it this way then please create a high priority bug to get the spec and implementation aligned. Remember that I?ve not really changed anything, just enhanced what already exists to support multi-release jar files. I submitted a bug, JDK-8155770, but I marked it as P4 according to the standard classifications: P1 - Blocks development and/or testing work, production could not run. P2 - Crashes, loss of data, severe memory leak. P3 - Major loss of function. P4 - Minor loss of function, or other problem where easy workaround is present. I just didn?t see it as any higher than P4. What would you like it to be? From Alan.Bateman at oracle.com Fri Apr 29 21:41:27 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 22:41:27 +0100 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> Message-ID: <5723D507.7050302@oracle.com> On 29/04/2016 22:12, Steve Drach wrote: > > I just didn?t see it as any higher than P4. What would you like it to be? > We've stumbled on an issue where the spec and implementation are in conflict. The right thing to do it to fix it while we have a handle on it. -Alan From stuart.marks at oracle.com Fri Apr 29 21:49:40 2016 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 29 Apr 2016 14:49:40 -0700 Subject: RFR 8147984: WindowsTerminal should support function keys In-Reply-To: <56A21578.5080105@oracle.com> References: <56A21578.5080105@oracle.com> Message-ID: Hi Jan, I finally got a chance to take a look at this. The change looks fine. It would be nice to have a reference to where the escape sequences are documented. There are links to the Windows VK_ codes there, which is great. But there's no reference for the escape sequences that each keypress is mapped to, e.g. F4 is "ESC O S", and F5 is "ESC [ 1 5 ~" (and what happened to "ESC [ 1 6 ~"??) I did some searching, and it seems really hard to find a definitive reference. Perhaps the best reference is "XTerm Control Sequences" [1] which seems to document xterm pretty thoroughly, which is what everybody seems to follow nowadays. It even looks like it's being kept up to date (last modified 2016-02-21). Anyway I'd suggest adding a comment with a reference to this document. As a cross-check, these sequences match what my Mac's Terminal.app emits, at least for unshifted F1-F12. (The Terminal app was probably copied from xterm.) Thanks, s'marks [1] http://invisible-island.net/xterm/ctlseqs/ctlseqs.html On 1/22/16 3:41 AM, Jan Lahoda wrote: > Hello, > > I'd like to enhance the WindowsTerminal in jdk.internal.le with function keys > handling. The intent is so that jshell can bind actions for shortcuts including > function keys. > > The patch for adding the function keys support is here: > http://cr.openjdk.java.net/~jlahoda/8147984/webrev.00/ > > An example of a feature that uses/may use this support is here: > http://mail.openjdk.java.net/pipermail/kulla-dev/2016-January/001226.html > > Any comments are welcome! > > Thanks, > Jan From Alan.Bateman at oracle.com Fri Apr 29 21:51:17 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Apr 2016 22:51:17 +0100 Subject: RFR(XXS): 8149519: Investigate implementation of java.specification.version In-Reply-To: References: <57208325.6080907@oracle.com> <57208E06.2060809@oracle.com> <572321E1.2030702@oracle.com> Message-ID: <5723D755.6060409@oracle.com> On 29/04/2016 21:03, Martin Buchholz wrote: > Today, I tried google-searching for "LinkedList se 9" which sent me to > http://download.java.net/jdk9/docs/api/java/util/LinkedList.html?is-external=true > which gives me 404. That's an improvement on the stale +104 docs, and > should prod Google's engine into learning about better docs, but it > may still take a while. Redirection could be improved. > I tried "binging" "LinkedList se 9" and it gave me the same result. > > Like I always say, populate the final jdk 9 docs directory from the > very first EA build! > I completely agree that is poor form to change location. From what I can tell, they've put a redirect from the top level directory to the new location. This should at least keep bookmarks working. Also the stale docs are removed so I assume the search engines will eventually discard their memory of the old locations. -Alan From steve.drach at oracle.com Fri Apr 29 21:59:00 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 14:59:00 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5723D507.7050302@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> <5723D507.7050302@oracle.com> Message-ID: <5E89A276-997C-44E3-B23A-ADA669AF2DF3@oracle.com> >> I just didn?t see it as any higher than P4. What would you like it to be? >> >> > We've stumbled on an issue where the spec and implementation are in conflict. The right thing to do it to fix it while we have a handle on it. I bumped the priority to P2. From aleksey.shipilev at oracle.com Fri Apr 29 22:12:29 2016 From: aleksey.shipilev at oracle.com (Aleksey Shipilev) Date: Sat, 30 Apr 2016 01:12:29 +0300 Subject: RFR (M) 8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures Message-ID: <5723DC4D.8090507@oracle.com> Hi, I would like to fix a simple testbug in our weakCompareAndSet VarHandles and Unsafe intrinsics tests. weakCompareAndSet is spec-ed to allow spurious failures, but current tests do not allow that. This blocks development and testing on non-x86 platforms. Bug: https://bugs.openjdk.java.net/browse/JDK-8155739 Webrevs: http://cr.openjdk.java.net/~shade/8155739/webrev.hs.00/ http://cr.openjdk.java.net/~shade/8155739/webrev.jdk.00/ The tests are auto-generated, and the substantiative changes are in *.template files. I also removed obsolete generate-unsafe-tests.sh. I would like to push through hs-comp to expose this to Power and AArch64 folks early. Testing: x86_64, jdk:java/lang/invoke/VarHandle, hotspot:compiler/unsafe Thanks, -Aleksey From steve.drach at oracle.com Fri Apr 29 22:30:59 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 15:30:59 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5E89A276-997C-44E3-B23A-ADA669AF2DF3@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> <5723D507.7050302@oracle.com> <5E89A276-997C-44E3-B23A-ADA669AF2DF3@oracle.com> Message-ID: <7044D545-58E6-4F6D-B65A-09C19F3D8FBA@oracle.com> I updated the webrev with changes that Alan suggested still needs to be fixed to compare the URL protocol without regard to case And Sherman suggested Shouldn't the realname just be the "super.getName()? ? The webrev is at http://cr.openjdk.java.net/~sdrach/8151542/webrev.03/index.html From david.holmes at oracle.com Fri Apr 29 22:57:26 2016 From: david.holmes at oracle.com (David Holmes) Date: Sat, 30 Apr 2016 08:57:26 +1000 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <45182d6e-34d0-d93b-c28a-5c99fc260cb6@Oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <57232E69.20800@oracle.com> <5723339E.306@oracle.com> <6f257e7e-d6b8-e489-86d3-6948af564e0f@oracle.com> <64C391E3-9FFC-4101-BD86-9F0936860677@oracle.com> <45182d6e-34d0-d93b-c28a-5c99fc260cb6@Oracle.com> Message-ID: (adding back hotspot-dev - still heed a hs/runtime reviewer) Hi Roger, On 30/04/2016 12:19 AM, Roger Riggs wrote: > Hi, > > This change seems fine to me; though barely observable only in a microcosm. Thanks for the review. > (I was going to make the same comment as Daniel, logging now uses higher > resolution timestamps). Good to know. Thanks, David > Roger > > > On 4/29/2016 9:46 AM, charlie hunt wrote: >>> On Apr 29, 2016, at 8:35 AM, Daniel Fuchs >>> wrote: >>> >>> Hi Aleksey, >>> >>> On 29/04/16 12:12, Aleksey Shipilev wrote: >>>> On 04/29/2016 01:05 PM, David Holmes wrote: >>>>> On 29/04/2016 7:50 PM, Aleksey Shipilev wrote: >>>>>> On 04/29/2016 02:09 AM, David Holmes wrote: >>>>>>> This change is small in nature but somewhat broad in scope. It >>>>>>> "affects" >>>>>>> the implementation of System.currentTimeMillis() in the Java >>>>>>> space, and >>>>>>> os::javaTimeMillis() in the VM. But on Solaris only. >>>>>>> >>>>>>> I say "affects" but the change will be unobservable other than in >>>>>>> terms >>>>>>> of performance. >>>>>> Observable enough to me. >>>>> :) Any apps you can think of that might show benefit from this? >>>> Theoretically, this might affect heavily logging apps. IIRC, >>>> SPECjbb2000 >>>> was affected by currentTimeMillis performance. But, I see no reason in >>>> trying to justify the change, apart from the targeted microbenchmark. >>> If by "logging" you mean java.util.logging then this should have no >>> effect as logging now calls os::javaTimeSystemUTC (through java.time), >>> to get more precise time stamps. >>> >>> best regards, >>> >>> ? daniel >> I think Alexey means getting timestamps via System.currentTimeMillis() >> and internal JVM?s os::javaTimeMillis(), (which could have included >> logging). That was the intention with my comment wrt SPECjbb2005, (of >> which was of similar flavor as SPECjbb2000). The good news (to me >> anyway) is SPECjbb2000 and SPECjbb2005 have been retired in favor of >> SPECjbb2015. >> >> hths, >> >> charlie >> >>>> -Aleksey > From paul.sandoz at oracle.com Fri Apr 29 23:16:29 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 29 Apr 2016 16:16:29 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5723C838.3010804@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> Message-ID: <492BAA09-39E3-4AA3-A4A6-900FA54EB356@oracle.com> > On 29 Apr 2016, at 13:46, Alan Bateman wrote: > > > > On 29/04/2016 19:36, Steve Drach wrote: >> I put a new webrev out with the change suggested by Paul, using file.indexOf(?!/?) instead of file.endsWith(?!/?). >> >> http://cr.openjdk.java.net/~sdrach/8151542/webrev.02/index.html > This still needs to be fixed to compare the URL protocol without regard to case (yes, some of the old code isn't right but best not to make it worss). > That triggered me to look at this much more closely. AFAICT URL instances do canonicalize the protocol to lower case, so it?s only where the raw URL characters are checked that this would need to be done. Steve is there a case whereby when you extract the nested URL from a jar URL it would ever get routed to Loader or FileLoader? It seems it would always route to JarLoader. If so, off the top of my head, could you do: String protocol = url.getProtocol(); String file = url.getFile(); if ("jar".equals(protocol) && file != null && file.indexOf("!/") == file.length() - 2) { // jar: protocols URL nestedUrlToJarFile = new URL(file.substring(0, file.length() - 2)); // extract the nested URL return new JarLoader(nestedUrlToJarFile, jarHandler, lmap); } else if ("file".equals(protocol)) { // file: protocols if (file != null && file.endsWith("/?)) { // Exploded from base directory return new FileLoader(url); } else { // Assumed to be a jar file return new JarLoader(url, jarHandler, lmap); } } else { // Fallback to URL connection return new Loader(url); } That makes all the cases much clearer. ? Paul. >> >>> So you are planning to eventually change the URLClassLoader spec to allow this or not? >> >> I think we should push this changeset since URLClassLoader has always accepted the jar:?!/ URL and all this changeset does is enable it to support multi-release jars. And create an issue to track the change to the URLClassLoader api. >> > There shouldn't be any urgency with this change going in but if you are doing it this way then please create a high priority bug to get the spec and implementation aligned. > > -Alan From daniel.daugherty at oracle.com Fri Apr 29 23:28:00 2016 From: daniel.daugherty at oracle.com (Daniel D. Daugherty) Date: Fri, 29 Apr 2016 17:28:00 -0600 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> Message-ID: <5723EE00.7070503@oracle.com> On 4/28/16 5:09 PM, David Holmes wrote: > bug: https://bugs.openjdk.java.net/browse/JDK-8154710 > webrev: http://cr.openjdk.java.net/~dholmes/8154710/webrev/ src/os/solaris/vm/os_solaris.cpp L1356: static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL; nit: two spaced between the type and the var name. Not sure why since you aren't lining up with anything. L4444: Solaris::_pthread_setname_np = // from 11.3 Thanks for documenting the release. L4450: nit: why add a blank line? Thumbs up! Nits only so feel free to fix or ignore, but don't need another webrev. Dan > > This change is small in nature but somewhat broad in scope. It > "affects" the implementation of System.currentTimeMillis() in the Java > space, and os::javaTimeMillis() in the VM. But on Solaris only. > > I say "affects" but the change will be unobservable other than in > terms of performance. > > As of Solaris 11.3.6 a new in-memory timestamp has been made available > (not unlike what has always existed on Windows). There are actually 3 > different timestamps exported but the one we are interested in is > get_nsecs_fromepoch - which is of course elapsed nanoseconds since the > epoch - which is exactly what javaTimeMillis() is, but expressed in > milliseconds. The in-memory timestamps have an update accuracy of 1ms, > so are not suitable for any other API's that want the time-of-day, but > at a greater accuracy. > > Microbenchmark shows the in-memory access is approx 45% faster (19ns > on my test system) compared to the gettimeofday call (35ns). > > Thanks, > David > From paul.sandoz at oracle.com Fri Apr 29 23:42:43 2016 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Fri, 29 Apr 2016 16:42:43 -0700 Subject: RFR (M) 8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures In-Reply-To: <5723DC4D.8090507@oracle.com> References: <5723DC4D.8090507@oracle.com> Message-ID: <76809325-CB53-499E-885B-9ED4AB0DBBB5@oracle.com> > On 29 Apr 2016, at 15:12, Aleksey Shipilev wrote: > > Hi, > > I would like to fix a simple testbug in our weakCompareAndSet VarHandles > and Unsafe intrinsics tests. weakCompareAndSet is spec-ed to allow > spurious failures, but current tests do not allow that. This blocks > development and testing on non-x86 platforms. > > Bug: > https://bugs.openjdk.java.net/browse/JDK-8155739 > > Webrevs: > http://cr.openjdk.java.net/~shade/8155739/webrev.hs.00/ > http://cr.openjdk.java.net/~shade/8155739/webrev.jdk.00/ > Looks good. Small tweak if you so wish to do so: #if[JdkInternalMisc] static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); #end[JdkInternalMisc] which avoids changes to the SunMiscUnsafe* tests. Paul. > The tests are auto-generated, and the substantiative changes are in > *.template files. I also removed obsolete generate-unsafe-tests.sh. I > would like to push through hs-comp to expose this to Power and AArch64 > folks early. > > Testing: x86_64, jdk:java/lang/invoke/VarHandle, hotspot:compiler/unsafe > > Thanks, > -Aleksey > From xueming.shen at oracle.com Fri Apr 29 23:47:37 2016 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 29 Apr 2016 16:47:37 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <7044D545-58E6-4F6D-B65A-09C19F3D8FBA@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> <5723D507.7050302@oracle.com> <5E89A276-997C-44E3-B23A-ADA669AF2DF3@oracle.com> <7044D545-58E6-4F6D-B65A-09C19F3D8FBA@oracle.com> Message-ID: <5723F299.1050203@oracle.com> On 4/29/16 3:30 PM, Steve Drach wrote: > I updated the webrev with changes that Alan suggested > > still needs to be fixed to compare the URL protocol without regard to case -> toLowerCase(Locale.ROOT). > > And Sherman suggested > > Shouldn't the realname just be the "super.getName()? ? > > The webrev is at > http://cr.openjdk.java.net/~sdrach/8151542/webrev.03/index.html > > From steve.drach at oracle.com Sat Apr 30 00:00:51 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 17:00:51 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5723F299.1050203@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> <5723D507.7050302@oracle.com> <5E89A276-997C-44E3-B23A-ADA669AF2DF3@oracle.com> <7044D545-58E6-4F6D-B65A-09C19F3D8FBA@oracle.com> <5723F299.1050203@oracle.com> Message-ID: <22BFF93C-17C1-44A2-BCE3-8B597D911EB4@oracle.com> > On Apr 29, 2016, at 4:47 PM, Xueming Shen wrote: > > On 4/29/16 3:30 PM, Steve Drach wrote: >> I updated the webrev with changes that Alan suggested >> >> still needs to be fixed to compare the URL protocol without regard to case > > -> toLowerCase(Locale.ROOT). Actually it?s already canonicalized in URL, so I don?t need to do it. > >> >> And Sherman suggested >> >> Shouldn't the realname just be the "super.getName()? ? >> >> The webrev is at http://cr.openjdk.java.net/~sdrach/8151542/webrev.03/index.html >> > From steve.drach at oracle.com Sat Apr 30 00:10:25 2016 From: steve.drach at oracle.com (Steve Drach) Date: Fri, 29 Apr 2016 17:10:25 -0700 Subject: RFR: 8151542: URL resources for multi-release jar files have a #runtime fragment appended to them In-Reply-To: <5723F299.1050203@oracle.com> References: <4A20DDA6-0E1F-4AD4-8966-5FC47315CA82@oracle.com> <57237074.6050608@oracle.com> <1F3280AE-A8FF-4F19-87B1-066EB73E6B30@oracle.com> <57239319.1060901@oracle.com> <52BA6F85-48BA-4E63-89BD-56504EEFE68B@oracle.com> <5723C838.3010804@oracle.com> <977D17CB-EE89-43E7-B68A-66CDF768CDB6@oracle.com> <5723D507.7050302@oracle.com> <5E89A276-997C-44E3-B23A-ADA669AF2DF3@oracle.com> <7044D545-58E6-4F6D-B65A-09C19F3D8FBA@oracle.com> <5723F299.1050203@oracle.com> Message-ID: <1F3D7F60-5D0E-4FDD-B253-C05F4619CC4F@oracle.com> Hopefully the last one ;-) This webrev removes the lowercase of protocol, and incorporates better (in my mind) seperation of choices for choosing the loader, similar to what Paul suggested. Everything else remains the same. Only URLClassPath changed from previous webrev. http://cr.openjdk.java.net/~sdrach/8151542/webrev.04/index.html From david.holmes at oracle.com Sat Apr 30 01:49:53 2016 From: david.holmes at oracle.com (David Holmes) Date: Sat, 30 Apr 2016 11:49:53 +1000 Subject: (S) RFR: 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's In-Reply-To: <5723EE00.7070503@oracle.com> References: <6a343a65-c2bf-475d-88de-0ec5c337e296@oracle.com> <5723EE00.7070503@oracle.com> Message-ID: On 30/04/2016 9:28 AM, Daniel D. Daugherty wrote: > On 4/28/16 5:09 PM, David Holmes wrote: >> bug: https://bugs.openjdk.java.net/browse/JDK-8154710 >> webrev: http://cr.openjdk.java.net/~dholmes/8154710/webrev/ > > src/os/solaris/vm/os_solaris.cpp > L1356: static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL; > nit: two spaced between the type and the var name. > Not sure why since you aren't lining up with anything. > > L4444: Solaris::_pthread_setname_np = // from 11.3 > Thanks for documenting the release. > > L4450: > nit: why add a blank line? > > Thumbs up! Nits only so feel free to fix or ignore, but don't > need another webrev. Thanks for the review Dan - will nit fix. :) David > Dan > > >> >> This change is small in nature but somewhat broad in scope. It >> "affects" the implementation of System.currentTimeMillis() in the Java >> space, and os::javaTimeMillis() in the VM. But on Solaris only. >> >> I say "affects" but the change will be unobservable other than in >> terms of performance. >> >> As of Solaris 11.3.6 a new in-memory timestamp has been made available >> (not unlike what has always existed on Windows). There are actually 3 >> different timestamps exported but the one we are interested in is >> get_nsecs_fromepoch - which is of course elapsed nanoseconds since the >> epoch - which is exactly what javaTimeMillis() is, but expressed in >> milliseconds. The in-memory timestamps have an update accuracy of 1ms, >> so are not suitable for any other API's that want the time-of-day, but >> at a greater accuracy. >> >> Microbenchmark shows the in-memory access is approx 45% faster (19ns >> on my test system) compared to the gettimeofday call (35ns). >> >> Thanks, >> David >> > From mandy.chung at oracle.com Sat Apr 30 05:02:30 2016 From: mandy.chung at oracle.com (Mandy Chung) Date: Fri, 29 Apr 2016 22:02:30 -0700 Subject: Review request: 8154190 & 8155513: Deprivilege java.compiler and jdk.charsets Message-ID: JDK-8154190: Deprivilege java.compiler module Webrev: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154190/webrev.00/ JDK-8155513: Deprivilege jdk.charsets module Webrev: http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8155513/webrev.00/ Very simple change. These patches move java.compiler and jdk.charsets module to be defined by the platform class loader and grant with AllPermissions initially. We could grant finer-grained permissions in the future. Mandy From Alan.Bateman at oracle.com Sat Apr 30 06:25:43 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sat, 30 Apr 2016 07:25:43 +0100 Subject: Review request: 8154190 & 8155513: Deprivilege java.compiler and jdk.charsets In-Reply-To: References: Message-ID: <57244FE7.4000302@oracle.com> On 30/04/2016 06:02, Mandy Chung wrote: > JDK-8154190: Deprivilege java.compiler module > Webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154190/webrev.00/ > > JDK-8155513: Deprivilege jdk.charsets module > Webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8155513/webrev.00/ > > Very simple change. > > These patches move java.compiler and jdk.charsets module to be defined by the platform class loader and grant with AllPermissions initially. We could grant finer-grained permissions in the future. > This looks okay to me. For jdk.charsets then I expect it should be easy to identify the permission it needs as there are only a few cases where it needs os.name or to read a resource file in the image. -Alan. From chris.hegarty at oracle.com Sat Apr 30 10:48:42 2016 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Sat, 30 Apr 2016 11:48:42 +0100 Subject: Review request: 8154190 & 8155513: Deprivilege java.compiler and jdk.charsets In-Reply-To: References: Message-ID: <7051CACE-C385-4CC4-8D34-93CD3E94134C@oracle.com> > On 30 Apr 2016, at 06:02, Mandy Chung wrote: > > JDK-8154190: Deprivilege java.compiler module > Webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8154190/webrev.00/ > > JDK-8155513: Deprivilege jdk.charsets module > Webrev: > http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8155513/webrev. These look good to me Mandy. -Chris. From joe.darcy at oracle.com Sat Apr 30 19:34:16 2016 From: joe.darcy at oracle.com (joe darcy) Date: Sat, 30 Apr 2016 12:34:16 -0700 Subject: JDK 9 RFR of adding a few @jls tags to java.lang.String Message-ID: Hello, Please review the small patch below to add some JLS references to the string class to supplement its textual discussion of a few sections of the JLS. Thanks, -Joe --- a/src/java.base/share/classes/java/lang/String.java Fri Apr 29 16:58:00 2016 -0700 +++ b/src/java.base/share/classes/java/lang/String.java Sat Apr 30 12:32:19 2016 -0700 @@ -117,6 +117,7 @@ * @see java.lang.StringBuilder * @see java.nio.charset.Charset * @since 1.0 + * @jls 15.18.1 String Concatenation Operator + */ public final class String @@ -2979,6 +2980,7 @@ * * @return a string that has the same contents as this string, but is * guaranteed to be from a pool of unique strings. + * @jls 3.10.5 String Literals */ public native String intern(); From Alan.Bateman at oracle.com Sat Apr 30 19:40:10 2016 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sat, 30 Apr 2016 20:40:10 +0100 Subject: JDK 9 RFR of adding a few @jls tags to java.lang.String In-Reply-To: References: Message-ID: <57250A1A.5040503@oracle.com> On 30/04/2016 20:34, joe darcy wrote: > Hello, > > Please review the small patch below to add some JLS references to the > string class to supplement its textual discussion of a few sections of > the JLS. As it happens, I have the JLS open beside me so easy to check the references. Looks good to me. -Alan