From m-matsushima at bk.jp.nec.com Fri Sep 1 02:34:30 2017 From: m-matsushima at bk.jp.nec.com (Mitsuru Matsushima) Date: Fri, 1 Sep 2017 02:34:30 +0000 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> Message-ID: Hi Naoto-san, The fix looks good, though I'm not a reviewer... By the way, I may have forgotten to inform you that there exist an issue at the short form of SimpleDateFormat has an issue. The SimpleDateFormat class is only capable to treat two form, Short and Long. At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long form. So, the behavior of SimpleDateFormat is incompatible to previous versions. (See the Comparison table, I described before.) --- Mitsuru > -----Original Message----- > From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf Of Naoto Sato > Sent: Thursday, August 31, 2017 7:56 AM > To: core-libs-dev ; i18n-dev > Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era > > Hi, > > Please review the fix to the following issue: > > https://bugs.openjdk.java.net/browse/JDK-8180469 > > The proposed changeset is located at: > > http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ > > The problem was caused by the difference of the Era display name for "SHORT" style between java.time and java.util.Calendar. > > Naoto From mandy.chung at oracle.com Fri Sep 1 05:39:54 2017 From: mandy.chung at oracle.com (mandy chung) Date: Thu, 31 Aug 2017 22:39:54 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> Message-ID: <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> Updated webrev: http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html This introduces two new methods, StackFrame::getMethodType and StackFrame::getDescriptor. Mandy On 8/30/17 12:25 AM, Remi Forax wrote: > Hi Mandy, > thanks for taking care of this. > > In my opinion, we should provide both getMethodType() and getDescriptor(), > getDescriptor() is handy for logging (finding the right overload when line numbers are not present) and getMethodType() is the one you whant if you want to inspect the runtime view of the stack frames (and by example interact with java.lang.invoke). For me, it's the same reason that give us getDeclaringClass() and getClassName() in the current API. > > So getDescriptor() can be called with no restriction but getMethodType() requires RETAIN_CLASS_REFERENCE. > > regards, > R?mi > > ----- Mail original ----- >> De: "mandy chung" >> ?: "core-libs-dev" >> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >> Objet: Review Request JDK-8186050: StackFrame should provide the method signature >> Method signature is missing in the StackFrame API. This proposes to add >> StackFrame::getMethodDescriptor method to return the method descriptor >> in a stack frame. >> >> Webrev at: >> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >> >> There are a couple options how to present the method signature in the >> API level: >> 1. Class[] getParameterTypes() and Class getReturnTypes() similiar >> to what java.lang.reflect.Method has. >> 2. java.lang.invoke.MethodType >> 3. a String representation (i) comma-separated list of the method's >> formal parameter types (ii) bytecode method descriptor as specified in JVMS >> >> Returning Class instance should require to add a new StackWalker >> option to access to the parameter types and return type for option #1 >> and #2. StackFrame::getDeclaringClass requires the stack walker to have >> the RETAIN_CLASS_REFERENCE capability. >> >> Option #2 returning MethodType is handy while java.lang would reference >> a type in java.lang.invoke. >> >> Option #3 requires the caller to parse the return string and call >> Class.forName to get the Class instance. OTOH >> MethodType::fromMethodDescriptorString method that returns MethodType >> from a bytecode method descriptor string. >> >> Method signature is for information for typical cases. Getting Class >> for the parameter types and return type would be a niche case. I think >> returning the method descriptor string is a good option - keep the API >> simple and can use MethodType::fromMethodDescriptorString to get back >> the types if needed. >> >> thanks >> Mandy From shade at redhat.com Fri Sep 1 06:14:29 2017 From: shade at redhat.com (Aleksey Shipilev) Date: Fri, 1 Sep 2017 08:14:29 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: Message-ID: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> On 08/31/2017 09:39 PM, Hans Boehm wrote: >> I guess you can make VarHandle.fullFence() between getClassDataLayout0() and storing it to the >> non-volatile field... > > ... with the usual warning about this sort of thing: > > According to the JMM, it's not guaranteed to work, because the reader-side guarantees are not > there. In practice, you're relying on dependency-based ordering, which the compiler is currently > unlikely to break in this case. But future implementations may. Right. > I presume the real concern here is the cost on the reader side? Presumably that could be reduced > with a VarHandle getAcquire(). I believe that eliminates the heavy-weight sync, and just keeps > an lwsync. Imperfect, but better. Oh right! This is exactly why acq/rel exist. Since OSC is a heavily used class, the Unsafe counterparts might be better: private static final Unsafe U = ...; private static final long CDS_OFFSET = U.objectFieldOffset(...); private volatile ClassDataSlot[] dataLayout; // volatile for safety of naked reads ClassDataSlot[] getClassDataLayout() throws InvalidClassException { ClassDataSlot[] slots = U.getObjectAcquire(this, CDS_OFFSET); if (slots == null) { slots = getClassDataLayout0(); U.putObjectRelease(this, CDS_OFFSET, slots); } return slots; } Ogata, please try if that indeed helps on POWER? Thanks, -Aleksey From OGATAK at jp.ibm.com Fri Sep 1 06:53:23 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Fri, 1 Sep 2017 15:53:23 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> Message-ID: Hi Aleksey and Hans, Thank you for your comments. I'll try to see how much Unsafe approach improves performance. I'm now thinking the approach to use final that Aleksey mentioned in the first reply is a good one. I checked the JIT generated code. It puts MEMBAR-store-store and MEMBAR-release before storing ClassDataSlot array to the final field "slots", and there is no MEMBAR when reading dataLayout or dataLayout.slots. Since dataLayout is heavily read than written, I think it is preferable if we can put all overhead into the writing side. But I'll see how performance changes with lwsync on reading it. private DataLayout dataLayout; /** * Class to ensure elements of ClassDataSlot[] are visible to other * threads. The "final" qualifier of the variable slots is necessary. */ private static class DataLayout { final ClassDataSlot[] slots; DataLayout(ClassDataSlot[] s) { slots = s; } } ClassDataSlot[] getClassDataLayout() throws InvalidClassException { // REMIND: synchronize instead of relying on volatile? if (dataLayout == null) { ClassDataSlot[] slots = getClassDataLayout0(); dataLayout = new DataLayout(slots); } return dataLayout.slots; } Regards, Ogata From: Aleksey Shipilev To: Hans Boehm Cc: Kazunori Ogata , core-libs-dev Date: 2017/09/01 15:14 Subject: Re: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() On 08/31/2017 09:39 PM, Hans Boehm wrote: >> I guess you can make VarHandle.fullFence() between getClassDataLayout0() and storing it to the >> non-volatile field... > > ... with the usual warning about this sort of thing: > > According to the JMM, it's not guaranteed to work, because the reader-side guarantees are not > there. In practice, you're relying on dependency-based ordering, which the compiler is currently > unlikely to break in this case. But future implementations may. Right. > I presume the real concern here is the cost on the reader side? Presumably that could be reduced > with a VarHandle getAcquire(). I believe that eliminates the heavy-weight sync, and just keeps > an lwsync. Imperfect, but better. Oh right! This is exactly why acq/rel exist. Since OSC is a heavily used class, the Unsafe counterparts might be better: private static final Unsafe U = ...; private static final long CDS_OFFSET = U.objectFieldOffset(...); private volatile ClassDataSlot[] dataLayout; // volatile for safety of naked reads ClassDataSlot[] getClassDataLayout() throws InvalidClassException { ClassDataSlot[] slots = U.getObjectAcquire(this, CDS_OFFSET); if (slots == null) { slots = getClassDataLayout0(); U.putObjectRelease(this, CDS_OFFSET, slots); } return slots; } Ogata, please try if that indeed helps on POWER? Thanks, -Aleksey [attachment "signature.asc" deleted by Kazunori Ogata/Japan/IBM] From forax at univ-mlv.fr Fri Sep 1 09:57:30 2017 From: forax at univ-mlv.fr (forax at univ-mlv.fr) Date: Fri, 1 Sep 2017 11:57:30 +0200 (CEST) Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> Message-ID: <1028258365.2136415.1504259850363.JavaMail.zimbra@u-pem.fr> Hi Mandy, good for me. in Basic.java, in methodTypes(), instead of using a new HashMap, you can use Map.of(). cheers, R?mi ----- Mail original ----- > De: "mandy chung" > ?: "Remi Forax" > Cc: "core-libs-dev" > Envoy?: Vendredi 1 Septembre 2017 07:39:54 > Objet: Re: Review Request JDK-8186050: StackFrame should provide the method signature > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html > > This introduces two new methods, StackFrame::getMethodType and > StackFrame::getDescriptor. > > Mandy > > On 8/30/17 12:25 AM, Remi Forax wrote: >> Hi Mandy, >> thanks for taking care of this. >> >> In my opinion, we should provide both getMethodType() and getDescriptor(), >> getDescriptor() is handy for logging (finding the right overload when line >> numbers are not present) and getMethodType() is the one you whant if you want >> to inspect the runtime view of the stack frames (and by example interact with >> java.lang.invoke). For me, it's the same reason that give us >> getDeclaringClass() and getClassName() in the current API. >> >> So getDescriptor() can be called with no restriction but getMethodType() >> requires RETAIN_CLASS_REFERENCE. >> >> regards, >> R?mi >> >> ----- Mail original ----- >>> De: "mandy chung" >>> ?: "core-libs-dev" >>> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >>> Objet: Review Request JDK-8186050: StackFrame should provide the method >>> signature >>> Method signature is missing in the StackFrame API. This proposes to add >>> StackFrame::getMethodDescriptor method to return the method descriptor >>> in a stack frame. >>> >>> Webrev at: >>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >>> >>> There are a couple options how to present the method signature in the >>> API level: >>> 1. Class[] getParameterTypes() and Class getReturnTypes() similiar >>> to what java.lang.reflect.Method has. >>> 2. java.lang.invoke.MethodType >>> 3. a String representation (i) comma-separated list of the method's >>> formal parameter types (ii) bytecode method descriptor as specified in JVMS >>> >>> Returning Class instance should require to add a new StackWalker >>> option to access to the parameter types and return type for option #1 >>> and #2. StackFrame::getDeclaringClass requires the stack walker to have >>> the RETAIN_CLASS_REFERENCE capability. >>> >>> Option #2 returning MethodType is handy while java.lang would reference >>> a type in java.lang.invoke. >>> >>> Option #3 requires the caller to parse the return string and call >>> Class.forName to get the Class instance. OTOH >>> MethodType::fromMethodDescriptorString method that returns MethodType >>> from a bytecode method descriptor string. >>> >>> Method signature is for information for typical cases. Getting Class >>> for the parameter types and return type would be a niche case. I think >>> returning the method descriptor string is a good option - keep the API >>> simple and can use MethodType::fromMethodDescriptorString to get back >>> the types if needed. >>> >>> thanks > >> Mandy From Alan.Bateman at oracle.com Fri Sep 1 13:44:55 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 1 Sep 2017 14:44:55 +0100 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> Message-ID: On 01/09/2017 06:39, mandy chung wrote: > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html > > > This introduces two new methods, StackFrame::getMethodType and > StackFrame::getDescriptor. The two new methods look good. -Alan From Alan.Bateman at oracle.com Fri Sep 1 14:36:44 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 1 Sep 2017 15:36:44 +0100 Subject: RFR JDK-8186751: Add ISO-8859-16 Charset support In-Reply-To: <59A7711F.9060801@oracle.com> References: <59A7711F.9060801@oracle.com> Message-ID: <13fc862e-60d8-d6e7-df48-28f62f2e451e@oracle.com> On 31/08/2017 03:14, Xueming Shen wrote: > Hi, > > Please help review the changeset to add the 8859_1 charset support. > > issue: https://bugs.openjdk.java.net/browse/JDK-8186751 > webrev: http://cr.openjdk.java.net/~sherman/8186751/webrev Looks good. -Alan From mandy.chung at oracle.com Fri Sep 1 16:40:24 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 1 Sep 2017 09:40:24 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <1028258365.2136415.1504259850363.JavaMail.zimbra@u-pem.fr> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <1028258365.2136415.1504259850363.JavaMail.zimbra@u-pem.fr> Message-ID: <3828f1ef-9591-0edf-950f-8e884eca3b84@oracle.com> On 9/1/17 2:57 AM, forax at univ-mlv.fr wrote: > Hi Mandy, > good for me. > > in Basic.java, in methodTypes(), instead of using a new HashMap, you can use Map.of(). Yes will fix it before push. Mandy > cheers, > R?mi > > ----- Mail original ----- >> De: "mandy chung" >> ?: "Remi Forax" >> Cc: "core-libs-dev" >> Envoy?: Vendredi 1 Septembre 2017 07:39:54 >> Objet: Re: Review Request JDK-8186050: StackFrame should provide the method signature >> Updated webrev: >> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html >> >> This introduces two new methods, StackFrame::getMethodType and >> StackFrame::getDescriptor. >> >> Mandy >> >> On 8/30/17 12:25 AM, Remi Forax wrote: >>> Hi Mandy, >>> thanks for taking care of this. >>> >>> In my opinion, we should provide both getMethodType() and getDescriptor(), >>> getDescriptor() is handy for logging (finding the right overload when line >>> numbers are not present) and getMethodType() is the one you whant if you want >>> to inspect the runtime view of the stack frames (and by example interact with >>> java.lang.invoke). For me, it's the same reason that give us >>> getDeclaringClass() and getClassName() in the current API. >>> >>> So getDescriptor() can be called with no restriction but getMethodType() >>> requires RETAIN_CLASS_REFERENCE. >>> >>> regards, >>> R?mi >>> >>> ----- Mail original ----- >>>> De: "mandy chung" >>>> ?: "core-libs-dev" >>>> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >>>> Objet: Review Request JDK-8186050: StackFrame should provide the method >>>> signature >>>> Method signature is missing in the StackFrame API. This proposes to add >>>> StackFrame::getMethodDescriptor method to return the method descriptor >>>> in a stack frame. >>>> >>>> Webrev at: >>>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >>>> >>>> There are a couple options how to present the method signature in the >>>> API level: >>>> 1. Class[] getParameterTypes() and Class getReturnTypes() similiar >>>> to what java.lang.reflect.Method has. >>>> 2. java.lang.invoke.MethodType >>>> 3. a String representation (i) comma-separated list of the method's >>>> formal parameter types (ii) bytecode method descriptor as specified in JVMS >>>> >>>> Returning Class instance should require to add a new StackWalker >>>> option to access to the parameter types and return type for option #1 >>>> and #2. StackFrame::getDeclaringClass requires the stack walker to have >>>> the RETAIN_CLASS_REFERENCE capability. >>>> >>>> Option #2 returning MethodType is handy while java.lang would reference >>>> a type in java.lang.invoke. >>>> >>>> Option #3 requires the caller to parse the return string and call >>>> Class.forName to get the Class instance. OTOH >>>> MethodType::fromMethodDescriptorString method that returns MethodType >>>> from a bytecode method descriptor string. >>>> >>>> Method signature is for information for typical cases. Getting Class >>>> for the parameter types and return type would be a niche case. I think >>>> returning the method descriptor string is a good option - keep the API >>>> simple and can use MethodType::fromMethodDescriptorString to get back >>>> the types if needed. >>>> >>>> thanks >>>> Mandy From mandy.chung at oracle.com Fri Sep 1 16:46:36 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 1 Sep 2017 09:46:36 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> Message-ID: Please also review CSR: https://bugs.openjdk.java.net/browse/JDK-8186872 Mandy On 8/31/17 10:39 PM, mandy chung wrote: > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html > > > This introduces two new methods, StackFrame::getMethodType and > StackFrame::getDescriptor. > > Mandy From brent.christian at oracle.com Fri Sep 1 17:21:15 2017 From: brent.christian at oracle.com (Brent Christian) Date: Fri, 1 Sep 2017 10:21:15 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> Message-ID: <92bf1dfa-c229-78cd-e99b-153d4b9d505f@oracle.com> Looks good. I have only one (minor) comment. In the new Javadoc for getMethodType(): StackWalker.java: 133 * Returns {@link MethodType} representing the parameter types and The docs for similar methods all begin with, "Returns _the_ ..." -Brent On 08/31/2017 10:39 PM, mandy chung wrote: > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html > > > This introduces two new methods, StackFrame::getMethodType and > StackFrame::getDescriptor. > > Mandy > > On 8/30/17 12:25 AM, Remi Forax wrote: >> Hi Mandy, >> thanks for taking care of this. >> >> In my opinion, we should provide both getMethodType() and >> getDescriptor(), >> getDescriptor() is handy for logging (finding the right overload when >> line numbers are not present) and getMethodType() is the one you whant >> if you want to inspect the runtime view of the stack frames (and by >> example interact with java.lang.invoke). For me, it's the same reason >> that give us getDeclaringClass() and getClassName() in the current API. >> >> So getDescriptor() can be called with no restriction but >> getMethodType() requires RETAIN_CLASS_REFERENCE. >> >> regards, >> R?mi >> >> ----- Mail original ----- >>> De: "mandy chung" >>> ?: "core-libs-dev" >>> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >>> Objet: Review Request JDK-8186050: StackFrame should provide the >>> method signature >>> Method signature is missing in the StackFrame API. This proposes to add >>> StackFrame::getMethodDescriptor method to return the method descriptor >>> in a stack frame. >>> >>> Webrev at: >>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >>> >>> >>> There are a couple options how to present the method signature in the >>> API level: >>> 1. Class[] getParameterTypes() and Class getReturnTypes() similiar >>> to what java.lang.reflect.Method has. >>> 2. java.lang.invoke.MethodType >>> 3. a String representation (i) comma-separated list of the method's >>> formal parameter types (ii) bytecode method descriptor as specified >>> in JVMS >>> >>> Returning Class instance should require to add a new StackWalker >>> option to access to the parameter types and return type for option #1 >>> and #2. StackFrame::getDeclaringClass requires the stack walker to have >>> the RETAIN_CLASS_REFERENCE capability. >>> >>> Option #2 returning MethodType is handy while java.lang would reference >>> a type in java.lang.invoke. >>> >>> Option #3 requires the caller to parse the return string and call >>> Class.forName to get the Class instance. OTOH >>> MethodType::fromMethodDescriptorString method that returns MethodType >>> from a bytecode method descriptor string. >>> >>> Method signature is for information for typical cases. Getting Class >>> for the parameter types and return type would be a niche case. I think >>> returning the method descriptor string is a good option - keep the API >>> simple and can use MethodType::fromMethodDescriptorString to get back >>> the types if needed. >>> >>> thanks >>> Mandy > From mandy.chung at oracle.com Fri Sep 1 17:42:58 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 1 Sep 2017 10:42:58 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <92bf1dfa-c229-78cd-e99b-153d4b9d505f@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <92bf1dfa-c229-78cd-e99b-153d4b9d505f@oracle.com> Message-ID: <0be2b47d-a045-be77-9a96-64dbd00e2109@oracle.com> On 9/1/17 10:21 AM, Brent Christian wrote: > Looks good.? I have only one (minor) comment. > > In the new Javadoc for getMethodType(): > > StackWalker.java: > > ?133????????? * Returns {@link MethodType} representing the parameter > types and > > > The docs for similar methods all begin with, "Returns _the_ ..." Fixed.? Thanks for the review. Mandy From naoto.sato at oracle.com Fri Sep 1 17:48:32 2017 From: naoto.sato at oracle.com (Naoto Sato) Date: Fri, 1 Sep 2017 10:48:32 -0700 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> Message-ID: <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> Hi Mitsuru-san, Yes, I remember we discussed on this issue before. The reason that LONG and SHORT names for Japanese era are the same is that CLDR's era names are not very consistent on length. They have "eraNames", "eraAbbr", and "eraNarrow" variations. We simply assign LONG to eraNames and SHORT to eraAbbr in SimpleDateFormat. Possibly the right solution is to provide "narrow" option in SimpleDateFormat, but it would be breaking the compatibility (text length of those pattern characters just have two options, one is 4 or greater (=LONG), and the other is less than 4 (=SHORT)). So, considering these, I have a couple of options. One is to use the newer java.time.format APIs which can correctly handle this, or use the JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. HTH, Naoto On 8/31/17 7:34 PM, Mitsuru Matsushima wrote: > Hi Naoto-san, > > The fix looks good, though I'm not a reviewer... > > By the way, I may have forgotten to inform you that there exist an issue at the short form of SimpleDateFormat has an issue. > > The SimpleDateFormat class is only capable to treat two form, Short and Long. > At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long form. > So, the behavior of SimpleDateFormat is incompatible to previous versions. > (See the Comparison table, I described before.) > > --- > Mitsuru > >> -----Original Message----- >> From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf Of Naoto Sato >> Sent: Thursday, August 31, 2017 7:56 AM >> To: core-libs-dev ; i18n-dev >> Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era >> >> Hi, >> >> Please review the fix to the following issue: >> >> https://bugs.openjdk.java.net/browse/JDK-8180469 >> >> The proposed changeset is located at: >> >> http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ >> >> The problem was caused by the difference of the Era display name for "SHORT" style between java.time and java.util.Calendar. >> >> Naoto From Ulf.Zibis at CoSoCo.de Fri Sep 1 18:22:39 2017 From: Ulf.Zibis at CoSoCo.de (Ulf Zibis) Date: Fri, 1 Sep 2017 20:22:39 +0200 Subject: RFR JDK-8186751: Add ISO-8859-16 Charset support In-Reply-To: <59A87FC0.4090505@oracle.com> References: <59A7711F.9060801@oracle.com> <59A87FC0.4090505@oracle.com> Message-ID: Hi again, Am 31.08.2017 um 23:29 schrieb Xueming Shen: > The 8859-16 aliases are the copy/paste from > https://www.iana.org/assignments/character-sets/character-sets.xhtml > > From the same page we have the followings for 8859-15 > ISO_8859-15 > Latin-9 > csISO885915 > > It appears only the first one is listed in our alias list (explicitly > commented). > Don't have the memory for the history (8859-15 was added a long time ago), > not sure whether the other two were missed at the very beginning or were > added later in the iana. Since we are here, I added them in. Fine! > http://cr.openjdk.java.net/~sherman/8186751/webrev > (the old one is copied to webrev.00) - I think, the comment should now be in plural: # IANA alias*es *- Also I think, it would make sense to at least add "ISO8859-16" and "ISO8859_16" as # Other aliases - "ISO-8859-15" must not be listed as alias, as it already is the canonical name. - Not sure, where "LATIN0" and "csISOlatin0" come from. -Ulf From fguillaume at nuxeo.com Fri Sep 1 19:16:13 2017 From: fguillaume at nuxeo.com (Florent Guillaume) Date: Fri, 1 Sep 2017 21:16:13 +0200 Subject: RFR JDK-8186751: Add ISO-8859-16 Charset support In-Reply-To: References: <59A7711F.9060801@oracle.com> <59A87FC0.4090505@oracle.com> Message-ID: Hi, >From https://www.cs.tut.fi/~jkorpela/latin9.html: > Originally (http://www.indigo.ie/egt/standards/iso8859/latin00.html) the project > which lead to the creation of ISO Latin 9 used the working name "Latin Alphabet > Number Zero" for it. Therefore it has often been referred to as "Latin 0". I don't think it should be included in the aliases. Florent On Fri, Sep 1, 2017 at 8:22 PM, Ulf Zibis wrote: > Hi again, > > Am 31.08.2017 um 23:29 schrieb Xueming Shen: > > The 8859-16 aliases are the copy/paste from > https://www.iana.org/assignments/character-sets/character-sets.xhtml > > From the same page we have the followings for 8859-15 > ISO_8859-15 > Latin-9 > csISO885915 > > It appears only the first one is listed in our alias list (explicitly > commented). > Don't have the memory for the history (8859-15 was added a long time ago), > not sure whether the other two were missed at the very beginning or were > added later in the iana. Since we are here, I added them in. > > > Fine! > > http://cr.openjdk.java.net/~sherman/8186751/webrev > (the old one is copied to webrev.00) > > > - I think, the comment should now be in plural: # IANA alias > *es *- Also I think, it would make sense to at least add "ISO8859-16" and > "ISO8859_16" as # Other aliases > - "ISO-8859-15" must not be listed as alias, as it already is the > canonical name. > - Not sure, where "LATIN0" and "csISOlatin0" come from. > > -Ulf > > -- [image: Nuxeo] Florent Guillaume Head of R&D Twitter: @efge From jonathan.gibbons at oracle.com Fri Sep 1 20:34:30 2017 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Fri, 01 Sep 2017 13:34:30 -0700 Subject: RFR: JDK-8186947: Fix accessibility and other issues in the java.xml.ws module Message-ID: <59A9C456.40809@oracle.com> Please review this small change to fix a broken link in the API docs for the java.xml.ws module. Although I've also posted a full webrev and API, the change is more easily seen here: --- old/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java 2017-09-01 12:29:36.684932965 -0700 +++ new/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java 2017-09-01 12:29:36.596929123 -0700 @@ -145,7 +145,7 @@ * Sets the {@code endpointName} as * {@code wsam:ServiceName/@EndpointName} in the * {@code wsa:Metadata} element. This method can only be called - * after the {@link #serviceName} method has been called. + * after the {@link #serviceName(QName)} method has been called. *

* See * 2.1 Referencing WSDL Metadata from an EPR for more details. JBS: https://bugs.openjdk.java.net/browse/JDK-8186947 Webrev: http://cr.openjdk.java.net/~jjg/8186947/webrev/index.html API: http://cr.openjdk.java.net/~jjg/8186947/api/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.html -- Jon From jonathan.gibbons at oracle.com Fri Sep 1 20:34:33 2017 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Fri, 01 Sep 2017 13:34:33 -0700 Subject: RFR: JDK-8186946: Fix accessibility and other issues in the java.xml.bind module Message-ID: <59A9C459.5080208@oracle.com> Please review these changes to address accessibility and other minor issues in the API docs for the java.xml.bind module. JBS: https://bugs.openjdk.java.net/browse/JDK-8186946 Webrev: http://cr.openjdk.java.net/~jjg/8186946/webrev API: http://cr.openjdk.java.net/~jjg/8186946/api/java.xml.bind-summary.html -- Jon Notes on the changes follow: src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java Convert file to use the standard "striped" pattern for tables src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java Fix broken links that arise when relative links are inherited into the docs for subtypes src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java Convert file to use the standard "striped" pattern for tables Fix broken links that arise when relative links are inherited into the docs for subtypes src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java Convert file to use the standard "striped" pattern for tables src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java Convert file to use the standard "striped" pattern for tables src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java Remove redundant

tags src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html Convert file to use the standard "striped" pattern for tables Replace nested layout tables with simple lists src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java Convert file to use the standard "striped" pattern for tables src/java.xml.bind/share/classes/javax/xml/bind/helpers/package-info.java Remove redundant

tags src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java Remove redundant

tags The following files are removed, since they are shadowed by the corresponding package-info.java files: src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html src/java.xml.bind/share/classes/javax/xml/bind/util/package.html -- Jon From joe.darcy at oracle.com Fri Sep 1 20:35:30 2017 From: joe.darcy at oracle.com (joe darcy) Date: Fri, 1 Sep 2017 13:35:30 -0700 Subject: RFR: JDK-8186947: Fix accessibility and other issues in the java.xml.ws module In-Reply-To: <59A9C456.40809@oracle.com> References: <59A9C456.40809@oracle.com> Message-ID: <90dbbfa0-5212-56af-9cda-7fefe9b7a5f4@oracle.com> +1 -Joe On 9/1/2017 1:34 PM, Jonathan Gibbons wrote: > Please review this small change to fix a broken link in the API docs > for the java.xml.ws module. > > Although I've also posted a full webrev and API, the change is more > easily seen here: > > --- > old/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java > 2017-09-01 12:29:36.684932965 -0700 > +++ > new/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java > 2017-09-01 12:29:36.596929123 -0700 > @@ -145,7 +145,7 @@ > * Sets the {@code endpointName} as > * {@code wsam:ServiceName/@EndpointName} in the > * {@code wsa:Metadata} element. This method can only be called > - * after the {@link #serviceName} method has been called. > + * after the {@link #serviceName(QName)} method has been called. > *

> * See href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904/#refmetadatfromepr"> > * 2.1 Referencing WSDL Metadata from an EPR for more details. > > > > JBS: https://bugs.openjdk.java.net/browse/JDK-8186947 > Webrev: http://cr.openjdk.java.net/~jjg/8186947/webrev/index.html > API: > http://cr.openjdk.java.net/~jjg/8186947/api/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.html > > -- Jon From mandy.chung at oracle.com Fri Sep 1 20:36:05 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 1 Sep 2017 13:36:05 -0700 Subject: RFR: JDK-8186947: Fix accessibility and other issues in the java.xml.ws module In-Reply-To: <59A9C456.40809@oracle.com> References: <59A9C456.40809@oracle.com> Message-ID: +1 Mandy On 9/1/17 1:34 PM, Jonathan Gibbons wrote: > Please review this small change to fix a broken link in the API docs > for the java.xml.ws module. > > Although I've also posted a full webrev and API, the change is more > easily seen here: > > --- > old/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java > 2017-09-01 12:29:36.684932965 -0700 > +++ > new/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java > 2017-09-01 12:29:36.596929123 -0700 > @@ -145,7 +145,7 @@ > ????? * Sets the {@code endpointName} as > ????? * {@code wsam:ServiceName/@EndpointName} in the > ????? * {@code wsa:Metadata} element. This method can only be called > -???? * after the {@link #serviceName} method has been called. > +???? * after the {@link #serviceName(QName)} method has been called. > ????? *

> ????? * See href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904/#refmetadatfromepr"> > ????? * 2.1 Referencing WSDL Metadata from an EPR for more details. > > > > JBS: https://bugs.openjdk.java.net/browse/JDK-8186947 > Webrev: http://cr.openjdk.java.net/~jjg/8186947/webrev/index.html > API: > http://cr.openjdk.java.net/~jjg/8186947/api/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.html > > -- Jon From lance.andersen at oracle.com Fri Sep 1 20:37:18 2017 From: lance.andersen at oracle.com (Lance Andersen) Date: Fri, 1 Sep 2017 16:37:18 -0400 Subject: RFR: JDK-8186947: Fix accessibility and other issues in the java.xml.ws module In-Reply-To: <59A9C456.40809@oracle.com> References: <59A9C456.40809@oracle.com> Message-ID: <0324B78D-0580-4982-933B-8803DEE624F4@oracle.com> looks fine Jon > On Sep 1, 2017, at 4:34 PM, Jonathan Gibbons wrote: > > Please review this small change to fix a broken link in the API docs for the java.xml.ws module. > > Although I've also posted a full webrev and API, the change is more easily seen here: > > --- old/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java 2017-09-01 12:29:36.684932965 -0700 > +++ new/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java 2017-09-01 12:29:36.596929123 -0700 > @@ -145,7 +145,7 @@ > * Sets the {@code endpointName} as > * {@code wsam:ServiceName/@EndpointName} in the > * {@code wsa:Metadata} element. This method can only be called > - * after the {@link #serviceName} method has been called. > + * after the {@link #serviceName(QName)} method has been called. > *

> * See > * 2.1 Referencing WSDL Metadata from an EPR for more details. > > > > JBS: https://bugs.openjdk.java.net/browse/JDK-8186947 > Webrev: http://cr.openjdk.java.net/~jjg/8186947/webrev/index.html > API: http://cr.openjdk.java.net/~jjg/8186947/api/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.html > > -- Jon 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 Fri Sep 1 20:50:26 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 1 Sep 2017 13:50:26 -0700 Subject: RFR: JDK-8186946: Fix accessibility and other issues in the java.xml.bind module In-Reply-To: <59A9C459.5080208@oracle.com> References: <59A9C459.5080208@oracle.com> Message-ID: <74bd6026-22c9-7f42-da16-2b4c31109a9a@oracle.com> Typo in the href link: e.g.See should be {@docRoot}/javax/xml/bind/XXX.html Mandy On 9/1/17 1:34 PM, Jonathan Gibbons wrote: > Please review these changes to address accessibility and other minor > issues in > the API docs for the java.xml.bind module. > > JBS: https://bugs.openjdk.java.net/browse/JDK-8186946 > Webrev: http://cr.openjdk.java.net/~jjg/8186946/webrev > API: > http://cr.openjdk.java.net/~jjg/8186946/api/java.xml.bind-summary.html > > -- Jon > > Notes on the changes follow: > > src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java > ??? Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java > ??? Fix broken links that arise when relative links are inherited into > the docs for subtypes > > src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java > ??? Convert file to use the standard "striped" pattern for tables > ??? Fix broken links that arise when relative links are inherited into > the docs for subtypes > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java > ??? Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java > ??? Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java > > ??? Remove redundant

tags > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html > ??? Convert file to use the standard "striped" pattern for tables > ??? Replace nested layout tables with simple lists > > src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java > > ??? Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/helpers/package-info.java > ??? Remove redundant

tags > > src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java > ??? Remove redundant

tags > > The following files are removed, since they are shadowed by the > corresponding package-info.java > files: > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html > src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html > src/java.xml.bind/share/classes/javax/xml/bind/util/package.html > > > -- Jon From lance.andersen at oracle.com Fri Sep 1 21:20:59 2017 From: lance.andersen at oracle.com (Lance Andersen) Date: Fri, 1 Sep 2017 17:20:59 -0400 Subject: RFR: JDK-8186946: Fix accessibility and other issues in the java.xml.bind module In-Reply-To: <74bd6026-22c9-7f42-da16-2b4c31109a9a@oracle.com> References: <59A9C459.5080208@oracle.com> <74bd6026-22c9-7f42-da16-2b4c31109a9a@oracle.com> Message-ID: Looks fine except for what mandy pointed out which is is a few files. > On Sep 1, 2017, at 4:50 PM, mandy chung wrote: > > Typo in the href link: > e.g.See > > should be {@docRoot}/javax/xml/bind/XXX.html > > Mandy > > On 9/1/17 1:34 PM, Jonathan Gibbons wrote: >> Please review these changes to address accessibility and other minor issues in >> the API docs for the java.xml.bind module. >> >> JBS: https://bugs.openjdk.java.net/browse/JDK-8186946 >> Webrev: http://cr.openjdk.java.net/~jjg/8186946/webrev >> API: http://cr.openjdk.java.net/~jjg/8186946/api/java.xml.bind-summary.html >> >> -- Jon >> >> Notes on the changes follow: >> >> src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java >> Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java >> Fix broken links that arise when relative links are inherited into the docs for subtypes >> >> src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java >> Convert file to use the standard "striped" pattern for tables >> Fix broken links that arise when relative links are inherited into the docs for subtypes >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java >> Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java >> Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java >> Remove redundant

tags >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html >> Convert file to use the standard "striped" pattern for tables >> Replace nested layout tables with simple lists >> >> src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java >> Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/helpers/package-info.java >> Remove redundant

tags >> >> src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java >> Remove redundant

tags >> >> The following files are removed, since they are shadowed by the corresponding package-info.java >> files: >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html >> src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html >> src/java.xml.bind/share/classes/javax/xml/bind/util/package.html >> >> >> -- Jon > 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 jonathan.gibbons at oracle.com Fri Sep 1 21:42:26 2017 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Fri, 01 Sep 2017 14:42:26 -0700 Subject: Update: Re: RFR: JDK-8186946: Fix accessibility and other issues in the java.xml.bind module In-Reply-To: <59A9C459.5080208@oracle.com> References: <59A9C459.5080208@oracle.com> Message-ID: <59A9D442.4090303@oracle.com> Sigh. The bad news is that I accidentally committed and pushed the changes for this issue (JDK-8186946) before they had been approved, along with the changes for JDK-8186947, which had been approved. The good news is that I had already addressed and verified Mandy's comments regarding broken links. So the net result is that the source code in the repo is good, but the metadata for these two issues is a bit messed up. I'll update the JBS bugs to document this. If anyone should find any additional issues in this review, I will of course address them and file an additional bug if necessary. -- Jon On 09/01/2017 01:34 PM, Jonathan Gibbons wrote: > Please review these changes to address accessibility and other minor > issues in > the API docs for the java.xml.bind module. > > JBS: https://bugs.openjdk.java.net/browse/JDK-8186946 > Webrev: http://cr.openjdk.java.net/~jjg/8186946/webrev > API: > http://cr.openjdk.java.net/~jjg/8186946/api/java.xml.bind-summary.html > > -- Jon > > Notes on the changes follow: > > src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java > Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java > Fix broken links that arise when relative links are inherited into > the docs for subtypes > > src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java > Convert file to use the standard "striped" pattern for tables > Fix broken links that arise when relative links are inherited into > the docs for subtypes > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java > Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java > Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java > > Remove redundant

tags > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html > Convert file to use the standard "striped" pattern for tables > Replace nested layout tables with simple lists > > src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java > > Convert file to use the standard "striped" pattern for tables > > src/java.xml.bind/share/classes/javax/xml/bind/helpers/package-info.java > Remove redundant

tags > > src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java > Remove redundant

tags > > The following files are removed, since they are shadowed by the > corresponding package-info.java > files: > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html > src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html > src/java.xml.bind/share/classes/javax/xml/bind/util/package.html > > > -- Jon From mandy.chung at oracle.com Fri Sep 1 21:49:18 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 1 Sep 2017 14:49:18 -0700 Subject: Update: Re: RFR: JDK-8186946: Fix accessibility and other issues in the java.xml.bind module In-Reply-To: <59A9D442.4090303@oracle.com> References: <59A9C459.5080208@oracle.com> <59A9D442.4090303@oracle.com> Message-ID: <23e04abb-16c8-defa-03b6-0f83fa49782f@oracle.com> No worries.? Thanks for doing all these javadoc cleanup. Mandy On 9/1/17 2:42 PM, Jonathan Gibbons wrote: > Sigh. > > The bad news is that I accidentally committed and pushed the changes > for this issue > (JDK-8186946) before they had been approved, along with the changes > for JDK-8186947, > which had been approved. > > The good news is that I had already addressed and verified Mandy's > comments > regarding broken links. So the net result is that the source code in > the repo is > good, but the metadata for these two issues is a bit messed up. I'll > update the > JBS bugs to document this. > > If anyone should find any additional issues in this review, I will of > course address > them and file an additional bug if necessary. > > -- Jon > > On 09/01/2017 01:34 PM, Jonathan Gibbons wrote: >> Please review these changes to address accessibility and other minor >> issues in >> the API docs for the java.xml.bind module. >> >> JBS: https://bugs.openjdk.java.net/browse/JDK-8186946 >> Webrev: http://cr.openjdk.java.net/~jjg/8186946/webrev >> API: >> http://cr.openjdk.java.net/~jjg/8186946/api/java.xml.bind-summary.html >> >> -- Jon >> >> Notes on the changes follow: >> >> src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java >> ??? Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java >> ??? Fix broken links that arise when relative links are inherited >> into the docs for subtypes >> >> src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java >> ??? Convert file to use the standard "striped" pattern for tables >> ??? Fix broken links that arise when relative links are inherited >> into the docs for subtypes >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java >> ??? Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java >> ??? Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java >> >> ??? Remove redundant

tags >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html >> ??? Convert file to use the standard "striped" pattern for tables >> ??? Replace nested layout tables with simple lists >> >> src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java >> >> ??? Convert file to use the standard "striped" pattern for tables >> >> src/java.xml.bind/share/classes/javax/xml/bind/helpers/package-info.java >> ??? Remove redundant

tags >> >> src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java >> ??? Remove redundant

tags >> >> The following files are removed, since they are shadowed by the >> corresponding package-info.java >> files: >> >> src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html >> >> src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html >> src/java.xml.bind/share/classes/javax/xml/bind/util/package.html >> >> >> -- Jon > From xueming.shen at oracle.com Fri Sep 1 23:17:54 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 01 Sep 2017 16:17:54 -0700 Subject: RFR JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files In-Reply-To: References: <599B8A4C.3050904@oracle.com> <599CAFDB.9020902@oracle.com> Message-ID: <59A9EAA2.3020102@oracle.com> On 8/22/17, 5:54 PM, Martin Buchholz wrote: > > > On Tue, Aug 22, 2017 at 3:27 PM, Xueming Shen > wrote: > > > How about to add an option to our zipfs to force the ZIP64 end > record when > enabled. Harmless if not specified. > > > I agree that adding more options for testability is good. Since our > users are likely to need such things as well, I'd also like to see > such features become public, analogous to zip's -fz- flag. > > OTOH, interoperability testing is very valuable, so despite the > troubles involved writing tests that involve both jdk and zipinfo > code, I think we should do it. > Martin, I have added a test case that tests "echo hello | zip infozip.zip -" via pb.startPipeline() in ReadZip.java, which should add some coverage for the "interoperability testing". Would you please help take a look? http://cr.openjdk.java.net/~sherman/8186464/webrev/ Thanks, Sherman From hboehm at google.com Sat Sep 2 02:53:42 2017 From: hboehm at google.com (Hans Boehm) Date: Fri, 1 Sep 2017 19:53:42 -0700 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> Message-ID: The problem is that all solutions that put all overhead on the writing side are inherently not correct with respect to the Java memory model. They rely on the necessary reader-side order (dataLayout read not reordered after read of ClassDataSlots that use the dataLayout value) to be enforced (as you would expect) by the data dependency. The Java memory model only guarantees that (under the right conditions) for final fields. (This is controversial, but "fixing" it opens another can of worms.) Here you would be relying on it for dataLayout, a non-final field. I believe current implementations in fact enforce the necessary ordering. But since it (surprisingly) appears to not be completely free to have dependencies of this kind enforce memory visibility ordering (DEC Alpha famously didn't), I wouldn't bet large sums of money on this statement remaining true indefinitely on all relevant architectures. On Thu, Aug 31, 2017 at 11:53 PM, Kazunori Ogata wrote: > Hi Aleksey and Hans, > > Thank you for your comments. I'll try to see how much Unsafe approach > improves performance. > > I'm now thinking the approach to use final that Aleksey mentioned in the > first reply is a good one. I checked the JIT generated code. It puts > MEMBAR-store-store and MEMBAR-release before storing ClassDataSlot array > to the final field "slots", and there is no MEMBAR when reading dataLayout > or dataLayout.slots. Since dataLayout is heavily read than written, I > think it is preferable if we can put all overhead into the writing side. > But I'll see how performance changes with lwsync on reading it. > > > private DataLayout dataLayout; > > /** > * Class to ensure elements of ClassDataSlot[] are visible to other > * threads. The "final" qualifier of the variable slots is necessary. > */ > private static class DataLayout { > final ClassDataSlot[] slots; > DataLayout(ClassDataSlot[] s) { > slots = s; > } > } > > ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > // REMIND: synchronize instead of relying on volatile? > if (dataLayout == null) { > ClassDataSlot[] slots = getClassDataLayout0(); > dataLayout = new DataLayout(slots); > } > return dataLayout.slots; > } > > > Regards, > Ogata > > > > From: Aleksey Shipilev > To: Hans Boehm > Cc: Kazunori Ogata , core-libs-dev > > Date: 2017/09/01 15:14 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > > > On 08/31/2017 09:39 PM, Hans Boehm wrote: > >> I guess you can make VarHandle.fullFence() between > getClassDataLayout0() and storing it to the > >> non-volatile field... > > > > ... with the usual warning about this sort of thing: > > > > According to the JMM, it's not guaranteed to work, because the > reader-side guarantees are not > > there. In practice, you're relying on dependency-based ordering, which > the compiler is currently > > unlikely to break in this case. But future implementations may. > > Right. > > > I presume the real concern here is the cost on the reader side? > Presumably that could be reduced > > with a VarHandle getAcquire(). I believe that eliminates the > heavy-weight sync, and just keeps > > an lwsync. Imperfect, but better. > Oh right! This is exactly why acq/rel exist. Since OSC is a heavily used > class, the Unsafe > counterparts might be better: > > private static final Unsafe U = ...; > private static final long CDS_OFFSET = U.objectFieldOffset(...); > > private volatile ClassDataSlot[] dataLayout; // volatile for safety of > naked reads > > ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > ClassDataSlot[] slots = U.getObjectAcquire(this, CDS_OFFSET); > if (slots == null) { > slots = getClassDataLayout0(); > U.putObjectRelease(this, CDS_OFFSET, slots); > } > return slots; > } > > Ogata, please try if that indeed helps on POWER? > > Thanks, > -Aleksey > > [attachment "signature.asc" deleted by Kazunori Ogata/Japan/IBM] > > > From aph at redhat.com Sat Sep 2 08:26:42 2017 From: aph at redhat.com (Andrew Haley) Date: Sat, 2 Sep 2017 09:26:42 +0100 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> Message-ID: On 02/09/17 03:53, Hans Boehm wrote: > The problem is that all solutions that put all overhead on the writing side > are inherently not correct with respect to the Java memory model. They rely > on the necessary reader-side order (dataLayout read not reordered after > read of ClassDataSlots that use the dataLayout value) to be enforced (as > you would expect) by the data dependency. The Java memory model only > guarantees that (under the right conditions) for final fields. (This is > controversial, but "fixing" it opens another can of worms.) Here you would > be relying on it for dataLayout, a non-final field. > > I believe current implementations in fact enforce the necessary ordering. > But since it (surprisingly) appears to not be completely free to have > dependencies of this kind enforce memory visibility ordering (DEC Alpha > famously didn't), I wouldn't bet large sums of money on this statement > remaining true indefinitely on all relevant architectures. Indeed, and I have my doubts about RISC V. But it seems to me that any processor architecture which broke dependency ordering in such a way would also require fences for every read, volatile or not, of reference type, would it not? Otherwise the basic security guarantees of the platform would not hold. -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671 From peter.levart at gmail.com Sat Sep 2 09:57:16 2017 From: peter.levart at gmail.com (Peter Levart) Date: Sat, 2 Sep 2017 11:57:16 +0200 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> Message-ID: <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> Hi Mandy, The API looks fine to me. Note that there is an opportunity for a follow-up optimization of the StackFrameInfo::getDescriptor() case. When MemberName's 'type' field is filled by native expandFromVM() it is usually filled with the descriptor string. MemberName::getMethodType() then parses this string into a MemberType, resolving all the types. So when StackFrameInfo::getDescriptor() is called, the descriptor string is 1st parsed into MethodType and then formatted back to the descriptor. By introducing new method into package-private MemberName - say getMethodDescriptorString(), this intermediate conversion could often be avoided (for example, if getMethodDescriptorString() was called before getMethodType() on an instance of MethodName). Regards, Peter On 09/01/2017 07:39 AM, mandy chung wrote: > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html > > > This introduces two new methods, StackFrame::getMethodType and > StackFrame::getDescriptor. > > Mandy > > On 8/30/17 12:25 AM, Remi Forax wrote: >> Hi Mandy, >> thanks for taking care of this. >> >> In my opinion, we should provide both getMethodType() and >> getDescriptor(), >> getDescriptor() is handy for logging (finding the right overload when >> line numbers are not present) and getMethodType() is the one you >> whant if you want to inspect the runtime view of the stack frames >> (and by example interact with java.lang.invoke). For me, it's the >> same reason that give us getDeclaringClass() and getClassName() in >> the current API. >> >> So getDescriptor() can be called with no restriction but >> getMethodType() requires RETAIN_CLASS_REFERENCE. >> >> regards, >> R?mi >> >> ----- Mail original ----- >>> De: "mandy chung" >>> ?: "core-libs-dev" >>> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >>> Objet: Review Request JDK-8186050: StackFrame should provide the >>> method signature >>> Method signature is missing in the StackFrame API. This proposes to add >>> StackFrame::getMethodDescriptor method to return the method descriptor >>> in a stack frame. >>> >>> Webrev at: >>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >>> >>> >>> There are a couple options how to present the method signature in the >>> API level: >>> 1. Class[] getParameterTypes() and Class getReturnTypes() >>> similiar >>> to what java.lang.reflect.Method has. >>> 2. java.lang.invoke.MethodType >>> 3. a String representation (i) comma-separated list of the method's >>> formal parameter types (ii) bytecode method descriptor as specified >>> in JVMS >>> >>> Returning Class instance should require to add a new StackWalker >>> option to access to the parameter types and return type for option #1 >>> and #2. StackFrame::getDeclaringClass requires the stack walker to have >>> the RETAIN_CLASS_REFERENCE capability. >>> >>> Option #2 returning MethodType is handy while java.lang would reference >>> a type in java.lang.invoke. >>> >>> Option #3 requires the caller to parse the return string and call >>> Class.forName to get the Class instance. OTOH >>> MethodType::fromMethodDescriptorString method that returns MethodType >>> from a bytecode method descriptor string. >>> >>> Method signature is for information for typical cases. Getting Class >>> for the parameter types and return type would be a niche case. I think >>> returning the method descriptor string is a good option - keep the API >>> simple and can use MethodType::fromMethodDescriptorString to get back >>> the types if needed. >>> >>> thanks >>> Mandy > From Alan.Bateman at oracle.com Sat Sep 2 12:06:39 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sat, 2 Sep 2017 13:06:39 +0100 Subject: RFR: JDK-8186946: Fix accessibility and other issues in the java.xml.bind module In-Reply-To: <59A9C459.5080208@oracle.com> References: <59A9C459.5080208@oracle.com> Message-ID: On 01/09/2017 21:34, Jonathan Gibbons wrote: > : > > src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java > ??? Remove redundant

tags > > The following files are removed, since they are shadowed by the > corresponding package-info.java > files: > > src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html > src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html > src/java.xml.bind/share/classes/javax/xml/bind/util/package.html Aleksej - do you think these changes can be committed the upstream project where the code is maintained? Otherwise I could imagine the deleted package.html and the other changes come back at the next sync up. -Alan From mandy.chung at oracle.com Sun Sep 3 02:52:23 2017 From: mandy.chung at oracle.com (mandy chung) Date: Sat, 2 Sep 2017 19:52:23 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> Message-ID: <4612ad06-2bae-4482-175d-3c3bfc0dab27@oracle.com> On 9/2/17 2:57 AM, Peter Levart wrote: > Hi Mandy, > > The API looks fine to me. > > Note that there is an opportunity for a follow-up optimization of the > StackFrameInfo::getDescriptor() case. When MemberName's 'type' field > is filled by native expandFromVM() it is usually filled with the > descriptor string. MemberName::getMethodType() then parses this string > into a MemberType, resolving all the types. So when > StackFrameInfo::getDescriptor() is called, the descriptor string is > 1st parsed into MethodType and then formatted back to the descriptor. > By introducing new method into package-private MemberName - say > getMethodDescriptorString(), this intermediate conversion could often > be avoided (for example, if getMethodDescriptorString() was called > before getMethodType() on an instance of MethodName). > Good suggestion. Updated webrev: http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.02/ Thanks Mandy > Regards, Peter > > On 09/01/2017 07:39 AM, mandy chung wrote: >> Updated webrev: >> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html >> >> >> This introduces two new methods, StackFrame::getMethodType and >> StackFrame::getDescriptor. >> >> Mandy >> >> On 8/30/17 12:25 AM, Remi Forax wrote: >>> Hi Mandy, >>> thanks for taking care of this. >>> >>> In my opinion, we should provide both getMethodType() and >>> getDescriptor(), >>> getDescriptor() is handy for logging (finding the right overload >>> when line numbers are not present) and getMethodType() is the one >>> you whant if you want to inspect the runtime view of the stack >>> frames (and by example interact with java.lang.invoke). For me, it's >>> the same reason that give us getDeclaringClass() and getClassName() >>> in the current API. >>> >>> So getDescriptor() can be called with no restriction but >>> getMethodType() requires RETAIN_CLASS_REFERENCE. >>> >>> regards, >>> R?mi >>> >>> ----- Mail original ----- >>>> De: "mandy chung" >>>> ?: "core-libs-dev" >>>> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >>>> Objet: Review Request JDK-8186050: StackFrame should provide the >>>> method signature >>>> Method signature is missing in the StackFrame API. This proposes to >>>> add >>>> StackFrame::getMethodDescriptor method to return the method descriptor >>>> in a stack frame. >>>> >>>> Webrev at: >>>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >>>> >>>> >>>> There are a couple options how to present the method signature in the >>>> API level: >>>> 1. Class[] getParameterTypes() and Class getReturnTypes() >>>> similiar >>>> to what java.lang.reflect.Method has. >>>> 2. java.lang.invoke.MethodType >>>> 3. a String representation (i) comma-separated list of the method's >>>> formal parameter types (ii) bytecode method descriptor as specified >>>> in JVMS >>>> >>>> Returning Class instance should require to add a new StackWalker >>>> option to access to the parameter types and return type for option #1 >>>> and #2. StackFrame::getDeclaringClass requires the stack walker to >>>> have >>>> the RETAIN_CLASS_REFERENCE capability. >>>> >>>> Option #2 returning MethodType is handy while java.lang would >>>> reference >>>> a type in java.lang.invoke. >>>> >>>> Option #3 requires the caller to parse the return string and call >>>> Class.forName to get the Class instance. OTOH >>>> MethodType::fromMethodDescriptorString method that returns MethodType >>>> from a bytecode method descriptor string. >>>> >>>> Method signature is for information for typical cases. Getting >>>> Class >>>> for the parameter types and return type would be a niche case. I think >>>> returning the method descriptor string is a good option - keep the API >>>> simple and can use MethodType::fromMethodDescriptorString to get back >>>> the types if needed. >>>> >>>> thanks >>>> Mandy >> > From peter.levart at gmail.com Sun Sep 3 14:02:54 2017 From: peter.levart at gmail.com (Peter Levart) Date: Sun, 3 Sep 2017 16:02:54 +0200 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <4612ad06-2bae-4482-175d-3c3bfc0dab27@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> <4612ad06-2bae-4482-175d-3c3bfc0dab27@oracle.com> Message-ID: <0c59deae-ac21-8062-c3c5-c4eb270b4b98@gmail.com> Hi Mandy, On 09/03/2017 04:52 AM, mandy chung wrote: > > On 9/2/17 2:57 AM, Peter Levart wrote: >> Hi Mandy, >> >> The API looks fine to me. >> >> Note that there is an opportunity for a follow-up optimization of the >> StackFrameInfo::getDescriptor() case. When MemberName's 'type' field >> is filled by native expandFromVM() it is usually filled with the >> descriptor string. MemberName::getMethodType() then parses this >> string into a MemberType, resolving all the types. So when >> StackFrameInfo::getDescriptor() is called, the descriptor string is >> 1st parsed into MethodType and then formatted back to the descriptor. >> By introducing new method into package-private MemberName - say >> getMethodDescriptorString(), this intermediate conversion could often >> be avoided (for example, if getMethodDescriptorString() was called >> before getMethodType() on an instance of MethodName). >> > Good suggestion. > > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.02/ That's what I had in mind, yes. Looking at the method names, I have a second thought about the too general StackFrame::getDescriptor(). Not looking at the javadocs, one could ask: "what is a descriptor of a stack frame?". I don't know, maybe getMethodDescriptor() would be more to the point or even getMethodTypeDescriptor() (since it is a descriptor of method parameter and return types, not containing method name). What do you and others think? Although it is not expected for StackFrame interface to be implemented by custom classes, it is a public interface. I have seen 3rd party code implementing JDK interface that was not meant to be implemented by custom classes just because the interface seemed appropriate. To keep binary compatibility with such potential implementations, those two new methods could be default methods throwing UOE. nit: while you are at it, you could remove the redundant "static" modifier from the StackWalker.StackFrame interface declaration. Regards, Peter > > Thanks > Mandy >> Regards, Peter >> >> On 09/01/2017 07:39 AM, mandy chung wrote: >>> Updated webrev: >>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html >>> >>> >>> This introduces two new methods, StackFrame::getMethodType and >>> StackFrame::getDescriptor. >>> >>> Mandy >>> >>> On 8/30/17 12:25 AM, Remi Forax wrote: >>>> Hi Mandy, >>>> thanks for taking care of this. >>>> >>>> In my opinion, we should provide both getMethodType() and >>>> getDescriptor(), >>>> getDescriptor() is handy for logging (finding the right overload >>>> when line numbers are not present) and getMethodType() is the one >>>> you whant if you want to inspect the runtime view of the stack >>>> frames (and by example interact with java.lang.invoke). For me, >>>> it's the same reason that give us getDeclaringClass() and >>>> getClassName() in the current API. >>>> >>>> So getDescriptor() can be called with no restriction but >>>> getMethodType() requires RETAIN_CLASS_REFERENCE. >>>> >>>> regards, >>>> R?mi >>>> >>>> ----- Mail original ----- >>>>> De: "mandy chung" >>>>> ?: "core-libs-dev" >>>>> Envoy?: Mardi 29 Ao?t 2017 00:57:28 >>>>> Objet: Review Request JDK-8186050: StackFrame should provide the >>>>> method signature >>>>> Method signature is missing in the StackFrame API. This proposes >>>>> to add >>>>> StackFrame::getMethodDescriptor method to return the method >>>>> descriptor >>>>> in a stack frame. >>>>> >>>>> Webrev at: >>>>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html >>>>> >>>>> >>>>> There are a couple options how to present the method signature in the >>>>> API level: >>>>> 1. Class[] getParameterTypes() and Class getReturnTypes() >>>>> similiar >>>>> to what java.lang.reflect.Method has. >>>>> 2. java.lang.invoke.MethodType >>>>> 3. a String representation (i) comma-separated list of the method's >>>>> formal parameter types (ii) bytecode method descriptor as >>>>> specified in JVMS >>>>> >>>>> Returning Class instance should require to add a new StackWalker >>>>> option to access to the parameter types and return type for option #1 >>>>> and #2. StackFrame::getDeclaringClass requires the stack walker to >>>>> have >>>>> the RETAIN_CLASS_REFERENCE capability. >>>>> >>>>> Option #2 returning MethodType is handy while java.lang would >>>>> reference >>>>> a type in java.lang.invoke. >>>>> >>>>> Option #3 requires the caller to parse the return string and call >>>>> Class.forName to get the Class instance. OTOH >>>>> MethodType::fromMethodDescriptorString method that returns MethodType >>>>> from a bytecode method descriptor string. >>>>> >>>>> Method signature is for information for typical cases. Getting >>>>> Class >>>>> for the parameter types and return type would be a niche case. I >>>>> think >>>>> returning the method descriptor string is a good option - keep the >>>>> API >>>>> simple and can use MethodType::fromMethodDescriptorString to get back >>>>> the types if needed. >>>>> >>>>> thanks >>>>> Mandy >>> >> > From OGATAK at jp.ibm.com Mon Sep 4 05:20:08 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Mon, 4 Sep 2017 14:20:08 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> Message-ID: Hi Aleksey and Hans, I implemented four variations of changes and measured performance improvement. 1) Put VarHandle.fullFence() between initialization of ClassDataSlot[] and writing the reference to non-volatile dataLayout. Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/ 2) Use Unsafe.getObjectAcquire() and Unsafe.putObjectRelease() for reading/writing dataLayout. Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-unsafe/ 3) Put reference to ClassDataSlot[] into a final field of an object and store the object to non-volatile dataLayout. Every invocation of getDataLayout() reads the final field needs to deference the object pointer. Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final/ 4) Put reference to ClassDataSlot[] into a final field of an object, read the final field immediately after the object creation, and store it to non-volatile dataLayout. I think this is also correct based on the semantics of final fields and data dependency. Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ The performance improvements were: 1) +3.5% 2) +1.1% 3) +2.2% 4) +3.4% The reason of small improvement in 2) is that the actual code of Unsafe.getObjectAcquire()/putObjectRelease() simply invokes getObjectVolatile()/putObjectVolatile() in them, respectively. If all implementations are correct, I'd like to take 4) because I want to back port this change to jdk8u but VarHandle is only available in jdk9 or later. Regards, Ogata From peter.levart at gmail.com Mon Sep 4 08:06:21 2017 From: peter.levart at gmail.com (Peter Levart) Date: Mon, 4 Sep 2017 10:06:21 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> Message-ID: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> Hi Ogata, On 09/04/2017 07:20 AM, Kazunori Ogata wrote: > 4) Put reference to ClassDataSlot[] into a final field of an object, read > the final field immediately after the object creation, and store it to > non-volatile dataLayout. I think this is also correct based on the > semantics of final fields and data dependency. > Webrev:http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ I'm sure others will tell you that final field semantics only works across threads when you also read the final field in the other thread from the thread that writes to it. Storing and reading the final field in the same thread won't help order the write to a non final field after writes that precede it in program order nor to order the read of a non-final field in the other thread before reads that follow it in program order. Regards, Peter From OGATAK at jp.ibm.com Mon Sep 4 08:23:29 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Mon, 4 Sep 2017 17:23:29 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> Message-ID: Hi Peter, Thank you for your comment. I thought the compiler must insert memory fence at the end of object initializer, but I agree relying on it is not correct w.r.t. JMM. Then I'll take 1) 1) Put VarHandle.fullFence() between initialization of ClassDataSlot[] and writing the reference to non-volatile dataLayout. (Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/), as it achieved the best performance. Regards, Ogata Peter Levart wrote on 2017/09/04 17:06:21: > From: Peter Levart > To: Kazunori Ogata , core-libs-dev dev at openjdk.java.net>, Aleksey Shipilev , Hans Boehm > > Date: 2017/09/04 17:06 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi Ogata, > On 09/04/2017 07:20 AM, Kazunori Ogata wrote: > 4) Put reference to ClassDataSlot[] into a final field of an object, read > the final field immediately after the object creation, and store it to > non-volatile dataLayout. I think this is also correct based on the > semantics of final fields and data dependency. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ > > I'm sure others will tell you that final field semantics only works across > threads when you also read the final field in the other thread from the > thread that writes to it. Storing and reading the final field in the same > thread won't help order the write to a non final field after writes that > precede it in program order nor to order the read of a non-final field in > the other thread before reads that follow it in program order. > > Regards, Peter From peter.levart at gmail.com Mon Sep 4 08:45:37 2017 From: peter.levart at gmail.com (Peter Levart) Date: Mon, 4 Sep 2017 10:45:37 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> Message-ID: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Hi Ogata, On 09/04/2017 10:23 AM, Kazunori Ogata wrote: > Hi Peter, > > Thank you for your comment. I thought the compiler must insert memory > fence at the end of object initializer, but I agree relying on it is not > correct w.r.t. JMM. > > Then I'll take 1) 1) Put VarHandle.fullFence() between initialization of > ClassDataSlot[] and writing the reference to non-volatile dataLayout. > (Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/), as > it achieved the best performance. > > > Regards, > Ogata > If playing with mutable plain fields in multiple threads, it is mandatory to read the plain field just once in program. Your implementation: 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException { 1197 // REMIND: synchronize instead of relying on volatile? 1198 if (dataLayout == null) { 1199 ClassDataSlot[] slots = getClassDataLayout0(); 1200 VarHandle.fullFence(); 1201 dataLayout = slots; 1202 } 1203 return dataLayout; 1204 } reads dataLayout field twice (line 1198 and 1203). Those two reads may reorder and 1st return non-null value, while the 2nd return previous value - null. You should use a local variable to store the 1st read and return the local variable at the end. Like: ClassDataSlot[] getClassDataLayout() throws InvalidClassException { ClassDataSlot[] slots = dataLayout; if (slots == null) { ClassDataSlot[] slots = getClassDataLayout0(); VarHandle.fullFence(); dataLayout = slots; } return slots; } Regards, Peter From peter.levart at gmail.com Mon Sep 4 08:49:23 2017 From: peter.levart at gmail.com (Peter Levart) Date: Mon, 4 Sep 2017 10:49:23 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Message-ID: <6b9ac36a-e911-454d-ce49-f9bdb5797ae3@gmail.com> Ops, pressed SEND to quickly... On 09/04/2017 10:45 AM, Peter Levart wrote: > > > ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > ClassDataSlot[] slots = dataLayout; > if (slots == null) { > ClassDataSlot[] slots = getClassDataLayout0(); > VarHandle.fullFence(); > dataLayout = slots; > } > return slots; > } > > Correct code (forgot to remove the 2nd declaration of local field): ClassDataSlot[] getClassDataLayout() throws InvalidClassException { ClassDataSlot[] slots = dataLayout; if (slots == null) { slots = getClassDataLayout0(); VarHandle.fullFence(); dataLayout = slots; } return slots; } Peter From peter.levart at gmail.com Mon Sep 4 09:07:37 2017 From: peter.levart at gmail.com (Peter Levart) Date: Mon, 4 Sep 2017 11:07:37 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> Message-ID: <41194d06-386d-e418-2e62-7709cfaf3dd9@gmail.com> Hi, Maybe a more knowledgeable soul could shed some light into an internal @Stable annotation... It was meant to be used internally in the java.lang.invoke package, but in JDK 9 it was made public, not exported, so it can be used in the entire java.base module. There are already some usages in java.util package and recently, sun.nio.cs.StandardCharsets added a usage in JDK 10. When @Stable annotation was designed it was debated whether @Stable instance fields should get the treatment of final instance fields as far as JMM is concerned. So the question is, was this suggestion actually implemented in the VM. Scanning the usages in JDK 10, I can see that all @Stable instance fields of array type(s) are also marked with final modifier. Except one: java.lang.invoke.VarForm#methodType_V_table Is this an oversight or a consequence of @Stable implying the memory order semantics of final? If it is the later, then perhaps Ogata could simply put @Stable in front of dataLayout field. Regards, Peter On 09/04/2017 07:20 AM, Kazunori Ogata wrote: > Hi Aleksey and Hans, > > I implemented four variations of changes and measured performance > improvement. > > 1) Put VarHandle.fullFence() between initialization of ClassDataSlot[] and > writing the reference to non-volatile dataLayout. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/ > > 2) Use Unsafe.getObjectAcquire() and Unsafe.putObjectRelease() for > reading/writing dataLayout. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-unsafe/ > > 3) Put reference to ClassDataSlot[] into a final field of an object and > store the object to non-volatile dataLayout. Every invocation of > getDataLayout() reads the final field needs to deference the object > pointer. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final/ > > 4) Put reference to ClassDataSlot[] into a final field of an object, read > the final field immediately after the object creation, and store it to > non-volatile dataLayout. I think this is also correct based on the > semantics of final fields and data dependency. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ > > > The performance improvements were: > > 1) +3.5% > 2) +1.1% > 3) +2.2% > 4) +3.4% > > The reason of small improvement in 2) is that the actual code of > Unsafe.getObjectAcquire()/putObjectRelease() simply invokes > getObjectVolatile()/putObjectVolatile() in them, respectively. > > > If all implementations are correct, I'd like to take 4) because I want to > back port this change to jdk8u but VarHandle is only available in jdk9 or > later. > > > Regards, > Ogata > From OGATAK at jp.ibm.com Mon Sep 4 09:13:47 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Mon, 4 Sep 2017 18:13:47 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Message-ID: Hi Peter, Thank you for fixing the code. I updated webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.02/ Regards, Ogata Peter Levart wrote on 2017/09/04 17:45:37: > From: Peter Levart > To: Kazunori Ogata > Cc: core-libs-dev , Hans Boehm > , Aleksey Shipilev > Date: 2017/09/04 17:45 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi Ogata, > If playing with mutable plain fields in multiple threads, it is > mandatory to read the plain field just once in program. Your implementation: > > 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > 1197 // REMIND: synchronize instead of relying on volatile? > 1198 if (dataLayout == null) { > 1199 ClassDataSlot[] slots = getClassDataLayout0(); > 1200 VarHandle.fullFence(); > 1201 dataLayout = slots; > 1202 } > 1203 return dataLayout; > 1204 } > > reads dataLayout field twice (line 1198 and 1203). Those two reads may > reorder and 1st return non-null value, while the 2nd return previous > value - null. You should use a local variable to store the 1st read and > return the local variable at the end. Like: > > ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > ClassDataSlot[] slots = dataLayout; > if (slots == null) { > ClassDataSlot[] slots = getClassDataLayout0(); > VarHandle.fullFence(); > dataLayout = slots; > } > return slots; > } > > > Regards, Peter > From Roger.Riggs at Oracle.com Tue Sep 5 13:42:08 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 5 Sep 2017 09:42:08 -0400 Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" Message-ID: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> Please review a fix for an intermittent issue with ProcessHandle.onExit. On Solaris, the start time of a process reported through /proc/pid/psinfo changes to zero when the process is exiting.? The onExit implementation incorrectly interpreted zero meaning the pid had been re-used and the process was no longer alive.? However, ProcessHandle.isAlive considered zero to be missing information and the process was still alive. Webrev: ? http://cr.openjdk.java.net/~rriggs/webrev-onexit-8177932/ Issue: ? https://bugs.openjdk.java.net/browse/JDK-8177932 Thanks, Roger From thomas.stuefe at gmail.com Tue Sep 5 15:06:25 2017 From: thomas.stuefe at gmail.com (=?UTF-8?Q?Thomas_St=C3=BCfe?=) Date: Tue, 5 Sep 2017 17:06:25 +0200 Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" In-Reply-To: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> References: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> Message-ID: Hi Roger, this looks reasonable. Best Regards, Thomas On Tue, Sep 5, 2017 at 3:42 PM, Roger Riggs wrote: > Please review a fix for an intermittent issue with ProcessHandle.onExit. > On Solaris, the start time of a process reported through /proc/pid/psinfo > changes to > zero when the process is exiting. The onExit implementation incorrectly > interpreted zero > meaning the pid had been re-used and the process was no longer alive. > However, > ProcessHandle.isAlive considered zero to be missing information and the > process was still alive. > > Webrev: > http://cr.openjdk.java.net/~rriggs/webrev-onexit-8177932/ > > Issue: > https://bugs.openjdk.java.net/browse/JDK-8177932 > > Thanks, Roger > > From david.holmes at oracle.com Tue Sep 5 21:43:20 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 6 Sep 2017 07:43:20 +1000 Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" In-Reply-To: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> References: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> Message-ID: Hi Roger, This seems quite reasonable. Thanks, David On 5/09/2017 11:42 PM, Roger Riggs wrote: > Please review a fix for an intermittent issue with ProcessHandle.onExit. > On Solaris, the start time of a process reported through > /proc/pid/psinfo changes to > zero when the process is exiting.? The onExit implementation incorrectly > interpreted zero > meaning the pid had been re-used and the process was no longer alive. > However, > ProcessHandle.isAlive considered zero to be missing information and the > process was still alive. > > Webrev: > ? http://cr.openjdk.java.net/~rriggs/webrev-onexit-8177932/ > > Issue: > ? https://bugs.openjdk.java.net/browse/JDK-8177932 > > Thanks, Roger > From martinrb at google.com Wed Sep 6 00:51:24 2017 From: martinrb at google.com (Martin Buchholz) Date: Tue, 5 Sep 2017 17:51:24 -0700 Subject: RFR JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files In-Reply-To: <59A9EAA2.3020102@oracle.com> References: <599B8A4C.3050904@oracle.com> <599CAFDB.9020902@oracle.com> <59A9EAA2.3020102@oracle.com> Message-ID: Thanks for doing this. I'm also hoping to contribute some testing effort, but time ... time ... This Looks Good To Me, but as always I have comments. --- I wouldn't create an echo process. Just create a zip subprocess and write the bytes from java to its stdin. 181 ProcessBuilder echo = new ProcessBuilder("echo", "hello"); --- You should check whether there's a usable zip program, e.g. I once wrote code like this: if (! new File("/usr/bin/perl").canExecute() 182 ProcessBuilder zip = new ProcessBuilder("zip", path.toString().toString(), "-"); oh wait, now I see 196 } catch (IOException x) { 197 // ignore, probably from process.start() for "Cannot run program" well ... I would still add some checks for /usr/bin/zip and elide the catch. --- """Always specify the charset""" (here "ASCII" is fine). 163 if (!"hello".equals(new String(zf.getInputStream(new ZipEntry("hello")) 164 .readAllBytes()))) --- Can we say something like // We must always check for a zip64 EOCD record; it is always permitted to be present 1125 // try if we have a zip64 end; --- Maybe // end64 candidate found 1139 // end64 found, --- It's 2017. Time to just make centot a long? 1152 end.centot = (int)centot64; // assume total < 2g --- Here's a typo to fix: entires On Fri, Sep 1, 2017 at 4:17 PM, Xueming Shen wrote: > On 8/22/17, 5:54 PM, Martin Buchholz wrote: > > > > On Tue, Aug 22, 2017 at 3:27 PM, Xueming Shen > wrote: > >> >> How about to add an option to our zipfs to force the ZIP64 end record when >> enabled. Harmless if not specified. >> > > I agree that adding more options for testability is good. Since our users > are likely to need such things as well, I'd also like to see such features > become public, analogous to zip's -fz- flag. > > OTOH, interoperability testing is very valuable, so despite the troubles > involved writing tests that involve both jdk and zipinfo code, I think we > should do it. > > > Martin, > > I have added a test case that tests "echo hello | zip infozip.zip -" via > pb.startPipeline() > in ReadZip.java, which should add some coverage for the "interoperability > testing". > > Would you please help take a look? > > http://cr.openjdk.java.net/~sherman/8186464/webrev/ > > Thanks, > Sherman > From weijun.wang at oracle.com Wed Sep 6 04:17:33 2017 From: weijun.wang at oracle.com (Weijun Wang) Date: Wed, 6 Sep 2017 12:17:33 +0800 Subject: RFR 8148371: Remove policytool In-Reply-To: References: Message-ID: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> Hi All Please review the change, which spans to root, jdk and langtools repos. http://cr.openjdk.java.net/~weijun/8148371/ I've searched for the "policytool" word in the whole jdk10/jdk10 forests, removed all files having the word inside the path name, and remove almost all occurrences of the word in other places. The exceptions are: 1. Two files with the jdk8 word in file name. I assume I should not touch them. Please advise me. jdk/src/java.base/share/classes/jdk/internal/module/jdk8_packages.dat: 1288 sun.security.tools.jarsigner 1289 sun.security.tools.keytool 1290: sun.security.tools.policytool 1291 sun.security.util 1292 sun.security.validator langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt: 977 sun.security.tools.jarsigner 978 sun.security.tools.keytool 979: sun.security.tools.policytool 980 sun.security.util 981 sun.security.validator 2. A swing test containing a full JDK 1.4.2 README text. Keep unchanged. jdk/test/javax/swing/JTextArea/4697612/bug4697612.txt: 122 bin/ktab and jre/bin/ktab 123 Kerberos key table manager 124: bin/policytool and jre/bin/policytool 125 Policy File Creation and Management Tool 126 bin/orbd and jre/bin/orbd 3. A manual test on what resource string are used. It is based on the pre-module source layout and needs to be updated anyway. Keep unchanged this time. https://bugs.openjdk.java.net/browse/JDK-8187265 filed. jdk/test/sun/security/util/Resources/NewResourcesNames.java: 62 "sun/security/tools/jarsigner/Resources.java", 63 "sun/security/tools/keytool/Resources.java", 64: "sun/security/tools/policytool/Resources.java", 65 "sun/security/util/Resources.java", 66 "sun/security/util/AuthResources.java", .. 103 // 104 // which is mismatch. There are only two such special cases list above. 105: // For KeyTool, there are 3 calls for showing help. For PolicyTool, 3 106 // for name prefixed with POLICY. They are covered in the two special 107 // cases above. There are some Japanese man pages containing the word. I've filed another bug (https://bugs.openjdk.java.net/browse/JDK-8187262) on it. Thanks Max From frank.yuan at oracle.com Wed Sep 6 05:41:37 2017 From: frank.yuan at oracle.com (Frank Yuan) Date: Wed, 6 Sep 2017 13:41:37 +0800 Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" In-Reply-To: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> References: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> Message-ID: <01fa01d326d2$d0302480$70906d80$@oracle.com> Hi Roger I think this is the cause and I believe the patch will work. However, I have the following concern and minor comments: a. Is it possible that following scenario happens? 1. process A exits 2. Completion thread in onExist runs and gets 0 as origStart, and then sleeps 5s 3. process reaper thread reaps the process A, and then the pid is reused 4. Completion thread gets a value as startTime, and then has to wait the new process termination I am not sure if the startTIme may be zero except the process is a zombie, if the startTIme may be zero only when the process is a zombie, we can change the condition to: if (startTime > 0 && startTime != origStart), otherwise we can't avoid such scenario, but if ProcessHandleImpl.onExit() passes startTime field to function completion, it may be a little bit better, at least, onExit() can be consistent with isAlive(). b. Should we rollback the change of JDK-8184808, at least, update the comment in that change? c. Should we remove @key intermittent and the debug info added in JDK-8183019? Thanks Frank > -----Original Message----- > From: core-libs-dev [mailto:core-libs-dev-bounces at openjdk.java.net] On Behalf Of Roger Riggs > Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" > > Please review a fix for an intermittent issue with ProcessHandle.onExit. > On Solaris, the start time of a process reported through > /proc/pid/psinfo changes to > zero when the process is exiting. The onExit implementation incorrectly > interpreted zero > meaning the pid had been re-used and the process was no longer alive. > However, > ProcessHandle.isAlive considered zero to be missing information and the > process was still alive. > > Webrev: > http://cr.openjdk.java.net/~rriggs/webrev-onexit-8177932/ > > Issue: > https://bugs.openjdk.java.net/browse/JDK-8177932 > > Thanks, Roger From li.jiang at oracle.com Wed Sep 6 06:15:56 2017 From: li.jiang at oracle.com (Leo Jiang) Date: Wed, 6 Sep 2017 14:15:56 +0800 Subject: RFR 8148371: Remove policytool In-Reply-To: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> References: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> Message-ID: Hi All, Kindly reminder: please file a bug to component globalization/translation and assign to Leo Jiang , when you need to add/remove a resource file which should be/was localized. We need to update a tbom file to track all of localizable resource files. Add me to email To: list would allow me being aware of these changes. Thanks, Leo On 09/06/2017 12:17 PM, Weijun Wang wrote: > Hi All > > Please review the change, which spans to root, jdk and langtools repos. > > http://cr.openjdk.java.net/~weijun/8148371/ > > I've searched for the "policytool" word in the whole jdk10/jdk10 forests, removed all files having the word inside the path name, and remove almost all occurrences of the word in other places. > > The exceptions are: > > 1. Two files with the jdk8 word in file name. I assume I should not touch them. Please advise me. > > jdk/src/java.base/share/classes/jdk/internal/module/jdk8_packages.dat: > 1288 sun.security.tools.jarsigner > 1289 sun.security.tools.keytool > 1290: sun.security.tools.policytool > 1291 sun.security.util > 1292 sun.security.validator > > langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt: > 977 sun.security.tools.jarsigner > 978 sun.security.tools.keytool > 979: sun.security.tools.policytool > 980 sun.security.util > 981 sun.security.validator > > 2. A swing test containing a full JDK 1.4.2 README text. Keep unchanged. > > jdk/test/javax/swing/JTextArea/4697612/bug4697612.txt: > 122 bin/ktab and jre/bin/ktab > 123 Kerberos key table manager > 124: bin/policytool and jre/bin/policytool > 125 Policy File Creation and Management Tool > 126 bin/orbd and jre/bin/orbd > > 3. A manual test on what resource string are used. It is based on the pre-module source layout and needs to be updated anyway. Keep unchanged this time. https://bugs.openjdk.java.net/browse/JDK-8187265 filed. > > jdk/test/sun/security/util/Resources/NewResourcesNames.java: > 62 "sun/security/tools/jarsigner/Resources.java", > 63 "sun/security/tools/keytool/Resources.java", > 64: "sun/security/tools/policytool/Resources.java", > 65 "sun/security/util/Resources.java", > 66 "sun/security/util/AuthResources.java", > .. > 103 // > 104 // which is mismatch. There are only two such special cases list above. > 105: // For KeyTool, there are 3 calls for showing help. For PolicyTool, 3 > 106 // for name prefixed with POLICY. They are covered in the two special > 107 // cases above. > > There are some Japanese man pages containing the word. I've filed another bug (https://bugs.openjdk.java.net/browse/JDK-8187262) on it. > > Thanks > Max > From erik.joelsson at oracle.com Wed Sep 6 08:53:27 2017 From: erik.joelsson at oracle.com (Erik Joelsson) Date: Wed, 6 Sep 2017 10:53:27 +0200 Subject: RFR 8148371: Remove policytool In-Reply-To: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> References: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> Message-ID: From a build point of view this looks good. /Erik On 2017-09-06 06:17, Weijun Wang wrote: > Hi All > > Please review the change, which spans to root, jdk and langtools repos. > > http://cr.openjdk.java.net/~weijun/8148371/ > > I've searched for the "policytool" word in the whole jdk10/jdk10 forests, removed all files having the word inside the path name, and remove almost all occurrences of the word in other places. > > The exceptions are: > > 1. Two files with the jdk8 word in file name. I assume I should not touch them. Please advise me. > > jdk/src/java.base/share/classes/jdk/internal/module/jdk8_packages.dat: > 1288 sun.security.tools.jarsigner > 1289 sun.security.tools.keytool > 1290: sun.security.tools.policytool > 1291 sun.security.util > 1292 sun.security.validator > > langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt: > 977 sun.security.tools.jarsigner > 978 sun.security.tools.keytool > 979: sun.security.tools.policytool > 980 sun.security.util > 981 sun.security.validator > > 2. A swing test containing a full JDK 1.4.2 README text. Keep unchanged. > > jdk/test/javax/swing/JTextArea/4697612/bug4697612.txt: > 122 bin/ktab and jre/bin/ktab > 123 Kerberos key table manager > 124: bin/policytool and jre/bin/policytool > 125 Policy File Creation and Management Tool > 126 bin/orbd and jre/bin/orbd > > 3. A manual test on what resource string are used. It is based on the pre-module source layout and needs to be updated anyway. Keep unchanged this time. https://bugs.openjdk.java.net/browse/JDK-8187265 filed. > > jdk/test/sun/security/util/Resources/NewResourcesNames.java: > 62 "sun/security/tools/jarsigner/Resources.java", > 63 "sun/security/tools/keytool/Resources.java", > 64: "sun/security/tools/policytool/Resources.java", > 65 "sun/security/util/Resources.java", > 66 "sun/security/util/AuthResources.java", > .. > 103 // > 104 // which is mismatch. There are only two such special cases list above. > 105: // For KeyTool, there are 3 calls for showing help. For PolicyTool, 3 > 106 // for name prefixed with POLICY. They are covered in the two special > 107 // cases above. > > There are some Japanese man pages containing the word. I've filed another bug (https://bugs.openjdk.java.net/browse/JDK-8187262) on it. > > Thanks > Max > From Alan.Bateman at oracle.com Wed Sep 6 09:24:22 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Wed, 6 Sep 2017 10:24:22 +0100 Subject: RFR 8148371: Remove policytool In-Reply-To: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> References: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> Message-ID: On 06/09/2017 05:17, Weijun Wang wrote: > Hi All > > Please review the change, which spans to root, jdk and langtools repos. > > http://cr.openjdk.java.net/~weijun/8148371/ > > I've searched for the "policytool" word in the whole jdk10/jdk10 forests, removed all files having the word inside the path name, and remove almost all occurrences of the word in other places. > This looks good, the only change that I'm not sure about is the change to ct.properties as it may be used when compiling to older releases. Someone on compiler-dev should be able to help you on that. -Alan From Roger.Riggs at Oracle.com Wed Sep 6 13:47:20 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Wed, 6 Sep 2017 09:47:20 -0400 Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" In-Reply-To: <01fa01d326d2$d0302480$70906d80$@oracle.com> References: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> <01fa01d326d2$d0302480$70906d80$@oracle.com> Message-ID: Hi Frank Thanks for the review. On 9/6/2017 1:41 AM, Frank Yuan wrote: > Hi Roger > > I think this is the cause and I believe the patch will work. > > However, I have the following concern and minor comments: > a. Is it possible that following scenario happens? > 1. process A exits > 2. Completion thread in onExist runs and gets 0 as origStart, and then sleeps 5s > 3. process reaper thread reaps the process A, and then the pid is reused > 4. Completion thread gets a value as startTime, and then has to wait the new process termination > I am not sure if the startTime may be zero except the process is a zombie, if the startTime may be zero only when the process is a zombie, we can change the condition to: if (startTime > 0 && startTime != origStart), otherwise we can't avoid such scenario, but if ProcessHandleImpl.onExit() passes startTime field to function completion, it may be a little bit better, at least, onExit() can be consistent with isAlive(). Note that the startTime in the ProcessHandle is acquired by ProcessHandle.of which uses isAlive, and may be 0. StartTime is optional and the provision to ignore startTime = 0 is intended to cover cases where the underlying operating system did not or could not provide a reasonable start time. We have not see any issues with pid re-use and I would prefer to avoid over engineering the code for a non-issue. With the proposed fix, the onExit completion handler and isAlive are consistent. > > b. Should we rollback the change of JDK-8184808, at least, update the comment in that change? I'll update the comment.? Double checking using kill seems to be more reliable. > > c. Should we remove @key intermittent and the debug info added in JDK-8183019? I'd prefer to leave them for some to make sure the issue does not re-appear. I created a subtask to re-check in 2 months. Roger > > Thanks > Frank > >> -----Original Message----- >> From: core-libs-dev [mailto:core-libs-dev-bounces at openjdk.java.net] On Behalf Of Roger Riggs >> Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" >> >> Please review a fix for an intermittent issue with ProcessHandle.onExit. >> On Solaris, the start time of a process reported through >> /proc/pid/psinfo changes to >> zero when the process is exiting. The onExit implementation incorrectly >> interpreted zero >> meaning the pid had been re-used and the process was no longer alive. >> However, >> ProcessHandle.isAlive considered zero to be missing information and the >> process was still alive. >> >> Webrev: >> http://cr.openjdk.java.net/~rriggs/webrev-onexit-8177932/ >> >> Issue: >> https://bugs.openjdk.java.net/browse/JDK-8177932 >> >> Thanks, Roger > From xueming.shen at oracle.com Wed Sep 6 16:25:09 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Wed, 06 Sep 2017 09:25:09 -0700 Subject: RFR JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files In-Reply-To: References: <599B8A4C.3050904@oracle.com> <599CAFDB.9020902@oracle.com> <59A9EAA2.3020102@oracle.com> Message-ID: <59B02165.8090601@oracle.com> Thanks Martin! webrev has been updated as suggested (the old webrev has been renamed to webrev00) http://cr.openjdk.java.net/~sherman/8186464/webrev The only thing is not updated is the centot, we are using it as "int" anyway at other place. Let's keep it for couple more years till the 32-bit is totally gone. -Sherman On 9/5/17, 5:51 PM, Martin Buchholz wrote: > Thanks for doing this. > I'm also hoping to contribute some testing effort, but time ... time ... > This Looks Good To Me, but as always I have comments. > --- > I wouldn't create an echo process. Just create a zip subprocess and > write the bytes from java to its stdin. > 181 ProcessBuilder echo = new ProcessBuilder("echo", "hello"); > --- > You should check whether there's a usable zip program, e.g. I once > wrote code like this: > > if (! new File("/usr/bin/perl").canExecute() > 182 ProcessBuilder zip = new ProcessBuilder("zip", path.toString().toString(), "-"); > oh wait, now I see > 196 } catch (IOException x) { > 197 // ignore, probably from process.start() for "Cannot run program" > well ... I would still add some checks for /usr/bin/zip and elide the > catch. > --- > > > """Always specify the charset""" (here "ASCII" is fine). > > 163 if (!"hello".equals(new String(zf.getInputStream(new ZipEntry("hello")) > 164 .readAllBytes()))) > > --- > Can we say something like > // We must always check for a zip64 EOCD record; it is always > permitted to be present > 1125 // try if we have a zip64 end; > --- > Maybe > // end64 candidate found > 1139 // end64 found, > --- > It's 2017. Time to just make centot a long? > 1152 end.centot = (int)centot64; // assume total< 2g > --- > Here's a typo to fix: > entires > > On Fri, Sep 1, 2017 at 4:17 PM, Xueming Shen > wrote: > > On 8/22/17, 5:54 PM, Martin Buchholz wrote: >> >> >> On Tue, Aug 22, 2017 at 3:27 PM, Xueming Shen >> > wrote: >> >> >> How about to add an option to our zipfs to force the ZIP64 >> end record when >> enabled. Harmless if not specified. >> >> >> I agree that adding more options for testability is good. Since >> our users are likely to need such things as well, I'd also like >> to see such features become public, analogous to zip's -fz- flag. >> >> OTOH, interoperability testing is very valuable, so despite the >> troubles involved writing tests that involve both jdk and zipinfo >> code, I think we should do it. >> > Martin, > > I have added a test case that tests "echo hello | zip infozip.zip > -" via pb.startPipeline() > in ReadZip.java, which should add some coverage for the > "interoperability testing". > > Would you please help take a look? > > http://cr.openjdk.java.net/~sherman/8186464/webrev/ > > > Thanks, > Sherman > > From martinrb at google.com Wed Sep 6 17:09:38 2017 From: martinrb at google.com (Martin Buchholz) Date: Wed, 6 Sep 2017 10:09:38 -0700 Subject: RFR JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files In-Reply-To: <59B02165.8090601@oracle.com> References: <599B8A4C.3050904@oracle.com> <599CAFDB.9020902@oracle.com> <59A9EAA2.3020102@oracle.com> <59B02165.8090601@oracle.com> Message-ID: Thanks! Ship it. On Wed, Sep 6, 2017 at 9:25 AM, Xueming Shen wrote: > Thanks Martin! > > webrev has been updated as suggested (the old webrev has been renamed to > webrev00) > > http://cr.openjdk.java.net/~sherman/8186464/webrev > > The only thing is not updated is the centot, we are using it as "int" > anyway at other place. > Let's keep it for couple more years till the 32-bit is totally gone. > > -Sherman > > > On 9/5/17, 5:51 PM, Martin Buchholz wrote: > > Thanks for doing this. > I'm also hoping to contribute some testing effort, but time ... time ... > This Looks Good To Me, but as always I have comments. > --- > I wouldn't create an echo process. Just create a zip subprocess and write > the bytes from java to its stdin. > > 181 ProcessBuilder echo = new ProcessBuilder("echo", "hello"); > > --- > You should check whether there's a usable zip program, e.g. I once wrote > code like this: > > if (! new File("/usr/bin/perl").canExecute() > > 182 ProcessBuilder zip = new ProcessBuilder("zip", path.toString().toString(), "-"); > > oh wait, now I see > > 196 } catch (IOException x) { 197 // ignore, probably from process.start() for "Cannot run program" > > well ... I would still add some checks for /usr/bin/zip and elide the > catch. > --- > > > """Always specify the charset""" (here "ASCII" is fine). > > 163 if (!"hello".equals(new String(zf.getInputStream(new ZipEntry("hello")) 164 .readAllBytes()))) > > > --- > Can we say something like > // We must always check for a zip64 EOCD record; it is always permitted to > be present > > 1125 // try if we have a zip64 end; > > --- > Maybe > // end64 candidate found > > 1139 // end64 found, > > --- > It's 2017. Time to just make centot a long? > > 1152 end.centot = (int)centot64; // assume total < 2g > > --- > Here's a typo to fix: > > entires > > > On Fri, Sep 1, 2017 at 4:17 PM, Xueming Shen > wrote: > >> On 8/22/17, 5:54 PM, Martin Buchholz wrote: >> >> >> >> On Tue, Aug 22, 2017 at 3:27 PM, Xueming Shen >> wrote: >> >>> >>> How about to add an option to our zipfs to force the ZIP64 end record >>> when >>> enabled. Harmless if not specified. >>> >> >> I agree that adding more options for testability is good. Since our >> users are likely to need such things as well, I'd also like to see such >> features become public, analogous to zip's -fz- flag. >> >> OTOH, interoperability testing is very valuable, so despite the troubles >> involved writing tests that involve both jdk and zipinfo code, I think we >> should do it. >> >> >> Martin, >> >> I have added a test case that tests "echo hello | zip infozip.zip -" via >> pb.startPipeline() >> in ReadZip.java, which should add some coverage for the "interoperability >> testing". >> >> Would you please help take a look? >> >> http://cr.openjdk.java.net/~sherman/8186464/webrev/ >> >> Thanks, >> Sherman >> > > > From sean.mullan at oracle.com Wed Sep 6 20:23:47 2017 From: sean.mullan at oracle.com (Sean Mullan) Date: Wed, 6 Sep 2017 16:23:47 -0400 Subject: RFR 8148371: Remove policytool In-Reply-To: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> References: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> Message-ID: <65e41154-26ee-6a45-7345-5547a50b9346@oracle.com> The jdk changes look fine to me. --Sean On 9/6/17 12:17 AM, Weijun Wang wrote: > Hi All > > Please review the change, which spans to root, jdk and langtools repos. > > http://cr.openjdk.java.net/~weijun/8148371/ > > I've searched for the "policytool" word in the whole jdk10/jdk10 forests, removed all files having the word inside the path name, and remove almost all occurrences of the word in other places. > > The exceptions are: > > 1. Two files with the jdk8 word in file name. I assume I should not touch them. Please advise me. > > jdk/src/java.base/share/classes/jdk/internal/module/jdk8_packages.dat: > 1288 sun.security.tools.jarsigner > 1289 sun.security.tools.keytool > 1290: sun.security.tools.policytool > 1291 sun.security.util > 1292 sun.security.validator > > langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt: > 977 sun.security.tools.jarsigner > 978 sun.security.tools.keytool > 979: sun.security.tools.policytool > 980 sun.security.util > 981 sun.security.validator > > 2. A swing test containing a full JDK 1.4.2 README text. Keep unchanged. > > jdk/test/javax/swing/JTextArea/4697612/bug4697612.txt: > 122 bin/ktab and jre/bin/ktab > 123 Kerberos key table manager > 124: bin/policytool and jre/bin/policytool > 125 Policy File Creation and Management Tool > 126 bin/orbd and jre/bin/orbd > > 3. A manual test on what resource string are used. It is based on the pre-module source layout and needs to be updated anyway. Keep unchanged this time. https://bugs.openjdk.java.net/browse/JDK-8187265 filed. > > jdk/test/sun/security/util/Resources/NewResourcesNames.java: > 62 "sun/security/tools/jarsigner/Resources.java", > 63 "sun/security/tools/keytool/Resources.java", > 64: "sun/security/tools/policytool/Resources.java", > 65 "sun/security/util/Resources.java", > 66 "sun/security/util/AuthResources.java", > .. > 103 // > 104 // which is mismatch. There are only two such special cases list above. > 105: // For KeyTool, there are 3 calls for showing help. For PolicyTool, 3 > 106 // for name prefixed with POLICY. They are covered in the two special > 107 // cases above. > > There are some Japanese man pages containing the word. I've filed another bug (https://bugs.openjdk.java.net/browse/JDK-8187262) on it. > > Thanks > Max > From frank.yuan at oracle.com Thu Sep 7 05:46:28 2017 From: frank.yuan at oracle.com (Frank Yuan) Date: Thu, 7 Sep 2017 13:46:28 +0800 Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" In-Reply-To: References: <291e45c6-1b49-a36c-fa39-166adda07cfd@Oracle.com> <01fa01d326d2$d0302480$70906d80$@oracle.com> Message-ID: <026401d3279c$a7e2dac0$f7a89040$@oracle.com> We have not see any issues with pid re-use and I would prefer to avoid over engineering the code for a non-issue. Yes, I agree. With the proposed fix, the onExit completion handler and isAlive are consistent. I mean, in ProcessHandleImpl.isAlive(), startTime is the final filed of the ProcessHandleImpl instance, in onExit(), the pid of the ProcessHandleImpl instance is passed to completion function, and then origStart is assigned with the return value of isAlive0(pid), at this time, the value of origStart may be different with startTime of the ProcessHandleImpl instance, so onExit() of the ProcessHandleImpl instance is inconsistent with isAlive()of the same ProcessHandleImpl instance. Anyway, it may be a non-issue:) b. Should we rollback the change of JDK-8184808, at least, update the comment in that change? I'll update the comment. Double checking using kill seems to be more reliable. c. Should we remove @key intermittent and the debug info added in JDK-8183019? I'd prefer to leave them for some to make sure the issue does not re-appear. I created a subtask to re-check in 2 months. Thank you for your follow-up! Frank Roger Thanks Frank -----Original Message----- From: core-libs-dev [mailto:core-libs-dev-bounces at openjdk.java.net] On Behalf Of Roger Riggs Subject: RFR 8177932 (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive" Please review a fix for an intermittent issue with ProcessHandle.onExit. On Solaris, the start time of a process reported through /proc/pid/psinfo changes to zero when the process is exiting. The onExit implementation incorrectly interpreted zero meaning the pid had been re-used and the process was no longer alive. However, ProcessHandle.isAlive considered zero to be missing information and the process was still alive. Webrev: http://cr.openjdk.java.net/~rriggs/webrev-onexit-8177932/ Issue: https://bugs.openjdk.java.net/browse/JDK-8177932 Thanks, Roger From OGATAK at jp.ibm.com Thu Sep 7 05:54:02 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Thu, 7 Sep 2017 14:54:02 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Message-ID: Hi, Ping. Can I have reviews and a sponsor? Regards, Ogata Kazunori Ogata/Japan/IBM wrote on 2017/09/04 18:13:47: > From: Kazunori Ogata/Japan/IBM > To: Peter Levart > Cc: core-libs-dev , Hans Boehm > , Aleksey Shipilev > Date: 2017/09/04 18:13 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi Peter, > > Thank you for fixing the code. > > I updated webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.02/ > > Regards, > Ogata From m-matsushima at bk.jp.nec.com Thu Sep 7 06:16:13 2017 From: m-matsushima at bk.jp.nec.com (Mitsuru Matsushima) Date: Thu, 7 Sep 2017 06:16:13 +0000 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> Message-ID: Hi, Naoto-san, > So, considering these, I have a couple of options. One is to use the newer > java.time.format APIs which can correctly handle > this, or use the > JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. Hmm, I think the first option is ok. However, the second one seems to be confused. I guess the behaviors with COPMAT and Supplemental Era become follows: * COMPAT (SimpleDateFormat) Long: Heisei Short: H * COMPAT (DateTimeFormatter) Long: Heisei Short: H Narrow: H * Supplemental Era (SimpleDateFormat) Long: NewEra Short: N.E * Supplemental Era (DateTimeFormatter) Long: NewEra Short: NewEra Narrow: N.E If this is true, the short value of Supplemental Era differs from COMPAT. So CalendarNameProviderImpl should be conscious about the type of provider. --- Mitsuru > -----Original Message----- > From: Naoto Sato [mailto:naoto.sato at oracle.com] > Sent: Saturday, September 02, 2017 2:49 AM > To: Matsushima Mitsuru(?? ?) ; core-libs-dev ; i18n-dev > > Subject: Re: [10] RFR 8180469: Wrong short form text for supplemental Japanese era > > Hi Mitsuru-san, > > Yes, I remember we discussed on this issue before. The reason that LONG and SHORT names for Japanese era are the same > is that CLDR's era names are not very consistent on length. They have "eraNames", "eraAbbr", and "eraNarrow" variations. > We simply assign LONG to eraNames and SHORT to eraAbbr in SimpleDateFormat. Possibly the right solution is to provide > "narrow" option in SimpleDateFormat, but it would be breaking the compatibility (text length of those pattern characters > just have two options, one is 4 or greater (=LONG), and the other is less than 4 (=SHORT)). > > So, considering these, I have a couple of options. One is to use the newer java.time.format APIs which can correctly handle > this, or use the > JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. > > HTH, > Naoto > > On 8/31/17 7:34 PM, Mitsuru Matsushima wrote: > > Hi Naoto-san, > > > > The fix looks good, though I'm not a reviewer... > > > > By the way, I may have forgotten to inform you that there exist an issue at the short form of SimpleDateFormat has an > issue. > > > > The SimpleDateFormat class is only capable to treat two form, Short and Long. > > At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long form. > > So, the behavior of SimpleDateFormat is incompatible to previous versions. > > (See the Comparison table, I described before.) > > > > --- > > Mitsuru > > > >> -----Original Message----- > >> From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf > >> Of Naoto Sato > >> Sent: Thursday, August 31, 2017 7:56 AM > >> To: core-libs-dev ; i18n-dev > >> > >> Subject: [10] RFR 8180469: Wrong short form text for > >> supplemental Japanese era > >> > >> Hi, > >> > >> Please review the fix to the following issue: > >> > >> https://bugs.openjdk.java.net/browse/JDK-8180469 > >> > >> The proposed changeset is located at: > >> > >> http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ > >> > >> The problem was caused by the difference of the Era display name for "SHORT" style between java.time and java.util.Calendar. > >> > >> Naoto From naoto.sato at oracle.com Thu Sep 7 17:28:41 2017 From: naoto.sato at oracle.com (Naoto Sato) Date: Thu, 7 Sep 2017 10:28:41 -0700 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> Message-ID: <77a2201b-cb28-425d-37a1-7f4492928050@oracle.com> Mitsuru-san, By those options I meant to address the inconsistency in SimpleDateFormat, between COMPAT and CLDR, for the existing eras (e.g. Heisei). As to the inconsistency you wrote below, I am not sure that's worth doing, considering 1) it is aligned with CLDR, 2) supplemental era functionality is for emergency situations till the era is officially supported. Naoto On 9/6/17 11:16 PM, Mitsuru Matsushima wrote: > Hi, Naoto-san, > >> So, considering these, I have a couple of options. One is to use the newer >> java.time.format APIs which can correctly handle >> this, or use the >> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. > > Hmm, I think the first option is ok. > However, the second one seems to be confused > > I guess the behaviors with COPMAT and Supplemental Era become follows: > > * COMPAT (SimpleDateFormat) > Long: Heisei > Short: H > > * COMPAT (DateTimeFormatter) > Long: Heisei > Short: H > Narrow: H > > * Supplemental Era (SimpleDateFormat) > Long: NewEra > Short: N.E > > * Supplemental Era (DateTimeFormatter) > Long: NewEra > Short: NewEra > Narrow: N.E > > If this is true, the short value of Supplemental Era differs from COMPAT. > So CalendarNameProviderImpl should be conscious about the type of provider. > > --- > Mitsuru > >> -----Original Message----- >> From: Naoto Sato [mailto:naoto.sato at oracle.com] >> Sent: Saturday, September 02, 2017 2:49 AM >> To: Matsushima Mitsuru(?? ?) ; core-libs-dev ; i18n-dev >> >> Subject: Re: [10] RFR 8180469: Wrong short form text for supplemental Japanese era >> >> Hi Mitsuru-san, >> >> Yes, I remember we discussed on this issue before. The reason that LONG and SHORT names for Japanese era are the same >> is that CLDR's era names are not very consistent on length. They have "eraNames", "eraAbbr", and "eraNarrow" variations. >> We simply assign LONG to eraNames and SHORT to eraAbbr in SimpleDateFormat. Possibly the right solution is to provide >> "narrow" option in SimpleDateFormat, but it would be breaking the compatibility (text length of those pattern characters >> just have two options, one is 4 or greater (=LONG), and the other is less than 4 (=SHORT)). >> >> So, considering these, I have a couple of options. One is to use the newer java.time.format APIs which can correctly handle >> this, or use the >> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. >> >> HTH, >> Naoto >> >> On 8/31/17 7:34 PM, Mitsuru Matsushima wrote: >>> Hi Naoto-san, >>> >>> The fix looks good, though I'm not a reviewer... >>> >>> By the way, I may have forgotten to inform you that there exist an issue at the short form of SimpleDateFormat has an >> issue. >>> >>> The SimpleDateFormat class is only capable to treat two form, Short and Long. >>> At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long form. >>> So, the behavior of SimpleDateFormat is incompatible to previous versions. >>> (See the Comparison table, I described before.) >>> >>> --- >>> Mitsuru >>> >>>> -----Original Message----- >>>> From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf >>>> Of Naoto Sato >>>> Sent: Thursday, August 31, 2017 7:56 AM >>>> To: core-libs-dev ; i18n-dev >>>> >>>> Subject: [10] RFR 8180469: Wrong short form text for >>>> supplemental Japanese era >>>> >>>> Hi, >>>> >>>> Please review the fix to the following issue: >>>> >>>> https://bugs.openjdk.java.net/browse/JDK-8180469 >>>> >>>> The proposed changeset is located at: >>>> >>>> http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ >>>> >>>> The problem was caused by the difference of the Era display name for "SHORT" style between java.time and java.util.Calendar. >>>> >>>> Naoto > From weijun.wang at oracle.com Fri Sep 8 01:51:07 2017 From: weijun.wang at oracle.com (Weijun Wang) Date: Fri, 8 Sep 2017 09:51:07 +0800 Subject: RFR 8148371: Remove policytool In-Reply-To: References: <76E698F8-551B-4DD8-9D42-3DA2764786EB@oracle.com> Message-ID: <7FD840F2-15D3-40F1-B2A1-9F816E4A8BD0@oracle.com> > On Sep 6, 2017, at 5:24 PM, Alan Bateman wrote: > > > > On 06/09/2017 05:17, Weijun Wang wrote: >> Hi All >> >> Please review the change, which spans to root, jdk and langtools repos. >> >> http://cr.openjdk.java.net/~weijun/8148371/ >> >> I've searched for the "policytool" word in the whole jdk10/jdk10 forests, removed all files having the word inside the path name, and remove almost all occurrences of the word in other places. >> > This looks good, the only change that I'm not sure about is the change to ct.properties as it may be used when compiling to older releases. Someone on compiler-dev should be able to help you on that. Jon suggested reverting this change, offline. --Max > > -Alan From m-matsushima at bk.jp.nec.com Fri Sep 8 07:51:19 2017 From: m-matsushima at bk.jp.nec.com (Mitsuru Matsushima) Date: Fri, 8 Sep 2017 07:51:19 +0000 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: <77a2201b-cb28-425d-37a1-7f4492928050@oracle.com> References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> <77a2201b-cb28-425d-37a1-7f4492928050@oracle.com> Message-ID: Hi, Naoto-san, Oh, I think I had misunderstood the behavior of COMPAT Provider. COMPAT Provider provide values, each of them are the same form as Supplemental Era, right? I think the value I wrote before are wrong at Short form of COMPAT (DateTimeFormatter). Is there no inconsistency, isn't it? --- Mitsuru > -----Original Message----- > From: Naoto Sato [mailto:naoto.sato at oracle.com] > Sent: Friday, September 08, 2017 2:29 AM > To: Matsushima Mitsuru(?? ?) ; core-libs-dev ; i18n-dev > > Subject: Re: [10] RFR 8180469: Wrong short form text for supplemental Japanese era > > Mitsuru-san, > > By those options I meant to address the inconsistency in SimpleDateFormat, between COMPAT and CLDR, for the existing eras > (e.g. > Heisei). As to the inconsistency you wrote below, I am not sure that's worth doing, considering 1) it is aligned with > CLDR, 2) supplemental era functionality is for emergency situations till the era is officially supported. > > Naoto > > > > On 9/6/17 11:16 PM, Mitsuru Matsushima wrote: > > Hi, Naoto-san, > > > >> So, considering these, I have a couple of options. One is to use the > >> newer java.time.format APIs which can correctly handle this, or use > >> the > >> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. > > > > Hmm, I think the first option is ok. > > However, the second one seems to be confused > I guess the behaviors > > with COPMAT and Supplemental Era become follows: > > > > * COMPAT (SimpleDateFormat) > > Long: Heisei > > Short: H > > > > * COMPAT (DateTimeFormatter) > > Long: Heisei > > Short: H > > Narrow: H > > > > * Supplemental Era (SimpleDateFormat) > > Long: NewEra > > Short: N.E > > > > * Supplemental Era (DateTimeFormatter) > > Long: NewEra > > Short: NewEra > > Narrow: N.E > > > > If this is true, the short value of Supplemental Era differs from COMPAT. > > So CalendarNameProviderImpl should be conscious about the type of provider. > > > > --- > > Mitsuru > > > >> -----Original Message----- > >> From: Naoto Sato [mailto:naoto.sato at oracle.com] > >> Sent: Saturday, September 02, 2017 2:49 AM > >> To: Matsushima Mitsuru(?? ?) ; > >> core-libs-dev ; i18n-dev > >> > >> Subject: Re: [10] RFR 8180469: Wrong short form text for > >> supplemental Japanese era > >> > >> Hi Mitsuru-san, > >> > >> Yes, I remember we discussed on this issue before. The reason that > >> LONG and SHORT names for Japanese era are the same is that CLDR's era names are not very consistent on length. They > have "eraNames", "eraAbbr", and "eraNarrow" variations. > >> We simply assign LONG to eraNames and SHORT to eraAbbr in > >> SimpleDateFormat. Possibly the right solution is to provide "narrow" > >> option in SimpleDateFormat, but it would be breaking the compatibility (text length of those pattern characters just > have two options, one is 4 or greater (=LONG), and the other is less than 4 (=SHORT)). > >> > >> So, considering these, I have a couple of options. One is to use the > >> newer java.time.format APIs which can correctly handle this, or use > >> the > >> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. > >> > >> HTH, > >> Naoto > >> > >> On 8/31/17 7:34 PM, Mitsuru Matsushima wrote: > >>> Hi Naoto-san, > >>> > >>> The fix looks good, though I'm not a reviewer... > >>> > >>> By the way, I may have forgotten to inform you that there exist an > >>> issue at the short form of SimpleDateFormat has an > >> issue. > >>> > >>> The SimpleDateFormat class is only capable to treat two form, Short and Long. > >>> At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long > form. > >>> So, the behavior of SimpleDateFormat is incompatible to previous versions. > >>> (See the Comparison table, I described before.) > >>> > >>> --- > >>> Mitsuru > >>> > >>>> -----Original Message----- > >>>> From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf > >>>> Of Naoto Sato > >>>> Sent: Thursday, August 31, 2017 7:56 AM > >>>> To: core-libs-dev ; i18n-dev > >>>> > >>>> Subject: [10] RFR 8180469: Wrong short form text for > >>>> supplemental Japanese era > >>>> > >>>> Hi, > >>>> > >>>> Please review the fix to the following issue: > >>>> > >>>> https://bugs.openjdk.java.net/browse/JDK-8180469 > >>>> > >>>> The proposed changeset is located at: > >>>> > >>>> http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ > >>>> > >>>> The problem was caused by the difference of the Era display name for "SHORT" style between java.time and > java.util.Calendar. > >>>> > >>>> Naoto > > From naoto.sato at oracle.com Fri Sep 8 22:19:31 2017 From: naoto.sato at oracle.com (Naoto Sato) Date: Fri, 8 Sep 2017 15:19:31 -0700 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> <77a2201b-cb28-425d-37a1-7f4492928050@oracle.com> Message-ID: Yes, I believe that's correct. Only inconsistency (outside of supplementary era support) is that "G" pattern for SimpleDateFormat outputs differently between COMPAT provider and CLDR provider, e.g., COMPAT returns "H" and CLDR returns "Heisei", which comes from CLDR data using "Heisei" for "abbreviated" names. Naoto On 9/8/17 12:51 AM, Mitsuru Matsushima wrote: > Hi, Naoto-san, > > Oh, I think I had misunderstood the behavior of COMPAT Provider. > > COMPAT Provider provide values, each of them are the same form as Supplemental Era, right? > > I think the value I wrote before are wrong at Short form of COMPAT (DateTimeFormatter). > Is there no inconsistency, isn't it? > > --- > Mitsuru > >> -----Original Message----- >> From: Naoto Sato [mailto:naoto.sato at oracle.com] >> Sent: Friday, September 08, 2017 2:29 AM >> To: Matsushima Mitsuru(?? ?) ; core-libs-dev ; i18n-dev >> >> Subject: Re: [10] RFR 8180469: Wrong short form text for supplemental Japanese era >> >> Mitsuru-san, >> >> By those options I meant to address the inconsistency in SimpleDateFormat, between COMPAT and CLDR, for the existing eras >> (e.g. >> Heisei). As to the inconsistency you wrote below, I am not sure that's worth doing, considering 1) it is aligned with >> CLDR, 2) supplemental era functionality is for emergency situations till the era is officially supported. >> >> Naoto >> >> >> >> On 9/6/17 11:16 PM, Mitsuru Matsushima wrote: >>> Hi, Naoto-san, >>> >>>> So, considering these, I have a couple of options. One is to use the >>>> newer java.time.format APIs which can correctly handle this, or use >>>> the >>>> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. >>> >>> Hmm, I think the first option is ok. >>> However, the second one seems to be confused > I guess the behaviors >>> with COPMAT and Supplemental Era become follows: >>> >>> * COMPAT (SimpleDateFormat) >>> Long: Heisei >>> Short: H >>> >>> * COMPAT (DateTimeFormatter) >>> Long: Heisei >>> Short: H >>> Narrow: H >>> >>> * Supplemental Era (SimpleDateFormat) >>> Long: NewEra >>> Short: N.E >>> >>> * Supplemental Era (DateTimeFormatter) >>> Long: NewEra >>> Short: NewEra >>> Narrow: N.E >>> >>> If this is true, the short value of Supplemental Era differs from COMPAT. >>> So CalendarNameProviderImpl should be conscious about the type of provider. >>> >>> --- >>> Mitsuru >>> >>>> -----Original Message----- >>>> From: Naoto Sato [mailto:naoto.sato at oracle.com] >>>> Sent: Saturday, September 02, 2017 2:49 AM >>>> To: Matsushima Mitsuru(?? ?) ; >>>> core-libs-dev ; i18n-dev >>>> >>>> Subject: Re: [10] RFR 8180469: Wrong short form text for >>>> supplemental Japanese era >>>> >>>> Hi Mitsuru-san, >>>> >>>> Yes, I remember we discussed on this issue before. The reason that >>>> LONG and SHORT names for Japanese era are the same is that CLDR's era names are not very consistent on length. They >> have "eraNames", "eraAbbr", and "eraNarrow" variations. >>>> We simply assign LONG to eraNames and SHORT to eraAbbr in >>>> SimpleDateFormat. Possibly the right solution is to provide "narrow" >>>> option in SimpleDateFormat, but it would be breaking the compatibility (text length of those pattern characters just >> have two options, one is 4 or greater (=LONG), and the other is less than 4 (=SHORT)). >>>> >>>> So, considering these, I have a couple of options. One is to use the >>>> newer java.time.format APIs which can correctly handle this, or use >>>> the >>>> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. >>>> >>>> HTH, >>>> Naoto >>>> >>>> On 8/31/17 7:34 PM, Mitsuru Matsushima wrote: >>>>> Hi Naoto-san, >>>>> >>>>> The fix looks good, though I'm not a reviewer... >>>>> >>>>> By the way, I may have forgotten to inform you that there exist an >>>>> issue at the short form of SimpleDateFormat has an >>>> issue. >>>>> >>>>> The SimpleDateFormat class is only capable to treat two form, Short and Long. >>>>> At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long >> form. >>>>> So, the behavior of SimpleDateFormat is incompatible to previous versions. >>>>> (See the Comparison table, I described before.) >>>>> >>>>> --- >>>>> Mitsuru >>>>> >>>>>> -----Original Message----- >>>>>> From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf >>>>>> Of Naoto Sato >>>>>> Sent: Thursday, August 31, 2017 7:56 AM >>>>>> To: core-libs-dev ; i18n-dev >>>>>> >>>>>> Subject: [10] RFR 8180469: Wrong short form text for >>>>>> supplemental Japanese era >>>>>> >>>>>> Hi, >>>>>> >>>>>> Please review the fix to the following issue: >>>>>> >>>>>> https://bugs.openjdk.java.net/browse/JDK-8180469 >>>>>> >>>>>> The proposed changeset is located at: >>>>>> >>>>>> http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ >>>>>> >>>>>> The problem was caused by the difference of the Era display name for "SHORT" style between java.time and >> java.util.Calendar. >>>>>> >>>>>> Naoto >>> > From m-matsushima at bk.jp.nec.com Mon Sep 11 03:18:00 2017 From: m-matsushima at bk.jp.nec.com (Mitsuru Matsushima) Date: Mon, 11 Sep 2017 03:18:00 +0000 Subject: [10] RFR 8180469: Wrong short form text for supplemental Japanese era In-Reply-To: References: <04f6fa07-019f-27f3-5971-b2b27d40ca0c@oracle.com> <5a6c018f-1292-a49b-a015-bd3154ff27cc@oracle.com> <77a2201b-cb28-425d-37a1-7f4492928050@oracle.com> Message-ID: Hi, Naoto-san, Okay, I got it. I'll intend to suggest refactoring with new API or using COMPAT provider, if there are issue relating about era forms on existing apps. Thank you for your response. --- Mitsuru > -----Original Message----- > From: Naoto Sato [mailto:naoto.sato at oracle.com] > Sent: Saturday, September 09, 2017 7:20 AM > To: Matsushima Mitsuru(?? ?) ; core-libs-dev ; i18n-dev > > Subject: Re: [10] RFR 8180469: Wrong short form text for supplemental Japanese era > > Yes, I believe that's correct. > > Only inconsistency (outside of supplementary era support) is that "G" > pattern for SimpleDateFormat outputs differently between COMPAT provider > and CLDR provider, e.g., COMPAT returns "H" and CLDR returns "Heisei", > which comes from CLDR data using "Heisei" for "abbreviated" names. > > Naoto > > On 9/8/17 12:51 AM, Mitsuru Matsushima wrote: > > Hi, Naoto-san, > > > > Oh, I think I had misunderstood the behavior of COMPAT Provider. > > > > COMPAT Provider provide values, each of them are the same form as Supplemental Era, right? > > > > I think the value I wrote before are wrong at Short form of COMPAT (DateTimeFormatter). > > Is there no inconsistency, isn't it? > > > > --- > > Mitsuru > > > >> -----Original Message----- > >> From: Naoto Sato [mailto:naoto.sato at oracle.com] > >> Sent: Friday, September 08, 2017 2:29 AM > >> To: Matsushima Mitsuru(?? ?) ; core-libs-dev ; > i18n-dev > >> > >> Subject: Re: [10] RFR 8180469: Wrong short form text for supplemental Japanese era > >> > >> Mitsuru-san, > >> > >> By those options I meant to address the inconsistency in SimpleDateFormat, between COMPAT and CLDR, for the existing > eras > >> (e.g. > >> Heisei). As to the inconsistency you wrote below, I am not sure that's worth doing, considering 1) it is aligned with > >> CLDR, 2) supplemental era functionality is for emergency situations till the era is officially supported. > >> > >> Naoto > >> > >> > >> > >> On 9/6/17 11:16 PM, Mitsuru Matsushima wrote: > >>> Hi, Naoto-san, > >>> > >>>> So, considering these, I have a couple of options. One is to use the > >>>> newer java.time.format APIs which can correctly handle this, or use > >>>> the > >>>> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. > >>> > >>> Hmm, I think the first option is ok. > >>> However, the second one seems to be confused > I guess the behaviors > >>> with COPMAT and Supplemental Era become follows: > >>> > >>> * COMPAT (SimpleDateFormat) > >>> Long: Heisei > >>> Short: H > >>> > >>> * COMPAT (DateTimeFormatter) > >>> Long: Heisei > >>> Short: H > >>> Narrow: H > >>> > >>> * Supplemental Era (SimpleDateFormat) > >>> Long: NewEra > >>> Short: N.E > >>> > >>> * Supplemental Era (DateTimeFormatter) > >>> Long: NewEra > >>> Short: NewEra > >>> Narrow: N.E > >>> > >>> If this is true, the short value of Supplemental Era differs from COMPAT. > >>> So CalendarNameProviderImpl should be conscious about the type of provider. > >>> > >>> --- > >>> Mitsuru > >>> > >>>> -----Original Message----- > >>>> From: Naoto Sato [mailto:naoto.sato at oracle.com] > >>>> Sent: Saturday, September 02, 2017 2:49 AM > >>>> To: Matsushima Mitsuru(?? ?) ; > >>>> core-libs-dev ; i18n-dev > >>>> > >>>> Subject: Re: [10] RFR 8180469: Wrong short form text for > >>>> supplemental Japanese era > >>>> > >>>> Hi Mitsuru-san, > >>>> > >>>> Yes, I remember we discussed on this issue before. The reason that > >>>> LONG and SHORT names for Japanese era are the same is that CLDR's era names are not very consistent on length. They > >> have "eraNames", "eraAbbr", and "eraNarrow" variations. > >>>> We simply assign LONG to eraNames and SHORT to eraAbbr in > >>>> SimpleDateFormat. Possibly the right solution is to provide "narrow" > >>>> option in SimpleDateFormat, but it would be breaking the compatibility (text length of those pattern characters just > >> have two options, one is 4 or greater (=LONG), and the other is less than 4 (=SHORT)). > >>>> > >>>> So, considering these, I have a couple of options. One is to use the > >>>> newer java.time.format APIs which can correctly handle this, or use > >>>> the > >>>> JDK8 locale data by specifying -Djava.locale.providers=COMPAT at runtime. > >>>> > >>>> HTH, > >>>> Naoto > >>>> > >>>> On 8/31/17 7:34 PM, Mitsuru Matsushima wrote: > >>>>> Hi Naoto-san, > >>>>> > >>>>> The fix looks good, though I'm not a reviewer... > >>>>> > >>>>> By the way, I may have forgotten to inform you that there exist an > >>>>> issue at the short form of SimpleDateFormat has an > >>>> issue. > >>>>> > >>>>> The SimpleDateFormat class is only capable to treat two form, Short and Long. > >>>>> At JDK9, the CLDR Provider become to default, the provider returns the same value for the Short form and the Long > >> form. > >>>>> So, the behavior of SimpleDateFormat is incompatible to previous versions. > >>>>> (See the Comparison table, I described before.) > >>>>> > >>>>> --- > >>>>> Mitsuru > >>>>> > >>>>>> -----Original Message----- > >>>>>> From: i18n-dev [mailto:i18n-dev-bounces at openjdk.java.net] On Behalf > >>>>>> Of Naoto Sato > >>>>>> Sent: Thursday, August 31, 2017 7:56 AM > >>>>>> To: core-libs-dev ; i18n-dev > >>>>>> > >>>>>> Subject: [10] RFR 8180469: Wrong short form text for > >>>>>> supplemental Japanese era > >>>>>> > >>>>>> Hi, > >>>>>> > >>>>>> Please review the fix to the following issue: > >>>>>> > >>>>>> https://bugs.openjdk.java.net/browse/JDK-8180469 > >>>>>> > >>>>>> The proposed changeset is located at: > >>>>>> > >>>>>> http://cr.openjdk.java.net/~naoto/8180469/webrev.00/ > >>>>>> > >>>>>> The problem was caused by the difference of the Era display name for "SHORT" style between java.time and > >> java.util.Calendar. > >>>>>> > >>>>>> Naoto > >>> > > From huaming.li at oracle.com Mon Sep 11 03:20:56 2017 From: huaming.li at oracle.com (huaming.li at oracle.com) Date: Mon, 11 Sep 2017 11:20:56 +0800 Subject: RFR of JDK-8187376: test issue in java/lang/invoke/VarHandles/VarHandleBaseTest.java Message-ID: <753f2c3d-ca45-e198-2156-f58572c65bbe@oracle.com> Would you please review the below patch? bug: https://bugs.openjdk.java.net/browse/JDK-8187376 webrev: http://cr.openjdk.java.net/~mli/8187376/webrev.00/ Thank you -Hamlin From dowhileforeach at gmail.com Mon Sep 11 08:29:28 2017 From: dowhileforeach at gmail.com (DoWhile ForEach) Date: Mon, 11 Sep 2017 11:29:28 +0300 Subject: Set the effective user ID of the Java process. Message-ID: Hello. Please explain someone why the Java API has not yet implemented a method that allows you to set the effective user ID of the Java process. To accomplish this simple task, you have to make some workarounds. A striking example of such workarounds is jsvc tool from the Apache commons-daemon project for Tomcat server: https://github.com/apache/commons-daemon/blob/6702852984689bc6507690113949b478dba157ef/src/native/unix/native/jsvc-unix.c#L163 From brunoaiss at gmail.com Mon Sep 11 08:58:14 2017 From: brunoaiss at gmail.com (bruno ais) Date: Mon, 11 Sep 2017 09:58:14 +0100 Subject: Set the effective user ID of the Java process. In-Reply-To: References: Message-ID: Any idea how it can be done on Windows? Or better yet; is there a cross-platform thing or equivalence of that feature? If not, then that can easily be the reason. On Mon, Sep 11, 2017 at 9:29 AM, DoWhile ForEach wrote: > Hello. > > Please explain someone why the Java API has not yet implemented a method > that allows you to set the effective user ID of the Java process. > > To accomplish this simple task, you have to make some workarounds. > A striking example of such workarounds is jsvc tool from the Apache > commons-daemon project for Tomcat server: > https://github.com/apache/commons-daemon/blob/6702852984689b > c6507690113949b478dba157ef/src/native/unix/native/jsvc-unix.c#L163 > From freehck at freehck.ru Mon Sep 11 12:31:12 2017 From: freehck at freehck.ru (Dmitrii Kashin) Date: Mon, 11 Sep 2017 15:31:12 +0300 Subject: Set the effective user ID of the Java process. References: Message-ID: <87poax1kof.fsf@ws00.freehck.ru> I'd like to add to the conversation that this thread was started because of the argue here[1] (russian). The main point of the argue was dropping privileges from root to some user after the program performed all the needed actions (f.e. when it started listening port < 1024). We've found an example in commons-daemon code[2] how to drop privileges in MS Windows systems. It seems a new Access Token is created for some unprivileged user, and then spawns a new process with this token. I suppose it makes some sense to say about it here: it would be very useful to have a possibility to drop privileges to some user. Please consider it as a user request. [1] https://www.opennet.ru/opennews/art.shtml?num=47170#29 [2] https://github.com/apache/commons-daemon/blob/6702852984689bc6507690113949b478dba157ef/src/native/windows/src/rprocess.c#L481 bruno ais writes: > Any idea how it can be done on Windows? > Or better yet; is there a cross-platform thing or equivalence of that > feature? > If not, then that can easily be the reason. > > On Mon, Sep 11, 2017 at 9:29 AM, DoWhile ForEach > wrote: > >> Hello. >> >> Please explain someone why the Java API has not yet implemented a method >> that allows you to set the effective user ID of the Java process. >> >> To accomplish this simple task, you have to make some workarounds. >> A striking example of such workarounds is jsvc tool from the Apache >> commons-daemon project for Tomcat server: >> https://github.com/apache/commons-daemon/blob/6702852984689b >> c6507690113949b478dba157ef/src/native/unix/native/jsvc-unix.c#L163 >> From dalibor.topic at oracle.com Mon Sep 11 12:49:44 2017 From: dalibor.topic at oracle.com (dalibor topic) Date: Mon, 11 Sep 2017 14:49:44 +0200 Subject: Set the effective user ID of the Java process. In-Reply-To: <87poax1kof.fsf@ws00.freehck.ru> References: <87poax1kof.fsf@ws00.freehck.ru> Message-ID: <1ae99fee-51e4-381c-a5f4-2a6d2a1f876a@oracle.com> Sounds like https://bugs.openjdk.java.net/browse/JDK-5032600 . cheers, dalibor topic On 11.09.2017 14:31, Dmitrii Kashin wrote: > > I'd like to add to the conversation that this thread was started because > of the argue here[1] (russian). > > The main point of the argue was dropping privileges from root to some > user after the program performed all the needed actions (f.e. when it > started listening port < 1024). > > We've found an example in commons-daemon code[2] how to drop privileges > in MS Windows systems. It seems a new Access Token is created for some > unprivileged user, and then spawns a new process with this token. > > I suppose it makes some sense to say about it here: it would be very > useful to have a possibility to drop privileges to some user. Please > consider it as a user request. > > [1] https://www.opennet.ru/opennews/art.shtml?num=47170#29 > [2] https://github.com/apache/commons-daemon/blob/6702852984689bc6507690113949b478dba157ef/src/native/windows/src/rprocess.c#L481 > > bruno ais writes: > >> Any idea how it can be done on Windows? >> Or better yet; is there a cross-platform thing or equivalence of that >> feature? >> If not, then that can easily be the reason. >> >> On Mon, Sep 11, 2017 at 9:29 AM, DoWhile ForEach >> wrote: >> >>> Hello. >>> >>> Please explain someone why the Java API has not yet implemented a method >>> that allows you to set the effective user ID of the Java process. >>> >>> To accomplish this simple task, you have to make some workarounds. >>> A striking example of such workarounds is jsvc tool from the Apache >>> commons-daemon project for Tomcat server: >>> https://github.com/apache/commons-daemon/blob/6702852984689b >>> c6507690113949b478dba157ef/src/native/unix/native/jsvc-unix.c#L163 >>> -- Dalibor Topic | Principal Product Manager Phone: +494089091214 | Mobile: +491737185961 ORACLE Deutschland B.V. & Co. KG | K?hneh?fe 5 | 22761 Hamburg ORACLE Deutschland B.V. & Co. KG Hauptverwaltung: Riesstr. 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-Niederlande, 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 aph at redhat.com Mon Sep 11 15:34:27 2017 From: aph at redhat.com (Andrew Haley) Date: Mon, 11 Sep 2017 16:34:27 +0100 Subject: Set the effective user ID of the Java process. In-Reply-To: References: Message-ID: On 11/09/17 09:29, DoWhile ForEach wrote: > > Please explain someone why the Java API has not yet implemented a method > that allows you to set the effective user ID of the Java process. Because it's tricky to do in Java, but trivial to do in C and then use the invocation API? -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671 From vyom.tewari at oracle.com Mon Sep 11 15:38:39 2017 From: vyom.tewari at oracle.com (vyom tewari) Date: Mon, 11 Sep 2017 21:08:39 +0530 Subject: RFR 8145635 : Add TCP_QUICKACK socket option In-Reply-To: <56CD7C0A.2080402@oracle.com> References: <56CD74E1.60309@oracle.com> <56CD7C0A.2080402@oracle.com> Message-ID: <0b0989b5-c791-a476-a82f-6c686b19c9d3@oracle.com> Hi All, As jdk.net API already moved out of java.base, Please review the below code change for jdk10. Bug: https://bugs.openjdk.java.net/browse/JDK-8145635 Webrev: http://cr.openjdk.java.net/~vtewari/8145635/webrev0.1/index.html Thanks, Vyom On Wednesday 24 February 2016 03:16 PM, Alan Bateman wrote: > > On 24/02/2016 09:16, vyom wrote: >> Hi All, >> >> Please review my code changes for the below issue. >> >> Bug: JDK-8145635 : Add TCP_QUICKACK socket option >> >> Webrev: http://cr.openjdk.java.net/~vtewari/8145635/webrev0.0/index.html >> >> Currently TCP_QUICKACK is only supported on Linux( since Linux 2.4.4) >> so i implemented is as "ExtendedSocketOption". > > Is there any urgency on this one? I'm just wondering if we should try > to the jdk.net API moved out of java.base before we add more socket > options. This is currently tracked as JDK-8044773 and important to get > into JDK 9. > > -Alan From jawnsy at cpan.org Mon Sep 11 17:26:29 2017 From: jawnsy at cpan.org (Jonathan Yu) Date: Mon, 11 Sep 2017 10:26:29 -0700 Subject: Set the effective user ID of the Java process. In-Reply-To: <87poax1kof.fsf@ws00.freehck.ru> References: <87poax1kof.fsf@ws00.freehck.ru> Message-ID: On Mon, Sep 11, 2017 at 5:31 AM, Dmitrii Kashin wrote: > > I'd like to add to the conversation that this thread was started because > of the argue here[1] (russian). > > The main point of the argue was dropping privileges from root to some > user after the program performed all the needed actions (f.e. when it > started listening port < 1024). > root isn't needed for binding service ports anymore, you can use setcap: https://stackoverflow.com/a/414258 > > We've found an example in commons-daemon code[2] how to drop privileges > in MS Windows systems. It seems a new Access Token is created for some > unprivileged user, and then spawns a new process with this token. > > I suppose it makes some sense to say about it here: it would be very > useful to have a possibility to drop privileges to some user. Please > consider it as a user request. > > [1] https://www.opennet.ru/opennews/art.shtml?num=47170#29 > [2] https://github.com/apache/commons-daemon/blob/ > 6702852984689bc6507690113949b478dba157ef/src/native/windows/ > src/rprocess.c#L481 > > bruno ais writes: > > > Any idea how it can be done on Windows? > > Or better yet; is there a cross-platform thing or equivalence of that > > feature? > > If not, then that can easily be the reason. > > > > On Mon, Sep 11, 2017 at 9:29 AM, DoWhile ForEach < > dowhileforeach at gmail.com> > > wrote: > > > >> Hello. > >> > >> Please explain someone why the Java API has not yet implemented a method > >> that allows you to set the effective user ID of the Java process. > >> > >> To accomplish this simple task, you have to make some workarounds. > >> A striking example of such workarounds is jsvc tool from the Apache > >> commons-daemon project for Tomcat server: > >> https://github.com/apache/commons-daemon/blob/6702852984689b > >> c6507690113949b478dba157ef/src/native/unix/native/jsvc-unix.c#L163 > >> > -- Cheers, Jonathan From david.holmes at oracle.com Mon Sep 11 21:27:58 2017 From: david.holmes at oracle.com (David Holmes) Date: Tue, 12 Sep 2017 07:27:58 +1000 Subject: [PATCH] java.util.Collections enhancement In-Reply-To: <389541505158828@web15g.yandex.ru> References: <389541505158828@web15g.yandex.ru> Message-ID: Moving to core-libs-dev ... On 12/09/2017 5:40 AM, ?????? ??????? wrote: > Hi, > > looking into the code of java.util.Collections I've found out that EmptyList#toArray() and EmptySet#toArray() both instantiate new instance of Object[] at each call. As far as Java array is immutable it's possible to cache empty Object array and return this cached instance. There is a slight issue with the specification of toArray here: "The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). " Of course for a zero-sized array it is perfectly safe to return a cached array, but the spec currently requires that a new array be returned. Cheers, David ----- > Patch.txt is attached to the body of this mail. > > Thanks, > - Sergei Tsypanov > > patch.txt > > diff --git a/src/java.base/share/classes/java/util/Collections.java b/src/java.base/share/classes/java/util/Collections.java > --- a/src/java.base/share/classes/java/util/Collections.java > +++ b/src/java.base/share/classes/java/util/Collections.java > @@ -108,6 +108,11 @@ > private static final int INDEXOFSUBLIST_THRESHOLD = 35; > > /** > + * Cached empty array > + */ > + private static final Object[] EMPTY_ARRAY = {}; > + > + /** > * Sorts the specified list into ascending order, according to the > * {@linkplain Comparable natural ordering} of its elements. > * All elements in the list must implement the {@link Comparable} > @@ -4329,7 +4334,7 @@ > public boolean contains(Object obj) {return false;} > public boolean containsAll(Collection c) { return c.isEmpty(); } > > - public Object[] toArray() { return new Object[0]; } > + public Object[] toArray() { return EMPTY_ARRAY; } > > public T[] toArray(T[] a) { > if (a.length > 0) > @@ -4458,7 +4463,7 @@ > public boolean contains(Object obj) {return false;} > public boolean containsAll(Collection c) { return c.isEmpty(); } > > - public Object[] toArray() { return new Object[0]; } > + public Object[] toArray() { return EMPTY_ARRAY; } > > public T[] toArray(T[] a) { > if (a.length > 0) From amaembo at gmail.com Tue Sep 12 02:48:14 2017 From: amaembo at gmail.com (Tagir Valeev) Date: Tue, 12 Sep 2017 09:48:14 +0700 Subject: [PATCH] java.util.Collections enhancement In-Reply-To: References: <389541505158828@web15g.yandex.ru> Message-ID: Also note that this changes visible behavior. E.g. somebody might synchronize on the array object returned by toArray call, so this change might cause unwanted lock sharing. Once I suggested similar improvement: to return EMPTY_LIST from Arrays.asList() when supplied array has zero length. It was declined with the same reason [1] With best regards, Tagir Valeev. [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-September/035197.html On Tue, Sep 12, 2017 at 4:27 AM, David Holmes wrote: > Moving to core-libs-dev ... > > On 12/09/2017 5:40 AM, ?????? ??????? wrote: >> >> Hi, >> >> looking into the code of java.util.Collections I've found out that >> EmptyList#toArray() and EmptySet#toArray() both instantiate new instance of >> Object[] at each call. As far as Java array is immutable it's possible to >> cache empty Object array and return this cached instance. > > > There is a slight issue with the specification of toArray here: > > "The returned array will be "safe" in that no references to it are > maintained by this list. (In other words, this method must allocate a new > array even if this list is backed by an array). " > > Of course for a zero-sized array it is perfectly safe to return a cached > array, but the spec currently requires that a new array be returned. > > Cheers, > David > ----- > >> Patch.txt is attached to the body of this mail. >> >> Thanks, >> - Sergei Tsypanov >> >> patch.txt >> >> diff --git a/src/java.base/share/classes/java/util/Collections.java >> b/src/java.base/share/classes/java/util/Collections.java >> --- a/src/java.base/share/classes/java/util/Collections.java >> +++ b/src/java.base/share/classes/java/util/Collections.java >> @@ -108,6 +108,11 @@ >> private static final int INDEXOFSUBLIST_THRESHOLD = 35; >> /** >> + * Cached empty array >> + */ >> + private static final Object[] EMPTY_ARRAY = {}; >> + >> + /** >> * Sorts the specified list into ascending order, according to the >> * {@linkplain Comparable natural ordering} of its elements. >> * All elements in the list must implement the {@link Comparable} >> @@ -4329,7 +4334,7 @@ >> public boolean contains(Object obj) {return false;} >> public boolean containsAll(Collection c) { return c.isEmpty(); >> } >> - public Object[] toArray() { return new Object[0]; } >> + public Object[] toArray() { return EMPTY_ARRAY; } >> public T[] toArray(T[] a) { >> if (a.length > 0) >> @@ -4458,7 +4463,7 @@ >> public boolean contains(Object obj) {return false;} >> public boolean containsAll(Collection c) { return c.isEmpty(); >> } >> - public Object[] toArray() { return new Object[0]; } >> + public Object[] toArray() { return EMPTY_ARRAY; } >> public T[] toArray(T[] a) { >> if (a.length > 0) > > From vyom.tewari at oracle.com Tue Sep 12 08:06:22 2017 From: vyom.tewari at oracle.com (vyom tewari) Date: Tue, 12 Sep 2017 13:36:22 +0530 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver Message-ID: Hi, Please review the below code change. BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 Webrev-1: http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html Webrev-2: http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html Code change will De-privilege jdk.httpserver, we gave "jdk.httpserver" all permission for now. Thanks, Vyom From Alan.Bateman at oracle.com Tue Sep 12 08:42:09 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 12 Sep 2017 09:42:09 +0100 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: References: Message-ID: On 12/09/2017 09:06, vyom tewari wrote: > Hi, > > Please review the below code change. > > BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 > > Webrev-1: > http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html > > Webrev-2: > http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html > > Code change will De-privilege jdk.httpserver, we gave "jdk.httpserver" > all permission for now. Moving jdk.httpserver to the platform class loader looks fine. Are you planning a second phase to identify the permissions needed so that it doesn't have to be granted AllPermission? -Alan From vyom.tewari at oracle.com Tue Sep 12 08:46:40 2017 From: vyom.tewari at oracle.com (vyom tewari) Date: Tue, 12 Sep 2017 14:16:40 +0530 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: References: Message-ID: <9aef924f-d72c-5342-1824-85362f9f25a0@oracle.com> On Tuesday 12 September 2017 02:12 PM, Alan Bateman wrote: > On 12/09/2017 09:06, vyom tewari wrote: >> Hi, >> >> Please review the below code change. >> >> BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 >> >> Webrev-1: >> http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html >> >> Webrev-2: >> http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html >> >> Code change will De-privilege jdk.httpserver, we gave >> "jdk.httpserver" all permission for now. > Moving jdk.httpserver to the platform class loader looks fine. Are you > planning a second phase to identify the permissions needed so that it > doesn't have to be granted AllPermission? yes, i will file a separate issue for this. Vyom > > -Alan From michael.x.mcmahon at oracle.com Tue Sep 12 09:02:15 2017 From: michael.x.mcmahon at oracle.com (Michael McMahon) Date: Tue, 12 Sep 2017 10:02:15 +0100 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: <9aef924f-d72c-5342-1824-85362f9f25a0@oracle.com> References: <9aef924f-d72c-5342-1824-85362f9f25a0@oracle.com> Message-ID: <59B7A297.3090409@oracle.com> Looks good Vyom. - Michael On 12/09/2017, 09:46, vyom tewari wrote: > > > On Tuesday 12 September 2017 02:12 PM, Alan Bateman wrote: >> On 12/09/2017 09:06, vyom tewari wrote: >>> Hi, >>> >>> Please review the below code change. >>> >>> BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 >>> >>> Webrev-1: >>> http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html >>> >>> Webrev-2: >>> http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html >>> >>> Code change will De-privilege jdk.httpserver, we gave >>> "jdk.httpserver" all permission for now. >> Moving jdk.httpserver to the platform class loader looks fine. Are >> you planning a second phase to identify the permissions needed so >> that it doesn't have to be granted AllPermission? > yes, i will file a separate issue for this. > > Vyom >> >> -Alan > From chris.hegarty at oracle.com Tue Sep 12 09:51:03 2017 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Tue, 12 Sep 2017 10:51:03 +0100 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: <9aef924f-d72c-5342-1824-85362f9f25a0@oracle.com> References: <9aef924f-d72c-5342-1824-85362f9f25a0@oracle.com> Message-ID: <51A9EA36-7904-4120-A88E-CECB80491DDE@oracle.com> > On 12 Sep 2017, at 09:46, vyom tewari wrote: > > On Tuesday 12 September 2017 02:12 PM, Alan Bateman wrote: >> On 12/09/2017 09:06, vyom tewari wrote: >>> Hi, >>> >>> Please review the below code change. >>> >>> BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 >>> >>> Webrev-1: http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html >>> >>> Webrev-2: http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html Thanks Vyom, this looks good. >>> Code change will De-privilege jdk.httpserver, we gave "jdk.httpserver" all permission for now. >> Moving jdk.httpserver to the platform class loader looks fine. Are you planning a second phase to identify the permissions needed so that it doesn't have to be granted AllPermission? > yes, i will file a separate issue for this. Thanks. Please link the new issue to 8159526. -Chris. From sean.mullan at oracle.com Tue Sep 12 15:46:04 2017 From: sean.mullan at oracle.com (Sean Mullan) Date: Tue, 12 Sep 2017 11:46:04 -0400 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: References: Message-ID: On 9/12/17 4:06 AM, vyom tewari wrote: > Hi, > > Please review the below code change. > > BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 > > Webrev-1: http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html Can you put the entry for jdk.httpserver after jdk.dynalink so you maintain the alphabetical ordering? Also, are there any tests for the jdk.httpserver module that use the SecurityManager? It would be good to have at least one test that checks that it properly gets granted AllPermission when doing something security-sensitive (it seems like nothing should go wrong, but ...). --Sean > > Webrev-2: > http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html > > Code change will De-privilege jdk.httpserver, we gave "jdk.httpserver" > all permission for now. > > Thanks, > > Vyom > From mandy.chung at oracle.com Tue Sep 12 15:58:52 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 12 Sep 2017 08:58:52 -0700 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: References: Message-ID: This patch looks fine.? It's fine with me to follow up the second phase to identify the permissions needed rather than granting AllPermissions. Mandy On 9/12/17 1:06 AM, vyom tewari wrote: > Hi, > > Please review the below code change. > > BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 > > Webrev-1: > http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html > > Webrev-2: > http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html > > Code change will De-privilege jdk.httpserver, we gave "jdk.httpserver" > all permission for now. > > Thanks, > > Vyom > From jaroslav.tulach at oracle.com Tue Sep 12 17:44:07 2017 From: jaroslav.tulach at oracle.com (Jaroslav Tulach) Date: Tue, 12 Sep 2017 19:44:07 +0200 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1906851.CDFazpJ8ns@pracovni> Message-ID: <1595796.xe8q7Anfpj@pracovni> Dear reviewers, after several reconsiderations I have webrev #4 ready for your review. Can you please take a look at http://cr.openjdk.java.net/~jtulach/8182701/webrev.04/ and let me know if it is in a reasonable shape? Thanks a lot. -jt From mandy.chung at oracle.com Tue Sep 12 18:19:45 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 12 Sep 2017 11:19:45 -0700 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: <1595796.xe8q7Anfpj@pracovni> References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1906851.CDFazpJ8ns@pracovni> <1595796.xe8q7Anfpj@pracovni> Message-ID: On 9/12/17 10:44 AM, Jaroslav Tulach wrote: > Dear reviewers, > after several reconsiderations I have webrev #4 ready for your review. Can you > please take a look at > > http://cr.openjdk.java.net/~jtulach/8182701/webrev.04/ > > and let me know if it is in a reasonable shape? Thanks a lot. > -jt Yes defining a new provider module for the platform mbean registration is a reasonable solution.? Generally the patch looks right.? I have a question on the build and a comment on the new mbean method. ./make/common/Modules.gmk ??? Nit: can you move jdk.internal.vm.compiler.management to keep the list in alphabetical order 199 # Filter out Graal specific modules if Graal build is disabled 200 201 ifeq ($(INCLUDE_GRAAL), false) 202 MODULES_FILTER += jdk.internal.vm.compiler 203 endif When will INCLUDE_GRAAL be set to false?? I think jdk.internal.vm.compiler.management should also be filtered if jdk.internal.vm.compiler is disabled. Is jdk.internal.vm.compiler and jdk.internal.vm.compiler.management built for all platforms in JDK 10? If not, ?? jdk/src/java.management/share/classes/module-info.java may fail to compile when jdk.internal.vm.compiler.management is not present.?? We can consult with the build team when you find out what configuration that jdk.internal.vm.compiler is not built. hotspot/src/jdk.internal.vm.compiler/share/classes/module-info.java 29 requires transitive jdk.internal.vm.ci; do you get any error without this requires transitive? jdk.internal.vm.compiler.management already requires jdk.internal.vm.ci.? I would think this requires transitive is not necessary. Is HotSpotGraalCompiler::mbean method necessary?? In GraalMBeans.java 53 public static Object findGraalRuntimeBean() { 54 JVMCIRuntime r = JVMCI.getRuntime(); 55 JVMCICompiler c = r.getCompiler(); 56 if (c instanceof HotSpotGraalCompiler) { 57 return ((HotSpotGraalCompiler) c).mbean(); 58 } 59 return null; 60 } It seems that you can call HotspotGraalRuntime::mbean directly.? As we discussed offline, we agree that HotSpotRuntimeMBean should belong to this new module but it requires some refactoring which may take some amount of work.? Such clean up will be followed up in a separate JBS issue. Mandy From paul.sandoz at oracle.com Tue Sep 12 19:09:35 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 12 Sep 2017 12:09:35 -0700 Subject: RFR of JDK-8187376: test issue in java/lang/invoke/VarHandles/VarHandleBaseTest.java In-Reply-To: <753f2c3d-ca45-e198-2156-f58572c65bbe@oracle.com> References: <753f2c3d-ca45-e198-2156-f58572c65bbe@oracle.com> Message-ID: <6EB878EE-080B-460E-8900-E477BC57649D@oracle.com> > On 10 Sep 2017, at 20:20, huaming.li at oracle.com wrote: > > Would you please review the below patch? > > bug: https://bugs.openjdk.java.net/browse/JDK-8187376 > > webrev: http://cr.openjdk.java.net/~mli/8187376/webrev.00/ > Looks good. I dunno what planet i was on when i wrote that code. Did you run all the VH tests? Paul. From Sergey.Bylokhov at oracle.com Tue Sep 12 19:18:22 2017 From: Sergey.Bylokhov at oracle.com (Sergey Bylokhov) Date: Tue, 12 Sep 2017 12:18:22 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher Message-ID: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> Hello, Please review the fix for jdk10/jdk10. Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 Webrev can be found at: http://cr.openjdk.java.net/~serb/8187442/webrev.00 The simple application with empty main method produce some "warnings" when Xcheck:jni is used. Because of that it is hard to cleanup other parts of jdk from such warnings. Two additional checks were added, in both cases the new code will return 0 in the same way as NULL_CHECK0 in the same methods. -- Best regards, Sergey. From david.holmes at oracle.com Tue Sep 12 20:56:17 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 13 Sep 2017 06:56:17 +1000 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> Message-ID: <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> Hi Sergey, On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: > Hello, > Please review the fix for jdk10/jdk10. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 > Webrev can be found at: http://cr.openjdk.java.net/~serb/8187442/webrev.00 This doesn't look right to me: str = (*env)->CallStaticObjectMethod(env, cls, makePlatformStringMID, USE_STDERR, ary); + CHECK_EXCEPTION_RETURN_VALUE(0); (*env)->DeleteLocalRef(env, ary); return str; If there is an exception pending you fail to delete the local ref. And there's no need to clear the exception before calling DeleteLocalRef as that is okay to call with a pending exception. But there is no point returning zero if an exception occurred because in that case str will already be 0/NULL. The same here: 1596 appClass = (*env)->CallStaticObjectMethod(env, cls, mid); 1597 CHECK_EXCEPTION_RETURN_VALUE(0); 1598 return appClass; If an exception is pending then appClass will be 0/NULL. In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending exception so I can't see what warnings this would be clearing up ??? Thanks, David ----- > The simple application with empty main method produce some "warnings" > when Xcheck:jni is used. Because of that it is hard to cleanup other > parts of jdk from such warnings. > > Two additional checks were added, in both cases the new code will return > 0 in the same way as NULL_CHECK0 in the same methods. > > From Sergey.Bylokhov at oracle.com Tue Sep 12 21:22:26 2017 From: Sergey.Bylokhov at oracle.com (Sergey Bylokhov) Date: Tue, 12 Sep 2017 14:22:26 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> Message-ID: Hi, David. Thank you for review, here are my thoughts. The patch uses the same pattern as NULL_CHECK0. If an exception is occurred then NULL_CHECK0 in one situation and CHECK_EXCEPTION_RETURN_VALUE in another situation will return 0 to the upper code which will process this value(there is the same 0/null checks). The difference between NULL_CHECK0 and CHECK_EXCEPTION_RETURN_VALUE, is that the first is used when the "NULL" result also means some error, for example: NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "getApplicationClass", "()Ljava/lang/Class;")); appClass = (*env)->CallStaticObjectMethod(env, cls, mid); CHECK_EXCEPTION_RETURN_VALUE(0); In the code above the GetStaticMethodID() returns NULL if the operation fails, but it also throw an exceptions like NoSuchMethodError/etc. But in case of CallStaticObjectMethod() we cannot check for NULL which can be a valid result, so I added a check for exception and return 0. This value will be propagated to JavaMain() and I as far as understand will stop the execution. On 9/12/17 13:56, David Holmes wrote: > Hi Sergey, > > On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >> Hello, >> Please review the fix for jdk10/jdk10. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >> Webrev can be found at: >> http://cr.openjdk.java.net/~serb/8187442/webrev.00 > > This doesn't look right to me: > > ????????????? str = (*env)->CallStaticObjectMethod(env, cls, > ????????????????????? makePlatformStringMID, USE_STDERR, ary); > +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); > ????????????? (*env)->DeleteLocalRef(env, ary); > ????????????? return str; > > If there is an exception pending you fail to delete the local ref. And > there's no need to clear the exception before calling DeleteLocalRef as > that is okay to call with a pending exception. But there is no point > returning zero if an exception occurred because in that case str will > already be 0/NULL. > > The same here: > > 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); > 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); > 1598???? return appClass; > > If an exception is pending then appClass will be 0/NULL. > > In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending > exception so I can't see what warnings this would be clearing up ??? > > Thanks, > David > ----- > >> The simple application with empty main method produce some "warnings" >> when Xcheck:jni is used. Because of that it is hard to cleanup other >> parts of jdk from such warnings. >> >> Two additional checks were added, in both cases the new code will >> return 0 in the same way as NULL_CHECK0 in the same methods. >> >> -- Best regards, Sergey. From david.holmes at oracle.com Tue Sep 12 21:28:18 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 13 Sep 2017 07:28:18 +1000 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> Message-ID: <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> Hi Sergey, On 13/09/2017 7:22 AM, Sergey Bylokhov wrote: > Hi, David. > Thank you for review, here are my thoughts. > > The patch uses the same pattern as NULL_CHECK0. > > If an exception is occurred then NULL_CHECK0 in one situation and > CHECK_EXCEPTION_RETURN_VALUE in another situation will return 0 to the > upper code which will process this value(there is the same 0/null checks). > > The difference between NULL_CHECK0 and CHECK_EXCEPTION_RETURN_VALUE, is > that the first is used when the "NULL" result also means some error, for > example: > ??? NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, > ??????????????? "getApplicationClass", > ??????????????? "()Ljava/lang/Class;")); > > ??? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); > ??? CHECK_EXCEPTION_RETURN_VALUE(0); > > In the code above the GetStaticMethodID() returns NULL if the operation > fails, but it also throw an exceptions like NoSuchMethodError/etc. > > But in case of CallStaticObjectMethod() we cannot check for NULL which > can be a valid result, so I added a check for exception and return 0. My point is that the check is completely redundant. If an exception occurred then the return value is already 0/NULL. In addition this does nothing to clear the pending exception so I can not see how it would affect any warnings. David > This value will be propagated to JavaMain() and I as far as understand > will stop the execution. > > > On 9/12/17 13:56, David Holmes wrote: >> Hi Sergey, >> >> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>> Hello, >>> Please review the fix for jdk10/jdk10. >>> >>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>> Webrev can be found at: >>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >> >> This doesn't look right to me: >> >> ?????????????? str = (*env)->CallStaticObjectMethod(env, cls, >> ?????????????????????? makePlatformStringMID, USE_STDERR, ary); >> +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); >> ?????????????? (*env)->DeleteLocalRef(env, ary); >> ?????????????? return str; >> >> If there is an exception pending you fail to delete the local ref. And >> there's no need to clear the exception before calling DeleteLocalRef >> as that is okay to call with a pending exception. But there is no >> point returning zero if an exception occurred because in that case str >> will already be 0/NULL. >> >> The same here: >> >> 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >> 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); >> 1598???? return appClass; >> >> If an exception is pending then appClass will be 0/NULL. >> >> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending >> exception so I can't see what warnings this would be clearing up ??? >> >> Thanks, >> David >> ----- >> >>> The simple application with empty main method produce some "warnings" >>> when Xcheck:jni is used. Because of that it is hard to cleanup other >>> parts of jdk from such warnings. >>> >>> Two additional checks were added, in both cases the new code will >>> return 0 in the same way as NULL_CHECK0 in the same methods. >>> >>> > > From Sergey.Bylokhov at oracle.com Tue Sep 12 21:58:13 2017 From: Sergey.Bylokhov at oracle.com (Sergey Bylokhov) Date: Tue, 12 Sep 2017 14:58:13 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> Message-ID: <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> On 9/12/17 14:28, David Holmes wrote: >> But in case of CallStaticObjectMethod() we cannot check for NULL which >> can be a valid result, so I added a check for exception and return 0. > > My point is that the check is completely redundant. If an exception > occurred then the return value is already 0/NULL. According to the spec of jni there is no information that CallStaticObjectMethod() return null/0 when exception is occurred. So checkjni is not smart enough or takes this into account. > In addition this does > nothing to clear the pending exception so I can not see how it would > affect any warnings. It does not clear an exception but preserve it instead, and does not use the result of the method which produced an exception. > > David > >> This value will be propagated to JavaMain() and I as far as understand >> will stop the execution. >> >> >> On 9/12/17 13:56, David Holmes wrote: >>> Hi Sergey, >>> >>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>> Hello, >>>> Please review the fix for jdk10/jdk10. >>>> >>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>> Webrev can be found at: >>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>> >>> This doesn't look right to me: >>> >>> ?????????????? str = (*env)->CallStaticObjectMethod(env, cls, >>> ?????????????????????? makePlatformStringMID, USE_STDERR, ary); >>> +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); >>> ?????????????? (*env)->DeleteLocalRef(env, ary); >>> ?????????????? return str; >>> >>> If there is an exception pending you fail to delete the local ref. >>> And there's no need to clear the exception before calling >>> DeleteLocalRef as that is okay to call with a pending exception. But >>> there is no point returning zero if an exception occurred because in >>> that case str will already be 0/NULL. >>> >>> The same here: >>> >>> 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>> 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); >>> 1598???? return appClass; >>> >>> If an exception is pending then appClass will be 0/NULL. >>> >>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending >>> exception so I can't see what warnings this would be clearing up ??? >>> >>> Thanks, >>> David >>> ----- >>> >>>> The simple application with empty main method produce some >>>> "warnings" when Xcheck:jni is used. Because of that it is hard to >>>> cleanup other parts of jdk from such warnings. >>>> >>>> Two additional checks were added, in both cases the new code will >>>> return 0 in the same way as NULL_CHECK0 in the same methods. >>>> >>>> >> >> -- Best regards, Sergey. From david.holmes at oracle.com Tue Sep 12 23:03:02 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 13 Sep 2017 09:03:02 +1000 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> Message-ID: On 13/09/2017 7:58 AM, Sergey Bylokhov wrote: > On 9/12/17 14:28, David Holmes wrote: >>> But in case of CallStaticObjectMethod() we cannot check for NULL >>> which can be a valid result, so I added a check for exception and >>> return 0. >> >> My point is that the check is completely redundant. If an exception >> occurred then the return value is already 0/NULL. > > According to the spec of jni there is no information that > CallStaticObjectMethod() return null/0 when exception is occurred. > So checkjni is not smart enough or takes this into account. Sorry - you are right. I keep thinking we have closed these holes in JNI but we haven't. Even worse the actual implementation will return uninitialized values for the CallXXXMethod functions! If we look at: 1543 jstring str = NewPlatformString(env, *strv++); 1544 NULL_CHECK0(str); 1545 (*env)->SetObjectArrayElement(env, ary, i, str); what currently happens is that if NewPlatformString has an exception pending due to the CallStaticObjectMethod call then we can get back a possibly non-zero "random" value. When non-zero the NULL_CHECK passes and we proceed with the SetObjectArrayElement with a pending exception and so get the warning. And what you are doing is strengthening the internal spec of NewPlatformString so that it is ensures 0 is returned if an exception is pending and hence we skip the SetObjectArrayElement call. That is fine, but still leaves the problem that you are skipping the DeleteLocalRef call. Thanks - and sorry again for my confusion on this. David ----- >> In addition this does nothing to clear the pending exception so I can >> not see how it would affect any warnings. > > It does not clear an exception but preserve it instead, and does not use > the result of the method which produced an exception. > >> >> David >> >>> This value will be propagated to JavaMain() and I as far as >>> understand will stop the execution. >>> >>> >>> On 9/12/17 13:56, David Holmes wrote: >>>> Hi Sergey, >>>> >>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>> Hello, >>>>> Please review the fix for jdk10/jdk10. >>>>> >>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>> Webrev can be found at: >>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>> >>>> This doesn't look right to me: >>>> >>>> ?????????????? str = (*env)->CallStaticObjectMethod(env, cls, >>>> ?????????????????????? makePlatformStringMID, USE_STDERR, ary); >>>> +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); >>>> ?????????????? (*env)->DeleteLocalRef(env, ary); >>>> ?????????????? return str; >>>> >>>> If there is an exception pending you fail to delete the local ref. >>>> And there's no need to clear the exception before calling >>>> DeleteLocalRef as that is okay to call with a pending exception. But >>>> there is no point returning zero if an exception occurred because in >>>> that case str will already be 0/NULL. >>>> >>>> The same here: >>>> >>>> 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>>> 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); >>>> 1598???? return appClass; >>>> >>>> If an exception is pending then appClass will be 0/NULL. >>>> >>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending >>>> exception so I can't see what warnings this would be clearing up ??? >>>> >>>> Thanks, >>>> David >>>> ----- >>>> >>>>> The simple application with empty main method produce some >>>>> "warnings" when Xcheck:jni is used. Because of that it is hard to >>>>> cleanup other parts of jdk from such warnings. >>>>> >>>>> Two additional checks were added, in both cases the new code will >>>>> return 0 in the same way as NULL_CHECK0 in the same methods. >>>>> >>>>> >>> >>> > > From Sergey.Bylokhov at oracle.com Tue Sep 12 23:42:20 2017 From: Sergey.Bylokhov at oracle.com (Sergey Bylokhov) Date: Tue, 12 Sep 2017 16:42:20 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> Message-ID: <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> On 9/12/17 16:03, David Holmes wrote: > call. That is fine, but still leaves the problem that you are skipping > the DeleteLocalRef call. The leak was there before: if we will get an exception at "1512 SetByteArrayRegion()" then we never call this DeleteLocalRef(). I assumed it was done intentionally since this will be kind of "fatal" error. The same pattern is used in the other places for example in NewPlatformStringArray: jstring str = NewPlatformString(env, *strv++); NULL_CHECK0(str); (*env)->SetObjectArrayElement(env, ary, i, str); (*env)->DeleteLocalRef(env, str); > > Thanks - and sorry again for my confusion on this. > > David > ----- > >>> In addition this does nothing to clear the pending exception so I can >>> not see how it would affect any warnings. >> >> It does not clear an exception but preserve it instead, and does not >> use the result of the method which produced an exception. >> >>> >>> David >>> >>>> This value will be propagated to JavaMain() and I as far as >>>> understand will stop the execution. >>>> >>>> >>>> On 9/12/17 13:56, David Holmes wrote: >>>>> Hi Sergey, >>>>> >>>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>>> Hello, >>>>>> Please review the fix for jdk10/jdk10. >>>>>> >>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>>> Webrev can be found at: >>>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>>> >>>>> This doesn't look right to me: >>>>> >>>>> ?????????????? str = (*env)->CallStaticObjectMethod(env, cls, >>>>> ?????????????????????? makePlatformStringMID, USE_STDERR, ary); >>>>> +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); >>>>> ?????????????? (*env)->DeleteLocalRef(env, ary); >>>>> ?????????????? return str; >>>>> >>>>> If there is an exception pending you fail to delete the local ref. >>>>> And there's no need to clear the exception before calling >>>>> DeleteLocalRef as that is okay to call with a pending exception. >>>>> But there is no point returning zero if an exception occurred >>>>> because in that case str will already be 0/NULL. >>>>> >>>>> The same here: >>>>> >>>>> 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>>>> 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); >>>>> 1598???? return appClass; >>>>> >>>>> If an exception is pending then appClass will be 0/NULL. >>>>> >>>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending >>>>> exception so I can't see what warnings this would be clearing up ??? >>>>> >>>>> Thanks, >>>>> David >>>>> ----- >>>>> >>>>>> The simple application with empty main method produce some >>>>>> "warnings" when Xcheck:jni is used. Because of that it is hard to >>>>>> cleanup other parts of jdk from such warnings. >>>>>> >>>>>> Two additional checks were added, in both cases the new code will >>>>>> return 0 in the same way as NULL_CHECK0 in the same methods. >>>>>> >>>>>> >>>> >>>> >> >> -- Best regards, Sergey. From david.holmes at oracle.com Wed Sep 13 00:04:06 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 13 Sep 2017 10:04:06 +1000 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> Message-ID: <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> On 13/09/2017 9:42 AM, Sergey Bylokhov wrote: > On 9/12/17 16:03, David Holmes wrote: >> call. That is fine, but still leaves the problem that you are skipping >> the DeleteLocalRef call. > > The leak was there before: if we will get an exception at > "1512 SetByteArrayRegion()" > then we never call this DeleteLocalRef(). > > I assumed it was done intentionally since this will be kind of "fatal" > error. On further checking DeleteLocalRef is not actually needed in NewPlatformString at all. The only time it is recommended practice to manually delete local refs is when looping, as in NewPlatformStringArray. So all good - Reviewed. And sorry for the noise. Thanks, David > The same pattern is used in the other places for example in > NewPlatformStringArray: > > ??????? jstring str = NewPlatformString(env, *strv++); > ??????? NULL_CHECK0(str); > ??????? (*env)->SetObjectArrayElement(env, ary, i, str); > ??????? (*env)->DeleteLocalRef(env, str); > >> >> Thanks - and sorry again for my confusion on this. >> >> David >> ----- >> >>>> In addition this does nothing to clear the pending exception so I >>>> can not see how it would affect any warnings. >>> >>> It does not clear an exception but preserve it instead, and does not >>> use the result of the method which produced an exception. >>> >>>> >>>> David >>>> >>>>> This value will be propagated to JavaMain() and I as far as >>>>> understand will stop the execution. >>>>> >>>>> >>>>> On 9/12/17 13:56, David Holmes wrote: >>>>>> Hi Sergey, >>>>>> >>>>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>>>> Hello, >>>>>>> Please review the fix for jdk10/jdk10. >>>>>>> >>>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>>>> Webrev can be found at: >>>>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>>>> >>>>>> This doesn't look right to me: >>>>>> >>>>>> ?????????????? str = (*env)->CallStaticObjectMethod(env, cls, >>>>>> ?????????????????????? makePlatformStringMID, USE_STDERR, ary); >>>>>> +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>> ?????????????? (*env)->DeleteLocalRef(env, ary); >>>>>> ?????????????? return str; >>>>>> >>>>>> If there is an exception pending you fail to delete the local ref. >>>>>> And there's no need to clear the exception before calling >>>>>> DeleteLocalRef as that is okay to call with a pending exception. >>>>>> But there is no point returning zero if an exception occurred >>>>>> because in that case str will already be 0/NULL. >>>>>> >>>>>> The same here: >>>>>> >>>>>> 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>>>>> 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>> 1598???? return appClass; >>>>>> >>>>>> If an exception is pending then appClass will be 0/NULL. >>>>>> >>>>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the pending >>>>>> exception so I can't see what warnings this would be clearing up ??? >>>>>> >>>>>> Thanks, >>>>>> David >>>>>> ----- >>>>>> >>>>>>> The simple application with empty main method produce some >>>>>>> "warnings" when Xcheck:jni is used. Because of that it is hard to >>>>>>> cleanup other parts of jdk from such warnings. >>>>>>> >>>>>>> Two additional checks were added, in both cases the new code will >>>>>>> return 0 in the same way as NULL_CHECK0 in the same methods. >>>>>>> >>>>>>> >>>>> >>>>> >>> >>> > > From huaming.li at oracle.com Wed Sep 13 01:18:49 2017 From: huaming.li at oracle.com (huaming.li at oracle.com) Date: Wed, 13 Sep 2017 09:18:49 +0800 Subject: RFR of JDK-8187376: test issue in java/lang/invoke/VarHandles/VarHandleBaseTest.java In-Reply-To: <6EB878EE-080B-460E-8900-E477BC57649D@oracle.com> References: <753f2c3d-ca45-e198-2156-f58572c65bbe@oracle.com> <6EB878EE-080B-460E-8900-E477BC57649D@oracle.com> Message-ID: On 13/09/2017 3:09 AM, Paul Sandoz wrote: >> On 10 Sep 2017, at 20:20, huaming.li at oracle.com wrote: >> >> Would you please review the below patch? >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8187376 >> >> webrev: http://cr.openjdk.java.net/~mli/8187376/webrev.00/ >> > Looks good. I dunno what planet i was on when i wrote that code. Hi Pual, Thank you for reviewing. We all make mistakes sometimes. :-) > > Did you run all the VH tests? Yes, all related jprt tests passed. I will push the change when jdk 10 repo consolidation finishes. Thank you -Hamlin > > Paul. From vyom.tewari at oracle.com Wed Sep 13 07:29:55 2017 From: vyom.tewari at oracle.com (vyom tewari) Date: Wed, 13 Sep 2017 12:59:55 +0530 Subject: RFR[10]:8159526 Deprivilege jdk.httpserver In-Reply-To: References: Message-ID: <041f77ce-b011-1a3d-e100-d12b251c9a09@oracle.com> On Tuesday 12 September 2017 09:16 PM, Sean Mullan wrote: > On 9/12/17 4:06 AM, vyom tewari wrote: >> Hi, >> >> Please review the below code change. >> >> BugId: https://bugs.openjdk.java.net/browse/JDK-8159526 >> >> Webrev-1: >> http://cr.openjdk.java.net/~vtewari/8159526/jdk/webrev/index.html > > Can you put the entry for jdk.httpserver after jdk.dynalink so you > maintain the alphabetical ordering? > sure will do that. > Also, are there any tests for the jdk.httpserver module that use the > SecurityManager? It would be good to have at least one test that > checks that it properly gets granted AllPermission when doing > something security-sensitive (it seems like nothing should go wrong, > but ...). > i found more then 70 entrys when i search jdk.httpserver in code base, i will double check if we have any test which use the SecurityManager. Vyom > --Sean > >> >> Webrev-2: >> http://cr.openjdk.java.net/~vtewari/8159526/root/webrev/index.html >> >> Code change will De-privilege jdk.httpserver, we gave >> "jdk.httpserver" all permission for now. >> >> Thanks, >> >> Vyom >> From daniel.fuchs at oracle.com Wed Sep 13 09:28:39 2017 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Wed, 13 Sep 2017 10:28:39 +0100 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: <1595796.xe8q7Anfpj@pracovni> References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1906851.CDFazpJ8ns@pracovni> <1595796.xe8q7Anfpj@pracovni> Message-ID: Hi Jaroslav, GraalMBeans.java: 77 @Override 78 public Set mbeanInterfaceNames() { 79 return Collections.singleton(name); 80 } This is not correct. The return set should be a set of MXBean interface names, as in Class.getName(), not a set of MXBean ObjectName strings. The interface in question must be implemented by the concrete MBean instance and must be a subclass of PlatformManagedObject. It is not required for an MBean to implement such an interface - if it doesn't then it simply won't be obtainable from ManagementFactory::getPlatformMXBean or ManagementFactory::getPlatformMXBeans. So I suspect that in your case, since mbeanInterfaces() returns an empty set then mbeanInterfaceNames() should also return an empty set. IIRC mbeanInterfaceNames() was introduced so that you could query for a particular MBean implementing a given interface without necessarily triggering the loading and initialization of all interfaces implemented by all MBeans. best regards, -- daniel On 12/09/2017 18:44, Jaroslav Tulach wrote: > Dear reviewers, > after several reconsiderations I have webrev #4 ready for your review. Can you > please take a look at > > http://cr.openjdk.java.net/~jtulach/8182701/webrev.04/ > > and let me know if it is in a reasonable shape? Thanks a lot. > -jt > From kumar.x.srinivasan at oracle.com Wed Sep 13 14:37:52 2017 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 13 Sep 2017 07:37:52 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> Message-ID: <59B942C0.2050201@oracle.com> Let me take a look as well, I will respond in a day. Kumar On 9/12/2017 5:04 PM, David Holmes wrote: > On 13/09/2017 9:42 AM, Sergey Bylokhov wrote: >> On 9/12/17 16:03, David Holmes wrote: >>> call. That is fine, but still leaves the problem that you are >>> skipping the DeleteLocalRef call. >> >> The leak was there before: if we will get an exception at >> "1512 SetByteArrayRegion()" >> then we never call this DeleteLocalRef(). >> >> I assumed it was done intentionally since this will be kind of >> "fatal" error. > > On further checking DeleteLocalRef is not actually needed in > NewPlatformString at all. The only time it is recommended practice to > manually delete local refs is when looping, as in NewPlatformStringArray. > > So all good - Reviewed. And sorry for the noise. > > Thanks, > David > > > >> The same pattern is used in the other places for example in >> NewPlatformStringArray: >> >> jstring str = NewPlatformString(env, *strv++); >> NULL_CHECK0(str); >> (*env)->SetObjectArrayElement(env, ary, i, str); >> (*env)->DeleteLocalRef(env, str); >> >>> >>> Thanks - and sorry again for my confusion on this. >>> >>> David >>> ----- >>> >>>>> In addition this does nothing to clear the pending exception so I >>>>> can not see how it would affect any warnings. >>>> >>>> It does not clear an exception but preserve it instead, and does >>>> not use the result of the method which produced an exception. >>>> >>>>> >>>>> David >>>>> >>>>>> This value will be propagated to JavaMain() and I as far as >>>>>> understand will stop the execution. >>>>>> >>>>>> >>>>>> On 9/12/17 13:56, David Holmes wrote: >>>>>>> Hi Sergey, >>>>>>> >>>>>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>>>>> Hello, >>>>>>>> Please review the fix for jdk10/jdk10. >>>>>>>> >>>>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>>>>> Webrev can be found at: >>>>>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>>>>> >>>>>>> This doesn't look right to me: >>>>>>> >>>>>>> str = (*env)->CallStaticObjectMethod(env, cls, >>>>>>> makePlatformStringMID, USE_STDERR, ary); >>>>>>> + CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>> (*env)->DeleteLocalRef(env, ary); >>>>>>> return str; >>>>>>> >>>>>>> If there is an exception pending you fail to delete the local >>>>>>> ref. And there's no need to clear the exception before calling >>>>>>> DeleteLocalRef as that is okay to call with a pending exception. >>>>>>> But there is no point returning zero if an exception occurred >>>>>>> because in that case str will already be 0/NULL. >>>>>>> >>>>>>> The same here: >>>>>>> >>>>>>> 1596 appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>>>>>> 1597 CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>> 1598 return appClass; >>>>>>> >>>>>>> If an exception is pending then appClass will be 0/NULL. >>>>>>> >>>>>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the >>>>>>> pending exception so I can't see what warnings this would be >>>>>>> clearing up ??? >>>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> The simple application with empty main method produce some >>>>>>>> "warnings" when Xcheck:jni is used. Because of that it is hard >>>>>>>> to cleanup other parts of jdk from such warnings. >>>>>>>> >>>>>>>> Two additional checks were added, in both cases the new code >>>>>>>> will return 0 in the same way as NULL_CHECK0 in the same methods. >>>>>>>> >>>>>>>> >>>>>> >>>>>> >>>> >>>> >> >> From mandy.chung at oracle.com Wed Sep 13 15:23:22 2017 From: mandy.chung at oracle.com (mandy chung) Date: Wed, 13 Sep 2017 08:23:22 -0700 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1906851.CDFazpJ8ns@pracovni> <1595796.xe8q7Anfpj@pracovni> Message-ID: <14ccc931-d861-1672-9d26-a95e51e2f440@oracle.com> On 9/13/17 2:28 AM, Daniel Fuchs wrote: > Hi Jaroslav, > > GraalMBeans.java: > > ? 77???????? @Override > ? 78???????? public Set mbeanInterfaceNames() { > ? 79???????????? return Collections.singleton(name); > ? 80???????? } Good catch, Daniel.? This should return empty set as mbeanInterfaces() returns.? mbeanInterfaceNames returns the class name of the mbean interfaces. Mandy > > This is not correct. The return set should be a set of > MXBean interface names, as in Class.getName(), not a set > of MXBean ObjectName strings. > > The interface in question must be implemented by the > concrete MBean instance and must be a subclass of > PlatformManagedObject. > > It is not required for an MBean to implement such > an interface - if it doesn't then it simply won't > be obtainable from ManagementFactory::getPlatformMXBean > or ManagementFactory::getPlatformMXBeans. > > So I suspect that in your case, since mbeanInterfaces() > returns an empty set then mbeanInterfaceNames() should > also return an empty set. > > IIRC mbeanInterfaceNames() was introduced so that > you could query for a particular MBean implementing > a given interface without necessarily triggering the > loading and initialization of all interfaces implemented > by all MBeans. > > best regards, > > -- daniel > > > > On 12/09/2017 18:44, Jaroslav Tulach wrote: >> Dear reviewers, >> after several reconsiderations I have webrev #4 ready for your >> review. Can you >> please take a look at >> >> http://cr.openjdk.java.net/~jtulach/8182701/webrev.04/ >> >> and let me know if it is in a reasonable shape? Thanks a lot. >> -jt >> > From kumar.x.srinivasan at oracle.com Wed Sep 13 17:16:15 2017 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 13 Sep 2017 10:16:15 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> Message-ID: <59B967DF.1090907@oracle.com> Hi Sergey, If you so wish, you could make the test a little simpler, by using the createJar method in TestHelper.java which compiles a file and creates an executable jar out of it, refer to ArgsEnvVar.java, lines 43 to 54 in the test can be replaced by: StringBuilder tsrc = new StringBuilder(); tsrc.append("public static void main(String... args) {\n"); tsrc.append(" System.out.println(\"Hello world\");\n"); tsrc.append("}\n"); createJar(testJar, new File("Foo"), tsrc.toString()); but what you currently have is also fine, thanks for making these changes. Kumar > On 13/09/2017 9:42 AM, Sergey Bylokhov wrote: >> On 9/12/17 16:03, David Holmes wrote: >>> call. That is fine, but still leaves the problem that you are >>> skipping the DeleteLocalRef call. >> >> The leak was there before: if we will get an exception at >> "1512 SetByteArrayRegion()" >> then we never call this DeleteLocalRef(). >> >> I assumed it was done intentionally since this will be kind of >> "fatal" error. > > On further checking DeleteLocalRef is not actually needed in > NewPlatformString at all. The only time it is recommended practice to > manually delete local refs is when looping, as in NewPlatformStringArray. > > So all good - Reviewed. And sorry for the noise. > > Thanks, > David > > > >> The same pattern is used in the other places for example in >> NewPlatformStringArray: >> >> jstring str = NewPlatformString(env, *strv++); >> NULL_CHECK0(str); >> (*env)->SetObjectArrayElement(env, ary, i, str); >> (*env)->DeleteLocalRef(env, str); >> >>> >>> Thanks - and sorry again for my confusion on this. >>> >>> David >>> ----- >>> >>>>> In addition this does nothing to clear the pending exception so I >>>>> can not see how it would affect any warnings. >>>> >>>> It does not clear an exception but preserve it instead, and does >>>> not use the result of the method which produced an exception. >>>> >>>>> >>>>> David >>>>> >>>>>> This value will be propagated to JavaMain() and I as far as >>>>>> understand will stop the execution. >>>>>> >>>>>> >>>>>> On 9/12/17 13:56, David Holmes wrote: >>>>>>> Hi Sergey, >>>>>>> >>>>>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>>>>> Hello, >>>>>>>> Please review the fix for jdk10/jdk10. >>>>>>>> >>>>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>>>>> Webrev can be found at: >>>>>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>>>>> >>>>>>> This doesn't look right to me: >>>>>>> >>>>>>> str = (*env)->CallStaticObjectMethod(env, cls, >>>>>>> makePlatformStringMID, USE_STDERR, ary); >>>>>>> + CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>> (*env)->DeleteLocalRef(env, ary); >>>>>>> return str; >>>>>>> >>>>>>> If there is an exception pending you fail to delete the local >>>>>>> ref. And there's no need to clear the exception before calling >>>>>>> DeleteLocalRef as that is okay to call with a pending exception. >>>>>>> But there is no point returning zero if an exception occurred >>>>>>> because in that case str will already be 0/NULL. >>>>>>> >>>>>>> The same here: >>>>>>> >>>>>>> 1596 appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>>>>>> 1597 CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>> 1598 return appClass; >>>>>>> >>>>>>> If an exception is pending then appClass will be 0/NULL. >>>>>>> >>>>>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the >>>>>>> pending exception so I can't see what warnings this would be >>>>>>> clearing up ??? >>>>>>> >>>>>>> Thanks, >>>>>>> David >>>>>>> ----- >>>>>>> >>>>>>>> The simple application with empty main method produce some >>>>>>>> "warnings" when Xcheck:jni is used. Because of that it is hard >>>>>>>> to cleanup other parts of jdk from such warnings. >>>>>>>> >>>>>>>> Two additional checks were added, in both cases the new code >>>>>>>> will return 0 in the same way as NULL_CHECK0 in the same methods. >>>>>>>> >>>>>>>> >>>>>> >>>>>> >>>> >>>> >> >> From adam.farley at uk.ibm.com Thu Sep 14 08:26:50 2017 From: adam.farley at uk.ibm.com (Adam Farley8) Date: Thu, 14 Sep 2017 08:26:50 +0000 Subject: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java Message-ID: Hi All, I was advised (on the OpenJDK IRC channel) that supplying a fix is better than proposing the idea of one, so I've gone ahead and written a "silent exit" fix for the example case: java -agentlib:jdwp=help This fix solves that bug, and also creates the tools for other code, VM and otherwise, to be able to solve their exit(0) problems as well. I've attached the hg diffs to this email, along with a zip containing the test I wrote to exercise this fix. The test, once unzipped, can be run via the TestStart.sh file, and is a bash script intended for linux execution. Run it like this: bash TestStart.sh /location/of/java To be clear, the Java directory is the one that contains the bin directory. Best Regards Adam Farley P.S. I debated returning a jni return code from the debugInit.c's parseOptions method, but elected not to on the basis that (a) a seperate isHelp method allows us to quit the OnLoad before the agent does anything that would require us figuring out how to unload half an agent, and (b) I thought it best to modify as few apis as possible. This is up for debate if people think a jni return code is a better option here. P.P.S. I know the files get stripped from list emails. If anyone wants copies, email me and they're yours. ------------------ Previous email ------------------ Hi All, I've included the full text of my reply in-line below. A summary is: I continue to support the idea of a new return code on the basis that, when the VM is nonusable but no error has occurred, we have no suitable option. Right now we can: - Report an error that has not occurred. - Die and take the user's code with us (except for any exit hook code). - Return a JNI_OK, and allow the user's next action to fail. I think that if VM developers concur that the correct action is to leave the VM in a nonusable state, but to not throw an error, that this RC gives us a better option than exit(0). - Adam P.S. Apologies for the delay. I was on vacation. :) > Hi Alan, David, and Tom, >> >> First, thanks again for your efforts on this. As a new guy to OpenJDK >> contributions, it means a lot to see so much progress on this so >> quickly. :) > >All I see is discussion :) Progress would be something else entirely. True. :) > >> >> >On 24/08/2017 07:33, David Holmes wrote: >> >> Hi Adam, >> >> >> >> cc'ing hotspot runtime dev as runtime own JNI and the invocation API - >> >> and some of the problematic code resides in the VM. >> >Yeah, the hotspot mailing list would be a better place to discuss this >> >as there are several issues here and several places where HotSpot aborts >> >the process when initialization fails. It's a long standing issue (going >> >back 15+ years) that I think is partly because it's not easy to release >> >all resources and cleanup before CreateJavaVM returns with an error. >> > >> >> According to the JNI spec, it is not possible (yet) to create a second VM >> in the same thread as the first. >> >> There is also a bug (dup'd against another bug I don't have the access for) >> which states that even a successful VM creation+destruction won't permit >> a second VM to be created. >> >> https://bugs.openjdk.java.net/browse/JDK-4712793 >> >> Both of these seem to imply that making a new VM after a failed VM-creation >> (in the same thread) is unsupported behaviour. >> >> So is it important to release all resources and cleanup, given that we >> won't >> be trying to create a new VM in this thread? By "important" I mean "more >> important than exiting with a return code and allowing the user's code >> to finish". > >Okay, so if there is no intention of attempting to reload the jvm again, >I'm unclear what the purpose of the hosting process actually is. To me >it is either a customer launcher - in which case the exit calls are >"harmless" (and atexit handlers could be used if the process has its own >clean up) - or it's something multi-purpose part of which is to launch a >VM. In the latter case given the inability to reload a VM, and assuming >the process does not what it's java launching powers to be removed, then >the only real option is to filter out the problematic arguments and >either ignore them or exec a separate process to handle them. My assumption is that the user's code may be doing many things, of which the Java work is only a part. I'm trying not to be too specific here, as I don't know what the user is trying to do, nor what they want their code to do if Java returns an error. I think we should tell the user what has happened, and allow them to act on the information. Right now the VM developers don't have that option. They don't have a mechanism to tell the user that the VM is not in a usable state, but had found no errors. Therefore the VM *must* call exit(0) to indicate "pass", but also to prevent the user trying to do anything with the unusable VM. I would give them that option. If they can return an RC, they should have one available that fits this scenario. By providing this negative return code both within and without the VM, we can give future VM-upgrade projects the option to indicate an unusable VM with no error, removing the need for them to call exit(0) when the VM is unusable despite no error occurring. Also, in regards to the example option: I agree that this option should really be filtered out before we get to the exit(0)-slash-JNI_SILENT_EXIT RC. Perhaps we could abstract the "is this a help option" logic into a shared function, and tie that into the unrecognised options logic? > >> >> >> >> This specific case seems like a bug to me as the logic is assuming it >> >> is only ever called by a launcher which it is okay to terminate. >> >> Though to be honest the very existence of the "help" option seems to >> >> me somewhat misguided in a hosted-VM environment. That said, I see >> >> unified logging in 9 also added a terminating "help" option . >> >The agent "help" option case is tricky and would likely need an update >> >to the JVM TI spec and the Agent_OnLoad return value. >> > >> >> To clarify, the agent "help" option is only an example of this problem. >> There are 19 locations both within and without hotspot that call exit(0) >> directly, plus more places where exit is passed a variable that can be >> 0 (e.g. the aforementioned agent "help", which calls the forceExit function >> with an argument of 0, which calls exit(arg) in turn). >> >> I understand that your comment was intended as an effort to effect a fix >> for this specific instance of the problem. I wanted to make sure we kept >> sight of the wider problem, as ideally we'd come up with an ideal solution >> that could be applied to all cases. > >The fact there are numerous potential process termination points in the >VM and JDK native code, is something we just have to live with. I'm only >considering these kind of "report and terminate" flags to be the problem >cases that should be handled better. A fair statement. I posit that simply having this option available could prevent the need for further exit(0)'s in the future. Though I'm certainly not ruling out an entrepreneurial VM developer fixing these issues in the future. I'm simply agreeing that resolving all of these issues are outside of this proposal's scope. > >> My thought on this was a unique return code that tells the user's code >> that the VM is not in a usable state, but that no error has occurred. This >> should be a negative code (so the usual x<0 check will prevent the user's >> code from using the VM), but it shouldn't be one of the existing JNI codes; >> all of which seem to indicate either: >> >> a) The VM is fine and can be used (0). >> or >> b) The VM is not fine because an error occurred (-1 to -6). >> >> Ideally we need a c) The VM is not fine, but no error has occurred. > >It's somewhat debatable how to classify the case where you ask the VM to >load and then perform a one-off action that effectively succeeds but >leaves the VM unusable. Again ideally, to me, the VM would never do that >- such actions would occur as part of VM initialization, the VM would be >usable, but the launcher would do the termination because that is how >the flag is specified. But that is non-trivial to untangle. > >David Agreed. > >> Or is there another solution to the exit(0) problem? Other than putting >> a copy of the rest of your code on the exit hook, I mean. >> >> > >> >> >> >> Options processed by the VM will be recognized, while options >> >> processed by the Java launcher will not be. "-version", "-X", "-help" >> >> and numerous others are launcher options. Pure VM options are -XX >> >> options, but the VM also processes some -X flags and, as a result of >> >> jigsaw, now also processes a bunch of module-related flags that are >> >> simple --foo options. >> >Right because these options need to passed to CreateJavaVM as they are >> >used when initializing the VM. Using system properties would just repeat >> >the issues of past (e.g. java.class.path) and require documenting a slew >> >of system properties (which is complicated at repeating options). >> > >> >-Alan Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU From OGATAK at jp.ibm.com Thu Sep 14 09:15:44 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Thu, 14 Sep 2017 18:15:44 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Message-ID: Hello, Could someone review this patch? I think this patch works correctly. Although making ObjectStreamClass.dataLayout non-volatile can cause benign race, it still works correctly. Even when two or more threads competes to store references to the field, the ClassDataSlots[] objects are equivalent because it represents the layout of the same class. Regards, Ogata From: Kazunori Ogata/Japan/IBM To: Peter Levart Cc: core-libs-dev , Hans Boehm , Aleksey Shipilev Date: 2017/09/04 18:13 Subject: Re: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() Hi Peter, Thank you for fixing the code. I updated webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.02/ Regards, Ogata Peter Levart wrote on 2017/09/04 17:45:37: > From: Peter Levart > To: Kazunori Ogata > Cc: core-libs-dev , Hans Boehm > , Aleksey Shipilev > Date: 2017/09/04 17:45 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi Ogata, > If playing with mutable plain fields in multiple threads, it is > mandatory to read the plain field just once in program. Your implementation: > > 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > 1197 // REMIND: synchronize instead of relying on volatile? > 1198 if (dataLayout == null) { > 1199 ClassDataSlot[] slots = getClassDataLayout0(); > 1200 VarHandle.fullFence(); > 1201 dataLayout = slots; > 1202 } > 1203 return dataLayout; > 1204 } > > reads dataLayout field twice (line 1198 and 1203). Those two reads may > reorder and 1st return non-null value, while the 2nd return previous > value - null. You should use a local variable to store the 1st read and > return the local variable at the end. Like: > > ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > ClassDataSlot[] slots = dataLayout; > if (slots == null) { > ClassDataSlot[] slots = getClassDataLayout0(); > VarHandle.fullFence(); > dataLayout = slots; > } > return slots; > } > > > Regards, Peter > From weijun.wang at oracle.com Thu Sep 14 09:58:09 2017 From: weijun.wang at oracle.com (Weijun Wang) Date: Thu, 14 Sep 2017 17:58:09 +0800 Subject: Scanning multi version jars? In-Reply-To: References: Message-ID: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> > On Sep 14, 2017, at 5:07 PM, Alan Bateman wrote: > > On 13/09/2017 23:12, Greg Wilkins wrote: >> I hope this is the right group for this question. please redirect me if not. > Probably core-libs-dev as this isn't anything to do with modules but in any case ... A related question: I know an MR jar allows you to shadow a class file with a release-specific one, but what if the new release has removed an old class? It will not appear in the release-specific directory but still exists in the root. Should we describe this in the MANIFEST? Thanks Max From Alan.Bateman at oracle.com Thu Sep 14 10:44:24 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 14 Sep 2017 11:44:24 +0100 Subject: Scanning multi version jars? In-Reply-To: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> Message-ID: <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> On 14/09/2017 10:58, Weijun Wang wrote: > : > I know an MR jar allows you to shadow a class file with a release-specific one, but what if the new release has removed an old class? It will not appear in the release-specific directory but still exists in the root. Should we describe this in the MANIFEST? > A MR JAR is not intended to support multiple versions of the same library, instead the versioned sections are for classes that take advantage of newer language or API features. They help with the migration from using JDK internal APIs to supported/standard APIs for example. So I don't think it should be complicated by an additional list of entries to "hide" in the base or overlaid version sections. Greg's mail doesn't say if Bar is public so I can't tell if his example involves an attempted API change or not. Assuming Bar is not public then compiling the 9 version of Foo.java will generate Foo.class and no Foo$Bar.class. This doesn't mean it's completely orphaned of course as there may be other classes in the base section, and in the same package, that were compiled with references to Bar. The `jar` tool could do some additional validation to catch these references and so avoid IncompatibleClassChangeError at runtime (as might arise if getEnclosingClass were invoked on the inner class). That would help with Greg's annotation scanning scenario too. -Alan From Roger.Riggs at Oracle.com Thu Sep 14 13:34:38 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Thu, 14 Sep 2017 09:34:38 -0400 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Message-ID: <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Hi, The repo's are closed in the short term for the consolidation. It seems like the consensus is that full fence is the best solution. I can sponsor the issue when the jdk 10 repos re-opens. Regards, Roger On 9/14/2017 5:15 AM, Kazunori Ogata wrote: > Hello, > > Could someone review this patch? > > I think this patch works correctly. Although making > ObjectStreamClass.dataLayout non-volatile can cause benign race, it still > works correctly. Even when two or more threads competes to store > references to the field, the ClassDataSlots[] objects are equivalent > because it represents the layout of the same class. > > > Regards, > Ogata > > > > From: Kazunori Ogata/Japan/IBM > To: Peter Levart > Cc: core-libs-dev , Hans Boehm > , Aleksey Shipilev > Date: 2017/09/04 18:13 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > > Hi Peter, > > Thank you for fixing the code. > > I updated webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.02/ > > Regards, > Ogata > > > Peter Levart wrote on 2017/09/04 17:45:37: > >> From: Peter Levart >> To: Kazunori Ogata >> Cc: core-libs-dev , Hans Boehm >> , Aleksey Shipilev >> Date: 2017/09/04 17:45 >> Subject: Re: RFR: 8187033: [PPC] Imporve performance of >> ObjectStreamClass.getClassDataLayout() >> >> Hi Ogata, > > > >> If playing with mutable plain fields in multiple threads, it is >> mandatory to read the plain field just once in program. Your > implementation: >> 1196 ClassDataSlot[] getClassDataLayout() throws > InvalidClassException { >> 1197 // REMIND: synchronize instead of relying on volatile? >> 1198 if (dataLayout == null) { >> 1199 ClassDataSlot[] slots = getClassDataLayout0(); >> 1200 VarHandle.fullFence(); >> 1201 dataLayout = slots; >> 1202 } >> 1203 return dataLayout; >> 1204 } >> >> reads dataLayout field twice (line 1198 and 1203). Those two reads may >> reorder and 1st return non-null value, while the 2nd return previous >> value - null. You should use a local variable to store the 1st read and >> return the local variable at the end. Like: >> >> ClassDataSlot[] getClassDataLayout() throws InvalidClassException > { >> ClassDataSlot[] slots = dataLayout; >> if (slots == null) { >> ClassDataSlot[] slots = getClassDataLayout0(); >> VarHandle.fullFence(); >> dataLayout = slots; >> } >> return slots; >> } >> >> >> Regards, Peter >> > > From OGATAK at jp.ibm.com Thu Sep 14 15:09:34 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Fri, 15 Sep 2017 00:09:34 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> Message-ID: Hi Roger, Thank you for taking care of this patch and offering to sponsor it. Regards, Ogata "core-libs-dev" wrote on 2017/09/14 22:34:38: > From: Roger Riggs > To: core-libs-dev at openjdk.java.net > Date: 2017/09/14 22:36 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > Sent by: "core-libs-dev" > > Hi, > > The repo's are closed in the short term for the consolidation. > > It seems like the consensus is that full fence is the best solution. > > I can sponsor the issue when the jdk 10 repos re-opens. > > Regards, Roger From Sergey.Bylokhov at oracle.com Thu Sep 14 19:01:01 2017 From: Sergey.Bylokhov at oracle.com (Sergey Bylokhov) Date: Thu, 14 Sep 2017 12:01:01 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <59B967DF.1090907@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> <59B967DF.1090907@oracle.com> Message-ID: <5bd33781-2acf-22e6-1b53-8399c1eb7330@oracle.com> Hi, Kumar. The test is updated as suggested: http://cr.openjdk.java.net/~serb/8187442/webrev.01 On 9/13/17 10:16, Kumar Srinivasan wrote: > Hi Sergey, > > If you so wish, you could make the test a little simpler, by using > the createJar method in TestHelper.java which compiles a file and > creates an executable jar out of it,?? refer to ArgsEnvVar.java, > lines 43 to 54 in the test can be replaced by: > > ??????? StringBuilder tsrc = new StringBuilder(); > ??????? tsrc.append("public static void main(String... args) {\n"); > ??????? tsrc.append("??? System.out.println(\"Hello world\");\n"); > ??????? tsrc.append("}\n"); > ??????? createJar(testJar, new File("Foo"), tsrc.toString()); > > but what you currently have is also fine, thanks for making these changes. > > Kumar > >> On 13/09/2017 9:42 AM, Sergey Bylokhov wrote: >>> On 9/12/17 16:03, David Holmes wrote: >>>> call. That is fine, but still leaves the problem that you are >>>> skipping the DeleteLocalRef call. >>> >>> The leak was there before: if we will get an exception at >>> "1512 SetByteArrayRegion()" >>> then we never call this DeleteLocalRef(). >>> >>> I assumed it was done intentionally since this will be kind of >>> "fatal" error. >> >> On further checking DeleteLocalRef is not actually needed in >> NewPlatformString at all. The only time it is recommended practice to >> manually delete local refs is when looping, as in NewPlatformStringArray. >> >> So all good - Reviewed. And sorry for the noise. >> >> Thanks, >> David >> >> >> >>> The same pattern is used in the other places for example in >>> NewPlatformStringArray: >>> >>> ???????? jstring str = NewPlatformString(env, *strv++); >>> ???????? NULL_CHECK0(str); >>> ???????? (*env)->SetObjectArrayElement(env, ary, i, str); >>> ???????? (*env)->DeleteLocalRef(env, str); >>> >>>> >>>> Thanks - and sorry again for my confusion on this. >>>> >>>> David >>>> ----- >>>> >>>>>> In addition this does nothing to clear the pending exception so I >>>>>> can not see how it would affect any warnings. >>>>> >>>>> It does not clear an exception but preserve it instead, and does >>>>> not use the result of the method which produced an exception. >>>>> >>>>>> >>>>>> David >>>>>> >>>>>>> This value will be propagated to JavaMain() and I as far as >>>>>>> understand will stop the execution. >>>>>>> >>>>>>> >>>>>>> On 9/12/17 13:56, David Holmes wrote: >>>>>>>> Hi Sergey, >>>>>>>> >>>>>>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>>>>>> Hello, >>>>>>>>> Please review the fix for jdk10/jdk10. >>>>>>>>> >>>>>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>>>>>> Webrev can be found at: >>>>>>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>>>>>> >>>>>>>> This doesn't look right to me: >>>>>>>> >>>>>>>> ?????????????? str = (*env)->CallStaticObjectMethod(env, cls, >>>>>>>> ?????????????????????? makePlatformStringMID, USE_STDERR, ary); >>>>>>>> +???????????? CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>>> ?????????????? (*env)->DeleteLocalRef(env, ary); >>>>>>>> ?????????????? return str; >>>>>>>> >>>>>>>> If there is an exception pending you fail to delete the local >>>>>>>> ref. And there's no need to clear the exception before calling >>>>>>>> DeleteLocalRef as that is okay to call with a pending exception. >>>>>>>> But there is no point returning zero if an exception occurred >>>>>>>> because in that case str will already be 0/NULL. >>>>>>>> >>>>>>>> The same here: >>>>>>>> >>>>>>>> 1596???? appClass = (*env)->CallStaticObjectMethod(env, cls, mid); >>>>>>>> 1597???? CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>>> 1598???? return appClass; >>>>>>>> >>>>>>>> If an exception is pending then appClass will be 0/NULL. >>>>>>>> >>>>>>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the >>>>>>>> pending exception so I can't see what warnings this would be >>>>>>>> clearing up ??? >>>>>>>> >>>>>>>> Thanks, >>>>>>>> David >>>>>>>> ----- >>>>>>>> >>>>>>>>> The simple application with empty main method produce some >>>>>>>>> "warnings" when Xcheck:jni is used. Because of that it is hard >>>>>>>>> to cleanup other parts of jdk from such warnings. >>>>>>>>> >>>>>>>>> Two additional checks were added, in both cases the new code >>>>>>>>> will return 0 in the same way as NULL_CHECK0 in the same methods. >>>>>>>>> >>>>>>>>> >>>>>>> >>>>>>> >>>>> >>>>> >>> >>> > -- Best regards, Sergey. From weijun.wang at oracle.com Thu Sep 14 23:22:01 2017 From: weijun.wang at oracle.com (Weijun Wang) Date: Fri, 15 Sep 2017 07:22:01 +0800 Subject: ArrayIndexOutOfBoundsException in java.util.JapaneseImperialCalendar In-Reply-To: References: Message-ID: <8906262E-E9CB-465D-97CE-B43BFECEAED4@oracle.com> Move to core-libs-dev. > On Sep 15, 2017, at 12:55 AM, Dominik Helm wrote: > > I did not find a better place to report this, so I'm going to post it here: > > There is an obvious ArrayIndexOutOfBoundsException in > java.util.JapaneseImperialCalendar.actualMonthLength(): > The third and fourth lines read > > if (eraIndex == -1) { > long transitionFixedDate = sinceFixedDates[eraIndex]; > > thereby always trying to access an out ouf bounds element on > sinceFixedDates. > > Best regards, > Dominik From hboehm at google.com Fri Sep 15 00:44:56 2017 From: hboehm at google.com (Hans Boehm) Date: Thu, 14 Sep 2017 17:44:56 -0700 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: Just to be clear, the semi-plausible failure scenario here is that a reader will see a non-null slots value, but then read an uninitialized value from the ClassDataSlot array. This could happen if the compiler or hardware correctly speculated (e.g. based on a previous program execution), the value of dataLayout, used that to first load a value from the ClassDataSlot array, and only then confirmed that the dataLayout value was correct. None of this is likely to happen today, but is potentially profitable, and allowed by the current memory model. I think the extra assumption here should at least be documented. Answering Andrew's earlier question (sorry), this could conceivably become an issue if the hardware provided multiple load instructions, one for final-field, and one for non-final-field loads, only the former of which implicitly enforced dependency ordering. The latter could behave like DEC Alpha's load. I'll let any hardware architects comment as to whether or not that might make sense. On Thu, Sep 14, 2017 at 8:09 AM, Kazunori Ogata wrote: > Hi Roger, > > Thank you for taking care of this patch and offering to sponsor it. > > Regards, > Ogata > > > "core-libs-dev" wrote on > 2017/09/14 22:34:38: > > > From: Roger Riggs > > To: core-libs-dev at openjdk.java.net > > Date: 2017/09/14 22:36 > > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > > ObjectStreamClass.getClassDataLayout() > > Sent by: "core-libs-dev" > > > > Hi, > > > > The repo's are closed in the short term for the consolidation. > > > > It seems like the consensus is that full fence is the best solution. > > > > I can sponsor the issue when the jdk 10 repos re-opens. > > > > Regards, Roger > > > From david.holmes at oracle.com Fri Sep 15 01:47:58 2017 From: david.holmes at oracle.com (David Holmes) Date: Fri, 15 Sep 2017 11:47:58 +1000 Subject: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java In-Reply-To: References: Message-ID: <9ae20280-0f27-1edb-4969-e7c9b40977e1@oracle.com> Hi Adam, I am still very much torn over this one. I think the idea of print-and-exit flags for a potentially hosted library like the JVM is just wrong - we should never have done that, but we did. Fixing that by moving the flags to the launcher is far from trivial**. Endorsing and encouraging these sorts of flag by adding JNI support seems to be sending the wrong message. ** I can envisage a "help xxx" Dcmd that can read back the info from the VM. The launcher can send the Dcmd, print the output and exit. The launcher would not need to know what the xxx values mean, but would have to intercept the existing ones. Another option is just to be aware of these flags (are there more than jdwp and Xlog?) and deal with them specially in your custom launcher - either filter them out and ignore them, or else launch the VM in its own process to respond to them. Any changes to the JNI specification need to go through the CSR process. Cheers, David On 14/09/2017 6:26 PM, Adam Farley8 wrote: > Hi All, > > I was advised (on the OpenJDK IRC channel) that supplying a fix is > better than > proposing the idea of one, so I've gone ahead and written a "silent > exit" fix for the > example case: > > java -agentlib:jdwp=help > > This fix solves that bug, and also creates the tools for other code, VM and > otherwise, to be able to solve their exit(0) problems as well. > > I've attached the hg diffs to this email, along with a zip containing > the test > I wrote to exercise this fix. The test, once unzipped, can be run via the > TestStart.sh file, and is a bash script intended for linux execution. > Run it like this: > > bash TestStart.sh /location/of/java > > To be clear, the Java directory is the one that contains the bin directory. > > Best Regards > > Adam Farley > > > > P.S. I debated returning a jni return code from the debugInit.c's > parseOptions > method, but elected not to on the basis that (a) a seperate isHelp method > allows us to quit the OnLoad before the agent does anything that would > require us figuring out how to unload half an agent, and (b) I thought > it best to > modify as few apis as possible. This is up for debate if people think a > jni return > code is a better option here. > > P.P.S. I know the files get stripped from list emails. If anyone wants > copies, > email me and they're yours. > > > ------------------ Previous email ------------------ > > Hi All, > > I've included the full text of my reply in-line below. > > A summary is: I continue to support the idea of a new return code on the > basis > that, when the VM is nonusable but no error has occurred, we have no > suitable > option. > > Right now we can: > - Report an error that has not occurred. > - Die and take the user's code with us (except for any exit hook code). > - Return a JNI_OK, and allow the user's next action to fail. > > I think that if VM developers concur that the correct action is to leave > the VM > in a nonusable state, but to not throw an error, that this RC gives us a > better option > than exit(0). > > - Adam > > P.S. Apologies for the delay. I was on vacation. :) > > > Hi Alan, David, and Tom, > >> > >> First, thanks again for your efforts on this. As a new guy to OpenJDK > >> contributions, it means a lot to see so much progress on this so > >> quickly. :) > > > >All I see is discussion :) Progress would be something else entirely. > > True. :) > > > > >> > >> ?>On 24/08/2017 07:33, David Holmes wrote: > >> ?>> Hi Adam, > >> ?>> > >> ?>> cc'ing hotspot runtime dev as runtime own JNI and the invocation > API - > >> ?>> and some of the problematic code resides in the VM. > >> ?>Yeah, the hotspot mailing list would be a better place to discuss > this > >> ?>as there are several issues here and several places where HotSpot > aborts > >> ?>the process when initialization fails. It's a long standing issue > (going > >> ?>back 15+ years) that I think is partly because it's not easy to > release > >> ?>all resources and cleanup before CreateJavaVM returns with an error. > >> ?> > >> > >> According to the JNI spec, it is not possible (yet) to create a > second VM > >> in the same thread as the first. > >> > >> There is also a bug (dup'd against another bug I don't have the > access for) > >> which states that even a successful VM creation+destruction won't > permit > >> a second VM to be created. > >> > >> https://bugs.openjdk.java.net/browse/JDK-4712793 > >> > >> Both of these seem to imply that making a new VM after a failed > VM-creation > >> (in the same thread) is unsupported behaviour. > >> > >> So is it important to release all resources and cleanup, given that we > >> won't > >> be trying to create a new VM in this thread? By "important" I mean > "more > >> important than exiting with a return code and allowing the user's code > >> to finish". > > > >Okay, so if there is no intention of attempting to reload the jvm again, > >I'm unclear what the purpose of the hosting process actually is. To me > >it is either a customer launcher - in which case the exit calls are > >"harmless" (and atexit handlers could be used if the process has its own > >clean up) - or it's something multi-purpose part of which is to launch a > >VM. In the latter case given the inability to reload a VM, and assuming > >the process does not what it's java launching powers to be removed, then > >the only real option is to filter out the problematic arguments and > >either ignore them or exec a separate process to handle them. > > My assumption is that the user's code may be doing many things, of which > the Java work is only a part. I'm trying not to be too specific here, as > I don't > know what the user is trying to do, nor what they want their code to do if > Java returns an error. I think we should tell the user what has > happened, and > allow them to act on the information. > > Right now the VM developers don't have that option. They don't have a > mechanism > to tell the user that the VM is not in a usable state, but had found no > errors. Therefore > the VM *must* call exit(0) to indicate "pass", but also to prevent the > user trying to do > anything with the unusable VM. > > I would give them that option. If they can return an RC, they should > have one available > that fits this scenario. > > By providing this negative return code both within and without the VM, > we can give future > VM-upgrade projects the option to indicate an unusable VM with no error, > removing > the need for them to call exit(0) when the VM is unusable despite no > error occurring. > > Also, in regards to the example option: I agree that this option should > really be filtered > out before we get to the exit(0)-slash-JNI_SILENT_EXIT RC. Perhaps we > could abstract > the "is this a help option" logic into a shared function, and tie that > into the unrecognised > options logic? > > > > >> ?>> > >> ?>> This specific case seems like a bug to me as the logic is > assuming it > >> ?>> is only ever called by a launcher which it is okay to terminate. > >> ?>> Though to be honest the very existence of the "help" option > seems to > >> ?>> me somewhat misguided in a hosted-VM environment. That said, I see > >> ?>> unified logging in 9 also added a terminating "help" option . > >> ?>The agent "help" option case is tricky and would likely need an > update > >> ?>to the JVM TI spec and the Agent_OnLoad return value. > >> ?> > >> > >> To clarify, the agent "help" option is only an example of this problem. > >> There are 19 locations both within and without hotspot that call > exit(0) > >> directly, plus more places where exit is passed a variable that can be > >> 0 (e.g. the aforementioned agent "help", which calls the forceExit > function > >> with an argument of 0, which calls exit(arg) in turn). > >> > >> I understand that your comment was intended as an effort to effect a > fix > >> for this specific instance of the problem. I wanted to make sure we > kept > >> sight of the wider problem, as ideally we'd come up with an ideal > solution > >> that could be applied to all cases. > > > >The fact there are numerous potential process termination points in the > >VM and JDK native code, is something we just have to live with. I'm only > >considering these kind of "report and terminate" flags to be the problem > >cases that should be handled better. > > A fair statement. I posit that simply having this option available could > prevent > the need for further exit(0)'s in the future. > > Though I'm certainly not ruling out an entrepreneurial VM developer fixing > these issues in the future. I'm simply agreeing that resolving all of these > issues are outside of this proposal's scope. > > > > >> My thought on this was a unique return code that tells the user's code > >> that the VM is not in a usable state, but that no error has > occurred. This > >> should be a negative code (so the usual x<0 check will prevent the > user's > >> code from using the VM), but it shouldn't be one of the existing JNI > codes; > >> all of which seem to indicate either: > >> > >> a) The VM is fine and can be used (0). > >> or > >> b) The VM is not fine because an error occurred (-1 to -6). > >> > >> Ideally we need a c) The VM is not fine, but no error has occurred. > > > >It's somewhat debatable how to classify the case where you ask the VM to > >load and then perform a one-off action that effectively succeeds but > >leaves the VM unusable. Again ideally, to me, the VM would never do that > >- such actions would occur as part of VM initialization, the VM would be > >usable, but the launcher would do the termination because that is how > >the flag is specified. But that is non-trivial to untangle. > > > >David > > Agreed. > > > > >> Or is there another solution to the exit(0) problem? Other than putting > >> a copy of the rest of your code on the exit hook, I mean. > >> > >> ?> > >> ?>> > >> ?>> Options processed by the VM will be recognized, while options > >> ?>> processed by the Java launcher will not be. "-version", "-X", > "-help" > >> ?>> and numerous others are launcher options. Pure VM options are -XX > >> ?>> options, but the VM also processes some -X flags and, as a > result of > >> ?>> jigsaw, now also processes a bunch of module-related flags that are > >> ?>> simple --foo options. > >> ?>Right because these options need to passed to CreateJavaVM as they > are > >> ?>used when initializing the VM. Using system properties would just > repeat > >> ?>the issues of past (e.g. java.class.path) and require documenting > a slew > >> ?>of system properties (which is complicated at repeating options). > >> ?> > >> ?>-Alan > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU From gregw at webtide.com Fri Sep 15 02:09:06 2017 From: gregw at webtide.com (Greg Wilkins) Date: Fri, 15 Sep 2017 12:09:06 +1000 Subject: Scanning multi version jars? In-Reply-To: <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> Message-ID: Alan, thanks for correcting me on the API of JarFile - I can see it kind of works, but in a very bizarre way (it gives different content for entries obtained via the enumerator vs the getJarEntry API, even though both entries report the same name). But I'll discuss that elsewhere. The main issue still remains is that it is entirely unclear what files we should scan. I understand the nuanced point that you are trying to make, ie "that it depends" on if the class is public or private, if it is an API change, if it is an alternate implementation rather than a new version of the same library etc. etc. I also totally understand that there are intended uses and unintended uses for this feature. However, as an implementer of an application container, it does not matter if I understand the nuances of MR jars and intended usage. What matters is do the developers of the 3rd party jars that will be deployed in my container understand those nuances? We have to look at jars that are supplied by third parties, with various levels of understanding, perhaps with some tricky clever ideas how to mess with the system, and we have to decide which classes we are going to scan for annotations. This is NOT a performance issue. It is a consistency/portability issue. We have to make exactly the same decisions as all the other application containers out there, else 3rd party library jars will act differently on different containers. Thus it looks like we need some kind of heuristic to guess what the 3rd party developer intended when they used the MR feature. Some approaches will need us to scan all the outer and inner classes to determine if the inner classes are referenced and if they are public or private. The heuristic could then be to analyse an inner class IFF it is public and referenced. Or perhaps that should be if it is public OR referenced? Alternately, can we just have an heuristic based only on the index. If Foo exists as a versioned class, then only similarly versioned Foo$Bar classes should be scanned and base Foo$Bar classes will be ignored? All of these are possible. But we need an official documented (perhaps tool enforced) policy so that all containers can implement the same heuristic so that we can have portability. Ideally, the containers would not need to implement this heuristic, as it would be implemented in the enumerator of JarFile. Unfortunately that is not the case and the enumerator returns all the entries regardless of version. So containers must implement their own enumeration and we need to make sure we all implement it the same! regards On 14 September 2017 at 20:44, Alan Bateman wrote: > On 14/09/2017 10:58, Weijun Wang wrote: > >> : >> I know an MR jar allows you to shadow a class file with a >> release-specific one, but what if the new release has removed an old class? >> It will not appear in the release-specific directory but still exists in >> the root. Should we describe this in the MANIFEST? >> >> A MR JAR is not intended to support multiple versions of the same > library, instead the versioned sections are for classes that take advantage > of newer language or API features. They help with the migration from using > JDK internal APIs to supported/standard APIs for example. So I don't think > it should be complicated by an additional list of entries to "hide" in the > base or overlaid version sections. > > Greg's mail doesn't say if Bar is public so I can't tell if his example > involves an attempted API change or not. Assuming Bar is not public then > compiling the 9 version of Foo.java will generate Foo.class and no > Foo$Bar.class. This doesn't mean it's completely orphaned of course as > there may be other classes in the base section, and in the same package, > that were compiled with references to Bar. The `jar` tool could do some > additional validation to catch these references and so avoid > IncompatibleClassChangeError at runtime (as might arise if > getEnclosingClass were invoked on the inner class). That would help with > Greg's annotation scanning scenario too. > > -Alan > -- Greg Wilkins CTO http://webtide.com From gregw at webtide.com Fri Sep 15 04:43:30 2017 From: gregw at webtide.com (Greg Wilkins) Date: Fri, 15 Sep 2017 14:43:30 +1000 Subject: MR JarFile was: Scanning multi version jars? Message-ID: All, Alan suggested this as a more appropriate forum for some issues I'm having with multi release jar files. My issues break down into two aspects: 1. How does a container know which classes within a jar should be scanned for annotations - and that is being discussed in the other thread: "Scanning multi version jars" 2. Confusion about the JarFile API - which I'd like to discuss in this thread. At the very least I think the javadoc on JarFile is wrong, but I also think the behaviour is very confusing Consider a MR jar with the following contents: example.jar ??? META-INF ? ??? MANIFEST.MF ? ??? versions ? ??? 9 ? ??? org ? ??? example ? ??? InBoth.class ? ??? OnlyIn9.class ??? org ??? example ??? InBoth.class ??? OnlyInBase.class where for debugging purposes I've made the contents of each file be its path within the jar. If I run the following code: JarFile jarFile = new JarFile(new File("/tmp/example.jar"), false, JarFile.OPEN_READ, Runtime.version()); for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { JarEntry entry0 = e.nextElement(); String name0 = entry0.getName(); String content0 = IO.toString(jarFile.getInputStream(entry0)); JarEntry entry1 = jarFile.getJarEntry(name0); String name1 = entry1.getName(); String content1 = IO.toString(jarFile.getInputStream(entry1)); System.err.printf("%n=== %s ===%n -> %s%n => %s%n => %s%n",name0,name1,content0,content1); } I get the following output: === META-INF/ === -> META-INF/ => => === META-INF/MANIFEST.MF === -> META-INF/MANIFEST.MF => Manifest-Version: 1.0 Multi-Release: true Created-By: 9 (Oracle Corporation) => Manifest-Version: 1.0 Multi-Release: true Created-By: 9 (Oracle Corporation) === org/ === -> org/ => => === org/example/ === -> org/example/ => => === org/example/OnlyInBase.class === -> org/example/OnlyInBase.class => org/example/OnlyInBase.class => org/example/OnlyInBase.class === org/example/InBoth.class === -> org/example/InBoth.class => org/example/InBoth.class => META-INF/versions/9/org/example/InBoth.class === META-INF/versions/ === -> META-INF/versions/ => => === META-INF/versions/9/ === -> META-INF/versions/9/ => => === META-INF/versions/9/org/ === -> META-INF/versions/9/org/ => => === META-INF/versions/9/org/example/ === -> META-INF/versions/9/org/example/ => => === META-INF/versions/9/org/example/OnlyIn9.class === -> META-INF/versions/9/org/example/OnlyIn9.class => META-INF/versions/9/org/example/OnlyIn9.class => META-INF/versions/9/org/example/OnlyIn9.class === META-INF/versions/9/org/example/InBoth.class === -> META-INF/versions/9/org/example/InBoth.class => META-INF/versions/9/org/example/InBoth.class => META-INF/versions/9/org/example/InBoth.class The issue I have are that sometimes the class is trying to hide the MR aspects, yet other times it is not. Specifically when iterating it returns JarEntry instances that ignore versions and always return the content to which they refer, yet if you obtain a JarEntry from the getJarEntry API, it behaves differently and may return the versioned content even if it has the un-versioned path. Specifically in the above example, if I obtain a JarEntry for org/example/InBoth.class from the enumerator, then it always returns be the base entry. But if I do entry=jarFile.getEntry(entry.getName()), I obtain a JarEntry that has the name of the base entry, but gives me the versioned content when used as a reference. More over, there is nothing in the JarEntry API that allows me to tell if it is versioned or not (no getVersion()) My expectations of the versioned JarFile API were that the enumeration should only return entries appropriate for the version. So when configured for java8, the above jar would enumerate over: META-INF/ META-INF/MANIFEST.MF org/ org/example/ org/example/OnlyInBase.class org/example/InBoth.class and for java9 the enumeration should return META-INF/ META-INF/MANIFEST.MF org/ org/example/ org/example/InBoth.class org/example/OnlyIn9.class Ie the existence of the META-INF/versions structure should be hidden unless a non versioned JarFile is instantiated. I had also expected that I would be able to query a JarEntry to ask what version it was for. The issue being discussed in the other thread about how containers can be portable in their scanning of MR jars. If the JarFile enumeration provided the behaviour above, then containers would not need to implement their own filtering and could just rely on the versioned JarFile enumeration. Currently as is, each container will have to implement their own logic to determine what class files in a jar should be scanned for annotations etc. regards On 15 September 2017 at 12:09, Greg Wilkins wrote: > > Alan, > > thanks for correcting me on the API of JarFile - I can see it kind of > works, but in a very bizarre way (it gives different content for entries > obtained via the enumerator vs the getJarEntry API, even though both > entries report the same name). But I'll discuss that elsewhere. > > > > The main issue still remains is that it is entirely unclear what files we > should scan. I understand the nuanced point that you are trying to make, > ie "that it depends" on if the class is public or private, if it is an API > change, if it is an alternate implementation rather than a new version of > the same library etc. etc. I also totally understand that there are > intended uses and unintended uses for this feature. > > However, as an implementer of an application container, it does not matter > if I understand the nuances of MR jars and intended usage. What matters is > do the developers of the 3rd party jars that will be deployed in my > container understand those nuances? We have to look at jars that are > supplied by third parties, with various levels of understanding, perhaps > with some tricky clever ideas how to mess with the system, and we have to > decide which classes we are going to scan for annotations. > > This is NOT a performance issue. It is a consistency/portability issue. > We have to make exactly the same decisions as all the other application > containers out there, else 3rd party library jars will act differently on > different containers. > > Thus it looks like we need some kind of heuristic to guess what the 3rd > party developer intended when they used the MR feature. Some approaches > will need us to scan all the outer and inner classes to determine if the > inner classes are referenced and if they are public or private. > > The heuristic could then be to analyse an inner class IFF it is public and > referenced. Or perhaps that should be if it is public OR referenced? > > Alternately, can we just have an heuristic based only on the index. If > Foo exists as a versioned class, then only similarly versioned Foo$Bar > classes should be scanned and base Foo$Bar classes will be ignored? > > All of these are possible. But we need an official documented (perhaps > tool enforced) policy so that all containers can implement the same > heuristic so that we can have portability. > > Ideally, the containers would not need to implement this heuristic, as it > would be implemented in the enumerator of JarFile. Unfortunately that is > not the case and the enumerator returns all the entries regardless of > version. So containers must implement their own enumeration and we need > to make sure we all implement it the same! > > regards > > > > > > On 14 September 2017 at 20:44, Alan Bateman > wrote: > >> On 14/09/2017 10:58, Weijun Wang wrote: >> >>> : >>> I know an MR jar allows you to shadow a class file with a >>> release-specific one, but what if the new release has removed an old class? >>> It will not appear in the release-specific directory but still exists in >>> the root. Should we describe this in the MANIFEST? >>> >>> A MR JAR is not intended to support multiple versions of the same >> library, instead the versioned sections are for classes that take advantage >> of newer language or API features. They help with the migration from using >> JDK internal APIs to supported/standard APIs for example. So I don't think >> it should be complicated by an additional list of entries to "hide" in the >> base or overlaid version sections. >> >> Greg's mail doesn't say if Bar is public so I can't tell if his example >> involves an attempted API change or not. Assuming Bar is not public then >> compiling the 9 version of Foo.java will generate Foo.class and no >> Foo$Bar.class. This doesn't mean it's completely orphaned of course as >> there may be other classes in the base section, and in the same package, >> that were compiled with references to Bar. The `jar` tool could do some >> additional validation to catch these references and so avoid >> IncompatibleClassChangeError at runtime (as might arise if >> getEnclosingClass were invoked on the inner class). That would help with >> Greg's annotation scanning scenario too. >> >> -Alan >> > > > > -- > Greg Wilkins CTO http://webtide.com > -- Greg Wilkins CTO http://webtide.com From OGATAK at jp.ibm.com Fri Sep 15 05:12:00 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Fri, 15 Sep 2017 14:12:00 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: Hi Hans, Thank you for your comment Hans Boehm wrote on 2017/09/15 09:44:56: > Just to be clear, the semi-plausible failure scenario here is that a > reader will see a non-null slots value, but then read an uninitialized > value from the ClassDataSlot array. This could happen if the compiler or > hardware correctly speculated (e.g. based on a previous program > execution), the value of dataLayout, used that to first load a value from > the ClassDataSlot array, and only then confirmed that the dataLayout value > was correct. None of this is likely to happen today, but is potentially > profitable, and allowed by the current memory model. I think the extra > assumption here should at least be documented. In this scenario, the load from the ClassDataSlot array is also a speculated load, so it should be confirmed after the load from dataLayout is confirmed, and the full fence should be detected during the confirmation of the speculated load from the array slot. Otherwise, the full fence won't work as expected, I think. Regards, Ogata From Alan.Bateman at oracle.com Fri Sep 15 07:27:52 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 15 Sep 2017 08:27:52 +0100 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> Message-ID: <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> On 15/09/2017 03:09, Greg Wilkins wrote: > > Alan, > > thanks for correcting me on the API of JarFile - I can see it kind of > works, but in a very bizarre way (it gives different content for > entries obtained via the enumerator vs the getJarEntry API, even > though both entries report the same name).? But I'll discuss that > elsewhere. This is something that was discussed on core-libs-dev on a number of occasions. The summary is that JarFile needs a new API for this, versionedStream() was suggested, but it was kicked down the road for later in order deal with the fallout from adding MR JARs. Since you have access to the code then look at jdk.internal.util.jar.VersionedStream for an example code of what I think you are looking for. -Alan From sergei.tsypanov at yandex.ru Fri Sep 15 09:49:01 2017 From: sergei.tsypanov at yandex.ru (=?utf-8?B?0KHQtdGA0LPQtdC5INCm0YvQv9Cw0L3QvtCy?=) Date: Fri, 15 Sep 2017 11:49:01 +0200 Subject: [PATCH] Enhancement proposal for TimSort and ComparableTimSort Message-ID: <225231505468941@web59g.yandex.ru> Current implementations of TimSort and ComparableTimSort both have fast path for the case when the size of array = 1 i.e. such array is considered to be sorted. My proposal is to add similar fast path for the case when the size of the array = 2. In this case it's enough to check if the first item is greater than the second one and swap them. Otherwise array is considered to be sorted. I have attached the patch to this mail. As for performance I have measured array sort with size = 2 using JDK-provided and patched implementations of TimSort and ComparableTimSort both execution time and throughput in two environments: 1)? Intel Core i5-4690 3,50 GHz 2)? Intel Core i3-3220 3,30 GHz On both environments I have Java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) Measurement results are 1) Benchmark? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Mode? Cnt? Score? Error? Units SortingBenchmark.measureConventionalSort? avgt? 500? 17,692 ? 0,040? ns/op SortingBenchmark.measureEnhancedSort? ? ? avgt? 500? 13,206 ? 0,025? ns/op SortingBenchmark.measureConventionalSort? thrpt? 500? 56,962 ? 0,051? ops/us SortingBenchmark.measureEnhancedSort? ? ? thrpt? 500? 72,278 ? 0,724? ops/us 2) Benchmark Mode Cnt Score Error Units SortingBenchmark.measureConventionalSort avgt 500 26,173 ? 0,251 ns/op SortingBenchmark.measureEnhancedSort avgt 500 18,191 ? 0,106 ns/op SortingBenchmark.measureConventionalSort thrpt 500 36,987 ? 0,437 ops/us SortingBenchmark.measureEnhancedSort thrpt 500 53,499 ? 0,456 ops/us So in both cases patched implementation demonstrates better throughput and execution time for the case array.lenght = 2. Regards, Sergei Tsypanov -------------- next part -------------- A non-text attachment was scrubbed... Name: patch.txt Type: text/x-diff Size: 1817 bytes Desc: not available URL: From claes.redestad at oracle.com Fri Sep 15 10:08:39 2017 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 15 Sep 2017 12:08:39 +0200 Subject: [PATCH] Enhancement proposal for TimSort and ComparableTimSort In-Reply-To: <225231505468941@web59g.yandex.ru> References: <225231505468941@web59g.yandex.ru> Message-ID: <003f4295-8de2-7616-c964-34cffe31450b@oracle.com> Hi, looks reasonable, but when adding a fast-path branch like this it's just as important to show that we don't regress *other* cases, e.g., benchmark using input data of randomized lengths, both on sets which include and don't include 1- and 2-element arrays. /Claes On 2017-09-15 11:49, ?????? ??????? wrote: > Current implementations of TimSort and ComparableTimSort both have fast path for the case when the size of array = 1 i.e. such array is considered to be sorted. > > My proposal is to add similar fast path for the case when the size of the array = 2. In this case it's enough to check if the first item is greater than the second one and swap them. > Otherwise array is considered to be sorted. > > I have attached the patch to this mail. > > As for performance I have measured array sort with size = 2 using JDK-provided and patched implementations of TimSort and ComparableTimSort both execution time and throughput in two environments: > > 1) Intel Core i5-4690 3,50 GHz > 2) Intel Core i3-3220 3,30 GHz > > On both environments I have Java version "1.8.0_144" > Java(TM) SE Runtime Environment (build 1.8.0_144-b01) > Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) > > Measurement results are > > 1) > > Benchmark Mode Cnt Score Error Units > > SortingBenchmark.measureConventionalSort avgt 500 17,692 ? 0,040 ns/op > SortingBenchmark.measureEnhancedSort avgt 500 13,206 ? 0,025 ns/op > > SortingBenchmark.measureConventionalSort thrpt 500 56,962 ? 0,051 ops/us > SortingBenchmark.measureEnhancedSort thrpt 500 72,278 ? 0,724 ops/us > > 2) > > Benchmark Mode Cnt Score Error Units > > SortingBenchmark.measureConventionalSort avgt 500 26,173 ? 0,251 ns/op > SortingBenchmark.measureEnhancedSort avgt 500 18,191 ? 0,106 ns/op > > SortingBenchmark.measureConventionalSort thrpt 500 36,987 ? 0,437 ops/us > SortingBenchmark.measureEnhancedSort thrpt 500 53,499 ? 0,456 ops/us > > So in both cases patched implementation demonstrates better throughput and execution time for the case array.lenght = 2. > > Regards, > Sergei Tsypanov From Alan.Bateman at oracle.com Fri Sep 15 10:17:25 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 15 Sep 2017 11:17:25 +0100 Subject: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java In-Reply-To: <9ae20280-0f27-1edb-4969-e7c9b40977e1@oracle.com> References: <9ae20280-0f27-1edb-4969-e7c9b40977e1@oracle.com> Message-ID: <1aa2e842-79b3-77a6-c4ab-dbab94ef870f@oracle.com> On 15/09/2017 02:47, David Holmes wrote: > Hi Adam, > > I am still very much torn over this one. I think the idea of > print-and-exit flags for a potentially hosted library like the JVM is > just wrong - we should never have done that, but we did. Fixing that > by moving the flags to the launcher is far from trivial**. Endorsing > and encouraging these sorts of flag by adding JNI support seems to be > sending the wrong message. > > ** I can envisage a "help xxx" Dcmd that can read back the info from > the VM. The launcher can send the Dcmd, print the output and exit. The > launcher would not need to know what the xxx values mean, but would > have to intercept the existing ones. > > Another option is just to be aware of these flags (are there more than > jdwp and Xlog?) and deal with them specially in your custom launcher - > either filter them out and ignore them, or else launch the VM in its > own process to respond to them. > > Any changes to the JNI specification need to go through the CSR process. Yes, it would require an update to the JNI spec, also a change to the JVM TI spec where Agent_OnLoad returning a non-0 value is specified to terminates the VM. The name and value needs discussion too, esp. as the JNI spec uses negative values for failure. In any case, I'm also torn over this one as it's a corner case that is only interesting for custom launchers that load agents with options that print usage messages. It wouldn't be hard to have the Agent_OnLoad specify a printf hook that the agent could use for output although there are complications with agents such as JDWP that also announce their transport end point. Beyond that there is still the issue of the custom launcher that would need to know to destroy the VM without reporting an error. So what happened to the more meaty part to this which is fixing the various cases in HotSpot that terminate the process during initialization? I would expect some progress could be made on those cases while trying to decide whether to rev the JNI and JVM TI specs to cover the help case. -Alan From Alan.Bateman at oracle.com Fri Sep 15 10:37:22 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 15 Sep 2017 11:37:22 +0100 Subject: MR JarFile was: Scanning multi version jars? In-Reply-To: References: Message-ID: On 15/09/2017 05:43, Greg Wilkins wrote: > > : > > The issue I have are that sometimes the class is trying to hide the MR > aspects, yet other times it is not.? ?Specifically when iterating it > returns JarEntry instances that ignore versions and always return the > content to which they refer, yet if you obtain a JarEntry from the > getJarEntry API, it behaves differently and may return the versioned > content even if it has the un-versioned path. The entries and stream methods have been discussed here several times. The conclusion was that they would continue to enumerate or return a stream over all entries in the JAR file.? A new versionedStream() method was proposed and I agree is needed, it just didn't make it into Java SE 9. Now might be the time to put it back on the table. -Alan From david.holmes at oracle.com Fri Sep 15 11:03:32 2017 From: david.holmes at oracle.com (David Holmes) Date: Fri, 15 Sep 2017 21:03:32 +1000 Subject: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java In-Reply-To: <1aa2e842-79b3-77a6-c4ab-dbab94ef870f@oracle.com> References: <9ae20280-0f27-1edb-4969-e7c9b40977e1@oracle.com> <1aa2e842-79b3-77a6-c4ab-dbab94ef870f@oracle.com> Message-ID: On 15/09/2017 8:17 PM, Alan Bateman wrote: > On 15/09/2017 02:47, David Holmes wrote: >> Hi Adam, >> >> I am still very much torn over this one. I think the idea of >> print-and-exit flags for a potentially hosted library like the JVM is >> just wrong - we should never have done that, but we did. Fixing that >> by moving the flags to the launcher is far from trivial**. Endorsing >> and encouraging these sorts of flag by adding JNI support seems to be >> sending the wrong message. >> >> ** I can envisage a "help xxx" Dcmd that can read back the info from >> the VM. The launcher can send the Dcmd, print the output and exit. The >> launcher would not need to know what the xxx values mean, but would >> have to intercept the existing ones. >> >> Another option is just to be aware of these flags (are there more than >> jdwp and Xlog?) and deal with them specially in your custom launcher - >> either filter them out and ignore them, or else launch the VM in its >> own process to respond to them. >> >> Any changes to the JNI specification need to go through the CSR process. > Yes, it would require an update to the JNI spec, also a change to the > JVM TI spec where Agent_OnLoad returning a non-0 value is specified to > terminates the VM. The name and value needs discussion too, esp. as the > JNI spec uses negative values for failure. > > In any case, I'm also torn over this one as it's a corner case that is > only interesting for custom launchers that load agents with options that > print usage messages. It wouldn't be hard to have the Agent_OnLoad > specify a printf hook that the agent could use for output although there > are complications with agents such as JDWP that also announce their > transport end point. Beyond that there is still the issue of the custom > launcher that would need to know to destroy the VM without reporting an > error. > > So what happened to the more meaty part to this which is fixing the > various cases in HotSpot that terminate the process during > initialization? I would expect some progress could be made on those > cases while trying to decide whether to rev the JNI and JVM TI specs to > cover the help case. Trying to eliminate the vm_exit_during_initialization paths in hotspot is a huge undertaking IMHO. David > > -Alan From jaroslav.tulach at oracle.com Fri Sep 15 12:32:04 2017 From: jaroslav.tulach at oracle.com (Jaroslav Tulach) Date: Fri, 15 Sep 2017 14:32:04 +0200 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1595796.xe8q7Anfpj@pracovni> Message-ID: <2523912.QeZCepiec8@pracovni> Thanks for the review Mandy, Daniel. Now, that the consolidated JDK10 repository is available, I have updated my webrev to its structure. In addition to that I addressed your comments: On ?ter? 12. z??? 2017 11:19:45 CEST mandy chung wrote: > ./make/common/Modules.gmk > Nit: can you move jdk.internal.vm.compiler.management to keep the > list in alphabetical order Inserted at appropriate place. > 199 # Filter out Graal specific modules if Graal build is disabled > 200 > 201 ifeq ($(INCLUDE_GRAAL), false) > 202 MODULES_FILTER += jdk.internal.vm.compiler > 203 endif > > When will INCLUDE_GRAAL be set to false? I think > jdk.internal.vm.compiler.management should also be filtered if > jdk.internal.vm.compiler is disabled. That is probably true. Fixed. > > Is jdk.internal.vm.compiler and jdk.internal.vm.compiler.management > built for all platforms in JDK 10? If not, > jdk/src/java.management/share/classes/module-info.java may fail to > compile when jdk.internal.vm.compiler.management is not present. We > can consult with the build team when you find out what configuration > that jdk.internal.vm.compiler is not built. I haven't found configuration where jdk.internal.vm.compiler wouldn't be built. However I wasn't looking very extensively... > hotspot/src/jdk.internal.vm.compiler/share/classes/module-info.java 29 > requires transitive jdk.internal.vm.ci; > do you get any error without this requires transitive? > jdk.internal.vm.compiler.management already requires > jdk.internal.vm.ci. I would think this requires transitive is not > necessary. Looks like this change isn't necessary. I am not sure what was the problem before, when I introduced it. > Is HotSpotGraalCompiler::mbean method necessary? In GraalMBeans.java > > 53 public static Object findGraalRuntimeBean() { > 54 JVMCIRuntime r = JVMCI.getRuntime(); > 55 JVMCICompiler c = r.getCompiler(); > 56 if (c instanceof HotSpotGraalCompiler) { > 57 return ((HotSpotGraalCompiler) c).mbean(); > 58 } > 59 return null; > 60 } > > It seems that you can call HotspotGraalRuntime::mbean directly. I don't think I can. There is no way to get to HotspotGraalRuntime except asking the HotSpotGraalCompiler. The HotspotGraalRuntime isn't JVMCIRuntime... At least I think so, there is slightly too much runtimes and providers in the codebase for my taste. However that isn't something I can change as part of JDK-8182701 > As we > discussed offline, we agree that HotSpotRuntimeMBean should belong to > this new module but it requires some refactoring which may take some > amount of work. Such clean up will be followed up in a separate JBS issue. Right. > GraalMBeans.java: > > 77 @Override > 78 public Set mbeanInterfaceNames() { > 79 return Collections.singleton(name); > 80 } > > This is not correct. The return set should be a set of > MXBean interface names, as in Class.getName(), not a set > of MXBean ObjectName strings. I see. Thanks. On st?eda 13. z??? 2017 8:23:22 CEST mandy chung wrote: > On 9/13/17 2:28 AM, Daniel Fuchs wrote: > Good catch, Daniel. This should return empty set as mbeanInterfaces() > returns. mbeanInterfaceNames returns the class name of the mbean > interfaces. OK, returning empty set. The webrev #5 is available at http://cr.openjdk.java.net/~jtulach/8182701/webrev.05/ -jt From doug.simon at oracle.com Fri Sep 15 12:47:00 2017 From: doug.simon at oracle.com (Doug Simon) Date: Fri, 15 Sep 2017 14:47:00 +0200 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: <2523912.QeZCepiec8@pracovni> References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1595796.xe8q7Anfpj@pracovni> <2523912.QeZCepiec8@pracovni> Message-ID: > On 15 Sep 2017, at 14:32, Jaroslav Tulach wrote: > > Thanks for the review Mandy, Daniel. Now, that the consolidated JDK10 > repository is available, I have updated my webrev to its structure. In > addition to that I addressed your comments: > > On ?ter? 12. z??? 2017 11:19:45 CEST mandy chung wrote: >> ./make/common/Modules.gmk >> Nit: can you move jdk.internal.vm.compiler.management to keep the >> list in alphabetical order > > Inserted at appropriate place. > >> 199 # Filter out Graal specific modules if Graal build is disabled >> 200 >> 201 ifeq ($(INCLUDE_GRAAL), false) >> 202 MODULES_FILTER += jdk.internal.vm.compiler >> 203 endif >> >> When will INCLUDE_GRAAL be set to false? I think >> jdk.internal.vm.compiler.management should also be filtered if >> jdk.internal.vm.compiler is disabled. > > That is probably true. Fixed. > >> >> Is jdk.internal.vm.compiler and jdk.internal.vm.compiler.management >> built for all platforms in JDK 10? If not, >> jdk/src/java.management/share/classes/module-info.java may fail to >> compile when jdk.internal.vm.compiler.management is not present. We >> can consult with the build team when you find out what configuration >> that jdk.internal.vm.compiler is not built. > > I haven't found configuration where jdk.internal.vm.compiler wouldn't be built. > However I wasn't looking very extensively... > >> hotspot/src/jdk.internal.vm.compiler/share/classes/module-info.java 29 >> requires transitive jdk.internal.vm.ci; >> do you get any error without this requires transitive? >> jdk.internal.vm.compiler.management already requires >> jdk.internal.vm.ci. I would think this requires transitive is not >> necessary. > > Looks like this change isn't necessary. I am not sure what was the problem > before, when I introduced it. > >> Is HotSpotGraalCompiler::mbean method necessary? In GraalMBeans.java >> >> 53 public static Object findGraalRuntimeBean() { >> 54 JVMCIRuntime r = JVMCI.getRuntime(); >> 55 JVMCICompiler c = r.getCompiler(); >> 56 if (c instanceof HotSpotGraalCompiler) { >> 57 return ((HotSpotGraalCompiler) c).mbean(); >> 58 } >> 59 return null; >> 60 } >> >> It seems that you can call HotspotGraalRuntime::mbean directly. > > I don't think I can. There is no way to get to HotspotGraalRuntime except > asking the HotSpotGraalCompiler. The HotspotGraalRuntime isn't JVMCIRuntime... > At least I think so That is correct - you have to obtain a HotspotGraalRuntime from a HotSpotGraalCompiler. There can be other HotspotGraalRuntime instances (e.g., Truffle has it's own HotSpotGraalCompiler/HotSpotGraalRuntime). -Doug From peter.levart at gmail.com Fri Sep 15 14:32:36 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 15 Sep 2017 16:32:36 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: Hi, On 09/15/2017 07:12 AM, Kazunori Ogata wrote: > Hi Hans, > > Thank you for your comment > > Hans Boehm wrote on 2017/09/15 09:44:56: > >> Just to be clear, the semi-plausible failure scenario here is that a >> reader will see a non-null slots value, but then read an uninitialized >> value from the ClassDataSlot array. This could happen if the compiler or >> hardware correctly speculated (e.g. based on a previous program >> execution), the value of dataLayout, used that to first load a value > from >> the ClassDataSlot array, and only then confirmed that the dataLayout > value >> was correct. None of this is likely to happen today, but is potentially >> profitable, and allowed by the current memory model. I think the extra >> assumption here should at least be documented. > In this scenario, the load from the ClassDataSlot array is also a > speculated load, so it should be confirmed after the load from dataLayout > is confirmed, and the full fence should be detected during the > confirmation of the speculated load from the array slot. Otherwise, the > full fence won't work as expected, I think. Just a reminder that the final code in question is the following: 1196???? ClassDataSlot[] getClassDataLayout() throws InvalidClassException { 1197???????? // REMIND: synchronize instead of relying on fullFence()? 1198???????? ClassDataSlot[] slots = dataLayout; 1199???????? if (slots == null) { 1200???????????? slots = getClassDataLayout0(); 1201???????????? VarHandle.fullFence(); 1202???????????? dataLayout = slots; 1203???????? } 1204???????? return slots; 1205???? } Does speculative read of 'dataLayout' into local variable 'slots' mean that 'slots' can change? Isn't this disallowed in Java (as apposed to C++)? Regards, Peter From OGATAK at jp.ibm.com Fri Sep 15 15:11:57 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Sat, 16 Sep 2017 00:11:57 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: Hi Peter, My understanding is the case when dataLayout is speculatively loaded (and stored to the local variable slots) and then an element of ClassDataSlot array (say slots[0]) is also speculatively loaded. I think the full fence should take effect when the speculative load of slots[0] is confirmed. Please correct me if I misunderstood. Regards, Ogata Peter Levart wrote on 2017/09/15 23:32:36: > From: Peter Levart > To: Kazunori Ogata , Hans Boehm > Cc: core-libs-dev > Date: 2017/09/15 23:32 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi, > > On 09/15/2017 07:12 AM, Kazunori Ogata wrote: > > Hi Hans, > > > > Thank you for your comment > > > > Hans Boehm wrote on 2017/09/15 09:44:56: > > > >> Just to be clear, the semi-plausible failure scenario here is that a > >> reader will see a non-null slots value, but then read an uninitialized > >> value from the ClassDataSlot array. This could happen if the compiler or > >> hardware correctly speculated (e.g. based on a previous program > >> execution), the value of dataLayout, used that to first load a value > > from > >> the ClassDataSlot array, and only then confirmed that the dataLayout > > value > >> was correct. None of this is likely to happen today, but is potentially > >> profitable, and allowed by the current memory model. I think the extra > >> assumption here should at least be documented. > > In this scenario, the load from the ClassDataSlot array is also a > > speculated load, so it should be confirmed after the load from dataLayout > > is confirmed, and the full fence should be detected during the > > confirmation of the speculated load from the array slot. Otherwise, the > > full fence won't work as expected, I think. > > Just a reminder that the final code in question is the following: > > 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > 1197 // REMIND: synchronize instead of relying on fullFence()? > 1198 ClassDataSlot[] slots = dataLayout; > 1199 if (slots == null) { > 1200 slots = getClassDataLayout0(); > 1201 VarHandle.fullFence(); > 1202 dataLayout = slots; > 1203 } > 1204 return slots; > 1205 } > > Does speculative read of 'dataLayout' into local variable 'slots' mean > that 'slots' can change? Isn't this disallowed in Java (as apposed to C++)? > > Regards, Peter > From mandy.chung at oracle.com Fri Sep 15 17:53:45 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 15 Sep 2017 10:53:45 -0700 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <1595796.xe8q7Anfpj@pracovni> <2523912.QeZCepiec8@pracovni> Message-ID: <48a815cd-2943-d328-d955-f301d39d7b86@oracle.com> On 9/15/17 5:47 AM, Doug Simon wrote: >> I don't think I can. There is no way to get to HotspotGraalRuntime except >> asking the HotSpotGraalCompiler. The HotspotGraalRuntime isn't JVMCIRuntime... >> At least I think so > That is correct - you have to obtain a HotspotGraalRuntime from a HotSpotGraalCompiler. There can be other HotspotGraalRuntime instances (e.g., Truffle has it's own HotSpotGraalCompiler/HotSpotGraalRuntime). Ah... that explains why you need two mbean() methods in this version. > http://cr.openjdk.java.net/~jtulach/8182701/webrev.05/index.html Looks good. Mandy From hboehm at google.com Fri Sep 15 17:54:17 2017 From: hboehm at google.com (Hans Boehm) Date: Fri, 15 Sep 2017 10:54:17 -0700 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: On Fri, Sep 15, 2017 at 7:32 AM, Peter Levart wrote: > Hi, > > On 09/15/2017 07:12 AM, Kazunori Ogata wrote: > >> Hi Hans, >> >> Thank you for your comment >> >> Hans Boehm wrote on 2017/09/15 09:44:56: >> >> Just to be clear, the semi-plausible failure scenario here is that a >>> reader will see a non-null slots value, but then read an uninitialized >>> value from the ClassDataSlot array. This could happen if the compiler or >>> hardware correctly speculated (e.g. based on a previous program >>> execution), the value of dataLayout, used that to first load a value >>> >> from >> >>> the ClassDataSlot array, and only then confirmed that the dataLayout >>> >> value >> >>> was correct. None of this is likely to happen today, but is potentially >>> profitable, and allowed by the current memory model. I think the extra >>> assumption here should at least be documented. >>> >> In this scenario, the load from the ClassDataSlot array is also a >> speculated load, so it should be confirmed after the load from dataLayout >> is confirmed, and the full fence should be detected during the >> confirmation of the speculated load from the array slot. Otherwise, the >> full fence won't work as expected, I think. >> > > Disclaimer: I don't know this code well. But it still doesn't look technically correct to me after the change. > Just a reminder that the final code in question is the following: > > 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException > { > 1197 // REMIND: synchronize instead of relying on fullFence()? > 1198 ClassDataSlot[] slots = dataLayout; > 1199 if (slots == null) { > 1200 slots = getClassDataLayout0(); > 1201 VarHandle.fullFence(); > 1202 dataLayout = slots; > 1203 } > 1204 // return slots; // Assume this code is inlined and > slots[17] is accessed by the caller. // To get a self-contained example, we assume this line is really: 1204b tmp = slots[17]; > 1205 ... > Does speculative read of 'dataLayout' into local variable 'slots' mean > that 'slots' can change? Isn't this disallowed in Java (as apposed to C++)? > The problem occurs if this is transformed (by hardware or compiler) to 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException { 1197 // REMIND: synchronize instead of relying on fullFence()? 1198 ClassDataSlot[] slots = DATA_LAYOUT_GUESS; 1199 if (slots == null) { if (dataLayout != DATA_LAYOUT_GUESS) 1200 slots = getClassDataLayout0(); 1201 VarHandle.fullFence(); 1202 dataLayout = slots; 1203 } 1204b tmp = slots[17]; 1204.5 if (dataLayout != DATA_LAYOUT_GUESS) 1205 ... (This is only an illustration. If the problem were to occur in real life, it would probably occur as a result of a different optimization. DEC Alpha allowed this sort of thing for entirely different reasons.) Observe that (1) This transformation is allowed by the Java memory model, since dataLayout is not a final field. (2) This code breaks if another thread runs all of the initialization code, including the code that sets slots[17] and the code that sets dataLayout, between 1204b and 1204.5, but the check in 1204.5 still succeeds (because we guessed well). tmp will contain the pre-initialization value of slots[17]. The fence is not executed by the reading thread, and has no impact on ordering within the reading thread. C++ fences have no effect unless they are paired with another fence or ordered atomic operation in the other thread involved in the communication. I think that is the current intent for Java as well. (At the hardware level, that's not entirely true, because dependency-based ordering can sometimes be used instead. But the only place in which we've been more or less successful in translating those guarantees to the PL level is for Java final fields. And those aren't used here.) Hans > Regards, Peter > > From gregw at webtide.com Fri Sep 15 21:58:36 2017 From: gregw at webtide.com (Greg Wilkins) Date: Sat, 16 Sep 2017 07:58:36 +1000 Subject: Scanning multi version jars? In-Reply-To: <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> Message-ID: Alan, I had a quick look at `jdk.internal.util.jar.VersionedStream` and have the following comments: - The style of the API is fine - pass in a JarFile and get a Stream. - It might be better to have a Stream which includes a method to query the actual version of each entry. - I think the stream needs to handle inner classes and only include them if their matching outerclass is available at the same version. So for example a base Foo$Bar.class will only be included if the stream includes a base Foo.class, and it will not be included if the Foo.class is version 9 or above. Likewise a version 9 Foo$Bar.class will only be included in the stream if the stream also includes a version 9 Foo.class, and will not be included if the stream has a version 10 or above Foo.class If you think this last point is possible, then I'll move the discussion back the EE expert groups to try to get an agreement on the exact stream code that will be used in the mid term until it is available in the JRE lib, at which time the specs should be amended to say they will defer the decision of which classes to scan the JRE lib so they will be future proof for any changes in java 10, 11 etc. cheers On 15 September 2017 at 17:27, Alan Bateman wrote: > > > On 15/09/2017 03:09, Greg Wilkins wrote: > >> >> Alan, >> >> thanks for correcting me on the API of JarFile - I can see it kind of >> works, but in a very bizarre way (it gives different content for entries >> obtained via the enumerator vs the getJarEntry API, even though both >> entries report the same name). But I'll discuss that elsewhere. >> > This is something that was discussed on core-libs-dev on a number of > occasions. The summary is that JarFile needs a new API for this, > versionedStream() was suggested, but it was kicked down the road for later > in order deal with the fallout from adding MR JARs. > > Since you have access to the code then look at > jdk.internal.util.jar.VersionedStream for an example code of what I think > you are looking for. > > -Alan > -- Greg Wilkins CTO http://webtide.com From stephen.felts at oracle.com Sat Sep 16 00:29:03 2017 From: stephen.felts at oracle.com (Stephen Felts) Date: Sat, 16 Sep 2017 00:29:03 +0000 (UTC) Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> Message-ID: <6e97133d-fa73-4098-bc93-8c1126debff2@default> FWIW I tracked down the MR jar file that I was having trouble with. It's the stand-alone JAXWS jar file com.sun.xml.ws.jaxws-rt.jar. Focusing on the problem class, the jar contains com/sun/xml/ws/util/xml/XmlCatalogUtil$1.class com/sun/xml/ws/util/xml/XmlCatalogUtil.class META-INF/versions/9/com/sun/xml/ws/util/xml/XmlCatalogUtil.class The inner class XmlCatalogUtil$1.class is not used by the JDK9 version of the outer class. Further, XmlCatalogUtil$1.class has class/method references that will not be resolved on JDK9. If the stream includes the inner class, it's possible that whatever is processing it will fail. In the use case that I had for processing jar files, we generated a collection of all class names in the jar file, and then removed class file names as Greg proposed. In the above example, com/sun/xml/ws/util/xml/XmlCatalogUtil$1.class and com/sun/xml/ws/util/xml/XmlCatalogUtil.class are removed. Processing of the class files can only proceed after we generate/modify the entire list for the jar. It ignores the possibility that a class outside the jar could be referencing something in the inner class that is public. -----Original Message----- From: Greg Wilkins [mailto:gregw at webtide.com] Sent: Friday, September 15, 2017 5:59 PM To: Alan Bateman Cc: jigsaw-dev ; core-libs-dev at openjdk.java.net Subject: Re: Scanning multi version jars? Alan, I had a quick look at `jdk.internal.util.jar.VersionedStream` and have the following comments: - The style of the API is fine - pass in a JarFile and get a Stream. - It might be better to have a Stream which includes a method to query the actual version of each entry. - I think the stream needs to handle inner classes and only include them if their matching outerclass is available at the same version. So for example a base Foo$Bar.class will only be included if the stream includes a base Foo.class, and it will not be included if the Foo.class is version 9 or above. Likewise a version 9 Foo$Bar.class will only be included in the stream if the stream also includes a version 9 Foo.class, and will not be included if the stream has a version 10 or above Foo.class If you think this last point is possible, then I'll move the discussion back the EE expert groups to try to get an agreement on the exact stream code that will be used in the mid term until it is available in the JRE lib, at which time the specs should be amended to say they will defer the decision of which classes to scan the JRE lib so they will be future proof for any changes in java 10, 11 etc. cheers On 15 September 2017 at 17:27, Alan Bateman wrote: > > > On 15/09/2017 03:09, Greg Wilkins wrote: > >> >> Alan, >> >> thanks for correcting me on the API of JarFile - I can see it kind of >> works, but in a very bizarre way (it gives different content for >> entries obtained via the enumerator vs the getJarEntry API, even >> though both entries report the same name). But I'll discuss that elsewhere. >> > This is something that was discussed on core-libs-dev on a number of > occasions. The summary is that JarFile needs a new API for this, > versionedStream() was suggested, but it was kicked down the road for > later in order deal with the fallout from adding MR JARs. > > Since you have access to the code then look at > jdk.internal.util.jar.VersionedStream for an example code of what I > think you are looking for. > > -Alan > -- Greg Wilkins CTO http://webtide.com From gregw at webtide.com Sat Sep 16 06:39:09 2017 From: gregw at webtide.com (Greg Wilkins) Date: Sat, 16 Sep 2017 16:39:09 +1000 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> Message-ID: Alen et al, here is a VersionedJarFile implementation that filters out inappropriate inner classes: https://gist.github.com/gregw/8f305e369d0b769e9c3fe791a0634b13 cheers On 16 September 2017 at 07:58, Greg Wilkins wrote: > > Alan, > > I had a quick look at `jdk.internal.util.jar.VersionedStream` and have > the following comments: > > - The style of the API is fine - pass in a JarFile and get a > Stream. > - It might be better to have a Stream which > includes a method to query the actual version of each entry. > - I think the stream needs to handle inner classes and only include > them if their matching outerclass is available at the same version. So for > example a base Foo$Bar.class will only be included if the stream includes a > base Foo.class, and it will not be included if the Foo.class is version 9 > or above. Likewise a version 9 Foo$Bar.class will only be included in the > stream if the stream also includes a version 9 Foo.class, and will not be > included if the stream has a version 10 or above Foo.class > > If you think this last point is possible, then I'll move the discussion > back the EE expert groups to try to get an agreement on the exact stream > code that will be used in the mid term until it is available in the JRE > lib, at which time the specs should be amended to say they will defer the > decision of which classes to scan the JRE lib so they will be future proof > for any changes in java 10, 11 etc. > > cheers > > > > > On 15 September 2017 at 17:27, Alan Bateman > wrote: > >> >> >> On 15/09/2017 03:09, Greg Wilkins wrote: >> >>> >>> Alan, >>> >>> thanks for correcting me on the API of JarFile - I can see it kind of >>> works, but in a very bizarre way (it gives different content for entries >>> obtained via the enumerator vs the getJarEntry API, even though both >>> entries report the same name). But I'll discuss that elsewhere. >>> >> This is something that was discussed on core-libs-dev on a number of >> occasions. The summary is that JarFile needs a new API for this, >> versionedStream() was suggested, but it was kicked down the road for later >> in order deal with the fallout from adding MR JARs. >> >> Since you have access to the code then look at >> jdk.internal.util.jar.VersionedStream for an example code of what I >> think you are looking for. >> >> -Alan >> > > > > -- > Greg Wilkins CTO http://webtide.com > -- Greg Wilkins CTO http://webtide.com From Alan.Bateman at oracle.com Sun Sep 17 19:27:47 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Sun, 17 Sep 2017 20:27:47 +0100 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> Message-ID: <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> On 15/09/2017 22:58, Greg Wilkins wrote: > : > > * I think the stream needs to handle inner classes and only include > them if their matching outerclass is available at the same > version.? So for example a base Foo$Bar.class will only be > included if the stream includes a base Foo.class, and it will not > be included if the Foo.class is version 9 or above.? Likewise a > version 9 Foo$Bar.class will only be included in the stream if the > stream also includes a version 9 Foo.class, and will not be > included if the stream has a version 10 or above Foo.class > > If you think this last point is possible, then I'll move the > discussion back the EE expert groups to try to get an agreement on the > exact stream code that will be used in the mid term until it is > available in the JRE lib, at which time the specs should be amended to > say they will defer the decision of which classes to scan the JRE lib > so they will be future proof for any changes in java 10, 11 etc. > I don't think this should be pushed down to the JarFile API. The JarFile API provides the base API for accessing JAR files and should not be concerned with the semantics or relationship between entries. I agree that annotation scanning tools and libraries need to do additional work to deal with orphaned or menacing inner classes in a MR JAR but it's not too different to arranging a class path with a JAR file containing the "classes for JDK 9" ahead of a JAR file containing the version of the library that runs on JDK 8. I do think that further checks could be done by the `jar` tool to identify issues at packaging time. -Alan From peter.levart at gmail.com Sun Sep 17 20:51:07 2017 From: peter.levart at gmail.com (Peter Levart) Date: Sun, 17 Sep 2017 22:51:07 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <9cee904a-aa3a-433f-0763-618bf385088d@redhat.com> <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: Hi, On 09/15/17 19:54, Hans Boehm wrote: > The problem occurs if this is transformed (by hardware or compiler) to > > 1196 ? ? ClassDataSlot[] getClassDataLayout() throws > InvalidClassException { > 1197 ? ? ? ? // REMIND: synchronize instead of relying on fullFence()? > ? ? ? ? ? ? ? ? ? > 1198 ? ? ? ? ClassDataSlot[] slots = DATA_LAYOUT_GUESS; > 1199 ? ? ? ? if (slots == null) { > ? ? ? ? ? ? ? ? ? ? ?if (dataLayout != DATA_LAYOUT_GUESS) > 1200 ? ? ? ? ? ? slots = getClassDataLayout0(); > 1201 ? ? ? ? ? ? VarHandle.fullFence(); > 1202 ? ? ? ? ? ? dataLayout = slots; > 1203 ? ? ? ? } > 1204b ? ? ? tmp = slots[17]; > 1204.5 ? ? ?if (dataLayout != DATA_LAYOUT_GUESS) > 1205 ? ? ... > > (This is only an illustration. If the problem were to occur in real > life, it would probably occur as a > result of a different optimization. DEC Alpha allowed this sort of > thing for entirely different reasons.) > > Observe that > > (1) This transformation is allowed by the Java memory model, since > dataLayout is not a final field. > (2) This code breaks if another thread runs all of the initialization > code, including the code that sets > slots[17] and the code that sets dataLayout, between 1204b and 1204.5, > but the check in > 1204.5 still succeeds (because we guessed well). tmp will contain the > pre-initialization value of slots[17]. > > The fence is not executed by the reading thread, and has no impact on > ordering within the reading thread. > > C++ fences have no effect unless they are paired with another fence or > ordered atomic operation in > the other thread involved in the communication. I think that is the > current intent for Java as well. Well, in that case, it's better to stick with final fields... @Ogata You said you implemented 4 variants: On 09/04/17 07:20, Kazunori Ogata wrote: > 1) Put VarHandle.fullFence() between initialization of ClassDataSlot[] and > writing the reference to non-volatile dataLayout. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/ > > 2) Use Unsafe.getObjectAcquire() and Unsafe.putObjectRelease() for > reading/writing dataLayout. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-unsafe/ > > 3) Put reference to ClassDataSlot[] into a final field of an object and > store the object to non-volatile dataLayout. Every invocation of > getDataLayout() reads the final field needs to deference the object > pointer. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final/ > > 4) Put reference to ClassDataSlot[] into a final field of an object, read > the final field immediately after the object creation, and store it to > non-volatile dataLayout. I think this is also correct based on the > semantics of final fields and data dependency. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ > > > The performance improvements were: > > 1) +3.5% > 2) +1.1% > 3) +2.2% > 4) +3.4% > The 1st and 4th are not correct as we have established. The 3rd is promising, but does not have the most speed improvement. Perhaps because of extra de-referencing. What if 'dataLayout' was not an array of ClassDataSlot records, each of them containing a reference to an ObjectStreamClass and a boolean, but an object containing two arrays: ??? static class ClassDataLayout { ??????? final ObjectStreamClass[] descs; ??????? final boolean[] hasDatas; ??? } Such object could be "unsafely" published. By eliminating the intermediate ClassDataSlot object, number of de-references should be kept down. Here's a prototype: http://cr.openjdk.java.net/~plevart/jdk10-dev/8187033_ObjectStreamClass.dataLayout/webrev.01/ Could you give it a try in your benchmark and compare it with your last approach (with fullFence)? Regards, Peter From gregw at webtide.com Mon Sep 18 00:30:55 2017 From: gregw at webtide.com (Greg Wilkins) Date: Mon, 18 Sep 2017 10:30:55 +1000 Subject: Scanning multi version jars? In-Reply-To: <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> Message-ID: Alan, I can sympathise somewhat with that point of view, however the counter point is that the semantics of MR jars is something that has come from a new feature released by the JVM that was perhaps a little under specified with regards to inner classes - probably because the JVM itself does not need to interpret that semantic when classloader and it is only an issue when scanning is involved. Now that the feature has been released and is being used, it is a bit of a tall ask to expect the disparate tool vendors, spec groups, container implementors and general developers to come up with a common semantic interpretation of MR jars that contain inner classes. Specially with the EE spec groups a bit pre-occupied with their move to eclipse. I think my own interpretation is common sense and I'm advocating it to be adopted by the servlet specification. But who is to say that the CDI groups might disagree and come up with another interpretation (it's not like the two groups can even decide on how to interpret @Resource the same way :) If core-libs were to signal their intention to provide an implementation of a particular semantic of inner classes in MR jars, then that would be a great unifying action that would guide the disparate groups to a common interpretation of the semantic that was missing from the original specification. regards On 18 September 2017 at 05:27, Alan Bateman wrote: > On 15/09/2017 22:58, Greg Wilkins wrote: > > : > > - I think the stream needs to handle inner classes and only include > them if their matching outerclass is available at the same version. So for > example a base Foo$Bar.class will only be included if the stream includes a > base Foo.class, and it will not be included if the Foo.class is version 9 > or above. Likewise a version 9 Foo$Bar.class will only be included in the > stream if the stream also includes a version 9 Foo.class, and will not be > included if the stream has a version 10 or above Foo.class > > If you think this last point is possible, then I'll move the discussion > back the EE expert groups to try to get an agreement on the exact stream > code that will be used in the mid term until it is available in the JRE > lib, at which time the specs should be amended to say they will defer the > decision of which classes to scan the JRE lib so they will be future proof > for any changes in java 10, 11 etc. > > I don't think this should be pushed down to the JarFile API. The JarFile > API provides the base API for accessing JAR files and should not be > concerned with the semantics or relationship between entries. I agree that > annotation scanning tools and libraries need to do additional work to deal > with orphaned or menacing inner classes in a MR JAR but it's not too > different to arranging a class path with a JAR file containing the "classes > for JDK 9" ahead of a JAR file containing the version of the library that > runs on JDK 8. I do think that further checks could be done by the `jar` > tool to identify issues at packaging time. > > -Alan > -- Greg Wilkins CTO http://webtide.com From OGATAK at jp.ibm.com Mon Sep 18 10:28:31 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Mon, 18 Sep 2017 19:28:31 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: Hi Hans and Peter, Thank you for your comments. Regarding the code Hans showed, I don't yet understand what it the problem. Since the load at 1204b is a speculative one, dereferencing slots[17] should not raise any exception. If the confirmation at 1204.5 succeeds, the value of tmp must also be correct because we put full fence and we see a non-NULL reference that was stored after the full fence. Also note that even the original code doesn't assume that a ClassDataSlot array is singleton for a given class. So even if another method modifies dataLayout between 1204b and 1204.5, the current thread can keep using the reference loaded earlier. If a thread reads a non-NULL reference, the ClassDataSlot[] entries reachable through the reference must be correct because we put full fence. @Peter, Thank you for the fix. I'll measure the performance. Regards, Ogata Peter Levart wrote on 2017/09/18 05:51:07: > From: Peter Levart > To: Hans Boehm > Cc: Kazunori Ogata , core-libs-dev dev at openjdk.java.net> > Date: 2017/09/18 05:51 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi, > On 09/15/17 19:54, Hans Boehm wrote: > The problem occurs if this is transformed (by hardware or compiler) to > > 1196 ClassDataSlot[] getClassDataLayout() throws InvalidClassException { > 1197 // REMIND: synchronize instead of relying on fullFence()? > > 1198 ClassDataSlot[] slots = DATA_LAYOUT_GUESS; > 1199 if (slots == null) { > if (dataLayout != DATA_LAYOUT_GUESS) > 1200 slots = getClassDataLayout0(); > 1201 VarHandle.fullFence(); > 1202 dataLayout = slots; > 1203 } > 1204b tmp = slots[17]; > 1204.5 if (dataLayout != DATA_LAYOUT_GUESS) > 1205 ... > > (This is only an illustration. If the problem were to occur in real life, > it would probably occur as a > result of a different optimization. DEC Alpha allowed this sort of thing > for entirely different reasons.) > > Observe that > > (1) This transformation is allowed by the Java memory model, since > dataLayout is not a final field. > (2) This code breaks if another thread runs all of the initialization > code, including the code that sets > slots[17] and the code that sets dataLayout, between 1204b and 1204.5, but > the check in > 1204.5 still succeeds (because we guessed well). tmp will contain the pre- > initialization value of slots[17]. > > The fence is not executed by the reading thread, and has no impact on > ordering within the reading thread. > > C++ fences have no effect unless they are paired with another fence or > ordered atomic operation in > the other thread involved in the communication. I think that is the > current intent for Java as well. > > Well, in that case, it's better to stick with final fields... > @Ogata > > You said you implemented 4 variants: > On 09/04/17 07:20, Kazunori Ogata wrote: > 1) Put VarHandle.fullFence() between initialization of ClassDataSlot[] and > writing the reference to non-volatile dataLayout. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/ > > 2) Use Unsafe.getObjectAcquire() and Unsafe.putObjectRelease() for > reading/writing dataLayout. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-unsafe/ > > 3) Put reference to ClassDataSlot[] into a final field of an object and > store the object to non-volatile dataLayout. Every invocation of > getDataLayout() reads the final field needs to deference the object > pointer. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final/ > > 4) Put reference to ClassDataSlot[] into a final field of an object, read > the final field immediately after the object creation, and store it to > non-volatile dataLayout. I think this is also correct based on the > semantics of final fields and data dependency. > Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ > > > The performance improvements were: > > 1) +3.5% > 2) +1.1% > 3) +2.2% > 4) +3.4% > > > The 1st and 4th are not correct as we have established. The 3rd is > promising, but does not have the most speed improvement. Perhaps because > of extra de-referencing. > > What if 'dataLayout' was not an array of ClassDataSlot records, each of > them containing a reference to an ObjectStreamClass and a boolean, but an > object containing two arrays: > > static class ClassDataLayout { > final ObjectStreamClass[] descs; > final boolean[] hasDatas; > } > > Such object could be "unsafely" published. By eliminating the intermediate > ClassDataSlot object, number of de-references should be kept down. > > Here's a prototype: > > http://cr.openjdk.java.net/~plevart/jdk10-dev/ > 8187033_ObjectStreamClass.dataLayout/webrev.01/ > > > Could you give it a try in your benchmark and compare it with your last > approach (with fullFence)? > > Regards, Peter From peter.levart at gmail.com Mon Sep 18 13:05:43 2017 From: peter.levart at gmail.com (Peter Levart) Date: Mon, 18 Sep 2017 15:05:43 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> Message-ID: <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Hi Ogata, On 09/18/2017 12:28 PM, Kazunori Ogata wrote: > Hi Hans and Peter, > > Thank you for your comments. > > Regarding the code Hans showed, I don't yet understand what it the > problem. Since the load at 1204b is a speculative one, dereferencing > slots[17] should not raise any exception. If the confirmation at 1204.5 > succeeds, the value of tmp must also be correct because we put full fence > and we see a non-NULL reference that was stored after the full fence. I don't know much, but I can imagine that speculative read may see the value and guess it correctly based on let's say some CPU state of half-processed write instruction in the pipeline, which is established even before the fence instruction flushes writes to array slots. So I can accept that such outcome is possible and doesn't violate JMM. > > Also note that even the original code doesn't assume that a ClassDataSlot > array is singleton for a given class. So even if another method modifies > dataLayout between 1204b and 1204.5, the current thread can keep using the > reference loaded earlier. If a thread reads a non-NULL reference, the > ClassDataSlot[] entries reachable through the reference must be correct > because we put full fence. It is not the problem of reading from different arrays since they are all equal in content. The problem is reading uninitialized array slots. > > > @Peter, > > Thank you for the fix. I'll measure the performance. ClassDataLayout object (instead of ClassDataSlot[] array) is also an opportunity to put into it some pre-computed cached state which is re-computed frequently in ObjectInputStream.readSerialData and maybe also ObjectOutputStream.writeSerialData. I'll show the variant which pre-computes the 'hasSpecialReadMethod' value which is always recomputed in ObjectInputStream.readSerialData if your benchmark shows this is a promising direction... Regards, Peter > > > Regards, > Ogata > > > Peter Levart wrote on 2017/09/18 05:51:07: > >> From: Peter Levart >> To: Hans Boehm >> Cc: Kazunori Ogata , core-libs-dev > dev at openjdk.java.net> >> Date: 2017/09/18 05:51 >> Subject: Re: RFR: 8187033: [PPC] Imporve performance of >> ObjectStreamClass.getClassDataLayout() >> >> Hi, >> On 09/15/17 19:54, Hans Boehm wrote: >> The problem occurs if this is transformed (by hardware or compiler) to >> >> 1196 ClassDataSlot[] getClassDataLayout() throws > InvalidClassException { >> 1197 // REMIND: synchronize instead of relying on fullFence()? >> >> 1198 ClassDataSlot[] slots = DATA_LAYOUT_GUESS; >> 1199 if (slots == null) { >> if (dataLayout != DATA_LAYOUT_GUESS) >> 1200 slots = getClassDataLayout0(); >> 1201 VarHandle.fullFence(); >> 1202 dataLayout = slots; >> 1203 } >> 1204b tmp = slots[17]; >> 1204.5 if (dataLayout != DATA_LAYOUT_GUESS) >> 1205 ... >> >> (This is only an illustration. If the problem were to occur in real > life, >> it would probably occur as a >> result of a different optimization. DEC Alpha allowed this sort of thing >> for entirely different reasons.) >> >> Observe that >> >> (1) This transformation is allowed by the Java memory model, since >> dataLayout is not a final field. >> (2) This code breaks if another thread runs all of the initialization >> code, including the code that sets >> slots[17] and the code that sets dataLayout, between 1204b and 1204.5, > but >> the check in >> 1204.5 still succeeds (because we guessed well). tmp will contain the > pre- >> initialization value of slots[17]. >> >> The fence is not executed by the reading thread, and has no impact on >> ordering within the reading thread. >> >> C++ fences have no effect unless they are paired with another fence or >> ordered atomic operation in >> the other thread involved in the communication. I think that is the >> current intent for Java as well. >> >> Well, in that case, it's better to stick with final fields... >> @Ogata >> >> You said you implemented 4 variants: >> On 09/04/17 07:20, Kazunori Ogata wrote: >> 1) Put VarHandle.fullFence() between initialization of ClassDataSlot[] > and >> writing the reference to non-volatile dataLayout. >> Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-fence/ >> >> 2) Use Unsafe.getObjectAcquire() and Unsafe.putObjectRelease() for >> reading/writing dataLayout. >> Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-unsafe/ >> >> 3) Put reference to ClassDataSlot[] into a final field of an object and >> store the object to non-volatile dataLayout. Every invocation of >> getDataLayout() reads the final field needs to deference the object >> pointer. >> Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final/ >> >> 4) Put reference to ClassDataSlot[] into a final field of an object, > read >> the final field immediately after the object creation, and store it to >> non-volatile dataLayout. I think this is also correct based on the >> semantics of final fields and data dependency. >> Webrev: http://cr.openjdk.java.net/~horii/8187033/webrev.01-final2/ >> >> >> The performance improvements were: >> >> 1) +3.5% >> 2) +1.1% >> 3) +2.2% >> 4) +3.4% >> >> The 1st and 4th are not correct as we have established. The 3rd is >> promising, but does not have the most speed improvement. Perhaps because >> of extra de-referencing. >> >> What if 'dataLayout' was not an array of ClassDataSlot records, each of >> them containing a reference to an ObjectStreamClass and a boolean, but > an >> object containing two arrays: >> >> static class ClassDataLayout { >> final ObjectStreamClass[] descs; >> final boolean[] hasDatas; >> } >> >> Such object could be "unsafely" published. By eliminating the > intermediate >> ClassDataSlot object, number of de-references should be kept down. >> >> Here's a prototype: >> >> http://cr.openjdk.java.net/~plevart/jdk10-dev/ >> 8187033_ObjectStreamClass.dataLayout/webrev.01/ >> >> >> Could you give it a try in your benchmark and compare it with your last >> approach (with fullFence)? >> >> Regards, Peter > From paul.sandoz at oracle.com Mon Sep 18 17:04:59 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 18 Sep 2017 10:04:59 -0700 Subject: Scanning multi version jars? In-Reply-To: <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> Message-ID: <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> I agree with Alan here, we should not be pushing a semantic understanding of inner classes into JarFile. I do sympathise with the case of annotation class scanning, which has always tunnelled through the class loader view to directly get at class file bytes possibly dealing with various URI schemes, since that is currently the only effective way of accessing the required information in an efficient manner. As Alan mentioned we should add a traversable versioned view of a JarFile, returning a Stream, from which it should be possible to filter according to certain semantics. Paul. > On 17 Sep 2017, at 12:27, Alan Bateman wrote: > > On 15/09/2017 22:58, Greg Wilkins wrote: >> : >> >> * I think the stream needs to handle inner classes and only include >> them if their matching outerclass is available at the same >> version. So for example a base Foo$Bar.class will only be >> included if the stream includes a base Foo.class, and it will not >> be included if the Foo.class is version 9 or above. Likewise a >> version 9 Foo$Bar.class will only be included in the stream if the >> stream also includes a version 9 Foo.class, and will not be >> included if the stream has a version 10 or above Foo.class >> >> If you think this last point is possible, then I'll move the discussion back the EE expert groups to try to get an agreement on the exact stream code that will be used in the mid term until it is available in the JRE lib, at which time the specs should be amended to say they will defer the decision of which classes to scan the JRE lib so they will be future proof for any changes in java 10, 11 etc. >> > I don't think this should be pushed down to the JarFile API. The JarFile API provides the base API for accessing JAR files and should not be concerned with the semantics or relationship between entries. I agree that annotation scanning tools and libraries need to do additional work to deal with orphaned or menacing inner classes in a MR JAR but it's not too different to arranging a class path with a JAR file containing the "classes for JDK 9" ahead of a JAR file containing the version of the library that runs on JDK 8. I do think that further checks could be done by the `jar` tool to identify issues at packaging time. > > -Alan From OGATAK at jp.ibm.com Mon Sep 18 17:52:13 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Tue, 19 Sep 2017 02:52:13 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> References: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: Hi Peter, Peter Levart wrote on 2017/09/18 22:05:43: > From: Peter Levart > To: Kazunori Ogata > Cc: Hans Boehm , core-libs-dev > Date: 2017/09/18 22:06 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi Ogata, > > On 09/18/2017 12:28 PM, Kazunori Ogata wrote: > > Hi Hans and Peter, > > > > Thank you for your comments. > > > > Regarding the code Hans showed, I don't yet understand what it the > > problem. Since the load at 1204b is a speculative one, dereferencing > > slots[17] should not raise any exception. If the confirmation at 1204.5 > > succeeds, the value of tmp must also be correct because we put full fence > > and we see a non-NULL reference that was stored after the full fence. > > I don't know much, but I can imagine that speculative read may see the > value and guess it correctly based on let's say some CPU state of > half-processed write instruction in the pipeline, which is established > even before the fence instruction flushes writes to array slots. So I > can accept that such outcome is possible and doesn't violate JMM. This seems to me that the processor/platform can't implement full fence correctly. I think it is the platform's (processor's and compiler's) responsibility to support full fence, otherwise the platform can't implement all Java API, including VarHandle.fullFence(). > > @Peter, > > > > Thank you for the fix. I'll measure the performance. > > ClassDataLayout object (instead of ClassDataSlot[] array) is also an > opportunity to put into it some pre-computed cached state which is > re-computed frequently in ObjectInputStream.readSerialData and maybe > also ObjectOutputStream.writeSerialData. > > I'll show the variant which pre-computes the 'hasSpecialReadMethod' > value which is always recomputed in ObjectInputStream.readSerialData if > your benchmark shows this is a promising direction... Do you mean caching the result of ObjectStreamClass.hasReadObjectMethod()? If so, can we cache it, though ObjectStreamClass.readObjectMethod is a mutable field? Regards, Ogata P.S. I'm waiting for finishing a long-running job on my machine. I'll measure your patch tomorrow. From Roger.Riggs at Oracle.com Mon Sep 18 19:28:34 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 18 Sep 2017 15:28:34 -0400 Subject: RFR 8187631 : Refactor FileDescriptor close implementation Message-ID: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> In anticipation of the re-opening (not yet) of the JDK 10 repo please review refactoring the handling of closing of files in FileInputStream, FileOutputStream, RandomAccessFile, and FileChannelImpl and related native code. The refactoring enables a future improvement to use the cleaner to close raw fds when the FileDescriptors becomes unreferenced. Webrev: ?? cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631/ Issue: ? https://bugs.openjdk.java.net/browse/JDK-8187631 Thanks, Roger From brian.burkhalter at oracle.com Mon Sep 18 20:46:55 2017 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Mon, 18 Sep 2017 13:46:55 -0700 Subject: RFR 8187631 : Refactor FileDescriptor close implementation In-Reply-To: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> References: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> Message-ID: Hi Roger, I think that this looks fine. Thanks, Brian On Sep 18, 2017, at 12:28 PM, Roger Riggs wrote: > Please review refactoring > the handling of closing of files in FileInputStream, FileOutputStream, RandomAccessFile, > and FileChannelImpl and related native code. > > The refactoring enables a future improvement to use the cleaner to close raw fds > when the FileDescriptors becomes unreferenced. From hboehm at google.com Mon Sep 18 20:47:12 2017 From: hboehm at google.com (Hans Boehm) Date: Mon, 18 Sep 2017 13:47:12 -0700 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: On Mon, Sep 18, 2017 at 10:52 AM, Kazunori Ogata wrote: > > Hi Peter, > > Peter Levart wrote on 2017/09/18 22:05:43: > > > On 09/18/2017 12:28 PM, Kazunori Ogata wrote: > > > Hi Hans and Peter, > > > > > > Thank you for your comments. > > > > > > Regarding the code Hans showed, I don't yet understand what it the > > > problem. Since the load at 1204b is a speculative one, dereferencing > > > slots[17] should not raise any exception. If the confirmation at > 1204.5 > > > succeeds, the value of tmp must also be correct because we put full > fence > > > and we see a non-NULL reference that was stored after the full fence. > > > > I don't know much, but I can imagine that speculative read may see the > > value and guess it correctly based on let's say some CPU state of > > half-processed write instruction in the pipeline, which is established > > even before the fence instruction flushes writes to array slots. So I > > can accept that such outcome is possible and doesn't violate JMM. > > This seems to me that the processor/platform can't implement full fence > correctly. I think it is the platform's (processor's and compiler's) > responsibility to support full fence, otherwise the platform can't > implement all Java API, including VarHandle.fullFence(). As Peter said, my concern is not with exceptions, but with seeing uninitialized data for slots[17]. The semantics of "full fences" are tricky, but basically they don't restrict reordering in other threads, only the thread that executed the fence. The thread with the problematic reordering here is the one that saw a non-null dataLayout value, and hence did not execute a fence. Hence fences generally have to be paired with either another fence in the other thread, or some other ordering mechanism. That other ordering mechanism is missing here, though many implementations will ensure correct ordering, due to hardware dependence-based ordering guarantees. But the JMM does not promise that. Hans From mandy.chung at oracle.com Mon Sep 18 21:44:16 2017 From: mandy.chung at oracle.com (mandy chung) Date: Mon, 18 Sep 2017 14:44:16 -0700 Subject: Review Request: JDK-8187449: jdeps fails when an upgradeable module is upgraded with an automatic module Message-ID: <3a3d7618-979f-0fcb-9520-be6f9e02d2c9@oracle.com> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8187449/webrev.00/ jdeps throws InternalError if a JDK module is not an explicit module.? This check should only apply to JDK modules loaded from the system image. This patch will relax the check for upgradeable modules that may be an automatic module.? For example, the following command should work. $ jdeps --upgrade-module-path javax.transaction-api-1.2.3-SNAPSHOT.jar -m java.transaction Mandy From gregw at webtide.com Tue Sep 19 00:18:43 2017 From: gregw at webtide.com (Greg Wilkins) Date: Tue, 19 Sep 2017 10:18:43 +1000 Subject: Scanning multi version jars? In-Reply-To: <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: Paul, yeh... I guess I concede it's not JarFiles job... as much as that would make things easier for containers to reach agreement:( However, can we at least look at having a new default method on JarEntry to query the version. Without that, containers don't have the information available to perform the semantic filtering required and thus will not be able to use the stream API and will have to work from an unversioned stream. regards On 19 September 2017 at 03:04, Paul Sandoz wrote: > I agree with Alan here, we should not be pushing a semantic understanding > of inner classes into JarFile. > > I do sympathise with the case of annotation class scanning, which has > always tunnelled through the class loader view to directly get at class > file bytes possibly dealing with various URI schemes, since that is > currently the only effective way of accessing the required information in > an efficient manner. > > As Alan mentioned we should add a traversable versioned view of a JarFile, > returning a Stream, from which it should be possible to filter according to > certain semantics. > > Paul. > > > > On 17 Sep 2017, at 12:27, Alan Bateman wrote: > > > > On 15/09/2017 22:58, Greg Wilkins wrote: > >> : > >> > >> * I think the stream needs to handle inner classes and only include > >> them if their matching outerclass is available at the same > >> version. So for example a base Foo$Bar.class will only be > >> included if the stream includes a base Foo.class, and it will not > >> be included if the Foo.class is version 9 or above. Likewise a > >> version 9 Foo$Bar.class will only be included in the stream if the > >> stream also includes a version 9 Foo.class, and will not be > >> included if the stream has a version 10 or above Foo.class > >> > >> If you think this last point is possible, then I'll move the discussion > back the EE expert groups to try to get an agreement on the exact stream > code that will be used in the mid term until it is available in the JRE > lib, at which time the specs should be amended to say they will defer the > decision of which classes to scan the JRE lib so they will be future proof > for any changes in java 10, 11 etc. > >> > > I don't think this should be pushed down to the JarFile API. The JarFile > API provides the base API for accessing JAR files and should not be > concerned with the semantics or relationship between entries. I agree that > annotation scanning tools and libraries need to do additional work to deal > with orphaned or menacing inner classes in a MR JAR but it's not too > different to arranging a class path with a JAR file containing the "classes > for JDK 9" ahead of a JAR file containing the version of the library that > runs on JDK 8. I do think that further checks could be done by the `jar` > tool to identify issues at packaging time. > > > > -Alan > > -- Greg Wilkins CTO http://webtide.com From stephen.felts at oracle.com Tue Sep 19 01:05:34 2017 From: stephen.felts at oracle.com (Stephen Felts) Date: Mon, 18 Sep 2017 18:05:34 -0700 (PDT) Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: A versioned file name, JarEntry.getName(), starts with "META-INF/versions/". The version is the following string up to the next "/". The version can be parsed with Runtime.Version.parse(). If not a versioned class file name, then use Jarfile.baseVersion(). That should be sufficient to get the version for any JarEntry. If it needs to run on pre-JDK9, this needs a lot of reflection. IMO Having a method that behaves as described below is likely to be needed for many use cases and it would be good if someone wrote it and put it in a well-known, public jar file. -----Original Message----- From: Greg Wilkins [mailto:gregw at webtide.com] Sent: Monday, September 18, 2017 8:19 PM To: Paul Sandoz Cc: jigsaw-dev ; core-libs-dev at openjdk.java.net Subject: Re: Scanning multi version jars? Paul, yeh... I guess I concede it's not JarFiles job... as much as that would make things easier for containers to reach agreement:( However, can we at least look at having a new default method on JarEntry to query the version. Without that, containers don't have the information available to perform the semantic filtering required and thus will not be able to use the stream API and will have to work from an unversioned stream. regards On 19 September 2017 at 03:04, Paul Sandoz wrote: > I agree with Alan here, we should not be pushing a semantic > understanding of inner classes into JarFile. > > I do sympathise with the case of annotation class scanning, which has > always tunnelled through the class loader view to directly get at > class file bytes possibly dealing with various URI schemes, since that > is currently the only effective way of accessing the required > information in an efficient manner. > > As Alan mentioned we should add a traversable versioned view of a > JarFile, returning a Stream, from which it should be possible to > filter according to certain semantics. > > Paul. > > > > On 17 Sep 2017, at 12:27, Alan Bateman wrote: > > > > On 15/09/2017 22:58, Greg Wilkins wrote: > >> : > >> > >> * I think the stream needs to handle inner classes and only include > >> them if their matching outerclass is available at the same > >> version. So for example a base Foo$Bar.class will only be > >> included if the stream includes a base Foo.class, and it will not > >> be included if the Foo.class is version 9 or above. Likewise a > >> version 9 Foo$Bar.class will only be included in the stream if the > >> stream also includes a version 9 Foo.class, and will not be > >> included if the stream has a version 10 or above Foo.class > >> > >> If you think this last point is possible, then I'll move the > >> discussion > back the EE expert groups to try to get an agreement on the exact > stream code that will be used in the mid term until it is available in > the JRE lib, at which time the specs should be amended to say they > will defer the decision of which classes to scan the JRE lib so they > will be future proof for any changes in java 10, 11 etc. > >> > > I don't think this should be pushed down to the JarFile API. The > > JarFile > API provides the base API for accessing JAR files and should not be > concerned with the semantics or relationship between entries. I agree > that annotation scanning tools and libraries need to do additional > work to deal with orphaned or menacing inner classes in a MR JAR but > it's not too different to arranging a class path with a JAR file > containing the "classes for JDK 9" ahead of a JAR file containing the > version of the library that runs on JDK 8. I do think that further > checks could be done by the `jar` tool to identify issues at packaging time. > > > > -Alan > > -- Greg Wilkins CTO http://webtide.com From gregw at webtide.com Tue Sep 19 01:32:48 2017 From: gregw at webtide.com (Greg Wilkins) Date: Tue, 19 Sep 2017 11:32:48 +1000 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: Stephen, It is not the case that the getName() always returns the path starting with "META-INF/versions/". Specifically, if the entry is obtained from getJarEntry() API (and not from the enumerator), then the name is that of the unversioned file, but the metadata and contents obtained using the jarEntry are for the versioned entry. For example the following code: JarFile jarFile = new JarFile(new File("/tmp/example.jar"), false, JarFile.OPEN_READ, Runtime.version()); JarEntry entry = jarFile.getJarEntry("org/example/OnlyIn9.class"); System.err.printf("%s -> %s%n",entry.getName(),IO.toString(jarFile.getInputStream(entry))); when run against a jar where the class files contain just the text of their full path produces the following output: org/example/OnlyIn9.class -> META-INF/versions/9/org/example/OnlyIn9.class There is nothing in the public API of the JarEntry so obtained that indicates that it the versioned entry, nor can I distinguish it from an entry obtained by iteration that may report the same name (if the entry was also in the base), although at least equals does return false. Moreover, the proposed stream API as represented by the current implementation of jdk.internal.util.jar.VersionedStream, applies some filtering based on the versioning and then converts it's enumerated JarEntry instances to opaquely versioned JarEntry instances by calling map(jf::getJarEntry),which thus hides the version information and makes any additional filtering based on version impossible by any users of that stream. regards On 19 September 2017 at 11:05, Stephen Felts wrote: > A versioned file name, JarEntry.getName(), starts with > "META-INF/versions/". > The version is the following string up to the next "/". > The version can be parsed with Runtime.Version.parse(). > If not a versioned class file name, then use Jarfile.baseVersion(). > That should be sufficient to get the version for any JarEntry. > > If it needs to run on pre-JDK9, this needs a lot of reflection. > > IMO Having a method that behaves as described below is likely to be needed > for many use cases and it would be good if someone wrote it and put it in a > well-known, public jar file. > > > > -----Original Message----- > From: Greg Wilkins [mailto:gregw at webtide.com] > Sent: Monday, September 18, 2017 8:19 PM > To: Paul Sandoz > Cc: jigsaw-dev ; > core-libs-dev at openjdk.java.net > Subject: Re: Scanning multi version jars? > > Paul, > > yeh... I guess I concede it's not JarFiles job... as much as that would > make things easier for containers to reach agreement:( > > However, can we at least look at having a new default method on JarEntry > to query the version. Without that, containers don't have the information > available to perform the semantic filtering required and thus will not be > able to use the stream API and will have to work from an unversioned stream. > > regards > > On 19 September 2017 at 03:04, Paul Sandoz wrote: > > > I agree with Alan here, we should not be pushing a semantic > > understanding of inner classes into JarFile. > > > > I do sympathise with the case of annotation class scanning, which has > > always tunnelled through the class loader view to directly get at > > class file bytes possibly dealing with various URI schemes, since that > > is currently the only effective way of accessing the required > > information in an efficient manner. > > > > As Alan mentioned we should add a traversable versioned view of a > > JarFile, returning a Stream, from which it should be possible to > > filter according to certain semantics. > > > > Paul. > > > > > > > On 17 Sep 2017, at 12:27, Alan Bateman > wrote: > > > > > > On 15/09/2017 22:58, Greg Wilkins wrote: > > >> : > > >> > > >> * I think the stream needs to handle inner classes and only include > > >> them if their matching outerclass is available at the same > > >> version. So for example a base Foo$Bar.class will only be > > >> included if the stream includes a base Foo.class, and it will not > > >> be included if the Foo.class is version 9 or above. Likewise a > > >> version 9 Foo$Bar.class will only be included in the stream if the > > >> stream also includes a version 9 Foo.class, and will not be > > >> included if the stream has a version 10 or above Foo.class > > >> > > >> If you think this last point is possible, then I'll move the > > >> discussion > > back the EE expert groups to try to get an agreement on the exact > > stream code that will be used in the mid term until it is available in > > the JRE lib, at which time the specs should be amended to say they > > will defer the decision of which classes to scan the JRE lib so they > > will be future proof for any changes in java 10, 11 etc. > > >> > > > I don't think this should be pushed down to the JarFile API. The > > > JarFile > > API provides the base API for accessing JAR files and should not be > > concerned with the semantics or relationship between entries. I agree > > that annotation scanning tools and libraries need to do additional > > work to deal with orphaned or menacing inner classes in a MR JAR but > > it's not too different to arranging a class path with a JAR file > > containing the "classes for JDK 9" ahead of a JAR file containing the > > version of the library that runs on JDK 8. I do think that further > > checks could be done by the `jar` tool to identify issues at packaging > time. > > > > > > -Alan > > > > > > > -- > Greg Wilkins CTO http://webtide.com > -- Greg Wilkins CTO http://webtide.com From stephen.felts at oracle.com Tue Sep 19 03:41:19 2017 From: stephen.felts at oracle.com (Stephen Felts) Date: Mon, 18 Sep 2017 20:41:19 -0700 (PDT) Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: Thanks for the clarification ? I overstated the ?any JarEntry?. I didn?t look at VersionedStream so I now understand the limitations you mention. ? In my case, it?s necessary to look at all files in the jar file to do the elimination of unneeded ordinary/inner classes so JarInputStream getNextJarEntry() can be used. By using the versioned JarFile constructor, getting the JarEntry returns the right one for processing.? If I needed further filtering on the file names, I?d need to return the real file names. ? Maybe the use case isn?t so universal or well defined. ? ?????????????????????????????????????????????????????????????????????????????????????????????????????????????? ? From: Greg Wilkins [mailto:gregw at webtide.com] Sent: Monday, September 18, 2017 9:33 PM To: Stephen Felts Cc: Paul Sandoz ; jigsaw-dev ; core-libs-dev at openjdk.java.net Subject: Re: Scanning multi version jars? ? Stephen, ? It is not the case that the getName() always returns the path starting with "META-INF/versions/". Specifically, if the entry is obtained from getJarEntry() API (and not from the enumerator), then the name is that of the unversioned file, but the metadata and contents obtained using the jarEntry are for the versioned entry. ? For example the following code: ? JarFile jarFile = new JarFile(new File("/tmp/example.jar"), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? JarFile.OPEN_READ, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Runtime.version()); JarEntry entry = jarFile.getJarEntry("org/example/OnlyIn9.class"); System.err.printf("%s -> %s%n",entry.getName(),IO.toString(jarFile.getInputStream(entry))); when run against a jar where the class files contain just the text of their full path produces the following output: ? org/example/OnlyIn9.class -> META-INF/versions/9/org/example/OnlyIn9.class ? There is nothing in the public API of the JarEntry so obtained that indicates that it the versioned entry, nor can I distinguish it from an entry obtained by iteration that may report the same name (if the entry was also in the base), although at least equals does return false. ? Moreover, the proposed stream API as represented by the current implementation of jdk.internal.util.jar.VersionedStream, applies some filtering based on the versioning and then converts it's enumerated JarEntry instances to opaquely versioned JarEntry instances by calling map(jf::getJarEntry),which thus hides the version information and makes any additional filtering based on version impossible by any users of that stream. ? regards ? ? On 19 September 2017 at 11:05, Stephen Felts wrote: A versioned file name, JarEntry.getName(), starts with "META-INF/versions/". The version is the following string up to the next "/". The version can be parsed with Runtime.Version.parse(). If not a versioned class file name, then use Jarfile.baseVersion(). That should be sufficient to get the version for any JarEntry. If it needs to run on pre-JDK9, this needs a lot of reflection. IMO Having a method that behaves as described below is likely to be needed for many use cases and it would be good if someone wrote it and put it in a well-known, public jar file. -----Original Message----- From: Greg Wilkins [mailto:HYPERLINK "mailto:gregw at webtide.com"gregw at webtide.com] Sent: Monday, September 18, 2017 8:19 PM To: Paul Sandoz Cc: jigsaw-dev ; HYPERLINK "mailto:core-libs-dev at openjdk.java.net"core-libs-dev at openjdk.java.net Subject: Re: Scanning multi version jars? Paul, yeh... I guess I concede it's not JarFiles job... as much as that would make things easier for containers to reach agreement:( However, can we at least look at having a new default method on JarEntry to query the version. Without that, containers don't have the information available to perform the semantic filtering required and thus will not be able to use the stream API and will have to work from an unversioned stream. regards On 19 September 2017 at 03:04, Paul Sandoz wrote: > I agree with Alan here, we should not be pushing a semantic > understanding of inner classes into JarFile. > > I do sympathise with the case of annotation class scanning, which has > always tunnelled through the class loader view to directly get at > class file bytes possibly dealing with various URI schemes, since that > is currently the only effective way of accessing the required > information in an efficient manner. > > As Alan mentioned we should add a traversable versioned view of a > JarFile, returning a Stream, from which it should be possible to > filter according to certain semantics. > > Paul. > > > > On 17 Sep 2017, at 12:27, Alan Bateman wrote: > > > > On 15/09/2017 22:58, Greg Wilkins wrote: > >> : > >> > >>? * I think the stream needs to handle inner classes and only include > >>? ? them if their matching outerclass is available at the same > >>? ? version.? So for example a base Foo$Bar.class will only be > >>? ? included if the stream includes a base Foo.class, and it will not > >>? ? be included if the Foo.class is version 9 or above.? Likewise a > >>? ? version 9 Foo$Bar.class will only be included in the stream if the > >>? ? stream also includes a version 9 Foo.class, and will not be > >>? ? included if the stream has a version 10 or above Foo.class > >> > >> If you think this last point is possible, then I'll move the > >> discussion > back the EE expert groups to try to get an agreement on the exact > stream code that will be used in the mid term until it is available in > the JRE lib, at which time the specs should be amended to say they > will defer the decision of which classes to scan the JRE lib so they > will be future proof for any changes in java 10, 11 etc. > >> > > I don't think this should be pushed down to the JarFile API. The > > JarFile > API provides the base API for accessing JAR files and should not be > concerned with the semantics or relationship between entries. I agree > that annotation scanning tools and libraries need to do additional > work to deal with orphaned or menacing inner classes in a MR JAR but > it's not too different to arranging a class path with a JAR file > containing the "classes for JDK 9" ahead of a JAR file containing the > version of the library that runs on JDK 8. I do think that further > checks could be done by the `jar` tool to identify issues at packaging time. > > > > -Alan > > -- Greg Wilkins CTO http://webtide.com ? -- Greg Wilkins CTO http://webtide.com From gregw at webtide.com Tue Sep 19 04:37:37 2017 From: gregw at webtide.com (Greg Wilkins) Date: Tue, 19 Sep 2017 14:37:37 +1000 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: Stephen, I think the use-case can be pretty well defined. There should be an enumeration/iterator/stream available that provides the contents of a jar file as it would be seen/interpreted by the JVMs classloader. So if the classloader is doing any processing to handle versioned classes/resources, then we need an iterator that implements the exact same logic. Which raises an interesting point.... with the multi versioned jar I have used as an example, which contains: - org/example/Foo.class - org/example/Foo$Bar.class - META-INF/versions/9/org/example/Foo.class What does the classloader do when asked to load "org.example.Foo$Bar" ? If it loads it OK, then the JarFile enumerator/iterator/stream should also return it. If it throws a ClassNotFoundException, then the JarFile enumerator/iterator/stream should skip it. Currently the classloader will happily return a resource for a base inner class even if its outerclass does not refer to it, so that suggests that the iteration should also not process out the inappropriate inner classes. However I think it could be argued that the loader should not load it. Eitherway, there should be an iteration available that is entirely consistent with what the classloader does. regards On 19 September 2017 at 13:41, Stephen Felts wrote: > Thanks for the clarification ? I overstated the ?any JarEntry?. > > I didn?t look at VersionedStream so I now understand the limitations you > mention. > > > > In my case, it?s necessary to look at all files in the jar file to do the > elimination of unneeded ordinary/inner classes so JarInputStream getNextJarEntry() > can be used. > > By using the versioned JarFile constructor, getting the JarEntry returns > the right one for processing. If I needed further filtering on the file > names, I?d need to return the real file names. > > > > Maybe the use case isn?t so universal or well defined. > > > > > > > > > *From:* Greg Wilkins [mailto:gregw at webtide.com] > *Sent:* Monday, September 18, 2017 9:33 PM > *To:* Stephen Felts > *Cc:* Paul Sandoz ; jigsaw-dev < > jigsaw-dev at openjdk.java.net>; core-libs-dev at openjdk.java.net > > *Subject:* Re: Scanning multi version jars? > > > > Stephen, > > > > It is not the case that the getName() always returns the path starting > with "META-INF/versions/". Specifically, if the entry is obtained from > getJarEntry() API (and not from the enumerator), then the name is that of > the unversioned file, but the metadata and contents obtained using the > jarEntry are for the versioned entry. > > > > For example the following code: > > > > JarFile jarFile = new JarFile(new File("/tmp/example.jar"), > false, > JarFile.OPEN_READ, > Runtime.version()); > JarEntry entry = jarFile.getJarEntry("org/example/OnlyIn9.class"); > System.err.printf("%s -> %s%n",entry.getName(),IO.toString(jarFile. > getInputStream(entry))); > > when run against a jar where the class files contain just the text of > their full path produces the following output: > > > > org/example/OnlyIn9.class -> META-INF/versions/9/org/example/OnlyIn9.class > > > > There is nothing in the public API of the JarEntry so obtained that > indicates that it the versioned entry, nor can I distinguish it from an > entry obtained by iteration that may report the same name (if the entry was > also in the base), although at least equals does return false. > > > > Moreover, the proposed stream API as represented by the current > implementation of jdk.internal.util.jar.VersionedStream, applies some > filtering based on the versioning and then converts it's enumerated > JarEntry instances to opaquely versioned JarEntry instances by calling > map(jf::getJarEntry),which thus hides the version information and makes > any additional filtering based on version impossible by any users of that > stream. > > > > regards > > > > > > On 19 September 2017 at 11:05, Stephen Felts > wrote: > > A versioned file name, JarEntry.getName(), starts with > "META-INF/versions/". > The version is the following string up to the next "/". > The version can be parsed with Runtime.Version.parse(). > If not a versioned class file name, then use Jarfile.baseVersion(). > That should be sufficient to get the version for any JarEntry. > > If it needs to run on pre-JDK9, this needs a lot of reflection. > > IMO Having a method that behaves as described below is likely to be needed > for many use cases and it would be good if someone wrote it and put it in a > well-known, public jar file. > > > > -----Original Message----- > From: Greg Wilkins [mailto:gregw at webtide.com] > Sent: Monday, September 18, 2017 8:19 PM > To: Paul Sandoz > Cc: jigsaw-dev ; > core-libs-dev at openjdk.java.net > Subject: Re: Scanning multi version jars? > > Paul, > > yeh... I guess I concede it's not JarFiles job... as much as that would > make things easier for containers to reach agreement:( > > However, can we at least look at having a new default method on JarEntry > to query the version. Without that, containers don't have the information > available to perform the semantic filtering required and thus will not be > able to use the stream API and will have to work from an unversioned stream. > > regards > > On 19 September 2017 at 03:04, Paul Sandoz wrote: > > > I agree with Alan here, we should not be pushing a semantic > > understanding of inner classes into JarFile. > > > > I do sympathise with the case of annotation class scanning, which has > > always tunnelled through the class loader view to directly get at > > class file bytes possibly dealing with various URI schemes, since that > > is currently the only effective way of accessing the required > > information in an efficient manner. > > > > As Alan mentioned we should add a traversable versioned view of a > > JarFile, returning a Stream, from which it should be possible to > > filter according to certain semantics. > > > > Paul. > > > > > > > On 17 Sep 2017, at 12:27, Alan Bateman > wrote: > > > > > > On 15/09/2017 22:58, Greg Wilkins wrote: > > >> : > > >> > > >> * I think the stream needs to handle inner classes and only include > > >> them if their matching outerclass is available at the same > > >> version. So for example a base Foo$Bar.class will only be > > >> included if the stream includes a base Foo.class, and it will not > > >> be included if the Foo.class is version 9 or above. Likewise a > > >> version 9 Foo$Bar.class will only be included in the stream if the > > >> stream also includes a version 9 Foo.class, and will not be > > >> included if the stream has a version 10 or above Foo.class > > >> > > >> If you think this last point is possible, then I'll move the > > >> discussion > > back the EE expert groups to try to get an agreement on the exact > > stream code that will be used in the mid term until it is available in > > the JRE lib, at which time the specs should be amended to say they > > will defer the decision of which classes to scan the JRE lib so they > > will be future proof for any changes in java 10, 11 etc. > > >> > > > I don't think this should be pushed down to the JarFile API. The > > > JarFile > > API provides the base API for accessing JAR files and should not be > > concerned with the semantics or relationship between entries. I agree > > that annotation scanning tools and libraries need to do additional > > work to deal with orphaned or menacing inner classes in a MR JAR but > > it's not too different to arranging a class path with a JAR file > > containing the "classes for JDK 9" ahead of a JAR file containing the > > version of the library that runs on JDK 8. I do think that further > > checks could be done by the `jar` tool to identify issues at packaging > time. > > > > > > -Alan > > > > > > > -- > Greg Wilkins CTO http://webtide.com > > > > > > -- > > Greg Wilkins CTO http://webtide.com > -- Greg Wilkins CTO http://webtide.com From forax at univ-mlv.fr Tue Sep 19 07:15:22 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Tue, 19 Sep 2017 09:15:22 +0200 (CEST) Subject: Scanning multi version jars? In-Reply-To: References: <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: <484658822.1202607.1505805322702.JavaMail.zimbra@u-pem.fr> Hi Greg, the notion of inner classes do not exist at runtime (apart if you explicitly ask by reflection). The compiler desugar inner classes to several classes, so the compiler needs attributes (InnerClasses and EnclosingMethod) in the classfile to be able to reconstruct the java source file view of the world when it sees already compiled classes. But the VM/runtime doesn't need those attributes, the VM doesn't care about inner classes. There is a comment at the end of section 4.7.6 of the JVMS that explain that the VM does not check the InnerClasses attribute at runtime "Oracle's Java Virtual Machine implementation does not check the consistency of an InnerClasses attribute against a class file representing a class or interface referenced by the attribute." So to answer to your question, the classloader do not care about inner classes. Note that in a close future with the introduction of nestmates [1], it will be another story, but we have at least to wait 18.9 for that. R?mi [1] http://openjdk.java.net/jeps/181 ----- Mail original ----- > De: "Greg Wilkins" > ?: "Stephen Felts" > Cc: "jigsaw-dev" , "core-libs-dev" > Envoy?: Mardi 19 Septembre 2017 06:37:37 > Objet: Re: Scanning multi version jars? > Stephen, > > I think the use-case can be pretty well defined. > > There should be an enumeration/iterator/stream available that provides the > contents of a jar file as it would be seen/interpreted by the JVMs > classloader. So if the classloader is doing any processing to handle > versioned classes/resources, then we need an iterator that implements the > exact same logic. > > Which raises an interesting point.... with the multi versioned jar I have > used as an example, which contains: > > - org/example/Foo.class > - org/example/Foo$Bar.class > - META-INF/versions/9/org/example/Foo.class > > What does the classloader do when asked to load "org.example.Foo$Bar" ? > If it loads it OK, then the JarFile enumerator/iterator/stream should also > return it. If it throws a ClassNotFoundException, then the > JarFile enumerator/iterator/stream should skip it. > > Currently the classloader will happily return a resource for a base inner > class even if its outerclass does not refer to it, so that suggests that > the iteration should also not process out the inappropriate inner classes. > However I think it could be argued that the loader should not load it. > > Eitherway, there should be an iteration available that is entirely > consistent with what the classloader does. > > regards > > > > > On 19 September 2017 at 13:41, Stephen Felts > wrote: > >> Thanks for the clarification ? I overstated the ?any JarEntry?. >> >> I didn?t look at VersionedStream so I now understand the limitations you >> mention. >> >> >> >> In my case, it?s necessary to look at all files in the jar file to do the >> elimination of unneeded ordinary/inner classes so JarInputStream >> getNextJarEntry() >> can be used. >> >> By using the versioned JarFile constructor, getting the JarEntry returns >> the right one for processing. If I needed further filtering on the file >> names, I?d need to return the real file names. >> >> >> >> Maybe the use case isn?t so universal or well defined. >> >> >> >> >> >> >> >> >> *From:* Greg Wilkins [mailto:gregw at webtide.com] >> *Sent:* Monday, September 18, 2017 9:33 PM >> *To:* Stephen Felts >> *Cc:* Paul Sandoz ; jigsaw-dev < >> jigsaw-dev at openjdk.java.net>; core-libs-dev at openjdk.java.net >> >> *Subject:* Re: Scanning multi version jars? >> >> >> >> Stephen, >> >> >> >> It is not the case that the getName() always returns the path starting >> with "META-INF/versions/". Specifically, if the entry is obtained from >> getJarEntry() API (and not from the enumerator), then the name is that of >> the unversioned file, but the metadata and contents obtained using the >> jarEntry are for the versioned entry. >> >> >> >> For example the following code: >> >> >> >> JarFile jarFile = new JarFile(new File("/tmp/example.jar"), >> false, >> JarFile.OPEN_READ, >> Runtime.version()); >> JarEntry entry = jarFile.getJarEntry("org/example/OnlyIn9.class"); >> System.err.printf("%s -> %s%n",entry.getName(),IO.toString(jarFile. >> getInputStream(entry))); >> >> when run against a jar where the class files contain just the text of >> their full path produces the following output: >> >> >> >> org/example/OnlyIn9.class -> META-INF/versions/9/org/example/OnlyIn9.class >> >> >> >> There is nothing in the public API of the JarEntry so obtained that >> indicates that it the versioned entry, nor can I distinguish it from an >> entry obtained by iteration that may report the same name (if the entry was >> also in the base), although at least equals does return false. >> >> >> >> Moreover, the proposed stream API as represented by the current >> implementation of jdk.internal.util.jar.VersionedStream, applies some >> filtering based on the versioning and then converts it's enumerated >> JarEntry instances to opaquely versioned JarEntry instances by calling >> map(jf::getJarEntry),which thus hides the version information and makes >> any additional filtering based on version impossible by any users of that >> stream. >> >> >> >> regards >> >> >> >> >> >> On 19 September 2017 at 11:05, Stephen Felts >> wrote: >> >> A versioned file name, JarEntry.getName(), starts with >> "META-INF/versions/". >> The version is the following string up to the next "/". >> The version can be parsed with Runtime.Version.parse(). >> If not a versioned class file name, then use Jarfile.baseVersion(). >> That should be sufficient to get the version for any JarEntry. >> >> If it needs to run on pre-JDK9, this needs a lot of reflection. >> >> IMO Having a method that behaves as described below is likely to be needed >> for many use cases and it would be good if someone wrote it and put it in a >> well-known, public jar file. >> >> >> >> -----Original Message----- >> From: Greg Wilkins [mailto:gregw at webtide.com] >> Sent: Monday, September 18, 2017 8:19 PM >> To: Paul Sandoz >> Cc: jigsaw-dev ; >> core-libs-dev at openjdk.java.net >> Subject: Re: Scanning multi version jars? >> >> Paul, >> >> yeh... I guess I concede it's not JarFiles job... as much as that would >> make things easier for containers to reach agreement:( >> >> However, can we at least look at having a new default method on JarEntry >> to query the version. Without that, containers don't have the information >> available to perform the semantic filtering required and thus will not be >> able to use the stream API and will have to work from an unversioned stream. >> >> regards >> >> On 19 September 2017 at 03:04, Paul Sandoz wrote: >> >> > I agree with Alan here, we should not be pushing a semantic >> > understanding of inner classes into JarFile. >> > >> > I do sympathise with the case of annotation class scanning, which has >> > always tunnelled through the class loader view to directly get at >> > class file bytes possibly dealing with various URI schemes, since that >> > is currently the only effective way of accessing the required >> > information in an efficient manner. >> > >> > As Alan mentioned we should add a traversable versioned view of a >> > JarFile, returning a Stream, from which it should be possible to >> > filter according to certain semantics. >> > >> > Paul. >> > >> > >> > > On 17 Sep 2017, at 12:27, Alan Bateman >> wrote: >> > > >> > > On 15/09/2017 22:58, Greg Wilkins wrote: >> > >> : >> > >> >> > >> * I think the stream needs to handle inner classes and only include >> > >> them if their matching outerclass is available at the same >> > >> version. So for example a base Foo$Bar.class will only be >> > >> included if the stream includes a base Foo.class, and it will not >> > >> be included if the Foo.class is version 9 or above. Likewise a >> > >> version 9 Foo$Bar.class will only be included in the stream if the >> > >> stream also includes a version 9 Foo.class, and will not be >> > >> included if the stream has a version 10 or above Foo.class >> > >> >> > >> If you think this last point is possible, then I'll move the >> > >> discussion >> > back the EE expert groups to try to get an agreement on the exact >> > stream code that will be used in the mid term until it is available in >> > the JRE lib, at which time the specs should be amended to say they >> > will defer the decision of which classes to scan the JRE lib so they >> > will be future proof for any changes in java 10, 11 etc. >> > >> >> > > I don't think this should be pushed down to the JarFile API. The >> > > JarFile >> > API provides the base API for accessing JAR files and should not be >> > concerned with the semantics or relationship between entries. I agree >> > that annotation scanning tools and libraries need to do additional >> > work to deal with orphaned or menacing inner classes in a MR JAR but >> > it's not too different to arranging a class path with a JAR file >> > containing the "classes for JDK 9" ahead of a JAR file containing the >> > version of the library that runs on JDK 8. I do think that further >> > checks could be done by the `jar` tool to identify issues at packaging >> time. >> > > >> > > -Alan >> > >> > >> >> >> -- >> Greg Wilkins CTO http://webtide.com >> >> >> >> >> >> -- >> >> Greg Wilkins CTO http://webtide.com >> > > > > -- > Greg Wilkins CTO http://webtide.com From Alan.Bateman at oracle.com Tue Sep 19 07:34:18 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Sep 2017 08:34:18 +0100 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: On 19/09/2017 05:37, Greg Wilkins wrote: > : > > Which raises an interesting point.... with the multi versioned jar I have > used as an example, which contains: > > - org/example/Foo.class > - org/example/Foo$Bar.class > - META-INF/versions/9/org/example/Foo.class > > What does the classloader do when asked to load "org.example.Foo$Bar" ? > If it loads it OK, then the JarFile enumerator/iterator/stream should also > return it. If it throws a ClassNotFoundException, then the > JarFile enumerator/iterator/stream should skip it. A class loader that loads from a JAR file will just map "org.example.Foo$Bar" to entry "org/example/Foo$Bar.class" and attempt to define the class bytes to VM.? It shouldn't care if the entry comes from the base or a versioned section. It also shouldn't care if the class name looks like it might have been compiled from an inner class. The one case where a custom class loader does need to know more is when it loading resources (findResource/findResources implementation usually). For that case then the returned URL needs to locate the right resource and so may encode a path to a resource in a versioned section. You'll see URLClassLoader does the right thing, as does the built-in class loaders for cases where you have modular MR JARs on the module path. There were a few threads on core-libs-dev discussing whether to add a getRealName method but in the end it was kicked down the road to re-examine later. -Alan From Alan.Bateman at oracle.com Tue Sep 19 12:48:12 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 19 Sep 2017 13:48:12 +0100 Subject: RFR 8187631 : Refactor FileDescriptor close implementation In-Reply-To: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> References: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> Message-ID: <04b5346a-0860-1c25-4372-94e3b8d9fbec@oracle.com> On 18/09/2017 20:28, Roger Riggs wrote: > In anticipation of the re-opening (not yet) of the JDK 10 repo please > review refactoring > the handling of closing of files in FileInputStream, FileOutputStream, > RandomAccessFile, > and FileChannelImpl and related native code. > > The refactoring enables a future improvement to use the cleaner to > close raw fds > when the FileDescriptors becomes unreferenced. > > Webrev: > ?? cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631/ > > Issue: > ? https://bugs.openjdk.java.net/browse/JDK-8187631 This looks okay to me. One thing to clear up in JavaIOFileDescriptorAccess is the parameter names as it seems to use "obj" in some places, "fd" in others. -Alan From jaroslav.tulach at oracle.com Tue Sep 19 12:56:45 2017 From: jaroslav.tulach at oracle.com (Jaroslav Tulach) Date: Tue, 19 Sep 2017 14:56:45 +0200 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: <48a815cd-2943-d328-d955-f301d39d7b86@oracle.com> References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <48a815cd-2943-d328-d955-f301d39d7b86@oracle.com> Message-ID: <2954772.sIDvmWlhCn@pracovni> On p?tek 15. z??? 2017 10:53:45 CEST mandy chung wrote: > > http://cr.openjdk.java.net/~jtulach/8182701/webrev.05/index.html > > Looks good. Great. Unless there are further comments, then we can plan integration of my changes. Vladimir, are you "sponsor" of my change? Will you integrate it somewhere? This is my first change that has a chance to get into JDK, so I don't think I have push rights. But I am thrilled. -jt From adam.farley at uk.ibm.com Tue Sep 19 12:57:48 2017 From: adam.farley at uk.ibm.com (Adam Farley8) Date: Tue, 19 Sep 2017 13:57:48 +0100 Subject: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java In-Reply-To: References: <9ae20280-0f27-1edb-4969-e7c9b40977e1@oracle.com> <1aa2e842-79b3-77a6-c4ab-dbab94ef870f@oracle.com> Message-ID: Hi David, Alan, You are right in that the changes to HotSpot would be nontrivial. I see a number of places in (e.g.) arguments.cpp that seem to exit in the same manner as Xlog (such as -Xinternalversion). I would advise ploughing through the CSR process to alter the JNI spec, and simultaneously identify some key paths that can be raised as bugs. That way, when people have time to address these issues, the mechanism to handle a silent exit is already in place. The JDWP fix can be raised separately as one of these bugs, if it would make things simpler. As for the name, JNI_SILENT_EXIT is a placeholder, and can be readily changed. Do you have any suggestions? Lastly, in an ideal world, the VM initialisation should never exit(#). It should return a return code that tells the caller something, pass or fail, messy or tidy. That way, if someone is using the JNI as part of something bigger (like a database or a web server), one of these scenarios is just a bug, rather than a world-ender like exit(#). And now for the individual messages. :) David: Having help data returned by the launcher seems like a good way to avoid exit(0) calls, but I'm not sure how we'd prevent a JNI-caller using those options. Ultimately, to be sure, we'd have to remove the logic for those options, centralise the data to better enable launcher access, and add some logic in there so it can find any other help data (e.g. from the jdwp agent library). I feel this would be a bigger task than adding the new return code and changing the vm, plus it wouldn't provide for any non-help scenarios where the vm wants to shut down without error during initialisation. Alan: I should mention that the silent exit solution is already in use in the OpenJ9 VM. Not all of the exit paths have been resolved, but many have. The code is open and can be found here: https://github.com/eclipse/openj9 And though the silent exit code is disabled for the time being, it can be re-enabled by entering this class: runtime/vm/jvminit.c and altering line 2343 ( ctrl-f for exit(1) if it's not there). I won't paste the full code here in case people are concerned about contamination, but I would assert that this code (and the associated vm files) prove that the concept is possible. Note that that code should not be enabled until after we've integrated the code that can handle a silent exit. Best Regards Adam Farley P.S. Thank you both for your efforts on this. :) From: David Holmes To: Alan Bateman , Adam Farley8 , core-libs-dev at openjdk.java.net, hotspot-runtime-dev at openjdk.java.net, thomas.stuefe at gmail.com Date: 15/09/2017 12:03 Subject: Re: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java On 15/09/2017 8:17 PM, Alan Bateman wrote: > On 15/09/2017 02:47, David Holmes wrote: >> Hi Adam, >> >> I am still very much torn over this one. I think the idea of >> print-and-exit flags for a potentially hosted library like the JVM is >> just wrong - we should never have done that, but we did. Fixing that >> by moving the flags to the launcher is far from trivial**. Endorsing >> and encouraging these sorts of flag by adding JNI support seems to be >> sending the wrong message. >> >> ** I can envisage a "help xxx" Dcmd that can read back the info from >> the VM. The launcher can send the Dcmd, print the output and exit. The >> launcher would not need to know what the xxx values mean, but would >> have to intercept the existing ones. >> >> Another option is just to be aware of these flags (are there more than >> jdwp and Xlog?) and deal with them specially in your custom launcher - >> either filter them out and ignore them, or else launch the VM in its >> own process to respond to them. >> >> Any changes to the JNI specification need to go through the CSR process. > Yes, it would require an update to the JNI spec, also a change to the > JVM TI spec where Agent_OnLoad returning a non-0 value is specified to > terminates the VM. The name and value needs discussion too, esp. as the > JNI spec uses negative values for failure. > > In any case, I'm also torn over this one as it's a corner case that is > only interesting for custom launchers that load agents with options that > print usage messages. It wouldn't be hard to have the Agent_OnLoad > specify a printf hook that the agent could use for output although there > are complications with agents such as JDWP that also announce their > transport end point. Beyond that there is still the issue of the custom > launcher that would need to know to destroy the VM without reporting an > error. > > So what happened to the more meaty part to this which is fixing the > various cases in HotSpot that terminate the process during > initialization? I would expect some progress could be made on those > cases while trying to decide whether to rev the JNI and JVM TI specs to > cover the help case. Trying to eliminate the vm_exit_during_initialization paths in hotspot is a huge undertaking IMHO. David > > -Alan Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU From Roger.Riggs at Oracle.com Tue Sep 19 13:51:42 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 19 Sep 2017 09:51:42 -0400 Subject: RFR 8187631 : Refactor FileDescriptor close implementation In-Reply-To: <04b5346a-0860-1c25-4372-94e3b8d9fbec@oracle.com> References: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> <04b5346a-0860-1c25-4372-94e3b8d9fbec@oracle.com> Message-ID: <507afba2-2dcd-a466-0e33-23e5e903a9bb@Oracle.com> Hi Alan, The updated webrev is: http://cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631-02/ I avoided cluttering the initial webrev with misc cleanup. I renamed the parameters, corrected some old markup and reordered the declarations so a side-by side diff of the Unix and Windows FileDescriptor.java files makes it easy to see the necessary differences. (Perhaps a future cleanup can merge the two and manage all the other differences in the native code.) Thanks, Roger p.s. still not ready for final test and pushing til the repo re-opens On 9/19/2017 8:48 AM, Alan Bateman wrote: > > > On 18/09/2017 20:28, Roger Riggs wrote: >> In anticipation of the re-opening (not yet) of the JDK 10 repo please >> review refactoring >> the handling of closing of files in FileInputStream, >> FileOutputStream, RandomAccessFile, >> and FileChannelImpl and related native code. >> >> The refactoring enables a future improvement to use the cleaner to >> close raw fds >> when the FileDescriptors becomes unreferenced. >> >> Webrev: >> ?? cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631/ >> >> Issue: >> ? https://bugs.openjdk.java.net/browse/JDK-8187631 > This looks okay to me. > > One thing to clear up in JavaIOFileDescriptorAccess is the parameter > names as it seems to use "obj" in some places, "fd" in others. > > -Alan From brian.burkhalter at oracle.com Tue Sep 19 14:52:09 2017 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Tue, 19 Sep 2017 07:52:09 -0700 Subject: RFR 8187631 : Refactor FileDescriptor close implementation In-Reply-To: <507afba2-2dcd-a466-0e33-23e5e903a9bb@Oracle.com> References: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> <04b5346a-0860-1c25-4372-94e3b8d9fbec@oracle.com> <507afba2-2dcd-a466-0e33-23e5e903a9bb@Oracle.com> Message-ID: <1B642BD2-DE47-485F-A28F-C215AADC7C19@oracle.com> Hi Roger, On Sep 19, 2017, at 6:51 AM, Roger Riggs wrote: > The updated webrev is: > http://cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631-02/ > > I avoided cluttering the initial webrev with misc cleanup. This looks good. The name ?rawfd? is good. It could equally well be named ?nativefd? but that?s being picky. > I renamed the parameters, corrected some old markup and reordered > the declarations so a side-by side diff of the Unix and Windows FileDescriptor.java files > makes it easy to see the necessary differences. All good. > (Perhaps a future cleanup can merge the two and manage all the other differences in the native code.) This would be nice to accomplish. Thanks, Brian From paul.sandoz at oracle.com Tue Sep 19 16:54:22 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 19 Sep 2017 09:54:22 -0700 Subject: Review Request: JDK-8187449: jdeps fails when an upgradeable module is upgraded with an automatic module In-Reply-To: <3a3d7618-979f-0fcb-9520-be6f9e02d2c9@oracle.com> References: <3a3d7618-979f-0fcb-9520-be6f9e02d2c9@oracle.com> Message-ID: <37BEFF5E-CD3B-43F3-AF64-BB183556FA5E@oracle.com> > On 18 Sep 2017, at 14:44, mandy chung wrote: > > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8187449/webrev.00/ > JdepsConfiguration ? 288 // is this module from the system module path? 289 boolean isSystem = false; 290 if (system.find(mn).isPresent()) { 291 URI loc = system.find(mn).get().location().orElse(null); 292 isSystem = location.equals(loc); 293 } I believe you can use flatMap so we transform from one Optional domain to another e.g.: URI loc = system.find(mn).flatMap(::location).orElse(null); boolean isSystem = location.equals(loc); Or: boolean isSystem = system.find(mn).flatMap(::location).map(l -> l.equals(loc)).orElse(Boolean.FALSE); Up to you. Paul. > jdeps throws InternalError if a JDK module is not an explicit module. This check should only apply to JDK modules loaded from the system image. This patch will relax the check for upgradeable modules that may be an automatic module. For example, the following command should work. > > $ jdeps --upgrade-module-path javax.transaction-api-1.2.3-SNAPSHOT.jar -m java.transaction > > Mandy From Roger.Riggs at Oracle.com Tue Sep 19 18:01:03 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Tue, 19 Sep 2017 14:01:03 -0400 Subject: RFR 8187631 : Refactor FileDescriptor close implementation In-Reply-To: <1B642BD2-DE47-485F-A28F-C215AADC7C19@oracle.com> References: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> <04b5346a-0860-1c25-4372-94e3b8d9fbec@oracle.com> <507afba2-2dcd-a466-0e33-23e5e903a9bb@Oracle.com> <1B642BD2-DE47-485F-A28F-C215AADC7C19@oracle.com> Message-ID: Hi, I had a suggestion to use? fdo and fd parameter names and to fix copyright dates. ? http://cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631-02/ Thanks, Roger On 9/19/2017 10:52 AM, Brian Burkhalter wrote: > Hi Roger, > > On Sep 19, 2017, at 6:51 AM, Roger Riggs > wrote: > >> The updated webrev is: >> http://cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631-02/ >> >> I avoided cluttering the initial webrev with misc cleanup. > > This looks good. The name ?rawfd? is good. It could equally well be > named ?nativefd? but that?s being picky. > >> I renamed the parameters, corrected some old markup and >> reordered >> the declarations so a side-by side diff of the Unix and Windows >> FileDescriptor.java files >> makes it easy to see the necessary differences. > > All good. > From vladimir.kozlov at oracle.com Tue Sep 19 18:32:52 2017 From: vladimir.kozlov at oracle.com (Vladimir Kozlov) Date: Tue, 19 Sep 2017 11:32:52 -0700 Subject: [10] RFR(M) 8182701: Modify JVMCI to allow Graal Compiler to expose platform MBean In-Reply-To: <2954772.sIDvmWlhCn@pracovni> References: <73a34e68-19cf-e949-0057-a2e16cfca6da@oracle.com> <48a815cd-2943-d328-d955-f301d39d7b86@oracle.com> <2954772.sIDvmWlhCn@pracovni> Message-ID: Finally ;) On 9/19/17 5:56 AM, Jaroslav Tulach wrote: > On p?tek 15. z??? 2017 10:53:45 CEST mandy chung wrote: >> > http://cr.openjdk.java.net/~jtulach/8182701/webrev.05/index.html >> >> Looks good. > > Great. Unless there are further comments, then we can plan integration of my > changes. Vladimir, are you "sponsor" of my change? Will you integrate it > somewhere? Yes, I will integrate them when jdk10 repos are open again after consolidation. > > This is my first change that has a chance to get into JDK, so I don't think I > have push rights. But I am thrilled. Yes, you have to propose about 8 "significant" changes before becoming Committer and allowed to push: http://openjdk.java.net/projects/#project-committer Thanks, Vladimir > > -jt > From paul.sandoz at oracle.com Tue Sep 19 18:48:23 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 19 Sep 2017 11:48:23 -0700 Subject: 18.3 RFR 8187688 Additional tests for MethodHandle.invokeWithArguments Message-ID: <7EF356BB-74FC-43FF-AB09-BE656AA24D8A@oracle.com> Hi, Please review some additional tests testing edge case aspects of MethodHandle.invokeWithArguments: http://cr.openjdk.java.net/~psandoz/jdk10/JDK-8187688-invoke-with-arguments-test/webrev/ This and the feature (https://bugs.openjdk.java.net/browse/JDK-8185993 ) will be pushed once the repo opens up again. Thanks, Paul. From tom.w.hood at gmail.com Tue Sep 19 18:52:08 2017 From: tom.w.hood at gmail.com (Tom Hood) Date: Tue, 19 Sep 2017 11:52:08 -0700 Subject: StackOverflowError - Java 9 Build 181 Message-ID: Hi, I hit an infinite recursion loop probably related to PolicyFile that exists in Java 9 build 181 for windows 64-bit. It might be related to JDK-8077418 I haven't tracked down what is causing our webstart app to hit this problem yet, but I thought I would let you know sooner than later. Also, it probably is not a problem for our particular application as I should be able to set the security manager to null which I think/hope will bypass this issue. I will try today to reproduce it in our app so I can confirm if setting security manager to null will work for us. The stack looks like the following: (with many repeat stacks omitted) Exception in thread "AWT-EventQueue-2" java.lang.StackOverflowError at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/sun.security.provider.PolicyFile.getPermissions( PolicyFile.java:1135) at java.base/sun.security.provider.PolicyFile.getPermissions( PolicyFile.java:1082) at java.base/sun.security.provider.PolicyFile.implies(PolicyFile.java:1038) at java.base/java.security.provider.ProtectionDomain.implies( ProtectionDomain.java:323) at java.base/java.security.provider.ProtectionDomain.impliesWit hAltFilePerm(ProtectionDomain.java:355) at java.base/java.security.provider.AccessControlContext.checkP ermission(AccessControlContext.java:450) at java.base/java.security.provider.AccessController.checkPermi ssion(AccessController.java:895) at java.base/java.lang.SecurityManager.checkPermission(Security Manager.java:558) at jdk.javaws/com.sun.javaws.security.JavaWebStartSecurity.chec kPermission(JavaWebStartSecurity.java:237) at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:897) at java.base/java.io.File.isDirectory(File.java:845) at java.base/sun.net.www.ParseUtil.fileToEncodedURL(ParseUtil.java:299) at java.base/sun.security.provider.PolicyFile.canonicalizeCodeb ase(PolicyFile.java:1665) at java.base/sun.security.provider.PolicyFile.access$700( PolicyFile.java:263) at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1139) at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1136) **** and again **** at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/sun.security.provider.PolicyFile.getPermissions( PolicyFile.java:1135) at java.base/sun.security.provider.PolicyFile.getPermissions( PolicyFile.java:1082) at java.base/sun.security.provider.PolicyFile.implies(PolicyFile.java:1038) at java.base/java.security.provider.ProtectionDomain.implies( ProtectionDomain.java:323) at java.base/java.security.provider.ProtectionDomain.impliesWit hAltFilePerm(ProtectionDomain.java:355) at java.base/java.security.provider.AccessControlContext.checkP ermission(AccessControlContext.java:450) at java.base/java.security.provider.AccessController.checkPermi ssion(AccessController.java:895) at java.base/java.lang.SecurityManager.checkPermission(Security Manager.java:558) at jdk.javaws/com.sun.javaws.security.JavaWebStartSecurity.chec kPermission(JavaWebStartSecurity.java:237) at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:897) at java.base/java.io.File.isDirectory(File.java:845) at java.base/sun.net.www.ParseUtil.fileToEncodedURL(ParseUtil.java:299) at java.base/sun.security.provider.PolicyFile.canonicalizeCodeb ase(PolicyFile.java:1665) at java.base/sun.security.provider.PolicyFile.access$700( PolicyFile.java:263) at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1139) at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1136) **** above lines start the stack that repeats until overflow **** at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/sun.security.provider.PolicyFile.getPermissions( PolicyFile.java:1135) at java.base/sun.security.provider.PolicyFile.getPermissions( PolicyFile.java:1082) at java.base/sun.security.provider.PolicyFile.implies(PolicyFile.java:1038) -- Tom From tom.w.hood at gmail.com Tue Sep 19 18:53:37 2017 From: tom.w.hood at gmail.com (Tom Hood) Date: Tue, 19 Sep 2017 11:53:37 -0700 Subject: StackOverflowError - Java 9 Build 181 In-Reply-To: References: Message-ID: I should add that we have not modified or overridden any policy files. Also, we are not using a custom security manager. On Tue, Sep 19, 2017 at 11:52 AM, Tom Hood wrote: > Hi, > > I hit an infinite recursion loop probably related to PolicyFile that > exists in Java 9 build 181 for windows 64-bit. It might be related to > JDK-8077418 > > I haven't tracked down what is causing our webstart app to hit this > problem yet, but I thought I would let you know sooner than later. Also, > it probably is not a problem for our particular application as I should be > able to set the security manager to null which I think/hope will bypass > this issue. I will try today to reproduce it in our app so I can confirm > if setting security manager to null will work for us. > > The stack looks like the following: (with many repeat stacks omitted) > > Exception in thread "AWT-EventQueue-2" java.lang.StackOverflowError > at java.base/java.security.AccessController.doPrivileged(Native Method) > at java.base/sun.security.provider.PolicyFile.getPermissions(Po > licyFile.java:1135) > at java.base/sun.security.provider.PolicyFile.getPermissions(Po > licyFile.java:1082) > at java.base/sun.security.provider.PolicyFile.implies(PolicyFil > e.java:1038) > at java.base/java.security.provider.ProtectionDomain.implies(Pr > otectionDomain.java:323) > at java.base/java.security.provider.ProtectionDomain.impliesWit > hAltFilePerm(ProtectionDomain.java:355) > at java.base/java.security.provider.AccessControlContext.checkP > ermission(AccessControlContext.java:450) > at java.base/java.security.provider.AccessController.checkPermi > ssion(AccessController.java:895) > at java.base/java.lang.SecurityManager.checkPermission(Security > Manager.java:558) > at jdk.javaws/com.sun.javaws.security.JavaWebStartSecurity.chec > kPermission(JavaWebStartSecurity.java:237) > at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:897) > at java.base/java.io.File.isDirectory(File.java:845) > at java.base/sun.net.www.ParseUtil.fileToEncodedURL(ParseUtil.java:299) > at java.base/sun.security.provider.PolicyFile.canonicalizeCodeb > ase(PolicyFile.java:1665) > at java.base/sun.security.provider.PolicyFile.access$700(Policy > File.java:263) > at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1139) > at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1136) > **** and again **** > at java.base/java.security.AccessController.doPrivileged(Native Method) > at java.base/sun.security.provider.PolicyFile.getPermissions(Po > licyFile.java:1135) > at java.base/sun.security.provider.PolicyFile.getPermissions(Po > licyFile.java:1082) > at java.base/sun.security.provider.PolicyFile.implies(PolicyFil > e.java:1038) > at java.base/java.security.provider.ProtectionDomain.implies(Pr > otectionDomain.java:323) > at java.base/java.security.provider.ProtectionDomain.impliesWit > hAltFilePerm(ProtectionDomain.java:355) > at java.base/java.security.provider.AccessControlContext.checkP > ermission(AccessControlContext.java:450) > at java.base/java.security.provider.AccessController.checkPermi > ssion(AccessController.java:895) > at java.base/java.lang.SecurityManager.checkPermission(Security > Manager.java:558) > at jdk.javaws/com.sun.javaws.security.JavaWebStartSecurity.chec > kPermission(JavaWebStartSecurity.java:237) > at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:897) > at java.base/java.io.File.isDirectory(File.java:845) > at java.base/sun.net.www.ParseUtil.fileToEncodedURL(ParseUtil.java:299) > at java.base/sun.security.provider.PolicyFile.canonicalizeCodeb > ase(PolicyFile.java:1665) > at java.base/sun.security.provider.PolicyFile.access$700(Policy > File.java:263) > at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1139) > at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1136) > **** above lines start the stack that repeats until overflow **** > at java.base/java.security.AccessController.doPrivileged(Native Method) > at java.base/sun.security.provider.PolicyFile.getPermissions(Po > licyFile.java:1135) > at java.base/sun.security.provider.PolicyFile.getPermissions(Po > licyFile.java:1082) > at java.base/sun.security.provider.PolicyFile.implies(PolicyFil > e.java:1038) > > -- Tom > > From OGATAK at jp.ibm.com Wed Sep 20 08:14:25 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Wed, 20 Sep 2017 17:14:25 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: Hi Peter, The performance improvement was +2.9%. It is faster than the version that uses an extra dereference (+2.2%). Although it's slower than the variation of full fence, I think I understand Hans's concern and I agree your fix is the right answer. @Hans, I thought DATA_LAYOUT_GUESS in your example is fetched from memory at somewhere and arbitrary time, but I now understand the meaning of "prefetch dataLayout" is to calculate the value of dataLayout without accessing memory. I'm not sure how to calculate it, but I noticed that even piking a random value can have a non-zero possibility of passing the check at line 1204.5. I agree that loading slot[17] can happen before executing full fence if the value of dataLayout does not come from memory and there is no data dependence between writing to dataLayout and reading from dataLayout. I appreciate your comments. Regards, Ogata From: Hans Boehm To: Kazunori Ogata Cc: Peter Levart , core-libs-dev Date: 2017/09/19 05:47 Subject: Re: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() On Mon, Sep 18, 2017 at 10:52 AM, Kazunori Ogata wrote: > > Hi Peter, > > Peter Levart wrote on 2017/09/18 22:05:43: > > > On 09/18/2017 12:28 PM, Kazunori Ogata wrote: > > > Hi Hans and Peter, > > > > > > Thank you for your comments. > > > > > > Regarding the code Hans showed, I don't yet understand what it the > > > problem. Since the load at 1204b is a speculative one, dereferencing > > > slots[17] should not raise any exception. If the confirmation at > 1204.5 > > > succeeds, the value of tmp must also be correct because we put full > fence > > > and we see a non-NULL reference that was stored after the full fence. > > > > I don't know much, but I can imagine that speculative read may see the > > value and guess it correctly based on let's say some CPU state of > > half-processed write instruction in the pipeline, which is established > > even before the fence instruction flushes writes to array slots. So I > > can accept that such outcome is possible and doesn't violate JMM. > > This seems to me that the processor/platform can't implement full fence > correctly. I think it is the platform's (processor's and compiler's) > responsibility to support full fence, otherwise the platform can't > implement all Java API, including VarHandle.fullFence(). As Peter said, my concern is not with exceptions, but with seeing uninitialized data for slots[17]. The semantics of "full fences" are tricky, but basically they don't restrict reordering in other threads, only the thread that executed the fence. The thread with the problematic reordering here is the one that saw a non-null dataLayout value, and hence did not execute a fence. Hence fences generally have to be paired with either another fence in the other thread, or some other ordering mechanism. That other ordering mechanism is missing here, though many implementations will ensure correct ordering, due to hardware dependence-based ordering guarantees. But the JMM does not promise that. Hans From peter.levart at gmail.com Wed Sep 20 08:51:23 2017 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 20 Sep 2017 10:51:23 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <64e57072-321e-eea9-143f-35131e14c348@gmail.com> <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: <32926e6d-d9cb-4482-dfdb-063b364343a3@gmail.com> Hi Ogata, Do you have a source for your benchmark to share? I might be able to squeeze a little more from this approach but it would be easier if I could test variants right away and not bother you... Regards, Peter On 09/20/17 10:14, Kazunori Ogata wrote: > Hi Peter, > > The performance improvement was +2.9%. It is faster than the version that > uses an extra dereference (+2.2%). > > Although it's slower than the variation of full fence, I think I > understand Hans's concern and I agree your fix is the right answer. > > > @Hans, > > I thought DATA_LAYOUT_GUESS in your example is fetched from memory at > somewhere and arbitrary time, but I now understand the meaning of > "prefetch dataLayout" is to calculate the value of dataLayout without > accessing memory. I'm not sure how to calculate it, but I noticed that > even piking a random value can have a non-zero possibility of passing the > check at line 1204.5. > > I agree that loading slot[17] can happen before executing full fence if > the value of dataLayout does not come from memory and there is no data > dependence between writing to dataLayout and reading from dataLayout. I > appreciate your comments. > > > Regards, > Ogata > > > > From: Hans Boehm > To: Kazunori Ogata > Cc: Peter Levart , core-libs-dev > > Date: 2017/09/19 05:47 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > > > On Mon, Sep 18, 2017 at 10:52 AM, Kazunori Ogata > wrote: >> Hi Peter, >> >> Peter Levart wrote on 2017/09/18 22:05:43: >> >>> On 09/18/2017 12:28 PM, Kazunori Ogata wrote: >>>> Hi Hans and Peter, >>>> >>>> Thank you for your comments. >>>> >>>> Regarding the code Hans showed, I don't yet understand what it the >>>> problem. Since the load at 1204b is a speculative one, > dereferencing >>>> slots[17] should not raise any exception. If the confirmation at >> 1204.5 >>>> succeeds, the value of tmp must also be correct because we put full >> fence >>>> and we see a non-NULL reference that was stored after the full > fence. >>> I don't know much, but I can imagine that speculative read may see the >>> value and guess it correctly based on let's say some CPU state of >>> half-processed write instruction in the pipeline, which is established >>> even before the fence instruction flushes writes to array slots. So I >>> can accept that such outcome is possible and doesn't violate JMM. >> This seems to me that the processor/platform can't implement full fence >> correctly. I think it is the platform's (processor's and compiler's) >> responsibility to support full fence, otherwise the platform can't >> implement all Java API, including VarHandle.fullFence(). > As Peter said, my concern is not with exceptions, but with seeing > uninitialized > data for slots[17]. > > The semantics of "full fences" are tricky, but basically they don't > restrict > reordering in other threads, only the thread that executed the fence. The > thread > with the problematic reordering here is the one that saw a non-null > dataLayout value, and hence did not execute a fence. > > Hence fences generally have to be paired with either another fence in the > other > thread, or some other ordering mechanism. That other ordering mechanism is > missing here, though many implementations will ensure correct ordering, > due to > hardware dependence-based ordering guarantees. But the JMM does not > promise that. > > Hans > > From OGATAK at jp.ibm.com Wed Sep 20 10:12:32 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Wed, 20 Sep 2017 19:12:32 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: <32926e6d-d9cb-4482-dfdb-063b364343a3@gmail.com> References: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: Hi Peter, Peter Levart wrote on 2017/09/20 17:51:23: > From: Peter Levart > To: Kazunori Ogata , Hans Boehm > Cc: core-libs-dev > Date: 2017/09/20 17:51 > Subject: Re: RFR: 8187033: [PPC] Imporve performance of > ObjectStreamClass.getClassDataLayout() > > Hi Ogata, > > Do you have a source for your benchmark to share? I might be able to > squeeze a little more from this approach but it would be easier if I could > test variants right away and not bother you... > > Regards, Peter > Hi Peter, The benchmark is GradientBoostingTree of Intel HiBench [1]. HiBench is a suite of programs using Hadoop or Spark, and GradientBoostingTree is a Spark program. The source code (in Scala) is [2]. To build the code, you need Apache Spark. The command line is equivalent to java -Xmx10g -D spark.master="local[4]" GradientBoostingTree 100, but what I actually use is a Java program that calls the main method and measures its execution time using currentTimeMills(). By the way, I'm running the benchmark on POWER8 machine. Removing volatile won't change the performance on x86. [1] https://github.com/intel-hadoop/HiBench [2] https://github.com/intel-hadoop/HiBench/blob/master/sparkbench/ml/src/main/scala/com/intel/sparkbench/ml/GradientBoostingTree.scala Regards, Ogata From peter.levart at gmail.com Wed Sep 20 13:47:55 2017 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 20 Sep 2017 15:47:55 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: Hi Ogata, On 09/20/2017 12:12 PM, Kazunori Ogata wrote: > Hi Peter, > > The benchmark is GradientBoostingTree of Intel HiBench [1]. HiBench is a > suite of programs using Hadoop or Spark, and GradientBoostingTree is a > Spark program. The source code (in Scala) is [2]. To build the code, you > need Apache Spark. > > The command line is equivalent to java -Xmx10g -D spark.master="local[4]" > GradientBoostingTree 100, but what I actually use is a Java > program that calls the main method and measures its execution time using > currentTimeMills(). > > By the way, I'm running the benchmark on POWER8 machine. Removing > volatile won't change the performance on x86. > > > [1] https://github.com/intel-hadoop/HiBench > [2] > https://github.com/intel-hadoop/HiBench/blob/master/sparkbench/ml/src/main/scala/com/intel/sparkbench/ml/GradientBoostingTree.scala > > > Regards, > Ogata > Huh, I thought it would be something easier to run. Am I right that the improvement we are expecting comes from execution of Java serialization and deserialization of some data structure? If you could extract from the benchmark just the approximate shape of the data structure and typical values it contains, I could create a JMH benchmark that tests just that part. Which would be appropriate to tune serialization code. After some best variant is chosen, you could verify it by running your test in your Spark setup. I think there is still room for improvement. I have a few ideas I would like to test. Regards, Peter From peter.levart at gmail.com Wed Sep 20 13:53:41 2017 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 20 Sep 2017 15:53:41 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: <8f85fcb6-61d6-d43e-f230-ab0e702b491d@gmail.com> On 09/20/2017 12:12 PM, Kazunori Ogata wrote: > By the way, I'm running the benchmark on POWER8 machine. Removing > volatile won't change the performance on x86. I would like to compare different variants of optimization using final fields. I won't compare it with current code that uses volatile. I think that overhead that is caused by fences imposed on POWER8 by final fields (does POWER8 use any memory ordering instructions on the read side for final fields?) can be offset with better overall algorithm. Regards, Peter From brian.burkhalter at oracle.com Wed Sep 20 16:34:56 2017 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Wed, 20 Sep 2017 09:34:56 -0700 Subject: RFR 8187631 : Refactor FileDescriptor close implementation In-Reply-To: References: <6050c6f8-a105-957b-95da-a0c8c0d8487e@Oracle.com> <04b5346a-0860-1c25-4372-94e3b8d9fbec@oracle.com> <507afba2-2dcd-a466-0e33-23e5e903a9bb@Oracle.com> <1B642BD2-DE47-485F-A28F-C215AADC7C19@oracle.com> Message-ID: Hi Roger, Looks good. Thanks, Brian On Sep 19, 2017, at 11:01 AM, Roger Riggs wrote: > I had a suggestion to use fdo and fd parameter names and to fix copyright dates. > http://cr.openjdk.java.net/~rriggs/webrev-fd-refactor-8187631-02/ From sean.mullan at oracle.com Tue Sep 19 19:13:50 2017 From: sean.mullan at oracle.com (Sean Mullan) Date: Tue, 19 Sep 2017 15:13:50 -0400 Subject: StackOverflowError - Java 9 Build 181 In-Reply-To: References: Message-ID: <00a010a2-1a93-4f33-9eb7-1c905ca1270e@oracle.com> Cross-posting to security-dev as this is more relevant to that list and bcc-ing core-libs-dev. I think this might be an issue with the JavaWebStart SecurityManager not being granted the proper permissions. It is possible that the deployment policy files are not being loaded or there is some other subtle bootstrapping issue. It should not result in a recursive loop of course, but there may be a workaround. In the meantime, can you send me more information, preferably a test case and a log file with -Djava.security.debug=all enabled? (The latter will help analyze the recursion and see what security checks are failing and for which ProtectionDomains). Also, have you tested this on builds earlier than b181? Thanks, Sean On 9/19/17 2:53 PM, Tom Hood wrote: > I should add that we have not modified or overridden any policy files. > Also, we are not using a custom security manager. > > On Tue, Sep 19, 2017 at 11:52 AM, Tom Hood wrote: > >> Hi, >> >> I hit an infinite recursion loop probably related to PolicyFile that >> exists in Java 9 build 181 for windows 64-bit. It might be related to >> JDK-8077418 >> >> I haven't tracked down what is causing our webstart app to hit this >> problem yet, but I thought I would let you know sooner than later. Also, >> it probably is not a problem for our particular application as I should be >> able to set the security manager to null which I think/hope will bypass >> this issue. I will try today to reproduce it in our app so I can confirm >> if setting security manager to null will work for us. >> >> The stack looks like the following: (with many repeat stacks omitted) >> >> Exception in thread "AWT-EventQueue-2" java.lang.StackOverflowError >> at java.base/java.security.AccessController.doPrivileged(Native Method) >> at java.base/sun.security.provider.PolicyFile.getPermissions(Po >> licyFile.java:1135) >> at java.base/sun.security.provider.PolicyFile.getPermissions(Po >> licyFile.java:1082) >> at java.base/sun.security.provider.PolicyFile.implies(PolicyFil >> e.java:1038) >> at java.base/java.security.provider.ProtectionDomain.implies(Pr >> otectionDomain.java:323) >> at java.base/java.security.provider.ProtectionDomain.impliesWit >> hAltFilePerm(ProtectionDomain.java:355) >> at java.base/java.security.provider.AccessControlContext.checkP >> ermission(AccessControlContext.java:450) >> at java.base/java.security.provider.AccessController.checkPermi >> ssion(AccessController.java:895) >> at java.base/java.lang.SecurityManager.checkPermission(Security >> Manager.java:558) >> at jdk.javaws/com.sun.javaws.security.JavaWebStartSecurity.chec >> kPermission(JavaWebStartSecurity.java:237) >> at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:897) >> at java.base/java.io.File.isDirectory(File.java:845) >> at java.base/sun.net.www.ParseUtil.fileToEncodedURL(ParseUtil.java:299) >> at java.base/sun.security.provider.PolicyFile.canonicalizeCodeb >> ase(PolicyFile.java:1665) >> at java.base/sun.security.provider.PolicyFile.access$700(Policy >> File.java:263) >> at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1139) >> at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1136) >> **** and again **** >> at java.base/java.security.AccessController.doPrivileged(Native Method) >> at java.base/sun.security.provider.PolicyFile.getPermissions(Po >> licyFile.java:1135) >> at java.base/sun.security.provider.PolicyFile.getPermissions(Po >> licyFile.java:1082) >> at java.base/sun.security.provider.PolicyFile.implies(PolicyFil >> e.java:1038) >> at java.base/java.security.provider.ProtectionDomain.implies(Pr >> otectionDomain.java:323) >> at java.base/java.security.provider.ProtectionDomain.impliesWit >> hAltFilePerm(ProtectionDomain.java:355) >> at java.base/java.security.provider.AccessControlContext.checkP >> ermission(AccessControlContext.java:450) >> at java.base/java.security.provider.AccessController.checkPermi >> ssion(AccessController.java:895) >> at java.base/java.lang.SecurityManager.checkPermission(Security >> Manager.java:558) >> at jdk.javaws/com.sun.javaws.security.JavaWebStartSecurity.chec >> kPermission(JavaWebStartSecurity.java:237) >> at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:897) >> at java.base/java.io.File.isDirectory(File.java:845) >> at java.base/sun.net.www.ParseUtil.fileToEncodedURL(ParseUtil.java:299) >> at java.base/sun.security.provider.PolicyFile.canonicalizeCodeb >> ase(PolicyFile.java:1665) >> at java.base/sun.security.provider.PolicyFile.access$700(Policy >> File.java:263) >> at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1139) >> at java.base/sun.security.provider.PolicyFile$7.run(PolicyFile.java:1136) >> **** above lines start the stack that repeats until overflow **** >> at java.base/java.security.AccessController.doPrivileged(Native Method) >> at java.base/sun.security.provider.PolicyFile.getPermissions(Po >> licyFile.java:1135) >> at java.base/sun.security.provider.PolicyFile.getPermissions(Po >> licyFile.java:1082) >> at java.base/sun.security.provider.PolicyFile.implies(PolicyFil >> e.java:1038) >> >> -- Tom >> >> From kumar.x.srinivasan at oracle.com Wed Sep 20 20:51:25 2017 From: kumar.x.srinivasan at oracle.com (Kumar Srinivasan) Date: Wed, 20 Sep 2017 13:51:25 -0700 Subject: [10] Review Request: 8187442 Xcheck:jni produces various "WARNING in native method" in launcher In-Reply-To: <5bd33781-2acf-22e6-1b53-8399c1eb7330@oracle.com> References: <74082349-3d44-ecaf-085e-db21544dd1a5@oracle.com> <394b735a-802f-2cb3-86c8-700d0b401ad6@oracle.com> <1dfd5c78-043a-913c-a645-e3402f561371@oracle.com> <90985c5b-4204-41a5-8bf2-49433a6f21f8@oracle.com> <13e0e6d0-4f06-f19c-2fdf-73077f328331@oracle.com> <960639b6-a383-7a41-43b2-62237a443f6c@oracle.com> <59B967DF.1090907@oracle.com> <5bd33781-2acf-22e6-1b53-8399c1eb7330@oracle.com> Message-ID: <59C2D4CD.6090806@oracle.com> Hi, Looks good to me. Kumar On 9/14/2017 12:01 PM, Sergey Bylokhov wrote: > Hi, Kumar. > The test is updated as suggested: > http://cr.openjdk.java.net/~serb/8187442/webrev.01 > > On 9/13/17 10:16, Kumar Srinivasan wrote: >> Hi Sergey, >> >> If you so wish, you could make the test a little simpler, by using >> the createJar method in TestHelper.java which compiles a file and >> creates an executable jar out of it, refer to ArgsEnvVar.java, >> lines 43 to 54 in the test can be replaced by: >> >> StringBuilder tsrc = new StringBuilder(); >> tsrc.append("public static void main(String... args) {\n"); >> tsrc.append(" System.out.println(\"Hello world\");\n"); >> tsrc.append("}\n"); >> createJar(testJar, new File("Foo"), tsrc.toString()); >> >> but what you currently have is also fine, thanks for making these >> changes. >> >> Kumar >> >>> On 13/09/2017 9:42 AM, Sergey Bylokhov wrote: >>>> On 9/12/17 16:03, David Holmes wrote: >>>>> call. That is fine, but still leaves the problem that you are >>>>> skipping the DeleteLocalRef call. >>>> >>>> The leak was there before: if we will get an exception at >>>> "1512 SetByteArrayRegion()" >>>> then we never call this DeleteLocalRef(). >>>> >>>> I assumed it was done intentionally since this will be kind of >>>> "fatal" error. >>> >>> On further checking DeleteLocalRef is not actually needed in >>> NewPlatformString at all. The only time it is recommended practice >>> to manually delete local refs is when looping, as in >>> NewPlatformStringArray. >>> >>> So all good - Reviewed. And sorry for the noise. >>> >>> Thanks, >>> David >>> >>> >>> >>>> The same pattern is used in the other places for example in >>>> NewPlatformStringArray: >>>> >>>> jstring str = NewPlatformString(env, *strv++); >>>> NULL_CHECK0(str); >>>> (*env)->SetObjectArrayElement(env, ary, i, str); >>>> (*env)->DeleteLocalRef(env, str); >>>> >>>>> >>>>> Thanks - and sorry again for my confusion on this. >>>>> >>>>> David >>>>> ----- >>>>> >>>>>>> In addition this does nothing to clear the pending exception so >>>>>>> I can not see how it would affect any warnings. >>>>>> >>>>>> It does not clear an exception but preserve it instead, and does >>>>>> not use the result of the method which produced an exception. >>>>>> >>>>>>> >>>>>>> David >>>>>>> >>>>>>>> This value will be propagated to JavaMain() and I as far as >>>>>>>> understand will stop the execution. >>>>>>>> >>>>>>>> >>>>>>>> On 9/12/17 13:56, David Holmes wrote: >>>>>>>>> Hi Sergey, >>>>>>>>> >>>>>>>>> On 13/09/2017 5:18 AM, Sergey Bylokhov wrote: >>>>>>>>>> Hello, >>>>>>>>>> Please review the fix for jdk10/jdk10. >>>>>>>>>> >>>>>>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8187442 >>>>>>>>>> Webrev can be found at: >>>>>>>>>> http://cr.openjdk.java.net/~serb/8187442/webrev.00 >>>>>>>>> >>>>>>>>> This doesn't look right to me: >>>>>>>>> >>>>>>>>> str = (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>> makePlatformStringMID, USE_STDERR, ary); >>>>>>>>> + CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>>>> (*env)->DeleteLocalRef(env, ary); >>>>>>>>> return str; >>>>>>>>> >>>>>>>>> If there is an exception pending you fail to delete the local >>>>>>>>> ref. And there's no need to clear the exception before calling >>>>>>>>> DeleteLocalRef as that is okay to call with a pending >>>>>>>>> exception. But there is no point returning zero if an >>>>>>>>> exception occurred because in that case str will already be >>>>>>>>> 0/NULL. >>>>>>>>> >>>>>>>>> The same here: >>>>>>>>> >>>>>>>>> 1596 appClass = (*env)->CallStaticObjectMethod(env, cls, >>>>>>>>> mid); >>>>>>>>> 1597 CHECK_EXCEPTION_RETURN_VALUE(0); >>>>>>>>> 1598 return appClass; >>>>>>>>> >>>>>>>>> If an exception is pending then appClass will be 0/NULL. >>>>>>>>> >>>>>>>>> In addition CHECK_EXCEPTION_RETURN_VALUE doesn't clear the >>>>>>>>> pending exception so I can't see what warnings this would be >>>>>>>>> clearing up ??? >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> David >>>>>>>>> ----- >>>>>>>>> >>>>>>>>>> The simple application with empty main method produce some >>>>>>>>>> "warnings" when Xcheck:jni is used. Because of that it is >>>>>>>>>> hard to cleanup other parts of jdk from such warnings. >>>>>>>>>> >>>>>>>>>> Two additional checks were added, in both cases the new code >>>>>>>>>> will return 0 in the same way as NULL_CHECK0 in the same >>>>>>>>>> methods. >>>>>>>>>> >>>>>>>>>> >>>>>>>> >>>>>>>> >>>>>> >>>>>> >>>> >>>> >> > > From stuart.marks at oracle.com Thu Sep 21 00:02:56 2017 From: stuart.marks at oracle.com (Stuart Marks) Date: Wed, 20 Sep 2017 17:02:56 -0700 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map Message-ID: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> (also includes 8184690: add Collectors for collecting into unmodifiable List, Set, and Map) Hi all, Please review the following changeset with specification changes to support the following: * new List.copyOf(), Set.copyOf(), and Map.copyOf() "copy factory" methods * new Collectors.toUnmodifiableList, Set, and Map methods * specification revisions to provide clearer definitions of "view" collections, "unmodifiable" collections, and "unmodifiable views" The specification text has walked back most uses of "immutable", changing many occurrences to "unmodifiable". (People thought that putting a mutable object into an immutable collection would somehow magically make the whole thing immutable. Also, there was continual confusion with "immutable persistent" data structures.) This review is mainly about specification. Minimal implementations are included, but no tests. Those will come later. Webrev: http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ Bugs: https://bugs.openjdk.java.net/browse/JDK-8177290 add copy factory methods for unmodifiable List, Set, Map https://bugs.openjdk.java.net/browse/JDK-8184690 add Collectors for collecting into unmodifiable List, Set, and Map Thanks, s'marks From martinrb at google.com Thu Sep 21 03:20:27 2017 From: martinrb at google.com (Martin Buchholz) Date: Wed, 20 Sep 2017 20:20:27 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 Message-ID: http://cr.openjdk.java.net/~martin/webrevs/openjdk10/jsr166-integration/ Our usual webrev, rejiggered for the consolidated repo. David, this includes your nestmates changes. From david.holmes at oracle.com Thu Sep 21 03:49:49 2017 From: david.holmes at oracle.com (David Holmes) Date: Thu, 21 Sep 2017 13:49:49 +1000 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: References: Message-ID: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> Hi Martin, On 21/09/2017 1:20 PM, Martin Buchholz wrote: > http://cr.openjdk.java.net/~martin/webrevs/openjdk10/jsr166-integration/ > > > Our usual webrev, rejiggered for the consolidated repo. > > David, this includes your nestmates changes. Thanks - much appreciated. The refactoring looks fine - though I wouldn't have immortalized the "nestmates" part in the naming. :) For others see: https://bugs.openjdk.java.net/browse/JDK-8187607 Cheers, David From amy.lu at oracle.com Thu Sep 21 05:52:48 2017 From: amy.lu at oracle.com (Amy Lu) Date: Thu, 21 Sep 2017 13:52:48 +0800 Subject: [10] RFR of JDK-8184329: Refactor java/lang/ClassLoader shell tests to java Message-ID: <59b9ace2-dba9-77e7-11e0-ddc83a3abf6f@oracle.com> test/jdk/java/lang/ClassLoader/getdotresource.sh Please review this patch to refactor the shell test to java. bug: https://bugs.openjdk.java.net/browse/JDK-8184329 webrev: http://cr.openjdk.java.net/~amlu/8184329/webrev.00/ Thanks, Amy From OGATAK at jp.ibm.com Thu Sep 21 09:39:58 2017 From: OGATAK at jp.ibm.com (Kazunori Ogata) Date: Thu, 21 Sep 2017 18:39:58 +0900 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: Hi Peter, > If you could extract from > the benchmark just the approximate shape of the data structure and > typical values it contains, I could create a JMH benchmark that tests > just that part. Which would be appropriate to tune serialization code. My colleague investigated the objects serialized/deserialized in the benchmark. He found there are several types of object trees, and one of the largest object tree looks like (in Scala types): scala.Tuple2[1] `-scala.Tuple2 +-Int `-scala.Tuple2 +-org.apache.spark.ml.tree.ContinuousSplit | +-Int | `-Boolean `-org.apache.spark.mllib.tree.model.ImpurityStats +-Double +-Double +-org.apache.spark.mllib.tree.impurity.VarianceCalculator | `-Double[3] +-org.apache.spark.mllib.tree.impurity.VarianceCalculator | `-Double[3] +-org.apache.spark.mllib.tree.impurity.VarianceCalculator | `-Double[3] `-Boolean Now the question is how the Java classes (including class hierarchy) look like because Scala types may need extra boxing/unboxing (though I'm not confident). I'll try to decompile .class files generated from the scala code and find the real Java types. Regards, Ogata From peter.levart at gmail.com Thu Sep 21 10:21:41 2017 From: peter.levart at gmail.com (Peter Levart) Date: Thu, 21 Sep 2017 12:21:41 +0200 Subject: RFR: 8187033: [PPC] Imporve performance of ObjectStreamClass.getClassDataLayout() In-Reply-To: References: <865eecec-7ad8-2b7c-5b9a-8418a7ef925f@gmail.com> <324462cb-8a78-21ed-4df6-1d7d87402807@Oracle.com> <8a0b32bf-7fea-4e3f-7d02-1faec073b175@gmail.com> Message-ID: Hi Ogata, Thanks, I'll try with a Java equivalent of below structure. I can change it later if needed. Stay tuned... Regards, Peter On 09/21/2017 11:39 AM, Kazunori Ogata wrote: > Hi Peter, > >> If you could extract from >> the benchmark just the approximate shape of the data structure and >> typical values it contains, I could create a JMH benchmark that tests >> just that part. Which would be appropriate to tune serialization code. > My colleague investigated the objects serialized/deserialized in the > benchmark. He found there are several types of object trees, and one of > the largest object tree looks like (in Scala types): > > scala.Tuple2[1] > `-scala.Tuple2 > +-Int > `-scala.Tuple2 > +-org.apache.spark.ml.tree.ContinuousSplit > | +-Int > | `-Boolean > `-org.apache.spark.mllib.tree.model.ImpurityStats > +-Double > +-Double > +-org.apache.spark.mllib.tree.impurity.VarianceCalculator > | `-Double[3] > +-org.apache.spark.mllib.tree.impurity.VarianceCalculator > | `-Double[3] > +-org.apache.spark.mllib.tree.impurity.VarianceCalculator > | `-Double[3] > `-Boolean > > > Now the question is how the Java classes (including class hierarchy) look > like because Scala types may need extra boxing/unboxing (though I'm not > confident). I'll try to decompile .class files generated from the scala > code and find the real Java types. > > > Regards, > Ogata > From Alan.Bateman at oracle.com Thu Sep 21 12:42:25 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 21 Sep 2017 13:42:25 +0100 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> Message-ID: <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> On 21/09/2017 01:02, Stuart Marks wrote: > (also includes 8184690: add Collectors for collecting into > unmodifiable List, Set, and Map) > > Hi all, > > Please review the following changeset with specification changes to > support the following: > > * new List.copyOf(), Set.copyOf(), and Map.copyOf() "copy factory" > methods > > * new Collectors.toUnmodifiableList, Set, and Map methods > > * specification revisions to provide clearer definitions of "view" > collections, "unmodifiable" collections, and "unmodifiable views" > > The specification text has walked back most uses of "immutable", > changing many occurrences to "unmodifiable". (People thought that > putting a mutable object into an immutable collection would somehow > magically make the whole thing immutable. Also, there was continual > confusion with "immutable persistent" data structures.) > > This review is mainly about specification. Minimal implementations are > included, but no tests. Those will come later. > > Webrev: > > ??? http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ I read through the updated/new definitions and they read well. For the copyOf methods then I can't immediately tell from the javadoc if the given collection can contain null elements. Taking List.copyOf as an example where coll may be null or it may contain null elements. The javadoc does link to "Unmodifiable lists" where it specifies the characteristics of the lists returned by the static factory methods - these include disallowing null elements. So I think this needs to be clarified. Minimal implementation is okay to get started but what is the reason not to include some basic tests? -Alan From adam.farley at uk.ibm.com Thu Sep 21 15:11:13 2017 From: adam.farley at uk.ibm.com (Adam Farley8) Date: Thu, 21 Sep 2017 16:11:13 +0100 Subject: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java Message-ID: Hi David and Alan, I'm on vacation for next week and can't guarantee an online presence. Andrew Leonard has volunteered to help out on this while I'm away. I've brought him up-to-date on the core points, and he has the diffs and tests if anyone needs another copy. Best Regards Adam Farley -- Previous Email -- Hi David, Alan, You are right in that the changes to HotSpot would be nontrivial. I see a number of places in (e.g.) arguments.cpp that seem to exit in the same manner as Xlog (such as -Xinternalversion). I would advise ploughing through the CSR process to alter the JNI spec, and simultaneously identify some key paths that can be raised as bugs. That way, when people have time to address these issues, the mechanism to handle a silent exit is already in place. The JDWP fix can be raised separately as one of these bugs, if it would make things simpler. As for the name, JNI_SILENT_EXIT is a placeholder, and can be readily changed. Do you have any suggestions? Lastly, in an ideal world, the VM initialisation should never exit(#). It should return a return code that tells the caller something, pass or fail, messy or tidy. That way, if someone is using the JNI as part of something bigger (like a database or a web server), one of these scenarios is just a bug, rather than a world-ender like exit(#). And now for the individual messages. :) David: Having help data returned by the launcher seems like a good way to avoid exit(0) calls, but I'm not sure how we'd prevent a JNI-caller using those options. Ultimately, to be sure, we'd have to remove the logic for those options, centralise the data to better enable launcher access, and add some logic in there so it can find any other help data (e.g. from the jdwp agent library). I feel this would be a bigger task than adding the new return code and changing the vm, plus it wouldn't provide for any non-help scenarios where the vm wants to shut down without error during initialisation. Alan: I should mention that the silent exit solution is already in use in the OpenJ9 VM. Not all of the exit paths have been resolved, but many have. The code is open and can be found here: https://github.com/eclipse/openj9 And though the silent exit code is disabled for the time being, it can be re-enabled by entering this class: runtime/vm/jvminit.c and altering line 2343 ( ctrl-f for exit(1) if it's not there). I won't paste the full code here in case people are concerned about contamination, but I would assert that this code (and the associated vm files) prove that the concept is possible. Note that that code should not be enabled until after we've integrated the code that can handle a silent exit. Best Regards Adam Farley P.S. Thank you both for your efforts on this. :) From: David Holmes To: Alan Bateman , Adam Farley8 , core-libs-dev at openjdk.java.net, hotspot-runtime-dev at openjdk.java.net, thomas.stuefe at gmail.com Date: 15/09/2017 12:03 Subject: Re: [BUG PROPOSAL]: C++ code that calls JNI_CreateJavaVM can be exited by java On 15/09/2017 8:17 PM, Alan Bateman wrote: > On 15/09/2017 02:47, David Holmes wrote: >> Hi Adam, >> >> I am still very much torn over this one. I think the idea of >> print-and-exit flags for a potentially hosted library like the JVM is >> just wrong - we should never have done that, but we did. Fixing that >> by moving the flags to the launcher is far from trivial**. Endorsing >> and encouraging these sorts of flag by adding JNI support seems to be >> sending the wrong message. >> >> ** I can envisage a "help xxx" Dcmd that can read back the info from >> the VM. The launcher can send the Dcmd, print the output and exit. The >> launcher would not need to know what the xxx values mean, but would >> have to intercept the existing ones. >> >> Another option is just to be aware of these flags (are there more than >> jdwp and Xlog?) and deal with them specially in your custom launcher - >> either filter them out and ignore them, or else launch the VM in its >> own process to respond to them. >> >> Any changes to the JNI specification need to go through the CSR process. > Yes, it would require an update to the JNI spec, also a change to the > JVM TI spec where Agent_OnLoad returning a non-0 value is specified to > terminates the VM. The name and value needs discussion too, esp. as the > JNI spec uses negative values for failure. > > In any case, I'm also torn over this one as it's a corner case that is > only interesting for custom launchers that load agents with options that > print usage messages. It wouldn't be hard to have the Agent_OnLoad > specify a printf hook that the agent could use for output although there > are complications with agents such as JDWP that also announce their > transport end point. Beyond that there is still the issue of the custom > launcher that would need to know to destroy the VM without reporting an > error. > > So what happened to the more meaty part to this which is fixing the > various cases in HotSpot that terminate the process during > initialization? I would expect some progress could be made on those > cases while trying to decide whether to rev the JNI and JVM TI specs to > cover the help case. Trying to eliminate the vm_exit_during_initialization paths in hotspot is a huge undertaking IMHO. David > > -Alan Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU From mandy.chung at oracle.com Thu Sep 21 15:15:32 2017 From: mandy.chung at oracle.com (mandy chung) Date: Thu, 21 Sep 2017 08:15:32 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <0c59deae-ac21-8062-c3c5-c4eb270b4b98@gmail.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> <4612ad06-2bae-4482-175d-3c3bfc0dab27@oracle.com> <0c59deae-ac21-8062-c3c5-c4eb270b4b98@gmail.com> Message-ID: <8354b7b2-baf5-a7fa-0c8c-5044d2eb024c@oracle.com> Hi Peter, Updated webrev: http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.03/ On 9/3/17 7:02 AM, Peter Levart wrote: > >> Updated webrev: >> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.02/ > > That's what I had in mind, yes. > > Looking at the method names, I have a second thought about the too > general StackFrame::getDescriptor(). Not looking at the javadocs, one > could ask: "what is a descriptor of a stack frame?". I don't know, > maybe getMethodDescriptor() would be more to the point or even > getMethodTypeDescriptor() (since it is a descriptor of method > parameter and return types, not containing method name). What do you > and others think? Descriptor is specified in JVMS 4.3: ??? A /descriptor/ is a string representing the type of a field or method. I initially had getMethodDescriptor() while "Method" is kinda redundant since StackFrame represents a method invocation. Descriptor in this context is for a method and never be a field. Hence I like Remi's suggestion to rename it to getDescriptor. > > Although it is not expected for StackFrame interface to be implemented > by custom classes, it is a public interface. I have seen 3rd party > code implementing JDK interface that was not meant to be implemented > by custom classes just because the interface seemed appropriate. To > keep binary compatibility with such potential implementations, those > two new methods could be default methods throwing UOE. > Having a second thought, while it's rarely to have custom StackFrame implementation, I agree making the new methods to be default method that would help migration for tests or other use. > nit: while you are at it, you could remove the redundant "static" > modifier from the StackWalker.StackFrame interface declaration. > Done Mandy From mandy.chung at oracle.com Thu Sep 21 17:15:57 2017 From: mandy.chung at oracle.com (mandy chung) Date: Thu, 21 Sep 2017 10:15:57 -0700 Subject: Review Request: JDK-8187449: jdeps fails when an upgradeable module is upgraded with an automatic module In-Reply-To: <37BEFF5E-CD3B-43F3-AF64-BB183556FA5E@oracle.com> References: <3a3d7618-979f-0fcb-9520-be6f9e02d2c9@oracle.com> <37BEFF5E-CD3B-43F3-AF64-BB183556FA5E@oracle.com> Message-ID: On 9/19/17 9:54 AM, Paul Sandoz wrote: >> On 18 Sep 2017, at 14:44, mandy chung wrote: >> >> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8187449/webrev.00/ >> > JdepsConfiguration > ? > > 288 // is this module from the system module path? > 289 boolean isSystem = false; > 290 if (system.find(mn).isPresent()) { > 291 URI loc = system.find(mn).get().location().orElse(null); > 292 isSystem = location.equals(loc); > 293 } > > I believe you can use flatMap so we transform from one Optional domain to another e.g.: > > URI loc = system.find(mn).flatMap(::location).orElse(null); > boolean isSystem = location.equals(loc); > Good idea.? I revised it to use flatMap as above. thanks Mandy From paul.sandoz at oracle.com Thu Sep 21 17:29:21 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 21 Sep 2017 10:29:21 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> Message-ID: <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> Looks good, i just need to look a little more closely at the ConcurrentSkipListMap changes. > On 20 Sep 2017, at 20:49, David Holmes wrote: > > Hi Martin, > > On 21/09/2017 1:20 PM, Martin Buchholz wrote: >> http://cr.openjdk.java.net/~martin/webrevs/openjdk10/jsr166-integration/ >> Our usual webrev, rejiggered for the consolidated repo. >> David, this includes your nestmates changes. > > Thanks - much appreciated. The refactoring looks fine - though I wouldn't have immortalized the "nestmates" part in the naming. :) > Perhaps use the prefix TopLevelAtomicTests or NonEnclosingAtomicTests ? Paul. > For others see: > > https://bugs.openjdk.java.net/browse/JDK-8187607 > > Cheers, > David From paul.sandoz at oracle.com Thu Sep 21 17:29:40 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 21 Sep 2017 10:29:40 -0700 Subject: Review Request: JDK-8187449: jdeps fails when an upgradeable module is upgraded with an automatic module In-Reply-To: References: <3a3d7618-979f-0fcb-9520-be6f9e02d2c9@oracle.com> <37BEFF5E-CD3B-43F3-AF64-BB183556FA5E@oracle.com> Message-ID: > On 21 Sep 2017, at 10:15, mandy chung wrote: > > > > On 9/19/17 9:54 AM, Paul Sandoz wrote: >>> On 18 Sep 2017, at 14:44, mandy chung wrote: >>> >>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8187449/webrev.00/ >>> >> JdepsConfiguration >> ? >> >> 288 // is this module from the system module path? >> 289 boolean isSystem = false; >> 290 if (system.find(mn).isPresent()) { >> 291 URI loc = system.find(mn).get().location().orElse(null); >> 292 isSystem = location.equals(loc); >> 293 } >> >> I believe you can use flatMap so we transform from one Optional domain to another e.g.: >> >> URI loc = system.find(mn).flatMap(::location).orElse(null); >> boolean isSystem = location.equals(loc); >> > > Good idea. I revised it to use flatMap as above. > Ok, +1 Paul. From martinrb at google.com Thu Sep 21 17:50:51 2017 From: martinrb at google.com (Martin Buchholz) Date: Thu, 21 Sep 2017 10:50:51 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> Message-ID: On Thu, Sep 21, 2017 at 10:29 AM, Paul Sandoz wrote: > > > Thanks - much appreciated. The refactoring looks fine - though I > wouldn't have immortalized the "nestmates" part in the naming. :) > > > > Perhaps use the prefix TopLevelAtomicTests or NonEnclosingAtomicTests ? > . NonNestmates does have nested classes, but they need to be non-nestmates of the invoking test code. I don't think we have a word for birds that are not in the same nest. Japanese has https://en.wikipedia.org/wiki/Uchi-soto so .... Soto.java ? From forax at univ-mlv.fr Thu Sep 21 18:42:46 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Thu, 21 Sep 2017 20:42:46 +0200 (CEST) Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> Message-ID: <532137552.3178493.1506019366298.JavaMail.zimbra@u-pem.fr> Bastard.java ? R?mi ----- Mail original ----- > De: "Martin Buchholz" > ?: "Paul Sandoz" > Cc: "core-libs-dev" > Envoy?: Jeudi 21 Septembre 2017 19:50:51 > Objet: Re: RFR: jsr166 jdk10 integration wave 3 > On Thu, Sep 21, 2017 at 10:29 AM, Paul Sandoz > wrote: > >> >> > Thanks - much appreciated. The refactoring looks fine - though I >> wouldn't have immortalized the "nestmates" part in the naming. :) >> > >> >> Perhaps use the prefix TopLevelAtomicTests or NonEnclosingAtomicTests ? >> > . > NonNestmates does have nested classes, but they need to be non-nestmates of > the invoking test code. I don't think we have a word for birds that are > not in the same nest. Japanese has > https://en.wikipedia.org/wiki/Uchi-soto > so .... Soto.java ? From mandy.chung at oracle.com Thu Sep 21 18:50:44 2017 From: mandy.chung at oracle.com (mandy chung) Date: Thu, 21 Sep 2017 11:50:44 -0700 Subject: [10] RFR of JDK-8184329: Refactor java/lang/ClassLoader shell tests to java In-Reply-To: <59b9ace2-dba9-77e7-11e0-ddc83a3abf6f@oracle.com> References: <59b9ace2-dba9-77e7-11e0-ddc83a3abf6f@oracle.com> Message-ID: <83d59dff-e012-f245-63f1-e5bde57ea834@oracle.com> On 9/20/17 10:52 PM, Amy Lu wrote: > test/jdk/java/lang/ClassLoader/getdotresource.sh > > Please review this patch to refactor the shell test to java. > > bug: https://bugs.openjdk.java.net/browse/JDK-8184329 > webrev: http://cr.openjdk.java.net/~amlu/8184329/webrev.00/ I think you can replace line 64-67 with ProcessTools.executeTestJava("-cp", CP, GetDotResource.class.getName(), DOT_FILENAME) Mandy From stuart.marks at oracle.com Thu Sep 21 18:55:54 2017 From: stuart.marks at oracle.com (Stuart Marks) Date: Thu, 21 Sep 2017 11:55:54 -0700 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> Message-ID: <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> On 9/21/17 5:42 AM, Alan Bateman wrote: > On 21/09/2017 01:02, Stuart Marks wrote: >> http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ > I read through the updated/new definitions and they read well. Great. > For the copyOf methods then I can't immediately tell from the javadoc if the > given collection can contain null elements. Taking List.copyOf as an example > where coll may be null or it may contain null elements. The javadoc does link to > "Unmodifiable lists" where it specifies the characteristics of the lists > returned by the static factory methods - these include disallowing null > elements. So I think this needs to be clarified. Agreed, I'll work on some clarifications here, and also disallow null for the argument itself. > Minimal implementation is okay to get started but what is the reason not to > include some basic tests? Sorry, I should have been more clear about this. The changeset is clearly not ready to go in as it stands. I wanted to get an initial review of the specifications going, then file a CSR request, etc. while continuing to work on tests and better implementations. I'll post a subsequent review when they're ready. Thanks. s'marks From Roger.Riggs at Oracle.com Thu Sep 21 19:16:20 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Thu, 21 Sep 2017 15:16:20 -0400 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> Message-ID: <936c0525-8494-c0a8-f355-6eebabbc0ffb@Oracle.com> Hi Stuart, The new text in Collections reads more like an @apinote than a specification. Are there any enforceable? assertions there? I think the markup used to refer to unmodifiable XXX reads better as a link in the text (as in Collection#unmodifableCollection) than as a second sentence (as in List#of()). A consistent treatment in all class would be a plus. The implementations of the Collectors are very inefficient, first creating a mutable version, then extracting to an array, and then constructing the final object.? So much garbage is created, especially for small n. Thanks, Roger On 9/21/2017 2:55 PM, Stuart Marks wrote: > > > On 9/21/17 5:42 AM, Alan Bateman wrote: >> On 21/09/2017 01:02, Stuart Marks wrote: >>> http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ >> I read through the updated/new definitions and they read well. > > Great. > >> For the copyOf methods then I can't immediately tell from the javadoc >> if the >> given collection can contain null elements. Taking List.copyOf as an >> example >> where coll may be null or it may contain null elements. The javadoc >> does link to >> "Unmodifiable lists" where it specifies the characteristics of the lists >> returned by the static factory methods - these include disallowing null >> elements. So I think this needs to be clarified. > > Agreed, I'll work on some clarifications here, and also disallow null > for the argument itself. > >> Minimal implementation is okay to get started but what is the reason >> not to >> include some basic tests? > > Sorry, I should have been more clear about this. The changeset is > clearly not ready to go in as it stands. I wanted to get an initial > review of the specifications going, then file a CSR request, etc. > while continuing to work on tests and better implementations. I'll > post a subsequent review when they're ready. > > Thanks. > > s'marks > From john.r.rose at oracle.com Thu Sep 21 19:36:52 2017 From: john.r.rose at oracle.com (John Rose) Date: Thu, 21 Sep 2017 12:36:52 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> Message-ID: <2206F016-DBE5-44FF-8999-FD6E5C5FB1CC@oracle.com> On Sep 21, 2017, at 10:50 AM, Martin Buchholz wrote: > > NonNestmates does have nested classes, but they need to be non-nestmates of > the invoking test code. I don't think we have a word for birds that are > not in the same nest. Japanese has > https://en.wikipedia.org/wiki/Uchi-soto > so .... Soto.java ? "One for whom household honorifics is inappropriate." Nice. So C.N and C may refer to each other as "C-san" and "C.N-san", reflecting their nestmate privileges. But they both refer to "D" as "D". The distinction of outsider vs. insider works in English as well. Hmmm, we have so many colorful terms for an outsider that tries to be an insider: impostor, interloper, crasher, bounder, poser? And among birds, the cuckoo does this. From martinrb at google.com Thu Sep 21 20:41:08 2017 From: martinrb at google.com (Martin Buchholz) Date: Thu, 21 Sep 2017 13:41:08 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: <2206F016-DBE5-44FF-8999-FD6E5C5FB1CC@oracle.com> References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> <2206F016-DBE5-44FF-8999-FD6E5C5FB1CC@oracle.com> Message-ID: Within a household, there's -chan and -kun https://en.wikipedia.org/wiki/Japanese_honorifics#Common_honorifics On Thu, Sep 21, 2017 at 12:36 PM, John Rose wrote: > On Sep 21, 2017, at 10:50 AM, Martin Buchholz wrote: > > > NonNestmates does have nested classes, but they need to be non-nestmates of > the invoking test code. I don't think we have a word for birds that are > not in the same nest. Japanese has > https://en.wikipedia.org/wiki/Uchi-soto > so .... Soto.java ? > > > "One for whom household honorifics is inappropriate." > Nice. So C.N and C may refer to each other as "C-san" > and "C.N-san", reflecting their nestmate privileges. > But they both refer to "D" as "D". > > The distinction of outsider vs. insider works in > English as well. > > Hmmm, we have so many colorful terms for an > outsider that tries to be an insider: impostor, > interloper, crasher, bounder, poser? And > among birds, the cuckoo does this. > > > From amy.lu at oracle.com Fri Sep 22 02:29:40 2017 From: amy.lu at oracle.com (Amy Lu) Date: Fri, 22 Sep 2017 10:29:40 +0800 Subject: [10] RFR of JDK-8184329: Refactor java/lang/ClassLoader shell tests to java In-Reply-To: <83d59dff-e012-f245-63f1-e5bde57ea834@oracle.com> References: <59b9ace2-dba9-77e7-11e0-ddc83a3abf6f@oracle.com> <83d59dff-e012-f245-63f1-e5bde57ea834@oracle.com> Message-ID: <13c3732d-62d5-c546-9cab-dd151dddb835@oracle.com> On 9/22/17 2:50 AM, mandy chung wrote: > > > On 9/20/17 10:52 PM, Amy Lu wrote: >> test/jdk/java/lang/ClassLoader/getdotresource.sh >> >> Please review this patch to refactor the shell test to java. >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8184329 >> webrev: http://cr.openjdk.java.net/~amlu/8184329/webrev.00/ > I think you can replace line 64-67 with > ProcessTools.executeTestJava("-cp", CP, > GetDotResource.class.getName(), DOT_FILENAME) > Mandy Thanks for reviewing! executeTestJava adds "-cp" with System.getProperty("java.class.path") when creating the process, thus the final command will have two "-cp". This is I'm trying to avoid. Thanks, Amy From amy.lu at oracle.com Fri Sep 22 04:31:48 2017 From: amy.lu at oracle.com (Amy Lu) Date: Fri, 22 Sep 2017 12:31:48 +0800 Subject: [10] RFR of JDK-8184329: Refactor java/lang/ClassLoader shell tests to java In-Reply-To: <83d59dff-e012-f245-63f1-e5bde57ea834@oracle.com> References: <59b9ace2-dba9-77e7-11e0-ddc83a3abf6f@oracle.com> <83d59dff-e012-f245-63f1-e5bde57ea834@oracle.com> Message-ID: <23d00562-9963-2721-7e39-4d8f26bbe5f2@oracle.com> On 9/22/17 2:50 AM, mandy chung wrote: > > > On 9/20/17 10:52 PM, Amy Lu wrote: >> test/jdk/java/lang/ClassLoader/getdotresource.sh >> >> Please review this patch to refactor the shell test to java. >> >> bug: https://bugs.openjdk.java.net/browse/JDK-8184329 >> webrev: http://cr.openjdk.java.net/~amlu/8184329/webrev.00/ > I think you can replace line 64-67 with > ProcessTools.executeTestJava("-cp", CP, > GetDotResource.class.getName(), DOT_FILENAME) > Mandy Hi, Mandy webrev updated, please review: http://cr.openjdk.java.net/~amlu/8184329/webrev.01 (I'll file bug for the inconsistent of adding "-cp" in executeTestJavainjdk.test.lib.process.ProcessTools and jdk.testlibrary.ProcessTools, so as this won't be forgotten when trying to remove jdk.testlibrary.ProcessTools) Thanks, Amy From mandy.chung at oracle.com Fri Sep 22 05:13:38 2017 From: mandy.chung at oracle.com (mandy chung) Date: Thu, 21 Sep 2017 22:13:38 -0700 Subject: [10] RFR of JDK-8184329: Refactor java/lang/ClassLoader shell tests to java In-Reply-To: <23d00562-9963-2721-7e39-4d8f26bbe5f2@oracle.com> References: <59b9ace2-dba9-77e7-11e0-ddc83a3abf6f@oracle.com> <83d59dff-e012-f245-63f1-e5bde57ea834@oracle.com> <23d00562-9963-2721-7e39-4d8f26bbe5f2@oracle.com> Message-ID: <686b8667-e50b-6d32-6690-9036d40481b5@oracle.com> On 9/21/17 9:31 PM, Amy Lu wrote: > On 9/22/17 2:50 AM, mandy chung wrote: >> >> >> On 9/20/17 10:52 PM, Amy Lu wrote: >>> test/jdk/java/lang/ClassLoader/getdotresource.sh >>> >>> Please review this patch to refactor the shell test to java. >>> >>> bug: https://bugs.openjdk.java.net/browse/JDK-8184329 >>> webrev: http://cr.openjdk.java.net/~amlu/8184329/webrev.00/ >> I think you can replace line 64-67 with >> ProcessTools.executeTestJava("-cp", CP, >> GetDotResource.class.getName(), DOT_FILENAME) >> Mandy > > Hi, Mandy > > webrev updated, please review: > http://cr.openjdk.java.net/~amlu/8184329/webrev.01 > Looks good.? Nit: can you wrap long lines 53 and 70. No need for a new webrev. > (I'll file bug for the inconsistent of adding "-cp" in > executeTestJavainjdk.test.lib.process.ProcessTools and > jdk.testlibrary.ProcessTools, so as this won't be forgotten when > trying to remove jdk.testlibrary.ProcessTools) > Thanks.? It'd be good to understand why these two ProcessTools are different. Mandy From weijun.wang at oracle.com Fri Sep 22 05:48:00 2017 From: weijun.wang at oracle.com (Weijun Wang) Date: Fri, 22 Sep 2017 13:48:00 +0800 Subject: Set a file readable/writable by owner only Message-ID: <8EB3260D-4D1D-44EF-93C9-C14674DF7936@oracle.com> I need to make a file rw only by the owner. How do you think of my code at the end? Especially, for the aclView case, I tried on Windows, and the result is like C:\>icacls x x NT AUTHORITY\SYSTEM:(I)(F) BUILTIN\Administrators:(I)(F) BUILTIN\Users:(I)(RX) Successfully processed 1 files; Failed processing 0 files C:\>java A9 x C:\>icacls x x BUILTIN\Administrators:(DE,RD,WD) Successfully processed 1 files; Failed processing 0 files Can I simply set it to (DE,RD,WD)? Is the original (F) better? Do I need to retain the permissions of other non-USERS? Thanks Max ----- import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.*; import java.util.Collections; public class A9 { public static void main(String[] args) throws Exception { Path file = Paths.get(args[0]); PosixFileAttributeView posixView = Files.getFileAttributeView( file, PosixFileAttributeView.class); if (posixView != null) { posixView.setPermissions(PosixFilePermissions.fromString("rw-------")); return; } AclFileAttributeView aclView = Files.getFileAttributeView( file, AclFileAttributeView.class); if (aclView != null) { AclEntry.Builder builder = AclEntry.newBuilder(); builder.setPermissions( AclEntryPermission.WRITE_DATA, AclEntryPermission.READ_DATA, AclEntryPermission.DELETE); builder.setPrincipal(aclView.getOwner()); builder.setType(AclEntryType.ALLOW); aclView.setAcl(Collections.singletonList(builder.build())); return; } System.out.println("No idea how"); } } From vyom.tewari at oracle.com Fri Sep 22 09:42:52 2017 From: vyom.tewari at oracle.com (vyom tewari) Date: Fri, 22 Sep 2017 15:12:52 +0530 Subject: RFR 8145635 : Add TCP_QUICKACK socket option In-Reply-To: <0b0989b5-c791-a476-a82f-6c686b19c9d3@oracle.com> References: <56CD74E1.60309@oracle.com> <56CD7C0A.2080402@oracle.com> <0b0989b5-c791-a476-a82f-6c686b19c9d3@oracle.com> Message-ID: ping!! Vyom On Monday 11 September 2017 09:08 PM, vyom tewari wrote: > > Hi All, > > As jdk.net API already moved out of java.base, Please review the below > code change for jdk10. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8145635 > > Webrev: http://cr.openjdk.java.net/~vtewari/8145635/webrev0.1/index.html > > Thanks, > > Vyom > > > On Wednesday 24 February 2016 03:16 PM, Alan Bateman wrote: >> >> On 24/02/2016 09:16, vyom wrote: >>> Hi All, >>> >>> Please review my code changes for the below issue. >>> >>> Bug: JDK-8145635 : Add TCP_QUICKACK socket option >>> >>> Webrev: >>> http://cr.openjdk.java.net/~vtewari/8145635/webrev0.0/index.html >>> >>> Currently TCP_QUICKACK is only supported on Linux( since Linux >>> 2.4.4) so i implemented is as "ExtendedSocketOption". >> >> Is there any urgency on this one? I'm just wondering if we should try >> to the jdk.net API moved out of java.base before we add more socket >> options. This is currently tracked as JDK-8044773 and important to >> get into JDK 9. >> >> -Alan > From peter.levart at gmail.com Fri Sep 22 10:45:32 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 22 Sep 2017 12:45:32 +0200 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: <8354b7b2-baf5-a7fa-0c8c-5044d2eb024c@oracle.com> References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> <4612ad06-2bae-4482-175d-3c3bfc0dab27@oracle.com> <0c59deae-ac21-8062-c3c5-c4eb270b4b98@gmail.com> <8354b7b2-baf5-a7fa-0c8c-5044d2eb024c@oracle.com> Message-ID: Hi Mandy, On 09/21/2017 05:15 PM, mandy chung wrote: > Hi Peter, > > Updated webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.03/ > > On 9/3/17 7:02 AM, Peter Levart wrote: >> >>> Updated webrev: >>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.02/ >> >> That's what I had in mind, yes. >> >> Looking at the method names, I have a second thought about the too >> general StackFrame::getDescriptor(). Not looking at the javadocs, one >> could ask: "what is a descriptor of a stack frame?". I don't know, >> maybe getMethodDescriptor() would be more to the point or even >> getMethodTypeDescriptor() (since it is a descriptor of method >> parameter and return types, not containing method name). What do you >> and others think? > > Descriptor is specified in JVMS 4.3: > ??? A /descriptor/ is a string representing the type of a field or method. > > I initially had getMethodDescriptor() while "Method" is kinda > redundant since StackFrame represents a method invocation. Descriptor > in this context is for a method and never be a field. Hence I like > Remi's suggestion to rename it to getDescriptor. Ok, I buy it. >> >> Although it is not expected for StackFrame interface to be >> implemented by custom classes, it is a public interface. I have seen >> 3rd party code implementing JDK interface that was not meant to be >> implemented by custom classes just because the interface seemed >> appropriate. To keep binary compatibility with such potential >> implementations, those two new methods could be default methods >> throwing UOE. >> > Having a second thought, while it's rarely to have custom StackFrame > implementation, I agree making the new methods to be default method > that would help migration for tests or other use. >> nit: while you are at it, you could remove the redundant "static" >> modifier from the StackWalker.StackFrame interface declaration. >> > > Done Just two more things... 1st: I was I little confused reading this part of javadoc of getDescriptor(): ?152????????? * Returns the descriptor of the method type for ?153????????? * this stack frame.? A method descriptor is a string representing the ?154????????? * types of parameters that the method takes, and a return descriptor, ?155????????? * representing the type of the value (if any) that the method returns ?156????????? * as defined by The Java™ Virtual Machine Specification. Wouldn't it be better to say: ?152????????? * Returns the descriptor of the method type for ?153????????? * this stack frame.? A method descriptor is a string representing the ?154????????? * types of parameters that the method takes, and the method's return type, ?156????????? * as defined by The Java™ Virtual Machine Specification. I think there is a slight difference between "method return type" and "the type of value (if any) that the method returns". The former is a property of the method, the later is a property of the returned value (primitive or reference or none) in a particular invocation of the method and may be different (a subtype). 2nd: I don't know in what circumstance may the MemberName.getMethodType() or .getMethodDescriptor() return null, but the MemberName code is written as follows: ?169???????? if (type == null) { ?170???????????? expandFromVM(); ?171???????????? if (type == null) { ?172???????????????? return null; ?173???????????? } ?174???????? } Is there a real circumstance when this may happen? Should StackWalker.StackFrame.getMethodType() / .getDescriptor() document that situation or maybe transform it into an exception or error? Regards, Peter From Roger.Riggs at Oracle.com Fri Sep 22 12:36:00 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 22 Sep 2017 08:36:00 -0400 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> Message-ID: Hi Stuart, I'm cautious about doing work piecemeal toward immutable collections. The current unmodifiable approach only gives partial protection to the caller and none to the callee. The assertions it makes are too weak to be useful. I think more value can be achieved by creating concrete final immutable collections that applications can use to be certain that the semantics of the collection are immutable. They can implement the current interfaces but would be compile time knowable of the complete semantics of mutability.? Then a good bridge between the current streams (and collections) would be methods that return the concrete final collections. BTW, I don't think many people are confused by 'immutable' collections appearing to be mutated because one of the objects in the collection is mutable. Thanks, Roger On 9/21/2017 2:55 PM, Stuart Marks wrote: > > > On 9/21/17 5:42 AM, Alan Bateman wrote: >> On 21/09/2017 01:02, Stuart Marks wrote: >>> http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ >> I read through the updated/new definitions and they read well. > > Great. > >> For the copyOf methods then I can't immediately tell from the javadoc >> if the >> given collection can contain null elements. Taking List.copyOf as an >> example >> where coll may be null or it may contain null elements. The javadoc >> does link to >> "Unmodifiable lists" where it specifies the characteristics of the lists >> returned by the static factory methods - these include disallowing null >> elements. So I think this needs to be clarified. > > Agreed, I'll work on some clarifications here, and also disallow null > for the argument itself. > >> Minimal implementation is okay to get started but what is the reason >> not to >> include some basic tests? > > Sorry, I should have been more clear about this. The changeset is > clearly not ready to go in as it stands. I wanted to get an initial > review of the specifications going, then file a CSR request, etc. > while continuing to work on tests and better implementations. I'll > post a subsequent review when they're ready. > > Thanks. > > s'marks > From peter.levart at gmail.com Fri Sep 22 14:11:16 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 22 Sep 2017 16:11:16 +0200 Subject: Scanning multi version jars? In-Reply-To: References: <521049DD-F550-4A6C-B0BB-1FE6AED69A78@oracle.com> <7d4cddeb-4235-3a12-1ed9-cd5333275289@oracle.com> <6d8d2f5c-3aef-1c58-58cd-699dea012b90@oracle.com> <00476a40-04bc-b1b5-678f-01f0ec4a07a9@oracle.com> <7570FD98-FD63-481D-A30A-72071CDF6050@oracle.com> Message-ID: <951c84eb-30a5-14c5-5923-8ff61dd6f100@gmail.com> On 09/19/2017 09:34 AM, Alan Bateman wrote: > On 19/09/2017 05:37, Greg Wilkins wrote: >> : >> >> Which raises an interesting point....?? with the multi versioned jar >> I have >> used as an example, which contains: >> >> ??? - org/example/Foo.class >> ??? - org/example/Foo$Bar.class >> ??? - META-INF/versions/9/org/example/Foo.class >> >> What does the classloader do when asked to load "org.example.Foo$Bar" ? >> ? If it loads it OK, then the JarFile enumerator/iterator/stream >> should also >> return it.?? If it throws a ClassNotFoundException, then the >> JarFile enumerator/iterator/stream should skip it. > A class loader that loads from a JAR file will just map > "org.example.Foo$Bar" to entry "org/example/Foo$Bar.class" and attempt > to define the class bytes to VM.? It shouldn't care if the entry comes > from the base or a versioned section. It also shouldn't care if the > class name looks like it might have been compiled from an inner class. > > The one case where a custom class loader does need to know more is > when it loading resources (findResource/findResources implementation > usually). For that case then the returned URL needs to locate the > right resource and so may encode a path to a resource in a versioned > section. You'll see URLClassLoader does the right thing, as does the > built-in class loaders for cases where you have modular MR JARs on the > module path. There were a few threads on core-libs-dev discussing > whether to add a getRealName method but in the end it was kicked down > the road to re-examine later. > > -Alan Just a though, The only problem with ClassLoader API is that it doesn't have any means to enumerate all the resources it is able to resolve. If it had such API, the code for scanning would be much simpler. But how would such API look like if we know that resolving works by delegation, might work by lazily generating the resource with a particular path on the fly, etc... Perhaps simply by ignoring the delegation and lazy generation and just return a stream of resources that a particular ClassLoader instance is responsible for and are backed by real bytes in some repository which has a means of enumeration (like filesystem, jar file, etc...) Regards, Peter From claes.redestad at oracle.com Fri Sep 22 14:47:09 2017 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 22 Sep 2017 16:47:09 +0200 Subject: RFR: 8187826: Avoid using reflection to bootstrap NamedFunctions Message-ID: <21eae28d-e9c2-b613-fa75-f5e0a14e95b2@oracle.com> Hi, please review this fix to resolve MemberNames instead of going via reflection to get the Method when setting up various NamedFunctions, since this no longer appears to be necessary to break bootstrap cycles: Webrev: http://cr.openjdk.java.net/~redestad/8187826/jdk.00/ Bug: https://bugs.openjdk.java.net/browse/JDK-8187826 This avoids loading a few classes and reduces cycles taken to bootstrap indy by ~2M (1.4%) and instructions count by ~1M (0.7%) in a minimal MH-exercising test. Thanks! /Claes From mandy.chung at oracle.com Fri Sep 22 18:20:50 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 22 Sep 2017 11:20:50 -0700 Subject: Review Request JDK-8186050: StackFrame should provide the method signature In-Reply-To: References: <5ad2e4a3-3fd3-0df4-c6c4-0b9ca8068a4e@oracle.com> <1207001620.848399.1504077914483.JavaMail.zimbra@u-pem.fr> <6717ed0c-17d7-66f2-a73b-0a96b4a97998@oracle.com> <778ffb8d-14dc-e3f3-5f77-562638d6fdef@gmail.com> <4612ad06-2bae-4482-175d-3c3bfc0dab27@oracle.com> <0c59deae-ac21-8062-c3c5-c4eb270b4b98@gmail.com> <8354b7b2-baf5-a7fa-0c8c-5044d2eb024c@oracle.com> Message-ID: <701feb0b-9b8c-9c23-fedf-82bc5cf4db28@oracle.com> On 9/22/17 3:45 AM, Peter Levart wrote: > > Just two more things... > > 1st: > > I was I little confused reading this part of javadoc of getDescriptor(): > > ?152????????? * Returns the descriptor of the method type for > ?153????????? * this stack frame.? A method descriptor is a string > representing the > ?154????????? * types of parameters that the method takes, and a > return descriptor, > ?155????????? * representing the type of the value (if any) that the > method returns > ?156????????? * as defined by The Java™ Virtual Machine > Specification. > > Wouldn't it be better to say: > > ?152????????? * Returns the descriptor of the method type for > ?153????????? * this stack frame.? A method descriptor is a string > representing the > ?154????????? * types of parameters that the method takes, and the > method's return type, > > ?156????????? * as defined by The Java™ Virtual Machine > Specification. > > I think there is a slight difference between "method return type" and > "the type of value (if any) that the method returns". The former is a > property of the method, the later is a property of the returned value > (primitive or reference or none) in a particular invocation of the > method and may be different (a subtype). > I agree the slight difference you call out.? Since it's specified in JVMS 4.3.3, there is no need to include this statement in javadoc. I simply take it out.? The webrev.03 is updated in place. > > 2nd: > > I don't know in what circumstance may the MemberName.getMethodType() > or .getMethodDescriptor() return null, but the MemberName code is > written as follows: > > ?169???????? if (type == null) { > ?170???????????? expandFromVM(); > ?171???????????? if (type == null) { > ?172???????????????? return null; > ?173???????????? } > ?174???????? } > > Is there a real circumstance when this may happen? Should > StackWalker.StackFrame.getMethodType() / .getDescriptor() document > that situation or maybe transform it into an exception or error? > There is no type when this MemberName is not resolved.? For stack frame case, the methods are already resolved. Mandy > Regards, Peter > From stuart.marks at oracle.com Fri Sep 22 20:11:22 2017 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 22 Sep 2017 13:11:22 -0700 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <936c0525-8494-c0a8-f355-6eebabbc0ffb@Oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> <936c0525-8494-c0a8-f355-6eebabbc0ffb@Oracle.com> Message-ID: On 9/21/17 12:16 PM, Roger Riggs wrote: > Hi Stuart, > > The new text in Collections reads more like an @apinote than a specification. > Are there any enforceable assertions there? There probably aren't any testable assertions, but the new text does contain normative definitions. Usually this stuff appears on package docs. Unfortunately java.util is shared with other stuff unrelated to collections, so the overview material isn't there. It ended up in java.util.Collection (which is the "lead" interface of the Collections Framework) so I've added the new material there. The @apiNote tag is for non-normative (informative) material, so I don't think it's appropriate for this new material. > I think the markup used to refer to unmodifiable XXX reads better as a link in > the text (as in Collection#unmodifableCollection) > than as a second sentence (as in List#of()). > A consistent treatment in all class would be a plus. OK, I can adjust these. > The implementations of the Collectors are very inefficient, first creating a > mutable version, > then extracting to an array, and then constructing the final object. So much > garbage is created, especially for small n. Yes, these are preliminary implementations, to which many optimizations can be applied. s'marks > Thanks, Roger > > > On 9/21/2017 2:55 PM, Stuart Marks wrote: >> >> >> On 9/21/17 5:42 AM, Alan Bateman wrote: >>> On 21/09/2017 01:02, Stuart Marks wrote: >>>> http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ >>> I read through the updated/new definitions and they read well. >> >> Great. >> >>> For the copyOf methods then I can't immediately tell from the javadoc if the >>> given collection can contain null elements. Taking List.copyOf as an example >>> where coll may be null or it may contain null elements. The javadoc does link to >>> "Unmodifiable lists" where it specifies the characteristics of the lists >>> returned by the static factory methods - these include disallowing null >>> elements. So I think this needs to be clarified. >> >> Agreed, I'll work on some clarifications here, and also disallow null for the >> argument itself. >> >>> Minimal implementation is okay to get started but what is the reason not to >>> include some basic tests? >> >> Sorry, I should have been more clear about this. The changeset is clearly not >> ready to go in as it stands. I wanted to get an initial review of the >> specifications going, then file a CSR request, etc. while continuing to work >> on tests and better implementations. I'll post a subsequent review when >> they're ready. >> >> Thanks. >> >> s'marks >> > From stuart.marks at oracle.com Fri Sep 22 20:37:39 2017 From: stuart.marks at oracle.com (Stuart Marks) Date: Fri, 22 Sep 2017 13:37:39 -0700 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> Message-ID: <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> On 9/22/17 5:36 AM, Roger Riggs wrote: > Hi Stuart, > > I'm cautious about doing work piecemeal toward immutable collections. > The current unmodifiable approach only gives partial protection to the caller > and none to the callee. The assertions it makes are too weak to be useful. I'm not entirely sure what you're driving at here. Looking at this again, I can see at least one place that should be strengthened. In List.copyOf, something like this should be added: Any modifications to the given Collection are not reflected in the returned List. (And similar for Set.copyOf and Map.copyOf.) Are there other assertions that should be added or strengthened? > I think more value can be achieved by creating concrete final immutable collections > that applications can use to be certain that the semantics of the collection > are immutable. They can implement the current interfaces but would be compile time > knowable of the complete semantics of mutability. Then a good bridge between > the current streams (and collections) would be methods that return the concrete > final collections. It would add some value to have concrete, "immutable" collection classes exposed. Presumably though these would implement the List/Set/Map interfaces. As instances get passed around, the "immutable" part would get "cast" away, limiting the value added. There is a large design space here (see Guava and Eclipse Collections, among others that have this concept of "immutability). They're certainly interesting, but I haven't yet seen an approach that is clearly better than the current approach of keeping the implementation classes completely hidden. > BTW, I don't think many people are confused by 'immutable' collections appearing > to be mutated because one of the objects in the collection is mutable. I'm sure *you* aren't confused by the issues. But I spend a lot of effort explaining these issues to the general public, so I think the change is worthwhile. s'marks > Thanks, Roger > > > On 9/21/2017 2:55 PM, Stuart Marks wrote: >> >> >> On 9/21/17 5:42 AM, Alan Bateman wrote: >>> On 21/09/2017 01:02, Stuart Marks wrote: >>>> http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ >>> I read through the updated/new definitions and they read well. >> >> Great. >> >>> For the copyOf methods then I can't immediately tell from the javadoc if the >>> given collection can contain null elements. Taking List.copyOf as an example >>> where coll may be null or it may contain null elements. The javadoc does link to >>> "Unmodifiable lists" where it specifies the characteristics of the lists >>> returned by the static factory methods - these include disallowing null >>> elements. So I think this needs to be clarified. >> >> Agreed, I'll work on some clarifications here, and also disallow null for the >> argument itself. >> >>> Minimal implementation is okay to get started but what is the reason not to >>> include some basic tests? >> >> Sorry, I should have been more clear about this. The changeset is clearly not >> ready to go in as it stands. I wanted to get an initial review of the >> specifications going, then file a CSR request, etc. while continuing to work >> on tests and better implementations. I'll post a subsequent review when >> they're ready. >> >> Thanks. >> >> s'marks >> > From mandy.chung at oracle.com Fri Sep 22 22:18:20 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 22 Sep 2017 15:18:20 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library Message-ID: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> This patch proposes to replace the ClassLoader use of finalizer with phantom reference, specifically Cleaner, for unloading native libraries.? It registers the class loader for cleanup only if it's not a builtin class loader which will never be unloaded. The spec for JNI_OnUnload [1] specifies that this function is called in an unknown context whereas the hotspot implementation uses the class loader being unloaded as the context, which I consider a bug.?? It should not load a class defined to that class loader.? The proposed spec change for JNI_FindClass if called from JNI_OnUnload to use system class loader (consistent with no caller context case). Webrev: http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8164512/webrev.00/ CSR: ?? https://bugs.openjdk.java.net/browse/JDK-8187882 Please see the spec change an behavioral change in this CSR.? A native library may fail to be reloaded if it is loaded immediately or soon after a class loader is GC'ed but the cleaner thread doesn't yet have the chance to handle the unloading of the native library.? Likewise, there is no guarantee regarding the timing of finalization and a native library may fail to reload.? It's believed that the compatibility risk should be low. I'm looking into adding a native jtreg test that will be added in the next revision. Mandy [1] http://docs.oracle.com/javase/9/docs/specs/jni/invocation.html#jni_onunload From martinrb at google.com Sun Sep 24 20:26:50 2017 From: martinrb at google.com (Martin Buchholz) Date: Sun, 24 Sep 2017 13:26:50 -0700 Subject: [PATCH] Enhancement proposal for TimSort and ComparableTimSort In-Reply-To: <225231505468941@web59g.yandex.ru> References: <225231505468941@web59g.yandex.ru> Message-ID: One learns to be sceptical of such special cases. Especially when so much effort was put into optimizing the original code. if (nRemaining < 2) return; // Arrays of size 0 and 1 are always sorted + //when array's size is 2 we just need to swap items + //if the first item is greater than the second one + if (nRemaining == 2) { If you're going to have a fastpath for small arrays, it should probably start with nRemaining <= 2 instead of nRemaining < 2 to avoid slowing down the normal path. On Fri, Sep 15, 2017 at 2:49 AM, ?????? ??????? wrote: > Current implementations of TimSort and ComparableTimSort both have fast > path for the case when the size of array = 1 i.e. such array is considered > to be sorted. > > My proposal is to add similar fast path for the case when the size of the > array = 2. In this case it's enough to check if the first item is greater > than the second one and swap them. > Otherwise array is considered to be sorted. > > I have attached the patch to this mail. > > As for performance I have measured array sort with size = 2 using > JDK-provided and patched implementations of TimSort and ComparableTimSort > both execution time and throughput in two environments: > > 1) Intel Core i5-4690 3,50 GHz > 2) Intel Core i3-3220 3,30 GHz > > On both environments I have Java version "1.8.0_144" > Java(TM) SE Runtime Environment (build 1.8.0_144-b01) > Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) > > Measurement results are > > 1) > > Benchmark Mode > Cnt Score Error Units > > SortingBenchmark.measureConventionalSort avgt 500 17,692 ? 0,040 > ns/op > SortingBenchmark.measureEnhancedSort avgt 500 13,206 ? 0,025 > ns/op > > SortingBenchmark.measureConventionalSort thrpt 500 56,962 ? 0,051 > ops/us > SortingBenchmark.measureEnhancedSort thrpt 500 72,278 ? 0,724 > ops/us > > 2) > > Benchmark Mode > Cnt Score Error Units > > SortingBenchmark.measureConventionalSort avgt 500 26,173 ? 0,251 > ns/op > SortingBenchmark.measureEnhancedSort avgt 500 18,191 ? 0,106 > ns/op > > SortingBenchmark.measureConventionalSort thrpt 500 36,987 ? 0,437 > ops/us > SortingBenchmark.measureEnhancedSort thrpt 500 53,499 ? 0,456 > ops/us > > So in both cases patched implementation demonstrates better throughput and > execution time for the case array.lenght = 2. > > Regards, > Sergei Tsypanov From chris.hegarty at oracle.com Sun Sep 24 20:27:32 2017 From: chris.hegarty at oracle.com (Chris Hegarty) Date: Sun, 24 Sep 2017 21:27:32 +0100 Subject: RFR 8145635 : Add TCP_QUICKACK socket option In-Reply-To: <0b0989b5-c791-a476-a82f-6c686b19c9d3@oracle.com> References: <56CD74E1.60309@oracle.com> <56CD7C0A.2080402@oracle.com> <0b0989b5-c791-a476-a82f-6c686b19c9d3@oracle.com> Message-ID: <54CDCFD4-97F5-480C-A4D9-03CEA58803B5@oracle.com> Vyom, > On 11 Sep 2017, at 16:38, vyom tewari wrote: > > Hi All, > > As jdk.net API already moved out of java.base, Please review the below code change for jdk10. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8145635 > Webrev: http://cr.openjdk.java.net/~vtewari/8145635/webrev0.1/index.html > This looks quite good. Some comments: 1) I wonder if we should just call the option TCP_QUICKACK, rather than SO_QUICKACK? Similar to TCP_NODELAY. 2) I think LinuxSocketOptions.h is largely unnecessary, if we do 1) above. 3) Java_jdk_net_LinuxSocketOptions_getQuickAck could return jint, rather than jobject, thus avoiding the need for createBoolean. The conversation can happen in the Java layer. Can you please reduce the lint length in this file, by wrapping similar to the style of the Solaris version. 4) ExtendedSocketOptions.java - drop the

, they are unnecessary. - I think, similar to TCP_NODELAY, the spec should say that the options is TCP specific. From TCP_NODELAY: "The socket option is specific to stream-oriented sockets using the TCP/IP protocol.? - "In TCP_QUICKACK mode?, maybe ?When the option is enabled?? -Chris. From david.holmes at oracle.com Sun Sep 24 20:56:56 2017 From: david.holmes at oracle.com (David Holmes) Date: Mon, 25 Sep 2017 06:56:56 +1000 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> Message-ID: <6619f002-fdf4-68da-a2f4-ae38a6f61617@oracle.com> On 23/09/2017 6:37 AM, Stuart Marks wrote: > On 9/22/17 5:36 AM, Roger Riggs wrote: >> BTW, I don't think many people are confused by 'immutable' collections >> appearing >> to be mutated because one of the objects in the collection is mutable. > > I'm sure *you* aren't confused by the issues. But I spend a lot of > effort explaining these issues to the general public, so I think the > change is worthwhile. I agree with Roger. This seems to conflate immutability of the collection with immutability of the elements in the collection. I don't see a definition of mutability/immutability that would imply that an immutable collection must have immutable elements. To me the notion of mutability is for the collection itself - the group of objects contained - not the objects themselves. Have I missed this definition of "immutable" somewhere? Otherwise it might be clearer to explain that an "immutable collection" may have different meanings to different people. I also find the use of "As above" in this sentence: "As above, an unmodifiable view collection is not necessarily immutable." inappropriate, because "above" you are referring to the mutability of the elements of the collection and in the current context you are referring to the mutability of the collection itself. And this is quite a different issue to the one "above". Cheers, David > s'marks > >> Thanks, Roger >> >> >> On 9/21/2017 2:55 PM, Stuart Marks wrote: >>> >>> >>> On 9/21/17 5:42 AM, Alan Bateman wrote: >>>> On 21/09/2017 01:02, Stuart Marks wrote: >>>>> http://cr.openjdk.java.net/~smarks/reviews/8177290/webrev.0/ >>>> I read through the updated/new definitions and they read well. >>> >>> Great. >>> >>>> For the copyOf methods then I can't immediately tell from the >>>> javadoc if the >>>> given collection can contain null elements. Taking List.copyOf as an >>>> example >>>> where coll may be null or it may contain null elements. The javadoc >>>> does link to >>>> "Unmodifiable lists" where it specifies the characteristics of the >>>> lists >>>> returned by the static factory methods - these include disallowing null >>>> elements. So I think this needs to be clarified. >>> >>> Agreed, I'll work on some clarifications here, and also disallow null >>> for the >>> argument itself. >>> >>>> Minimal implementation is okay to get started but what is the reason >>>> not to >>>> include some basic tests? >>> >>> Sorry, I should have been more clear about this. The changeset is >>> clearly not >>> ready to go in as it stands. I wanted to get an initial review of the >>> specifications going, then file a CSR request, etc. while continuing >>> to work >>> on tests and better implementations. I'll post a subsequent review when >>> they're ready. >>> >>> Thanks. >>> >>> s'marks >>> >> From scolebourne at joda.org Mon Sep 25 10:36:20 2017 From: scolebourne at joda.org (Stephen Colebourne) Date: Mon, 25 Sep 2017 11:36:20 +0100 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> Message-ID: On 22 September 2017 at 21:37, Stuart Marks wrote: > On 9/22/17 5:36 AM, Roger Riggs wrote: >> I think more value can be achieved by creating concrete final immutable >> collections >> that applications can use to be certain that the semantics of the >> collection >> are immutable. They can implement the current interfaces but would be >> compile time >> knowable of the complete semantics of mutability. Then a good bridge >> between >> the current streams (and collections) would be methods that return the >> concrete >> final collections. > > It would add some value to have concrete, "immutable" collection classes > exposed. Presumably though these would implement the List/Set/Map > interfaces. As instances get passed around, the "immutable" part would get > "cast" away, limiting the value added. > > There is a large design space here (see Guava and Eclipse Collections, among > others that have this concept of "immutability). They're certainly > interesting, but I haven't yet seen an approach that is clearly better than > the current approach of keeping the implementation classes completely > hidden. Like Roger, I am cautious about this design space. We use Guava's Immutable* collection classes everywhere because we want to clearly assert the immutable nature. But it is a risk, because Guava does change its API more than most, and we are limited to the concrete classes that they provide. There is no ImmutableList.nCopies() for example. What we really need however is immutability as a language feature, where an immutable collection can be an interface, and it can assert that only other immutable classes can be contained. Since we are a long way from this, it seems reasonable to make the change outlined in the webrev. It also seems reasonable to use the term "unmodifiable" not "immutable" to leave "immutable free for the future. I think it is unfortunate that we have List.of(E...), as it would have been better to have List.copyOf(E[]) alongside List.copyOf(Collection). While I know Iterable is out of fashion, it would be an appropriate choice here to make the method as widely applicable as possible. Stephen From Roger.Riggs at Oracle.com Mon Sep 25 13:38:56 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Mon, 25 Sep 2017 09:38:56 -0400 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> Message-ID: <2aa477d6-50fb-bc4c-1740-49168d1ead6e@Oracle.com> Hi Stuart, On 9/22/2017 4:37 PM, Stuart Marks wrote: > > > On 9/22/17 5:36 AM, Roger Riggs wrote: >> Hi Stuart, >> >> I'm cautious about doing work piecemeal toward immutable collections. >> The current unmodifiable approach only gives partial protection to >> the caller >> and none to the callee. The assertions it makes are too weak to be >> useful. > > I'm not entirely sure what you're driving at here. Looking at this > again, I can see at least one place that should be strengthened. In > List.copyOf, something like this should be added: > > ??? Any modifications to the given Collection are not reflected in the > ??? returned List. > > (And similar for Set.copyOf and Map.copyOf.) > > Are there other assertions that should be added or strengthened? > >> I think more value can be achieved by creating concrete final >> immutable collections >> that applications can use to be certain that the semantics of the >> collection >> are immutable. They can implement the current interfaces but would be >> compile time >> knowable of the complete semantics of mutability.? Then a good bridge >> between >> the current streams (and collections) would be methods that return >> the concrete >> final collections. > > It would add some value to have concrete, "immutable" collection > classes exposed. Presumably though these would implement the > List/Set/Map interfaces. As instances get passed around, the > "immutable" part would get "cast" away, limiting the value added. What it enables, is writing a library or implementation in which the immutable never gets cast away. The concrete immutable types would be the *only* types used in the interface to the library. If desired a library might provide convenience functions that accept loosely typed lists/maps/sets and makes copies to effect the assertions. Any objects returned would be the concrete immutable types and callers could rely upon the full semantics. I'm suggesting caution now, because if such immutable types become part of SE then the new methods you are adding should be returning the concrete immutable types and not the current interfaces with no assertions about immutability.? Adding additional methods with similar names later to return immutable instances will be redundant and create their own kind of confusion. Roger From paul.sandoz at oracle.com Mon Sep 25 15:43:52 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Mon, 25 Sep 2017 08:43:52 -0700 Subject: RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map In-Reply-To: References: <728d0159-e735-17a5-a158-88957e174b85@oracle.com> <2973464f-0ed7-fcb3-bc4c-c06d4ea61057@oracle.com> <2ec4e2f9-863b-5a85-7638-56df6958c741@oracle.com> <2b28ac48-f16a-3854-3abb-ea19838fe7e0@oracle.com> Message-ID: <44BE3EBF-EC90-48B5-B4B2-85B790A7DC0A@oracle.com> > On 25 Sep 2017, at 03:36, Stephen Colebourne wrote: > > What we really need however is immutability as a language feature, > where an immutable collection can be an interface, and it can assert > that only other immutable classes can be contained. Since we are a > long way from this, Yes, and even a long way from getting immutable collections that make no guarantees on the mutability of their elements. (Note that even if immutable collections exist there is a notion of building up such a collection mutably in a confined manner after which it is frozen and published in its immutable form.) > it seems reasonable to make the change outlined in > the webrev. It also seems reasonable to use the term "unmodifiable" > not "immutable" to leave "immutable free for the future. > +1 I was gonna say much the same thing. The notion of unmodifiable can be improved independently of anything that may be done in the future regarding immutable collections (including say persistent collections). Improving the ?old? mutable world is still beneficial even if there will be some future ?new? immutable collection world (independent of the mutability of the elements) as we will need bridges between the two. Pail. From ivan.gerasimov at oracle.com Mon Sep 25 17:49:07 2017 From: ivan.gerasimov at oracle.com (Ivan Gerasimov) Date: Mon, 25 Sep 2017 10:49:07 -0700 Subject: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator In-Reply-To: <37e162ca-bf08-9211-afce-7fbd85484208@oracle.com> References: <92ca3601-f228-026a-8378-16c331ab9cb5@oracle.com> <08f39675-ba33-70f6-7f35-467569825989@oracle.com> <37e162ca-bf08-9211-afce-7fbd85484208@oracle.com> Message-ID: Hello! Could you please review at your convenience? In the latest webrev I took all suggestions into account (unless I missed something.) http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ I think, if the suggested comparator is found useful by the users, then it may make sense to create the String-oriented variant, which can be implemented through the CharSequence-oriented one as: class String { ... @SuppressWarnings("unchecked") public static Comparator comparingAlphaDecimal(Comparator alphaComparator) { return (Comparator) (Comparator) new Comparators.AlphaDecimalComparator<>(Objects.requireNonNull( (Comparator) alphaComparator), false); } } This will be safe, since the specification guarantees that String.subSequence() returns a String. Then in the application code it would be possible to instantiate the comparators as String.comparingAlphaDecimal(String::compareTo); String.comparingAlphaDecimal(String::compareToIgnoreCase); or, alternatively, String.comparingAlphaDecimal(Comparator.naturalOrder()); String.comparingAlphaDecimal(String.CASE_INSENSITIVE_ORDER); But this could be deferred for later, of course. With kind regards, Ivan On 8/27/17 1:38 PM, Ivan Gerasimov wrote: > Hello everyone! > > Here's another iteration of the comparator with suggested improvements. > > Now, there is the only input argument -- the alpha-comparator for > comparing the non-decimal-digit sub-sequences. > > For the javadoc I used the text suggested by Peter with some > modifications, additional example and API/implementation notes. > Overall, the javadoc looks heavier than need to me, so I'd love to > hear comments about how to make it shorter and cleaner. > > Also, I adopted the name AlphaDecimal, suggested by Peter. This name > is one of popular in the list of variants found in the wild. So, there > are higher chances the users can find the routine by its name. > > For testing if a code point is a decimal digit, I used > (Character.getType(cp) == Character.DECIMAL_DIGIT_NUMBER), which seem > to be more appropriate than Character.isDigit(). (The later is true > for things like a digit in a circle, superscript, etc., which do not > seem to be a part of a decimal number composed of several digits.) > > The updated webrev: > http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ > > Please review at your convenience. > > With kind regards, > Ivan > > On 8/9/17 4:59 PM, Stuart Marks wrote: >> On 8/1/17 11:56 PM, Ivan Gerasimov wrote: >>> I've tried to go one step further and created even more abstract >>> comparator: It >>> uses a supplied predicate to decompose the input sequences into >>> odd/even >>> subsequences (e.g. alpha/numeric) and then uses two separate >>> comparator to >>> compare them. Additionally, a comparator for comparing sequences, >>> consisting >>> only of digits is provided. For example, to build a case-insensitive >>> AlphaDecimal comparator one could use: 1) Character::isDigit -- as >>> the predicate >>> for decomposing, 2) String::compareToIgnoreCase -- to compare alpha >>> (i.e. odd >>> parts); to work with CharSequences one would need to make it >>> Comparator.comparing(CharSequence::toString, >>> String::compareToIgnoreCase), 3) >>> The special decimal-only comparator, which compares the decimal >>> representation >>> of the sequences. Here's the file with all the comparators and a >>> simple test: >>> http://cr.openjdk.java.net/~igerasim/8134512/test/Test.java >> >> Hi, a couple follow-up thoughts on this. >> >> 1) Supplementary characters >> >> The current code uses Character.isDigit(char), which works only for >> char values in the BMP (basic multilingual plane, values <= U+FFFF). >> It won't work for supplementary characters. There are several blocks >> of digits in the BMP, but there are several more in the supplementary >> character range. >> >> I don't see any reason not to handle the supplementary characters as >> well, except that it spoils the nice char-by-char technique of >> processing the string. Instead, it'd have to pull in code point >> values, which might be comprised of two surrogate chars. There are a >> variety of methods on Character that help with this. Note that there >> is an overload Character.isDigit(int) which takes any code point >> value, including supplementary characters. >> >> 2) Too much generality? >> >> This version includes Predicate for determining whether a >> character is part of the alphabetic or decimal portion of the string. >> I'm thinking this might be overkill. It might be sufficient to >> "hardwire" the partitioning predicate to be Character::isDigit and >> the value mapping function to use Character::digit. >> >> The problem is that adding a predicate opens the door to a lot more >> complexity, while providing dimishing value. First, the predicate >> would have to handle code points (per the above) so it'd need to be >> an IntPredicate. Second, there would also need to be a mapping >> function from the code point value to a numeric value. This might be >> an IntUnaryOperator. This would allow someone to sort based on Roman >> numerals, using Character::getNumericValue. (Yes, Roman numerals are >> in Unicode.) Or maybe the mapping function should return any >> Comparable value, not an int. ... See where I'm going here? >> >> Since this kind of sorting is intended to be viewed by people, it's >> probably worth providing full internationalization support >> (supplementary characters, and delegation to sub-comparators, to >> allow locale-specific collating sequences). But I start to question >> any complexity beyond that. >> >> s'marks >> > -- With kind regards, Ivan Gerasimov From brent.christian at oracle.com Mon Sep 25 23:02:49 2017 From: brent.christian at oracle.com (Brent Christian) Date: Mon, 25 Sep 2017 16:02:49 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> Message-ID: <23a23d63-0056-126f-4736-4a61d75b16b4@oracle.com> Hi, Mandy The changes look alright to me. One thing that I noticed: ClassLoader.NativeLibrary.register() writes to 'loadedLibraryNames', 'nativeLibraries', and 'systemNativeLibraries' without first synchronizing on them. There is not a bug here per se, as register() is called from inside the needed synchronized blocks in loadLibrary0(). But perhaps it's worth a comment to call out that this is what is happening? Thanks, -Brent On 9/22/17 3:18 PM, mandy chung wrote: > This patch proposes to replace the ClassLoader use of finalizer with > phantom reference, specifically Cleaner, for unloading native > libraries.? It registers the class loader for cleanup only if it's not a > builtin class loader which will never be unloaded. > > The spec for JNI_OnUnload [1] specifies that this function is called in > an unknown context whereas the hotspot implementation uses the class > loader being unloaded as the context, which I consider a bug.?? It > should not load a class defined to that class loader.? The proposed spec > change for JNI_FindClass if called from JNI_OnUnload to use system class > loader (consistent with no caller context case). > > Webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8164512/webrev.00/ > > CSR: > ?? https://bugs.openjdk.java.net/browse/JDK-8187882 > > Please see the spec change an behavioral change in this CSR.? A native > library may fail to be reloaded if it is loaded immediately or soon > after a class loader is GC'ed but the cleaner thread doesn't yet have > the chance to handle the unloading of the native library.? Likewise, > there is no guarantee regarding the timing of finalization and a native > library may fail to reload.? It's believed that the compatibility risk > should be low. > > I'm looking into adding a native jtreg test that will be added in the > next revision. > > Mandy > [1] > http://docs.oracle.com/javase/9/docs/specs/jni/invocation.html#jni_onunload From kim.barrett at oracle.com Tue Sep 26 06:37:20 2017 From: kim.barrett at oracle.com (Kim Barrett) Date: Tue, 26 Sep 2017 02:37:20 -0400 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> Message-ID: > On Sep 22, 2017, at 6:18 PM, mandy chung wrote: > > This patch proposes to replace the ClassLoader use of finalizer with phantom reference, specifically Cleaner, for unloading native libraries. It registers the class loader for cleanup only if it's not a builtin class loader which will never be unloaded. > > The spec for JNI_OnUnload [1] specifies that this function is called in an unknown context whereas the hotspot implementation uses the class loader being unloaded as the context, which I consider a bug. It should not load a class defined to that class loader. The proposed spec change for JNI_FindClass if called from JNI_OnUnload to use system class loader (consistent with no caller context case). > > Webrev: > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8164512/webrev.00/ > > CSR: > https://bugs.openjdk.java.net/browse/JDK-8187882 > > Please see the spec change an behavioral change in this CSR. A native library may fail to be reloaded if it is loaded immediately or soon after a class loader is GC'ed but the cleaner thread doesn't yet have the chance to handle the unloading of the native library. Likewise, there is no guarantee regarding the timing of finalization and a native library may fail to reload. It's believed that the compatibility risk should be low. > > I'm looking into adding a native jtreg test that will be added in the next revision. > > Mandy > [1] http://docs.oracle.com/javase/9/docs/specs/jni/invocation.html#jni_onunload Thanks for dealing with this. ============================================================================== src/java.base/share/native/libjava/ClassLoader.c 415 Java_java_lang_ClassLoader_00024NativeLibrary_00024Unloader_unload 416 (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin, jlong address) With this change, the "this" argument is no longer used. Because of this, the native function could be a static member function of the new Unloader class, or could (I think) still be a (now static) member function of NativeLibrary. The latter would not require a name change, only a signature change. But I don't really care which class has the method. ============================================================================== src/java.base/share/classes/java/lang/ClassLoader.java 2394 public void register() { [...] 2406 // register the class loader for cleanup when unloaded 2407 if (loader != getBuiltinPlatformClassLoader() && 2408 loader != getBuiltinAppClassLoader()) { 2409 CleanerFactory.cleaner() 2410 .register(loader, new Unloader(name, handle, isBuiltin)); 2411 } Can anything before the cleanup registration throw? If so, do we leak because we haven't registered the cleanup yet? And what if the registration itself fails to complete? ============================================================================== src/hotspot/share/prims/jni.cpp 405 // Special handling to make sure JNI_OnLoad are executed in the correct class context. s/are executed/is executed/ ============================================================================== From david.holmes at oracle.com Tue Sep 26 11:01:16 2017 From: david.holmes at oracle.com (David Holmes) Date: Tue, 26 Sep 2017 21:01:16 +1000 Subject: Xbootclasspath/a adds CWD to boot class path In-Reply-To: References: Message-ID: <4d3b4b8a-3e6d-90be-a6da-56b8365597d4@oracle.com> Hi Michael, Moving over to core-libs-dev. The discussion in 8185540 is a bit confusing to me. David On 26/09/2017 8:45 PM, Michael Rasmussen wrote: > Hi > > We have discovered an issue with using -Xbootclasspath/a on Java 9. > if you add -Xbootclasspath/a as JVM argument, the current working directory > also gets added to boot class path! > > take the following Test.java class: > import java.util.Collections; > public class Test { > public static void main(String[] args) throws Throwable { > System.out.println(Collections.list( > ClassLoader.getPlatformClassLoader().getResources("foo.txt"))); > } > } > > $ java -fullversion > openjdk full version "9+181" > $ javac Test.java > $ pwd > /home/michael/test > $ touch foo.txt > $ touch /tmp/foo.txt > $ java Test > [] > $ java -Xbootclasspath/a:/tmp Test > [file:/home/michael/test/foo.txt, file:/tmp/foo.txt] > > As the above shows, adding the -Xbootclasspath/a, also added the current > working directory to the boot class path. Using a new ClassLoader(null){} > instead of the platform class loader gives the same result. > > A bit of digging shows that "jdk.boot.class.path.append" system property > contains a leading path-separator char, like ":/tmp" (";C:/tmp" on Win), > meaning in jdk.internal.loader.ClassLoaders., when that string > is converted to a classpath, the empty first part gets parsed as cwd. > > I assume this is not the intended behavior of -Xbootclasspath/a, as the > same thing doesn't happen on Java 8, also it's not documented as such. > > I found some related issues in Jira, such as JDK-8185540, that seems > to remedy this, but it's still weird that the JVM adds the empty path > element to begin with. > > Kind regards, > Michael Rasmussen > From david.holmes at oracle.com Tue Sep 26 11:18:46 2017 From: david.holmes at oracle.com (David Holmes) Date: Tue, 26 Sep 2017 21:18:46 +1000 Subject: Xbootclasspath/a adds CWD to boot class path In-Reply-To: <4d3b4b8a-3e6d-90be-a6da-56b8365597d4@oracle.com> References: <4d3b4b8a-3e6d-90be-a6da-56b8365597d4@oracle.com> Message-ID: Hi Michael, On 26/09/2017 9:01 PM, David Holmes wrote: > Hi Michael, > > Moving over to core-libs-dev. > > The discussion in 8185540 is a bit confusing to me. I've re-read the discussion and related bugs. As I understand it what you see now is expected and reflects what happens in 7 and 8. What should see is that the empty path elements causes CWD to be included for resource lookup, but not for class lookup. That inconsistency was flagged for fixing in 7, deferred to 9, rectified early on, but then reverted when the module system was integrated - with the eventual fix re-appearing in JDK 10. Cheers, David > David > > On 26/09/2017 8:45 PM, Michael Rasmussen wrote: >> Hi >> >> We have discovered an issue with using -Xbootclasspath/a on Java 9. >> if you add -Xbootclasspath/a as JVM argument, the current working >> directory >> also gets added to boot class path! >> >> take the following Test.java class: >> import java.util.Collections; >> public class Test { >> ?? public static void main(String[] args) throws Throwable { >> ???? System.out.println(Collections.list( >> ?????? ClassLoader.getPlatformClassLoader().getResources("foo.txt"))); >> ?? } >> } >> >> $ java -fullversion >> openjdk full version "9+181" >> $ javac Test.java >> $ pwd >> /home/michael/test >> $ touch foo.txt >> $ touch /tmp/foo.txt >> $ java Test >> [] >> $ java -Xbootclasspath/a:/tmp Test >> [file:/home/michael/test/foo.txt, file:/tmp/foo.txt] >> >> As the above shows, adding the -Xbootclasspath/a, also added the current >> working directory to the boot class path. Using a new ClassLoader(null){} >> instead of the platform class loader gives the same result. >> >> A bit of digging shows that "jdk.boot.class.path.append" system property >> contains a leading path-separator char, like ":/tmp" (";C:/tmp" on Win), >> meaning in jdk.internal.loader.ClassLoaders., when that string >> is converted to a classpath, the empty first part gets parsed as cwd. >> >> I assume this is not the intended behavior of -Xbootclasspath/a, as the >> same thing doesn't happen on Java 8, also it's not documented as such. >> >> I found some related issues in Jira, such as JDK-8185540, that seems >> to remedy this, but it's still weird that the JVM adds the empty path >> element to begin with. >> >> Kind regards, >> Michael Rasmussen >> From michael.rasmussen at zeroturnaround.com Tue Sep 26 11:49:47 2017 From: michael.rasmussen at zeroturnaround.com (Michael Rasmussen) Date: Tue, 26 Sep 2017 14:49:47 +0300 Subject: Xbootclasspath/a adds CWD to boot class path In-Reply-To: References: <4d3b4b8a-3e6d-90be-a6da-56b8365597d4@oracle.com> Message-ID: On 26 September 2017 at 14:18, David Holmes wrote: > Hi Michael, > > On 26/09/2017 9:01 PM, David Holmes wrote: > >> Hi Michael, >> >> Moving over to core-libs-dev. >> >> The discussion in 8185540 is a bit confusing to me. >> > > I've re-read the discussion and related bugs. As I understand it what you > see now is expected and reflects what happens in 7 and 8. What should see > is that the empty path elements causes CWD to be included for resource > lookup, but not for class lookup. That inconsistency was flagged for fixing > in 7, deferred to 9, rectified early on, but then reverted when the module > system was integrated - with the eventual fix re-appearing in JDK 10. > No, running similar code on Java 8 (using new ClassLoader(null){} instead of platform classloader), yields only the resource found in /tmp, not the one in CWD: $ java -version java version "1.8.0_144" $ java -Xbootclasspath/a:/tmp Test [file:/tmp/foo.txt] The issue I wrote about is that that adding *any* -Xbootclasspath/a on Java 9 will also add an empty path element (thus add CWD). The case I linked was somewhat related, in that it inadvertently fixes this issue (by removing all empty path elements, regardless of origin). /Michael From Alan.Bateman at oracle.com Tue Sep 26 12:01:35 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Tue, 26 Sep 2017 13:01:35 +0100 Subject: Xbootclasspath/a adds CWD to boot class path In-Reply-To: References: <4d3b4b8a-3e6d-90be-a6da-56b8365597d4@oracle.com> Message-ID: <59902cc5-0c35-92a9-9151-7edf93cb6a5b@oracle.com> On 26/09/2017 12:18, David Holmes wrote: > > I've re-read the discussion and related bugs. As I understand it what > you see now is expected and reflects what happens in 7 and 8. What > should see is that the empty path elements causes CWD to be included > for resource lookup, but not for class lookup. That inconsistency was > flagged for fixing in 7, deferred to 9, rectified early on, but then > reverted when the module system was integrated - with the eventual fix > re-appearing in JDK 10. Right except there is a small regression in JDK 9 where the boot loader will locate resources in the working directory when using -Xbootclasspath/a. It's fixed in jdk10/master and Mandy had added a good set of tests via JDK-8185541 to ensure that inconsistencies going come back. -Alan From mandy.chung at oracle.com Tue Sep 26 17:27:18 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 26 Sep 2017 10:27:18 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> Message-ID: <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> On 9/25/17 11:37 PM, Kim Barrett wrote: > Thanks for dealing with this. I'm all for eliminating the finalizers in the JDK.? Looking forward to having a finalizer-free JDK. > ============================================================================== > src/java.base/share/native/libjava/ClassLoader.c > 415 Java_java_lang_ClassLoader_00024NativeLibrary_00024Unloader_unload > 416 (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin, jlong address) > > With this change, the "this" argument is no longer used. > > Because of this, the native function could be a static member function > of the new Unloader class, or could (I think) still be a (now static) > member function of NativeLibrary. The latter would not require a name > change, only a signature change. But I don't really care which class > has the method. Yes it can be a static method. > ============================================================================== > src/java.base/share/classes/java/lang/ClassLoader.java > 2394 public void register() { > [...] > 2406 // register the class loader for cleanup when unloaded > 2407 if (loader != getBuiltinPlatformClassLoader() && > 2408 loader != getBuiltinAppClassLoader()) { > 2409 CleanerFactory.cleaner() > 2410 .register(loader, new Unloader(name, handle, isBuiltin)); > 2411 } > > Can anything before the cleanup registration throw? No within the register method.? The builtin loaders are created early during startup.? I shall make sure that System::loadLibrary is not called during init phase 1. > If so, do we leak > because we haven't registered the cleanup yet? And what if the > registration itself fails to complete? If Cleaner::register fails, it should throw an exception. Otherwise, the registration should complete. > ============================================================================== > src/hotspot/share/prims/jni.cpp > 405 // Special handling to make sure JNI_OnLoad are executed in the correct class context. > > s/are executed/is executed/ > Will fix it. I'm considering to separate the JNI_FindClass change to target 18.3 and provide a flag to restore the current behavior so that it may help existing code to identify its dependency on the current behavior and give time to migrate.? Then target the finalizer to Cleaner change in 18.9. It's unknown to us how many existing native libraries are impacted by this change (calling FindClass from JNI_OnUnload to load classes visible the class loader being unloaded). ? I suspect it's rare. If FindClass is called when the native library is being unloaded and fail to find the class due to this change, it is not hard to find out but the code might crash if it does not handle the class not found case properly. Any opinion? Mandy From paul.sandoz at oracle.com Tue Sep 26 19:12:55 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 26 Sep 2017 12:12:55 -0700 Subject: RFR: 8187826: Avoid using reflection to bootstrap NamedFunctions In-Reply-To: <21eae28d-e9c2-b613-fa75-f5e0a14e95b2@oracle.com> References: <21eae28d-e9c2-b613-fa75-f5e0a14e95b2@oracle.com> Message-ID: <4790A47E-F44E-4EFF-AF35-5BEB1B6C369E@oracle.com> > On 22 Sep 2017, at 07:47, Claes Redestad wrote: > > Hi, > > please review this fix to resolve MemberNames instead of > going via reflection to get the Method when setting up > various NamedFunctions, since this no longer appears to be > necessary to break bootstrap cycles: > > Webrev: http://cr.openjdk.java.net/~redestad/8187826/jdk.00/ > Bug: https://bugs.openjdk.java.net/browse/JDK-8187826 > > This avoids loading a few classes and reduces cycles taken > to bootstrap indy by ~2M (1.4%) and instructions count by > ~1M (0.7%) in a minimal MH-exercising test. > +1 Paul. From mandy.chung at oracle.com Tue Sep 26 20:13:44 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 26 Sep 2017 13:13:44 -0700 Subject: Review Request: JDK-6373396: (cl spec) clarify spec of ClassLoader.getPackages() about run-time package Message-ID: <902c2df2-c8ae-fd8e-f830-8be4e1b8d86c@oracle.com> Minor update to the spec of ClassLoader::getPackages and other relevant methods to clarify that the Package(s) are the packages that *have been* defined.? Also include a link to JVMS 5.3 about run-time packages, as in Package class spec. http://cr.openjdk.java.net/~mchung/jdk10/webrevs/6373396/webrev.00/ Mandy From kim.barrett at oracle.com Tue Sep 26 21:20:19 2017 From: kim.barrett at oracle.com (Kim Barrett) Date: Tue, 26 Sep 2017 17:20:19 -0400 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> Message-ID: <69E59AD1-DA51-425F-BD63-574933243F90@oracle.com> > On Sep 26, 2017, at 1:27 PM, mandy chung wrote: > On 9/25/17 11:37 PM, Kim Barrett wrote: >> src/java.base/share/classes/java/lang/ClassLoader.java >> 2394 public void register() { >> [...] >> 2406 // register the class loader for cleanup when unloaded >> 2407 if (loader != getBuiltinPlatformClassLoader() && >> 2408 loader != getBuiltinAppClassLoader()) { >> 2409 CleanerFactory.cleaner() >> 2410 .register(loader, new Unloader(name, handle, isBuiltin)); >> 2411 } >> >> Can anything before the cleanup registration throw? > > No within the register method. I think there are some opportunities for OOME, but I think no worse than before. And the result would be a loaded library without the unload registration, which seems like it might perhaps be annoying but probably not fatal. > I'm considering to separate the JNI_FindClass change to target 18.3 and provide a flag to restore the current behavior so that it may help existing code to identify its dependency on the current behavior and give time to migrate. Then target the finalizer to Cleaner change in 18.9. > > It's unknown to us how many existing native libraries are impacted by this change (calling FindClass from JNI_OnUnload to load classes visible the class loader being unloaded). I suspect it's rare. If FindClass is called when the native library is being unloaded and fail to find the class due to this change, it is not hard to find out but the code might crash if it does not handle the class not found case properly. > > Any opinion? I?m in favor of removing this finalizer sooner rather than later, but you probably could have guessed that. From claes.redestad at oracle.com Tue Sep 26 23:12:43 2017 From: claes.redestad at oracle.com (Claes Redestad) Date: Wed, 27 Sep 2017 01:12:43 +0200 Subject: 18.3 RFR 8187688 Additional tests for MethodHandle.invokeWithArguments In-Reply-To: <7EF356BB-74FC-43FF-AB09-BE656AA24D8A@oracle.com> References: <7EF356BB-74FC-43FF-AB09-BE656AA24D8A@oracle.com> Message-ID: Hi Paul, On 2017-09-19 20:48, Paul Sandoz wrote: > Hi, > > Please review some additional tests testing edge case aspects of MethodHandle.invokeWithArguments: > > http://cr.openjdk.java.net/~psandoz/jdk10/JDK-8187688-invoke-with-arguments-test/webrev/ looks good to me, reviewed. /Claes > > This and the feature (https://bugs.openjdk.java.net/browse/JDK-8185993 ) will be pushed once the repo opens up again. > > Thanks, > Paul. From david.holmes at oracle.com Wed Sep 27 00:34:02 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Sep 2017 10:34:02 +1000 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> Message-ID: Hi Mandy, On 27/09/2017 3:27 AM, mandy chung wrote: > > > On 9/25/17 11:37 PM, Kim Barrett wrote: >> Thanks for dealing with this. > > I'm all for eliminating the finalizers in the JDK.? Looking forward to > having a finalizer-free JDK. >> ============================================================================== >> >> src/java.base/share/native/libjava/ClassLoader.c >> ? 415 Java_java_lang_ClassLoader_00024NativeLibrary_00024Unloader_unload >> ? 416 (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin, >> jlong address) >> >> With this change, the "this" argument is no longer used. >> >> Because of this, the native function could be a static member function >> of the new Unloader class, or could (I think) still be a (now static) >> member function of NativeLibrary.? The latter would not require a name >> change, only a signature change.? But I don't really care which class >> has the method. > Yes it can be a static method. >> ============================================================================== >> >> src/java.base/share/classes/java/lang/ClassLoader.java >> 2394???????? public void register() { >> ????????????????? [...] >> 2406???????????????? // register the class loader for cleanup when >> unloaded >> 2407???????????????? if (loader != getBuiltinPlatformClassLoader() && >> 2408???????????????????? loader != getBuiltinAppClassLoader()) { >> 2409???????????????????? CleanerFactory.cleaner() >> 2410???????????????????????? .register(loader, new Unloader(name, >> handle, isBuiltin)); >> 2411???????????????? } >> >> Can anything before the cleanup registration throw? > > No within the register method.? The builtin loaders are created early > during startup.? I shall make sure that System::loadLibrary is not > called during init phase 1. >> If so, do we leak >> because we haven't registered the cleanup yet?? And what if the >> registration itself fails to complete? > > If Cleaner::register fails, it should throw an exception. Otherwise, the > registration should complete. >> ============================================================================== >> >> src/hotspot/share/prims/jni.cpp >> ? 405???? // Special handling to make sure JNI_OnLoad are executed in >> the correct class context. >> >> s/are executed/is executed/ >> > Will fix it. > > I'm considering to separate the JNI_FindClass change to target 18.3 and > provide a flag to restore the current behavior so that it may help > existing code to identify its dependency on the current behavior and > give time to migrate.? Then target the finalizer to Cleaner change in 18.9. > > It's unknown to us how many existing native libraries are impacted by > this change (calling FindClass from JNI_OnUnload to load classes visible > the class loader being unloaded). ? I suspect it's rare. If FindClass is > called when the native library is being unloaded and fail to find the > class due to this change, it is not hard to find out but the code might > crash if it does not handle the class not found case properly. > > Any opinion? Yes :) I agree with being conservative here. We don't know how this may be being used. But I'm still not completely clear how the FindClass change is tied to the switch to Cleaner ?? Thanks, David > Mandy From mandy.chung at oracle.com Wed Sep 27 01:32:31 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 26 Sep 2017 18:32:31 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> Message-ID: <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> On 9/26/17 5:34 PM, David Holmes wrote: > Hi Mandy, > > On 27/09/2017 3:27 AM, mandy chung wrote: >> >> >> On 9/25/17 11:37 PM, Kim Barrett wrote: >>> Thanks for dealing with this. >> >> I'm all for eliminating the finalizers in the JDK.? Looking forward >> to having a finalizer-free JDK. >>> ============================================================================== >>> >>> src/java.base/share/native/libjava/ClassLoader.c >>> ? 415 >>> Java_java_lang_ClassLoader_00024NativeLibrary_00024Unloader_unload >>> ? 416 (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin, >>> jlong address) >>> >>> With this change, the "this" argument is no longer used. >>> >>> Because of this, the native function could be a static member function >>> of the new Unloader class, or could (I think) still be a (now static) >>> member function of NativeLibrary.? The latter would not require a name >>> change, only a signature change.? But I don't really care which class >>> has the method. >> Yes it can be a static method. >>> ============================================================================== >>> >>> src/java.base/share/classes/java/lang/ClassLoader.java >>> 2394???????? public void register() { >>> ????????????????? [...] >>> 2406???????????????? // register the class loader for cleanup when >>> unloaded >>> 2407???????????????? if (loader != getBuiltinPlatformClassLoader() && >>> 2408???????????????????? loader != getBuiltinAppClassLoader()) { >>> 2409???????????????????? CleanerFactory.cleaner() >>> 2410???????????????????????? .register(loader, new Unloader(name, >>> handle, isBuiltin)); >>> 2411???????????????? } >>> >>> Can anything before the cleanup registration throw? >> >> No within the register method.? The builtin loaders are created early >> during startup.? I shall make sure that System::loadLibrary is not >> called during init phase 1. >>> If so, do we leak >>> because we haven't registered the cleanup yet?? And what if the >>> registration itself fails to complete? >> >> If Cleaner::register fails, it should throw an exception. Otherwise, >> the registration should complete. >>> ============================================================================== >>> >>> src/hotspot/share/prims/jni.cpp >>> ? 405???? // Special handling to make sure JNI_OnLoad are executed >>> in the correct class context. >>> >>> s/are executed/is executed/ >>> >> Will fix it. >> >> I'm considering to separate the JNI_FindClass change to target 18.3 >> and provide a flag to restore the current behavior so that it may >> help existing code to identify its dependency on the current behavior >> and give time to migrate.? Then target the finalizer to Cleaner >> change in 18.9. >> >> It's unknown to us how many existing native libraries are impacted by >> this change (calling FindClass from JNI_OnUnload to load classes >> visible the class loader being unloaded). ? I suspect it's rare. If >> FindClass is called when the native library is being unloaded and >> fail to find the class due to this change, it is not hard to find out >> but the code might crash if it does not handle the class not found >> case properly. >> >> Any opinion? > > Yes :) I agree with being conservative here. We don't know how this > may be being used. But I'm still not completely clear how the > FindClass change is tied to the switch to Cleaner ?? It is not tied with the Cleaner change.? Instead, the FindClass bug blocks the finalizer to Cleaner change. FindClass bug is uncovered when I implemented the change from finalizer to Cleaner (or phantom reference).?? There is a test calling FindClass to look for a class defined by the class loader being unloaded, say L.? L is not Gc'ed and so FindClass successfully finds the class (which resurrect the class loader which was marked finalizable). Is that clearer? Mandy From david.holmes at oracle.com Wed Sep 27 02:06:34 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Sep 2017 12:06:34 +1000 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> Message-ID: <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> On 27/09/2017 11:32 AM, mandy chung wrote: > On 9/26/17 5:34 PM, David Holmes wrote: >> Hi Mandy, >> >> On 27/09/2017 3:27 AM, mandy chung wrote: >>> >>> >>> On 9/25/17 11:37 PM, Kim Barrett wrote: >>>> Thanks for dealing with this. >>> >>> I'm all for eliminating the finalizers in the JDK.? Looking forward >>> to having a finalizer-free JDK. >>>> ============================================================================== >>>> >>>> src/java.base/share/native/libjava/ClassLoader.c >>>> ? 415 >>>> Java_java_lang_ClassLoader_00024NativeLibrary_00024Unloader_unload >>>> ? 416 (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin, >>>> jlong address) >>>> >>>> With this change, the "this" argument is no longer used. >>>> >>>> Because of this, the native function could be a static member function >>>> of the new Unloader class, or could (I think) still be a (now static) >>>> member function of NativeLibrary.? The latter would not require a name >>>> change, only a signature change.? But I don't really care which class >>>> has the method. >>> Yes it can be a static method. >>>> ============================================================================== >>>> >>>> src/java.base/share/classes/java/lang/ClassLoader.java >>>> 2394???????? public void register() { >>>> ????????????????? [...] >>>> 2406???????????????? // register the class loader for cleanup when >>>> unloaded >>>> 2407???????????????? if (loader != getBuiltinPlatformClassLoader() && >>>> 2408???????????????????? loader != getBuiltinAppClassLoader()) { >>>> 2409???????????????????? CleanerFactory.cleaner() >>>> 2410???????????????????????? .register(loader, new Unloader(name, >>>> handle, isBuiltin)); >>>> 2411???????????????? } >>>> >>>> Can anything before the cleanup registration throw? >>> >>> No within the register method.? The builtin loaders are created early >>> during startup.? I shall make sure that System::loadLibrary is not >>> called during init phase 1. >>>> If so, do we leak >>>> because we haven't registered the cleanup yet?? And what if the >>>> registration itself fails to complete? >>> >>> If Cleaner::register fails, it should throw an exception. Otherwise, >>> the registration should complete. >>>> ============================================================================== >>>> >>>> src/hotspot/share/prims/jni.cpp >>>> ? 405???? // Special handling to make sure JNI_OnLoad are executed >>>> in the correct class context. >>>> >>>> s/are executed/is executed/ >>>> >>> Will fix it. >>> >>> I'm considering to separate the JNI_FindClass change to target 18.3 >>> and provide a flag to restore the current behavior so that it may >>> help existing code to identify its dependency on the current behavior >>> and give time to migrate.? Then target the finalizer to Cleaner >>> change in 18.9. >>> >>> It's unknown to us how many existing native libraries are impacted by >>> this change (calling FindClass from JNI_OnUnload to load classes >>> visible the class loader being unloaded). ? I suspect it's rare. If >>> FindClass is called when the native library is being unloaded and >>> fail to find the class due to this change, it is not hard to find out >>> but the code might crash if it does not handle the class not found >>> case properly. >>> >>> Any opinion? >> >> Yes :) I agree with being conservative here. We don't know how this >> may be being used. But I'm still not completely clear how the >> FindClass change is tied to the switch to Cleaner ?? > It is not tied with the Cleaner change.? Instead, the FindClass bug > blocks the finalizer to Cleaner change. > > FindClass bug is uncovered when I implemented the change from finalizer > to Cleaner (or phantom reference).?? There is a test calling FindClass > to look for a class defined by the class loader being unloaded, say L. L > is not Gc'ed and so FindClass successfully finds the class (which > resurrect the class loader which was marked finalizable). > > Is that clearer? So the issue is only that this test breaks?? And you want to change the FindClass spec to make it clear the test is what needs to be changed? David > Mandy From mandy.chung at oracle.com Wed Sep 27 02:11:56 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 26 Sep 2017 19:11:56 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> Message-ID: On 9/26/17 7:06 PM, David Holmes wrote: > >> It is not tied with the Cleaner change. Instead, the FindClass bug >> blocks the finalizer to Cleaner change. >> >> FindClass bug is uncovered when I implemented the change from >> finalizer to Cleaner (or phantom reference).?? There is a test >> calling FindClass to look for a class defined by the class loader >> being unloaded, say L. L is not Gc'ed and so FindClass successfully >> finds the class (which resurrect the class loader which was marked >> finalizable). >> >> Is that clearer? > > So the issue is only that this test breaks?? No.? The test reveals a bug in JNI_FindClass that uses a class loader being finalized as the context when NativeLibrary is the caller. > And you want to change the FindClass spec to make it clear the test is > what needs to be changed? No.?? It is a bug in the hotspot implementation. ? The JNI spec says that the context of JNI_OnUnload being called is unknown.? The hotspot implementation of FindClass uses the class loader associated with that native library as the context when invoked from JNI_OnUnload which is wrong. I will file a separate JBS issue to separate this JNI bug. Mandy From david.holmes at oracle.com Wed Sep 27 02:35:18 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Sep 2017 12:35:18 +1000 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> Message-ID: <3d52390c-d468-1f74-6e1e-4a9bc960b681@oracle.com> On 27/09/2017 12:11 PM, mandy chung wrote: > On 9/26/17 7:06 PM, David Holmes wrote: >> >>> It is not tied with the Cleaner change. Instead, the FindClass bug >>> blocks the finalizer to Cleaner change. >>> >>> FindClass bug is uncovered when I implemented the change from >>> finalizer to Cleaner (or phantom reference).?? There is a test >>> calling FindClass to look for a class defined by the class loader >>> being unloaded, say L. L is not Gc'ed and so FindClass successfully >>> finds the class (which resurrect the class loader which was marked >>> finalizable). >>> >>> Is that clearer? >> >> So the issue is only that this test breaks?? > > No.? The test reveals a bug in JNI_FindClass that uses a class loader > being finalized as the context when NativeLibrary is the caller. >> And you want to change the FindClass spec to make it clear the test is >> what needs to be changed? > No.?? It is a bug in the hotspot implementation. ? The JNI spec says > that the context of JNI_OnUnload being called is unknown.? The hotspot > implementation of FindClass uses the class loader associated with that > native library as the context when invoked from JNI_OnUnload which is > wrong. I'm not sure I agree it is wrong. As I've said elsewhere there's a good chance that if you are trying to load classes via FindClass as part of a unload hook (which implies you are using custom classloaders), then it may be only the current loader or a parent (still custom) can load that class. But we're on the fringe of realistic expectations here as the context is specified as being "unknown". That said given the spec says "unknown" the behaviour of the VM could change and still be in spec. I presume that when using a cleaner the current classloader that would be used by FindClass is the system loader? Hence the observed behaviour of FindClass "changes" if you switch to the cleaner from the finalizer - and can't be reverted to the old behaviour by using a command-line flag. Hence if we want to be able to revert we have to do that in a FindClass-only change first. Then drop-in the cleaner update and remove the flag. > I will file a separate JBS issue to separate this JNI bug. Okay. I see this as a RFE not a bug per-se: change from "unknown context" to a specific well known context. Thanks, David > Mandy From mandy.chung at oracle.com Wed Sep 27 03:36:02 2017 From: mandy.chung at oracle.com (mandy chung) Date: Tue, 26 Sep 2017 20:36:02 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <3d52390c-d468-1f74-6e1e-4a9bc960b681@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> <3d52390c-d468-1f74-6e1e-4a9bc960b681@oracle.com> Message-ID: <1e71b112-cdd5-ba0d-d519-5d54e5ace549@oracle.com> On 9/26/17 7:35 PM, David Holmes wrote: > On 27/09/2017 12:11 PM, mandy chung wrote: >> On 9/26/17 7:06 PM, David Holmes wrote: >>> >>>> It is not tied with the Cleaner change. Instead, the FindClass bug >>>> blocks the finalizer to Cleaner change. >>>> >>>> FindClass bug is uncovered when I implemented the change from >>>> finalizer to Cleaner (or phantom reference).?? There is a test >>>> calling FindClass to look for a class defined by the class loader >>>> being unloaded, say L. L is not Gc'ed and so FindClass successfully >>>> finds the class (which resurrect the class loader which was marked >>>> finalizable). >>>> >>>> Is that clearer? >>> >>> So the issue is only that this test breaks?? >> >> No.? The test reveals a bug in JNI_FindClass that uses a class loader >> being finalized as the context when NativeLibrary is the caller. >>> And you want to change the FindClass spec to make it clear the test >>> is what needs to be changed? >> No.?? It is a bug in the hotspot implementation. ? The JNI spec says >> that the context of JNI_OnUnload being called is unknown. The hotspot >> implementation of FindClass uses the class loader associated with >> that native library as the context when invoked from JNI_OnUnload >> which is wrong. > > I'm not sure I agree it is wrong. As I've said elsewhere there's a > good chance that if you are trying to load classes via FindClass as > part of a unload hook (which implies you are using custom > classloaders), then it may be only the current loader or a parent > (still custom) can load that class. But we're on the fringe of > realistic expectations here as the context is specified as being > "unknown". > For a native unload hook to access some class defined by this class loader, definitely it should not write to any fields since the class and class loader are not strongly reachable.?? Reading the current state stored in the class can be done by writing to the native fields. I'd like to know what other use cases that FindClass must ressurrect a class defined by this class loader or find a class defined by its ancestor if you have any in mind that the existing code can't be replaced due to the proposed change. > That said given the spec says "unknown" the behaviour of the VM could > change and still be in spec. > > I presume that when using a cleaner the current classloader that would > be used by FindClass is the system loader? Hence the observed > behaviour of FindClass "changes" if you switch to the cleaner from the > finalizer - and can't be reverted to the old behaviour by using a > command-line flag. Hence if we want to be able to revert we have to do > that in a FindClass-only change first. Then drop-in the cleaner update > and remove the flag. > >> I will file a separate JBS issue to separate this JNI bug. > > Okay. I see this as a RFE not a bug per-se: change from "unknown > context" to a specific well known context. This case is arguable whether it's considered as a RFE or a bug because the current spec of JNI_OnUnload and JNI_FindClass are not aligned.? I lean toward a bug.??? The bottom line:? do you agree with this proposed JNI spec change? Mandy From david.holmes at oracle.com Wed Sep 27 04:36:47 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Sep 2017 14:36:47 +1000 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <1e71b112-cdd5-ba0d-d519-5d54e5ace549@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> <3d52390c-d468-1f74-6e1e-4a9bc960b681@oracle.com> <1e71b112-cdd5-ba0d-d519-5d54e5ace549@oracle.com> Message-ID: <0c6802f2-678b-977d-e827-ef03c7f376a2@oracle.com> On 27/09/2017 1:36 PM, mandy chung wrote: > On 9/26/17 7:35 PM, David Holmes wrote: >> On 27/09/2017 12:11 PM, mandy chung wrote: >>> On 9/26/17 7:06 PM, David Holmes wrote: >>>> >>>>> It is not tied with the Cleaner change. Instead, the FindClass bug >>>>> blocks the finalizer to Cleaner change. >>>>> >>>>> FindClass bug is uncovered when I implemented the change from >>>>> finalizer to Cleaner (or phantom reference).?? There is a test >>>>> calling FindClass to look for a class defined by the class loader >>>>> being unloaded, say L. L is not Gc'ed and so FindClass successfully >>>>> finds the class (which resurrect the class loader which was marked >>>>> finalizable). >>>>> >>>>> Is that clearer? >>>> >>>> So the issue is only that this test breaks?? >>> >>> No.? The test reveals a bug in JNI_FindClass that uses a class loader >>> being finalized as the context when NativeLibrary is the caller. >>>> And you want to change the FindClass spec to make it clear the test >>>> is what needs to be changed? >>> No.?? It is a bug in the hotspot implementation. ? The JNI spec says >>> that the context of JNI_OnUnload being called is unknown. The hotspot >>> implementation of FindClass uses the class loader associated with >>> that native library as the context when invoked from JNI_OnUnload >>> which is wrong. >> >> I'm not sure I agree it is wrong. As I've said elsewhere there's a >> good chance that if you are trying to load classes via FindClass as >> part of a unload hook (which implies you are using custom >> classloaders), then it may be only the current loader or a parent >> (still custom) can load that class. But we're on the fringe of >> realistic expectations here as the context is specified as being >> "unknown". >> > For a native unload hook to access some class defined by this class > loader, definitely it should not write to any fields since the class and > class loader are not strongly reachable.?? Reading the current state > stored in the class can be done by writing to the native fields. Yes that is a good point - but as the spec says due to the unknown context the hook has to be very careful about what it tries to do. I agree it is doubtful that anyone can, or should, be relying on the direct use of the classloader that has become unreachable, but ... > I'd like to know what other use cases that FindClass must ressurrect a > class defined by this class loader or find a class defined by its > ancestor if you have any in mind that the existing code can't be > replaced due to the proposed change. ... I can easily imagine a subsystem that runs under a custom loader and which then instantiates further execution contexts (per connection for example) each with their own classloader and which can be reclaimed after the request is complete. I can then easily imagine that they use an unload hook to record statistics about native library use, and that the statistics classes are in the top-level custom loader, and not locatable from the system loader. While the spec makes no guarantees this will work it only says programmers "should be conservative in their use of VM services" which strongly suggests to me a "try it and see if it works" approach. In the current code while loading from the loader being reclaimed is highly dubious, delegating through that loader seems fairly reasonable to me. >> That said given the spec says "unknown" the behaviour of the VM could >> change and still be in spec. >> >> I presume that when using a cleaner the current classloader that would >> be used by FindClass is the system loader? Hence the observed >> behaviour of FindClass "changes" if you switch to the cleaner from the >> finalizer - and can't be reverted to the old behaviour by using a >> command-line flag. Hence if we want to be able to revert we have to do >> that in a FindClass-only change first. Then drop-in the cleaner update >> and remove the flag. >> >>> I will file a separate JBS issue to separate this JNI bug. >> >> Okay. I see this as a RFE not a bug per-se: change from "unknown >> context" to a specific well known context. > This case is arguable whether it's considered as a RFE or a bug because > the current spec of JNI_OnUnload and JNI_FindClass are not aligned.? I > lean toward a bug.??? The bottom line:? do you agree with this proposed > JNI spec change? I don't think the spec _has_ to change because I disagree that there is a misalignment between JNI_OnUnload and JNI_FindClass. FindClass clearly states it uses the current loader or else the system loader if there is no notion of a current loader. OnUnload says it runs in an unknown context, so you don't know what the current loader may be, or even if there is one. But regardless a call to FindClass from OnUnload should use the current loader if it exists, or else the system loader. The fact it may be dubious to use the current loader when it is itself in the process of being unloaded does not impinge on the voracity of the spec in my opinion. So you can change to using a Cleaner instead of a finalizer and while it will behave differently, that change in behaviour does not violate the spec in any way - again in my opinion. Now if you want to pave the way for a future switch to Cleaner by changing the spec for JNI_OnUnload such that it must be executed in a context where (equivalently) there either is no current loader or the current loader is the system loader, then I do not oppose that. But the only purpose that serves is to allow a migration path to the new behaviour - and then forever locks us in. Note however I would not want to see the implementation of FindClass having to special case this - I would hope it just happens naturally if the Cleaner thread reports the current class loader as the system loader. Does it? Thanks, David > > Mandy From xueming.shen at oracle.com Wed Sep 27 06:35:26 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Tue, 26 Sep 2017 23:35:26 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers Message-ID: <59CB46AE.2000701@oracle.com> Hi, Please help review the change for JDK-8185582. issue: https://bugs.openjdk.java.net/browse/JDK-8185582 webrev: http://cr.openjdk.java.net/~sherman/8185582/webrev/ csr: https://bugs.openjdk.java.net/browse/JDK-8187485 The proposed change here is to replace the finalize() cleanup mechanism with the newly introduced java.lang.ref.Cleaner for java.util.zip package (Deflater, Inflater, ZipFile and ZipFile.ZipFileInputStrean/ZipFileInflaterInputStream). Since it's an "incompatible" change, both behavioral and source incompatibility, to remove the public finalize() from these classes, a corresponding CSR is also created and need review as well. Thanks, Sherman From vyom.tewari at oracle.com Wed Sep 27 08:56:13 2017 From: vyom.tewari at oracle.com (vyom tewari) Date: Wed, 27 Sep 2017 14:26:13 +0530 Subject: RFR 8145635 : Add TCP_QUICKACK socket option In-Reply-To: <54CDCFD4-97F5-480C-A4D9-03CEA58803B5@oracle.com> References: <56CD74E1.60309@oracle.com> <56CD7C0A.2080402@oracle.com> <0b0989b5-c791-a476-a82f-6c686b19c9d3@oracle.com> <54CDCFD4-97F5-480C-A4D9-03CEA58803B5@oracle.com> Message-ID: <82e35025-cd86-5119-3556-f0989eb3a785@oracle.com> Hi Chris, Thanks for review, please find the latest webrev(http://cr.openjdk.java.net/~vtewari/8145635/webrev0.2/index.html). I incorporated review comments from you and re-base the patch to our consolidated repo(jdk10/master). Thanks, Vyom On Monday 25 September 2017 01:57 AM, Chris Hegarty wrote: > Vyom, > >> On 11 Sep 2017, at 16:38, vyom tewari wrote: >> >> Hi All, >> >> As jdk.net API already moved out of java.base, Please review the below code change for jdk10. >> >> Bug: https://bugs.openjdk.java.net/browse/JDK-8145635 >> Webrev: http://cr.openjdk.java.net/~vtewari/8145635/webrev0.1/index.html >> > This looks quite good. Some comments: > > 1) I wonder if we should just call the option TCP_QUICKACK, rather than SO_QUICKACK? Similar to TCP_NODELAY. > > 2) I think LinuxSocketOptions.h is largely unnecessary, if we do 1) above. > > 3) Java_jdk_net_LinuxSocketOptions_getQuickAck could return jint, rather than jobject, thus avoiding the need for createBoolean. The conversation can happen in the Java layer. Can you please reduce the lint length in this file, by wrapping similar to the style of the Solaris version. > > 4) ExtendedSocketOptions.java > - drop the

, they are unnecessary. > - I think, similar to TCP_NODELAY, the spec should say that the options is TCP specific. From TCP_NODELAY: "The socket option is specific to stream-oriented sockets using the TCP/IP protocol.? > - "In TCP_QUICKACK mode?, maybe ?When the option is enabled?? > > -Chris. > > From peter.levart at gmail.com Wed Sep 27 09:31:12 2017 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 27 Sep 2017 11:31:12 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CB46AE.2000701@oracle.com> References: <59CB46AE.2000701@oracle.com> Message-ID: <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Hi Sherman, At first I checked the Deflater/Inflater changes. I'll come back with ZipFile later. I think the code is mostly correct, but I have a concern. If clean() is invoked via Deflater.end(), then the Deflater instance is still alive and synchronization is necessary as other threads might be concurrently invoking other methods. If clean() is invoked via Cleaner thread, then Deflater instance is already phantom reachable and no thread may be accessing it or be in the middle of executing any of its instance methods. How is this guaranteed? Critical Deflater methods synchronize on the zsRef instance, so at least at the beginning of the synchronized block, the Deflater instance is strongly reachable. Take for example the following Deflater instance method: ?254???? public void setDictionary(byte[] b, int off, int len) { ?255???????? if (b == null) { ?256???????????? throw new NullPointerException(); ?257???????? } ?258???????? if (off < 0 || len < 0 || off > b.length - len) { ?259???????????? throw new ArrayIndexOutOfBoundsException(); ?260???????? } ?261???????? synchronized (zsRef) { ?262???????????? ensureOpen(); ?263???????????? setDictionary(zsRef.address(), b, off, len); ?264???????? } ?265???? } Up to a point where 'this' is dereferenced to obtain the 'zsRef' value (line 261), the Deflater instance is reachable. But after that, even ensureOpen() may be inlined and 'this' is not needed any more. After that point, obtaining zsRef.address() and calling setDictionaly on the obtained address may be racing with Cleaner thread invoking ZStreamRef.run(): ? 49???? public void run() { ? 50???????? long addr = address; ? 51???????? address = 0; ? 52???????? if (addr != 0) { ? 53???????????? end.accept(addr); ? 54???????? } ? 55???? } Possible program execution is therefore: Thread1: zsRef.address() - returning non-zero address Thread2: ZStreamRef.run() - invoking Deflater.end(address) with non-zero address via the passed-in lambda. Thread1: setDictionary(, b, off, len) To fix this, you could sprinkle Reference.reachabilityFence(this) at appropriate places in Deflater, but it is simpler to just add synchronized modifier to ZStreamRef.run() method. There's no danger of deadlock(s) since Cleaner ensures the run() method is invoked at most once. The same reasoning applies to Inflater to as code is similar. A nit (Deflater and similar to Inflater): ?187???????? ZStreamRef ref = new ZStreamRef(init(level, DEFAULT_STRATEGY, nowrap), ?188???????????????????????????????????????? addr -> end(addr)); You could use a method reference there. Regards, Peter On 09/27/2017 08:35 AM, Xueming Shen wrote: > Hi, > > Please help review the change for JDK-8185582. > > issue:??? https://bugs.openjdk.java.net/browse/JDK-8185582 > webrev: http://cr.openjdk.java.net/~sherman/8185582/webrev/ > csr:?????? https://bugs.openjdk.java.net/browse/JDK-8187485 > > The proposed change here is to replace the finalize() cleanup > mechanism with > the newly introduced java.lang.ref.Cleaner for java.util.zip package > (Deflater, > Inflater, ZipFile and > ZipFile.ZipFileInputStrean/ZipFileInflaterInputStream). > > Since it's an "incompatible" change, both behavioral and source > incompatibility, > to remove the public finalize() from these classes, a corresponding > CSR is also > created and need review as well. > > Thanks, > Sherman > From david.holmes at oracle.com Wed Sep 27 09:52:42 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Sep 2017 19:52:42 +1000 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <23d51a9d-6b25-4324-c293-556215169401@gmail.com> References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Message-ID: Hi Peter, I thought Cleaner was supposed to avoid all these unpredictable reachability races? Otherwise why switch from using a finalizer ?? David On 27/09/2017 7:31 PM, Peter Levart wrote: > Hi Sherman, > > At first I checked the Deflater/Inflater changes. I'll come back with > ZipFile later. > > I think the code is mostly correct, but I have a concern. If clean() is > invoked via Deflater.end(), then the Deflater instance is still alive > and synchronization is necessary as other threads might be concurrently > invoking other methods. If clean() is invoked via Cleaner thread, then > Deflater instance is already phantom reachable and no thread may be > accessing it or be in the middle of executing any of its instance > methods. How is this guaranteed? Critical Deflater methods synchronize > on the zsRef instance, so at least at the beginning of the synchronized > block, the Deflater instance is strongly reachable. Take for example the > following Deflater instance method: > > > ?254???? public void setDictionary(byte[] b, int off, int len) { > ?255???????? if (b == null) { > ?256???????????? throw new NullPointerException(); > ?257???????? } > ?258???????? if (off < 0 || len < 0 || off > b.length - len) { > ?259???????????? throw new ArrayIndexOutOfBoundsException(); > ?260???????? } > ?261???????? synchronized (zsRef) { > ?262???????????? ensureOpen(); > ?263???????????? setDictionary(zsRef.address(), b, off, len); > ?264???????? } > ?265???? } > > > Up to a point where 'this' is dereferenced to obtain the 'zsRef' value > (line 261), the Deflater instance is reachable. But after that, even > ensureOpen() may be inlined and 'this' is not needed any more. After > that point, obtaining zsRef.address() and calling setDictionaly on the > obtained address may be racing with Cleaner thread invoking > ZStreamRef.run(): > > ? 49???? public void run() { > ? 50???????? long addr = address; > ? 51???????? address = 0; > ? 52???????? if (addr != 0) { > ? 53???????????? end.accept(addr); > ? 54???????? } > ? 55???? } > > > Possible program execution is therefore: > > Thread1: > > zsRef.address() - returning non-zero address > > Thread2: > > ZStreamRef.run() - invoking Deflater.end(address) with non-zero address > via the passed-in lambda. > > Thread1: > > setDictionary(, b, off, len) > > > To fix this, you could sprinkle Reference.reachabilityFence(this) at > appropriate places in Deflater, but it is simpler to just add > synchronized modifier to ZStreamRef.run() method. There's no danger of > deadlock(s) since Cleaner ensures the run() method is invoked at most once. > > The same reasoning applies to Inflater to as code is similar. > > A nit (Deflater and similar to Inflater): > > ?187???????? ZStreamRef ref = new ZStreamRef(init(level, > DEFAULT_STRATEGY, nowrap), > ?188???????????????????????????????????????? addr -> end(addr)); > > You could use a method reference there. > > Regards, Peter > > > > On 09/27/2017 08:35 AM, Xueming Shen wrote: >> Hi, >> >> Please help review the change for JDK-8185582. >> >> issue:??? https://bugs.openjdk.java.net/browse/JDK-8185582 >> webrev: http://cr.openjdk.java.net/~sherman/8185582/webrev/ >> csr:?????? https://bugs.openjdk.java.net/browse/JDK-8187485 >> >> The proposed change here is to replace the finalize() cleanup >> mechanism with >> the newly introduced java.lang.ref.Cleaner for java.util.zip package >> (Deflater, >> Inflater, ZipFile and >> ZipFile.ZipFileInputStrean/ZipFileInflaterInputStream). >> >> Since it's an "incompatible" change, both behavioral and source >> incompatibility, >> to remove the public finalize() from these classes, a corresponding >> CSR is also >> created and need review as well. >> >> Thanks, >> Sherman >> > From uschindler at apache.org Wed Sep 27 10:31:42 2017 From: uschindler at apache.org (Uwe Schindler) Date: Wed, 27 Sep 2017 12:31:42 +0200 Subject: Invoke MR-JAR file verifier on command line without actually packaging Message-ID: <04c401d3377b$d1ee3230$75ca9690$@apache.org> Hi, I am building a multi-release JAR file using Apache Ant (for Lucene, see https://issues.apache.org/jira/browse/LUCENE-7966). As build tools like Ant/Gradle/Maven are packaging JAR files on their own, not using the official JAR tool, I wanted to do a quick check if the resulting JAR file is valid. https://bugs.openjdk.java.net/browse/JDK-8158295 added some checks to compare method signatures and class file between the base and the META-INF/versions occurrences. Is there a way to invoke those checks on an already packaged JAR file? Uwe P.S.: Just a bit of background for those who are interested! This is a totally new way to create a MR JAR by just pacthing the already compiled class files before packaging as JAR file. The use case here is: - We want to use java.util.Arrays / java.util.Objects static methods throughout Lucene, especially to improve bounds checks by having Java 9 use the intrinsics when accessing arrays/ByteBuffers. We have already seen a huge speed improvement for our implementation of the LZ4 compression! - We need to be compatible with Java 8, but improve Java 9. - So we compile all our Lucene classes against a "custom" variant of the interesting methods, located in a fallback classes we have implemented in our own org.apache.lucene.future.FutureArrays/FutureObjects. - We do not want to duplicate our code by creating clonesof all .java files that use these methods and we still want to still compile against Java 8 - as this is the release JDK version! We want it automatic! So our trick is new and also way cool: During packaging the JAR file we patch all class files using ASM's ClassRemapper and replace the Type org.apache.lucene.future.FutureArrays by java.util.Arrays, only for those that actually contain a reference to our own replacement methods. This is a 74-liner in Groovy! After patching we also place the patched files in the MR part of JAR file. Patch can be seen here: https://github.com/apache/lucene-solr/compare/master...uschindler:jira/LUCENE-7966-v2 Especially this is how we patch our class files, way cool: https://github.com/uschindler/lucene-solr/blob/d67eb6274d4c0b8315848db3f09809fbc0797f6e/lucene/core/src/tools/groovy/patch-mrjar-classes.groovy ----- Uwe Schindler uschindler at apache.org ASF Member, Apache Lucene PMC / Committer Bremen, Germany http://lucene.apache.org/ From peter.levart at gmail.com Wed Sep 27 10:36:20 2017 From: peter.levart at gmail.com (Peter Levart) Date: Wed, 27 Sep 2017 12:36:20 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Message-ID: <2139d434-c550-af36-b92c-3991535e1de6@gmail.com> Hi David, On 09/27/2017 11:52 AM, David Holmes wrote: > Hi Peter, > > I thought Cleaner was supposed to avoid all these unpredictable > reachability races? Otherwise why switch from using a finalizer ?? Unfortunately, there is no hidden magic in Cleaner. It is better than finalize() mostly because the clean-up function may be invoked by the user, which also de-registers it, allowing GC to collect it rather than leaving it to reference-processing pipeline to process it for no reason. And of course, it guarantees that the tracked referent can not be resurrected as a result of cleanup code execution. What remains unchanged with Cleaner is the point in program execution when the tracked referent is determined to be phantom-reachable (finalizable) and therefore its associated PhantomReference(s) eligible for processing (finalize() invoked). Regards, Peter > > David > > On 27/09/2017 7:31 PM, Peter Levart wrote: >> Hi Sherman, >> >> At first I checked the Deflater/Inflater changes. I'll come back with >> ZipFile later. >> >> I think the code is mostly correct, but I have a concern. If clean() >> is invoked via Deflater.end(), then the Deflater instance is still >> alive and synchronization is necessary as other threads might be >> concurrently invoking other methods. If clean() is invoked via >> Cleaner thread, then Deflater instance is already phantom reachable >> and no thread may be accessing it or be in the middle of executing >> any of its instance methods. How is this guaranteed? Critical >> Deflater methods synchronize on the zsRef instance, so at least at >> the beginning of the synchronized block, the Deflater instance is >> strongly reachable. Take for example the following Deflater instance >> method: >> >> >> ??254???? public void setDictionary(byte[] b, int off, int len) { >> ??255???????? if (b == null) { >> ??256???????????? throw new NullPointerException(); >> ??257???????? } >> ??258???????? if (off < 0 || len < 0 || off > b.length - len) { >> ??259???????????? throw new ArrayIndexOutOfBoundsException(); >> ??260???????? } >> ??261???????? synchronized (zsRef) { >> ??262???????????? ensureOpen(); >> ??263???????????? setDictionary(zsRef.address(), b, off, len); >> ??264???????? } >> ??265???? } >> >> >> Up to a point where 'this' is dereferenced to obtain the 'zsRef' >> value (line 261), the Deflater instance is reachable. But after that, >> even ensureOpen() may be inlined and 'this' is not needed any more. >> After that point, obtaining zsRef.address() and calling setDictionaly >> on the obtained address may be racing with Cleaner thread invoking >> ZStreamRef.run(): >> >> ?? 49???? public void run() { >> ?? 50???????? long addr = address; >> ?? 51???????? address = 0; >> ?? 52???????? if (addr != 0) { >> ?? 53???????????? end.accept(addr); >> ?? 54???????? } >> ?? 55???? } >> >> >> Possible program execution is therefore: >> >> Thread1: >> >> zsRef.address() - returning non-zero address >> >> Thread2: >> >> ZStreamRef.run() - invoking Deflater.end(address) with non-zero >> address via the passed-in lambda. >> >> Thread1: >> >> setDictionary(, b, off, len) >> >> >> To fix this, you could sprinkle Reference.reachabilityFence(this) at >> appropriate places in Deflater, but it is simpler to just add >> synchronized modifier to ZStreamRef.run() method. There's no danger >> of deadlock(s) since Cleaner ensures the run() method is invoked at >> most once. >> >> The same reasoning applies to Inflater to as code is similar. >> >> A nit (Deflater and similar to Inflater): >> >> ??187???????? ZStreamRef ref = new ZStreamRef(init(level, >> DEFAULT_STRATEGY, nowrap), >> ??188???????????????????????????????????????? addr -> end(addr)); >> >> You could use a method reference there. >> >> Regards, Peter >> >> >> >> On 09/27/2017 08:35 AM, Xueming Shen wrote: >>> Hi, >>> >>> Please help review the change for JDK-8185582. >>> >>> issue:??? https://bugs.openjdk.java.net/browse/JDK-8185582 >>> webrev: http://cr.openjdk.java.net/~sherman/8185582/webrev/ >>> csr:?????? https://bugs.openjdk.java.net/browse/JDK-8187485 >>> >>> The proposed change here is to replace the finalize() cleanup >>> mechanism with >>> the newly introduced java.lang.ref.Cleaner for java.util.zip package >>> (Deflater, >>> Inflater, ZipFile and >>> ZipFile.ZipFileInputStrean/ZipFileInflaterInputStream). >>> >>> Since it's an "incompatible" change, both behavioral and source >>> incompatibility, >>> to remove the public finalize() from these classes, a corresponding >>> CSR is also >>> created and need review as well. >>> >>> Thanks, >>> Sherman >>> >> From david.holmes at oracle.com Wed Sep 27 12:49:10 2017 From: david.holmes at oracle.com (David Holmes) Date: Wed, 27 Sep 2017 22:49:10 +1000 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <0c6802f2-678b-977d-e827-ef03c7f376a2@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> <3d52390c-d468-1f74-6e1e-4a9bc960b681@oracle.com> <1e71b112-cdd5-ba0d-d519-5d54e5ace549@oracle.com> <0c6802f2-678b-977d-e827-ef03c7f376a2@oracle.com> Message-ID: <22d101c6-5255-b9b7-606c-6f5519a5c597@oracle.com> Corrections ... On 27/09/2017 2:36 PM, David Holmes wrote: > On 27/09/2017 1:36 PM, mandy chung wrote: >> On 9/26/17 7:35 PM, David Holmes wrote: >>> On 27/09/2017 12:11 PM, mandy chung wrote: >>>> On 9/26/17 7:06 PM, David Holmes wrote: >>>>> >>>>>> It is not tied with the Cleaner change. Instead, the FindClass bug >>>>>> blocks the finalizer to Cleaner change. >>>>>> >>>>>> FindClass bug is uncovered when I implemented the change from >>>>>> finalizer to Cleaner (or phantom reference).?? There is a test >>>>>> calling FindClass to look for a class defined by the class loader >>>>>> being unloaded, say L. L is not Gc'ed and so FindClass >>>>>> successfully finds the class (which resurrect the class loader >>>>>> which was marked finalizable). >>>>>> >>>>>> Is that clearer? >>>>> >>>>> So the issue is only that this test breaks?? >>>> >>>> No.? The test reveals a bug in JNI_FindClass that uses a class >>>> loader being finalized as the context when NativeLibrary is the caller. >>>>> And you want to change the FindClass spec to make it clear the test >>>>> is what needs to be changed? >>>> No.?? It is a bug in the hotspot implementation. ? The JNI spec says >>>> that the context of JNI_OnUnload being called is unknown. The >>>> hotspot implementation of FindClass uses the class loader associated >>>> with that native library as the context when invoked from >>>> JNI_OnUnload which is wrong. >>> >>> I'm not sure I agree it is wrong. As I've said elsewhere there's a >>> good chance that if you are trying to load classes via FindClass as >>> part of a unload hook (which implies you are using custom >>> classloaders), then it may be only the current loader or a parent >>> (still custom) can load that class. But we're on the fringe of >>> realistic expectations here as the context is specified as being >>> "unknown". >>> >> For a native unload hook to access some class defined by this class >> loader, definitely it should not write to any fields since the class >> and class loader are not strongly reachable.?? Reading the current >> state stored in the class can be done by writing to the native fields. > > Yes that is a good point - but as the spec says due to the unknown > context the hook has to be very careful about what it tries to do. I > agree it is doubtful that anyone can, or should, be relying on the > direct use of the classloader that has become unreachable, but ... > >> I'd like to know what other use cases that FindClass must ressurrect a >> class defined by this class loader or find a class defined by its >> ancestor if you have any in mind that the existing code can't be >> replaced due to the proposed change. > > ... I can easily imagine a subsystem that runs under a custom loader and > which then instantiates further execution contexts (per connection for > example) each with their own classloader and which can be reclaimed > after the request is complete. I can then easily imagine that they use > an unload hook to record statistics about native library use, and that > the statistics classes are in the top-level custom loader, and not > locatable from the system loader. > > While the spec makes no guarantees this will work it only says > programmers "should be conservative in their use of VM services" which > strongly suggests to me a "try it and see if it works" approach. In the > current code while loading from the loader being reclaimed is highly > dubious, delegating through that loader seems fairly reasonable to me. > >>> That said given the spec says "unknown" the behaviour of the VM could >>> change and still be in spec. >>> >>> I presume that when using a cleaner the current classloader that >>> would be used by FindClass is the system loader? Hence the observed >>> behaviour of FindClass "changes" if you switch to the cleaner from >>> the finalizer - and can't be reverted to the old behaviour by using a >>> command-line flag. Hence if we want to be able to revert we have to >>> do that in a FindClass-only change first. Then drop-in the cleaner >>> update and remove the flag. >>> >>>> I will file a separate JBS issue to separate this JNI bug. >>> >>> Okay. I see this as a RFE not a bug per-se: change from "unknown >>> context" to a specific well known context. >> This case is arguable whether it's considered as a RFE or a bug >> because the current spec of JNI_OnUnload and JNI_FindClass are not >> aligned.? I lean toward a bug.??? The bottom line:? do you agree with >> this proposed JNI spec change? > > I don't think the spec _has_ to change because I disagree that there is > a misalignment between JNI_OnUnload and JNI_FindClass. FindClass clearly > states it uses the current loader or else the system loader if there is That is not accurate - sorry. FindClass doesn't actually address the possibility of being called via these load/unload hooks. See more below. > no notion of a current loader. OnUnload says it runs in an unknown > context, so you don't know what the current loader may be, or even if > there is one. But regardless a call to FindClass from OnUnload should > use the current loader if it exists, or else the system loader. The fact > it may be dubious to use the current loader when it is itself in the > process of being unloaded does not impinge on the voracity of the spec > in my opinion. > > So you can change to using a Cleaner instead of a finalizer and while it > will behave differently, that change in behaviour does not violate the > spec in any way - again in my opinion. > > Now if you want to pave the way for a future switch to Cleaner by > changing the spec for JNI_OnUnload such that it must be executed in a > context where (equivalently) there either is no current loader or the > current loader is the system loader, then I do not oppose that. But the > only purpose that serves is to allow a migration path to the new > behaviour - and then forever locks us in. > > Note however I would not want to see the implementation of FindClass > having to special case this - I would hope it just happens naturally if > the Cleaner thread reports the current class loader as the system > loader. Does it? I missed the fact that we already special case this for JNI_OnLoad and JNI_OnUnload. I would have thought that in the OnLoad case we would find the classloader of the class loading the native library without any need to resort to the NativeLibrary support code in ClassLoader. I guess that this: // Find calling class Klass* k = thread->security_get_caller_class(0); does not find the "caller" that I would have expected, but instead finds java.lang.System because we're executing System.loadLibrary - and hence finds the boot loader not the actual loader required. But the fact we jump through all these hoops is in itself questionable because the specification for JNI_FindClass does not indicate this will happen. It only accounts for two cases: 1. A JNI call from a declared native method - which uses the loader of the class that defines the method 2. A JNI call "through the Invocation Interface" which I interpret as being a JNI call from C code, from an attached thread, with no Java frames on the stack. In which case the system loader is used. A call from JNI_OnLoad (or OnUnload) does not, to me, fit either of these cases; nor does JNI_OnLoad say anything about the context in which it executes. So it seems we have presumed that this case should mean "use the loader of the class which loaded the native library". A very reasonable approach, but not one defined by the specification as far as I can see. But given this, it is not unreasonable to also use the same interpretation for JNI_OnUnload. So there is a gap in the specification regarding the execution context of the library lifecycle function hooks - other than onUnload being an "unknown context". David ----- > > Thanks, > David > >> >> Mandy From xueming.shen at oracle.com Wed Sep 27 14:56:43 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Wed, 27 Sep 2017 07:56:43 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <23d51a9d-6b25-4324-c293-556215169401@gmail.com> References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Message-ID: <59CBBC2B.7030800@oracle.com> Hi Peter, Sorry, I might not understand your use scenario correctly. Let me try :-) If clean() is invoked via Deflater.end() first, my reading of the Cleaner code suggests that the clean()->ZStreamRef.run() is run by the thread calling deflater.end() directly, not the Cleaner thread. In this scenario, since we are still inside the synchronized(zsRef) block, all other "zsRef" sensitive deflater methods should be blocked by the same synchronzied(zeRef) ? I would assume we don't have problem in this use scenario? 567 public void end() { 568 synchronized (zsRef) { 569 cleanable.clean(); 570 buf = null; 571 } 572 } If some other method is invoked first, for example the setDictionary(...) as in your sample, any direct invocation of delfater.end() from other thread should be blocked because of "synchronized(zsRef)". So I would assume this is not a concern. It seems the concern is that the "Deflater.this" object itself is no longer needed and becomes unreachable after line#261, therefore this deflater becomes phantom-reachable and the ZStreamRef.run() is called by the Cleaner thread, then we have a race condition between the thread calls the setDictionary() and the Cleaner thread? I guess I might have a wrong assumption here, is it true that if someone/thread is calling deflater.setDictionary(), that someone/thread should still hold a reference to the deflater and therefore prevent it from becoming phantom-reachable? Or you are saying it is possible under the hotspot optimization the deflater.setDictionary() (and its ensureOpen() included) is being inline-ed and therefore there is no more reference to that deflater even we are still inside that deflater.setDictionary(), so that "after ine#261" scenario becomes possible? Thanks, Sherman On 9/27/17, 2:31 AM, Peter Levart wrote: > Hi Sherman, > > At first I checked the Deflater/Inflater changes. I'll come back with > ZipFile later. > > I think the code is mostly correct, but I have a concern. If clean() > is invoked via Deflater.end(), then the Deflater instance is still > alive and synchronization is necessary as other threads might be > concurrently invoking other methods. If clean() is invoked via Cleaner > thread, then Deflater instance is already phantom reachable and no > thread may be accessing it or be in the middle of executing any of its > instance methods. How is this guaranteed? Critical Deflater methods > synchronize on the zsRef instance, so at least at the beginning of the > synchronized block, the Deflater instance is strongly reachable. Take > for example the following Deflater instance method: > > > 254 public void setDictionary(byte[] b, int off, int len) { > 255 if (b == null) { > 256 throw new NullPointerException(); > 257 } > 258 if (off < 0 || len < 0 || off > b.length - len) { > 259 throw new ArrayIndexOutOfBoundsException(); > 260 } > 261 synchronized (zsRef) { > 262 ensureOpen(); > 263 setDictionary(zsRef.address(), b, off, len); > 264 } > 265 } > > > Up to a point where 'this' is dereferenced to obtain the 'zsRef' value > (line 261), the Deflater instance is reachable. But after that, even > ensureOpen() may be inlined and 'this' is not needed any more. After > that point, obtaining zsRef.address() and calling setDictionaly on the > obtained address may be racing with Cleaner thread invoking > ZStreamRef.run(): > > 49 public void run() { > 50 long addr = address; > 51 address = 0; > 52 if (addr != 0) { > 53 end.accept(addr); > 54 } > 55 } > > > Possible program execution is therefore: > > Thread1: > > zsRef.address() - returning non-zero address > > Thread2: > > ZStreamRef.run() - invoking Deflater.end(address) with non-zero > address via the passed-in lambda. > > Thread1: > > setDictionary(, b, off, len) > > > To fix this, you could sprinkle Reference.reachabilityFence(this) at > appropriate places in Deflater, but it is simpler to just add > synchronized modifier to ZStreamRef.run() method. There's no danger of > deadlock(s) since Cleaner ensures the run() method is invoked at most > once. > > The same reasoning applies to Inflater to as code is similar. > > A nit (Deflater and similar to Inflater): > > 187 ZStreamRef ref = new ZStreamRef(init(level, > DEFAULT_STRATEGY, nowrap), > 188 addr -> end(addr)); > > You could use a method reference there. > > Regards, Peter > > > > On 09/27/2017 08:35 AM, Xueming Shen wrote: >> Hi, >> >> Please help review the change for JDK-8185582. >> >> issue: https://bugs.openjdk.java.net/browse/JDK-8185582 >> webrev: http://cr.openjdk.java.net/~sherman/8185582/webrev/ >> csr: https://bugs.openjdk.java.net/browse/JDK-8187485 >> >> The proposed change here is to replace the finalize() cleanup >> mechanism with >> the newly introduced java.lang.ref.Cleaner for java.util.zip package >> (Deflater, >> Inflater, ZipFile and >> ZipFile.ZipFileInputStrean/ZipFileInflaterInputStream). >> >> Since it's an "incompatible" change, both behavioral and source >> incompatibility, >> to remove the public finalize() from these classes, a corresponding >> CSR is also >> created and need review as well. >> >> Thanks, >> Sherman >> > From paul.sandoz at oracle.com Wed Sep 27 17:07:17 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 27 Sep 2017 10:07:17 -0700 Subject: Invoke MR-JAR file verifier on command line without actually packaging In-Reply-To: <04c401d3377b$d1ee3230$75ca9690$@apache.org> References: <04c401d3377b$d1ee3230$75ca9690$@apache.org> Message-ID: Hi Uwe, Unfortunately i don?t recall there being a publicly supported way to validate an existing Mr.Jar (except by recreating it), either by the jar tool itself nor by a programatic API. In a more general sense the problem is one of given two jars validate that the class file bytes in each expose a compatible public API, with a valid Mr.Jar being more restrictive that no new public artifacts should be introduced. I don?t know of any tooling outside of the JDK that might do such checks. > On 27 Sep 2017, at 03:31, Uwe Schindler wrote: > > Hi, > > I am building a multi-release JAR file using Apache Ant (for Lucene, see https://issues.apache.org/jira/browse/LUCENE-7966). > > As build tools like Ant/Gradle/Maven are packaging JAR files on their own, not using the official JAR tool, I wanted to do a quick check if the resulting JAR file is valid. https://bugs.openjdk.java.net/browse/JDK-8158295 added some checks to compare method signatures and class file between the base and the META-INF/versions occurrences. > > Is there a way to invoke those checks on an already packaged JAR file? > > Uwe > > P.S.: Just a bit of background for those who are interested! This is a totally new way to create a MR JAR by just pacthing the already compiled class files before packaging as JAR file. The use case here is: > - We want to use java.util.Arrays / java.util.Objects static methods throughout Lucene, especially to improve bounds checks by having Java 9 use the intrinsics when accessing arrays/ByteBuffers. We have already seen a huge speed improvement for our implementation of the LZ4 compression! Good know! > - We need to be compatible with Java 8, but improve Java 9. > - So we compile all our Lucene classes against a "custom" variant of the interesting methods, located in a fallback classes we have implemented in our own org.apache.lucene.future.FutureArrays/FutureObjects. > - We do not want to duplicate our code by creating clonesof all .java files that use these methods and we still want to still compile against Java 8 - as this is the release JDK version! We want it automatic! > > So our trick is new and also way cool: During packaging the JAR file we patch all class files using ASM's ClassRemapper and replace the Type org.apache.lucene.future.FutureArrays by java.util.Arrays, only for those that actually contain a reference to our own replacement methods. This is a 74-liner in Groovy! After patching we also place the patched files in the MR part of JAR file. > > Patch can be seen here: > https://github.com/apache/lucene-solr/compare/master...uschindler:jira/LUCENE-7966-v2 > > Especially this is how we patch our class files, way cool: > https://github.com/uschindler/lucene-solr/blob/d67eb6274d4c0b8315848db3f09809fbc0797f6e/lucene/core/src/tools/groovy/patch-mrjar-classes.groovy > Very neat. Paul. From hboehm at google.com Wed Sep 27 17:55:13 2017 From: hboehm at google.com (Hans Boehm) Date: Wed, 27 Sep 2017 10:55:13 -0700 Subject: Phantom Referencesvs finalizers (was: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers) Message-ID: "And of course, it guarantees that the tracked referent can not be resurrected as a result of cleanup code execution." True, but it seems to me that the real property you want is "it guarantees that the tracked referent can not be resurrected". Full stop. Actually, the property I really need is: "The referent of an enqueued PhantomReference cannot subsequently be accessed." Unfortunately, neither of those last two appear to be true due to the weakly specified behavior of JNI WeakGlobalRefs. The spec says: "Interactions between weak global references and PhantomReferences are undefined. In particular, implementations of a Java VM may (or may not) process weak global references after PhantomReferences, and it may (or may not) be possible to use weak global references to hold on to objects which are also referred to by PhantomReference objects. This undefined use of weak global references should be avoided." This allows a WeakGlobalRef to be converted to a strong JNI ref after a PhantomReference to the same object has been enqueued, thus resurrecting the referent, and allowing access. The advice in the last sentence seems to be both essential and completely impractical, since the WeakGlobalRef may point to another object, which may then indirectly point ot the PhantomReference referent. Hence you can't prevent this interaction without global, whole program knowledge of which objects may indirectly reference PhantomReference referents. This is essentially the same problem we had with (unordered) finalization, only now confined to programs that use WeakGlobalRefs. Am I reading this correctly? Is it intended? It seems like it should be fixable by giving WeakGlobalRefs essentially WeakReference behavior, as the name implies? On Wed, Sep 27, 2017 at 3:36 AM, Peter Levart wrote: > Hi David, > > On 09/27/2017 11:52 AM, David Holmes wrote: > >> Hi Peter, >> >> I thought Cleaner was supposed to avoid all these unpredictable >> reachability races? Otherwise why switch from using a finalizer ?? >> > > Unfortunately, there is no hidden magic in Cleaner. It is better than > finalize() mostly because the clean-up function may be invoked by the user, > which also de-registers it, allowing GC to collect it rather than leaving > it to reference-processing pipeline to process it for no reason. And of > course, it guarantees that the tracked referent can not be resurrected as a > result of cleanup code execution. What remains unchanged with Cleaner is > the point in program execution when the tracked referent is determined to > be phantom-reachable (finalizable) and therefore its associated > PhantomReference(s) eligible for processing (finalize() invoked). > > Regards, Peter > > > >> David >> >> On 27/09/2017 7:31 PM, Peter Levart wrote: >> >>> Hi Sherman, >>> >>> At first I checked the Deflater/Inflater changes. I'll come back with >>> ZipFile later. >>> >>> I think the code is mostly correct, but I have a concern. If clean() is >>> invoked via Deflater.end(), then the Deflater instance is still alive and >>> synchronization is necessary as other threads might be concurrently >>> invoking other methods. If clean() is invoked via Cleaner thread, then >>> Deflater instance is already phantom reachable and no thread may be >>> accessing it or be in the middle of executing any of its instance methods. >>> How is this guaranteed? Critical Deflater methods synchronize on the zsRef >>> instance, so at least at the beginning of the synchronized block, the >>> Deflater instance is strongly reachable. Take for example the following >>> Deflater instance method: >>> >>> >>> 254 public void setDictionary(byte[] b, int off, int len) { >>> 255 if (b == null) { >>> 256 throw new NullPointerException(); >>> 257 } >>> 258 if (off < 0 || len < 0 || off > b.length - len) { >>> 259 throw new ArrayIndexOutOfBoundsException(); >>> 260 } >>> 261 synchronized (zsRef) { >>> 262 ensureOpen(); >>> 263 setDictionary(zsRef.address(), b, off, len); >>> 264 } >>> 265 } >>> >>> >>> Up to a point where 'this' is dereferenced to obtain the 'zsRef' value >>> (line 261), the Deflater instance is reachable. But after that, even >>> ensureOpen() may be inlined and 'this' is not needed any more. After that >>> point, obtaining zsRef.address() and calling setDictionaly on the obtained >>> address may be racing with Cleaner thread invoking ZStreamRef.run(): >>> >>> 49 public void run() { >>> 50 long addr = address; >>> 51 address = 0; >>> 52 if (addr != 0) { >>> 53 end.accept(addr); >>> 54 } >>> 55 } >>> >>> >>> Possible program execution is therefore: >>> >>> Thread1: >>> >>> zsRef.address() - returning non-zero address >>> >>> Thread2: >>> >>> ZStreamRef.run() - invoking Deflater.end(address) with non-zero address >>> via the passed-in lambda. >>> >>> Thread1: >>> >>> setDictionary(, b, off, len) >>> >>> >>> To fix this, you could sprinkle Reference.reachabilityFence(this) at >>> appropriate places in Deflater, but it is simpler to just add synchronized >>> modifier to ZStreamRef.run() method. There's no danger of deadlock(s) since >>> Cleaner ensures the run() method is invoked at most once. >>> >>> The same reasoning applies to Inflater to as code is similar. >>> >>> A nit (Deflater and similar to Inflater): >>> >>> 187 ZStreamRef ref = new ZStreamRef(init(level, >>> DEFAULT_STRATEGY, nowrap), >>> 188 addr -> end(addr)); >>> >>> You could use a method reference there. >>> >>> Regards, Peter >>> >>> >>> >>> On 09/27/2017 08:35 AM, Xueming Shen wrote: >>> >>>> Hi, >>>> >>>> Please help review the change for JDK-8185582. >>>> >>>> issue: https://bugs.openjdk.java.net/browse/JDK-8185582 >>>> webrev: http://cr.openjdk.java.net/~sherman/8185582/webrev/ >>>> csr: https://bugs.openjdk.java.net/browse/JDK-8187485 >>>> >>>> The proposed change here is to replace the finalize() cleanup mechanism >>>> with >>>> the newly introduced java.lang.ref.Cleaner for java.util.zip package >>>> (Deflater, >>>> Inflater, ZipFile and ZipFile.ZipFileInputStrean/Zip >>>> FileInflaterInputStream). >>>> >>>> Since it's an "incompatible" change, both behavioral and source >>>> incompatibility, >>>> to remove the public finalize() from these classes, a corresponding CSR >>>> is also >>>> created and need review as well. >>>> >>>> Thanks, >>>> Sherman >>>> >>>> >>> > From paul.sandoz at oracle.com Wed Sep 27 18:38:30 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 27 Sep 2017 11:38:30 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> Message-ID: <9F0F9A64-1F0C-4EB2-A087-9898B933A447@oracle.com> > On 21 Sep 2017, at 10:29, Paul Sandoz wrote: > > Looks good, i just need to look a little more closely at the ConcurrentSkipListMap changes. > 328 * Note that, with VarHandles, a boolean result of 329 * compareAndSet must be declared even if not used. This should not be necessary, since for such methods the return is not polymorphic. Did you observe some performance or code generation issues? Paul. From mandy.chung at oracle.com Wed Sep 27 18:58:22 2017 From: mandy.chung at oracle.com (mandy chung) Date: Wed, 27 Sep 2017 11:58:22 -0700 Subject: Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library In-Reply-To: <22d101c6-5255-b9b7-606c-6f5519a5c597@oracle.com> References: <1643128c-8714-4d6d-253a-b7413a5eb8ef@oracle.com> <9b5b908b-e54c-67c4-13a4-250d2087241f@oracle.com> <42cd522c-4a1f-f231-3323-6bb4a0183a1e@oracle.com> <3a0fe286-f38a-f7f1-4a23-15c43bb42a80@oracle.com> <3d52390c-d468-1f74-6e1e-4a9bc960b681@oracle.com> <1e71b112-cdd5-ba0d-d519-5d54e5ace549@oracle.com> <0c6802f2-678b-977d-e827-ef03c7f376a2@oracle.com> <22d101c6-5255-b9b7-606c-6f5519a5c597@oracle.com> Message-ID: On 9/27/17 5:49 AM, David Holmes wrote: > > I missed the fact that we already special case this for JNI_OnLoad and > JNI_OnUnload. Yes this is buried in JNI_FindClass method. > I would have thought that in the OnLoad case we would find the > classloader of the class loading the native library without any need > to resort to the NativeLibrary support code in ClassLoader. I guess > that this: > > ? // Find calling class > ? Klass* k = thread->security_get_caller_class(0); > > does not find the "caller" that I would have expected, but instead > finds java.lang.System because we're executing System.loadLibrary - > and hence finds the boot loader not the actual loader required. > In the current implementation (without this change), NativeLibrary.load and NativeLibrary.unload native methods are the caller calling JNI_OnLoad and JNI_OnUnload respectively. > But the fact we jump through all these hoops is in itself questionable > because the specification for JNI_FindClass does not indicate this > will happen. It only accounts for two cases: > > 1. A JNI call from a declared native method - which uses the loader of > the class that defines the method > > 2. A JNI call "through the Invocation Interface" which I interpret as > being a JNI call from C code, from an attached thread, with no Java > frames on the stack. In which case the system loader is used. > > A call from JNI_OnLoad (or OnUnload) does not, to me, fit either of > these cases; nor does JNI_OnLoad say anything about the context in > which it executes. So it seems we have presumed that this case should > mean "use the loader of the class which loaded the native library". A > very reasonable approach, but not one defined by the specification as > far as I can see. That's the whole point of this discussion and the spec needs clarification. > But given this, it is not unreasonable to also use the same > interpretation for JNI_OnUnload. > That might be how it ends up the current implementation. > So there is a gap in the specification regarding the execution context > of the library lifecycle function hooks - other than onUnload being an > "unknown context". This suggests that we should clarify in JNI_OnLoad spec to specify the context. FYI.? I file a separate issue: https://bugs.openjdk.java.net/browse/JDK-8188052 Mandy From paul.sandoz at oracle.com Wed Sep 27 19:18:05 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 27 Sep 2017 12:18:05 -0700 Subject: Review Request: JDK-6373396: (cl spec) clarify spec of ClassLoader.getPackages() about run-time package In-Reply-To: <902c2df2-c8ae-fd8e-f830-8be4e1b8d86c@oracle.com> References: <902c2df2-c8ae-fd8e-f830-8be4e1b8d86c@oracle.com> Message-ID: <8855126C-BA96-49C3-999E-7CBDD021705B@oracle.com> > On 26 Sep 2017, at 13:13, mandy chung wrote: > > Minor update to the spec of ClassLoader::getPackages and other relevant methods to clarify that the Package(s) are the packages that *have been* defined. Also include a link to JVMS 5.3 about run-time packages, as in Package class spec. > > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/6373396/webrev.00/ > +1 Paul. From mandy.chung at oracle.com Wed Sep 27 20:41:20 2017 From: mandy.chung at oracle.com (mandy chung) Date: Wed, 27 Sep 2017 13:41:20 -0700 Subject: Phantom Referencesvs finalizers (was: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers) In-Reply-To: References: Message-ID: On 9/27/17 10:55 AM, Hans Boehm wrote: > "And of course, it guarantees that the tracked referent can not be > resurrected as a result of cleanup code execution." > > True, but it seems to me that the real property you want is "it guarantees > that the tracked referent can not be resurrected". Full stop. Actually, the > property I really need is: "The referent of an enqueued PhantomReference > cannot subsequently be accessed." > > Unfortunately, neither of those last two appear to be true due to the > weakly specified behavior of JNI WeakGlobalRefs. The spec says: > > "Interactions between weak global references and PhantomReferences are > undefined. In particular, implementations of a Java VM may (or may not) > process weak global references after PhantomReferences, and it may (or may > not) be possible to use weak global references to hold on to objects which > are also referred to by PhantomReference objects. This undefined use of > weak global references should be avoided." > > This allows a WeakGlobalRef to be converted to a strong JNI ref after a > PhantomReference to the same object has been enqueued, thus resurrecting > the referent, and allowing access. > > The advice in the last sentence seems to be both essential and completely > impractical, since the WeakGlobalRef may point to another object, which may > then indirectly point ot the PhantomReference referent. Hence you can't > prevent this interaction without global, whole program knowledge of which > objects may indirectly reference PhantomReference referents. This is > essentially the same problem we had with (unordered) finalization, only now > confined to programs that use WeakGlobalRefs. > > Am I reading this correctly? Is it intended? It seems like it should be > fixable by giving WeakGlobalRefs essentially WeakReference behavior, as the > name implies? > Thanks for pointing this out.?? I create a JBS issue to follow up this: ?? https://bugs.openjdk.java.net/browse/JDK-8188066 Mandy From dl at cs.oswego.edu Wed Sep 27 20:44:09 2017 From: dl at cs.oswego.edu (Doug Lea) Date: Wed, 27 Sep 2017 16:44:09 -0400 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: <9F0F9A64-1F0C-4EB2-A087-9898B933A447@oracle.com> References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> <9F0F9A64-1F0C-4EB2-A087-9898B933A447@oracle.com> Message-ID: On 09/27/2017 02:38 PM, Paul Sandoz wrote: >> Looks good, i just need to look a little more closely at the ConcurrentSkipListMap changes. >> > > > 328 * Note that, with VarHandles, a boolean result of > 329 * compareAndSet must be declared even if not used. > This should not be necessary, since for such methods the return is not polymorphic. Did you observe some performance or code generation issues? > It was necessary at the time I started rewriting this in June, but apparently not now. I'll get rid of the annoying unnecessary declarations. Thanks to whoever fixed this! -Doug From kim.barrett at oracle.com Wed Sep 27 21:12:37 2017 From: kim.barrett at oracle.com (Kim Barrett) Date: Wed, 27 Sep 2017 17:12:37 -0400 Subject: Phantom Referencesvs finalizers (was: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers) In-Reply-To: References: Message-ID: <73D2ABF1-0E00-4544-B456-BFE6CF9DF92E@oracle.com> > On Sep 27, 2017, at 1:55 PM, Hans Boehm wrote: > > "And of course, it guarantees that the tracked referent can not be > resurrected as a result of cleanup code execution." > > True, but it seems to me that the real property you want is "it guarantees > that the tracked referent can not be resurrected". Full stop. Actually, the > property I really need is: "The referent of an enqueued PhantomReference > cannot subsequently be accessed." > > Unfortunately, neither of those last two appear to be true due to the > weakly specified behavior of JNI WeakGlobalRefs. The spec says: > > "Interactions between weak global references and PhantomReferences are > undefined. In particular, implementations of a Java VM may (or may not) > process weak global references after PhantomReferences, and it may (or may > not) be possible to use weak global references to hold on to objects which > are also referred to by PhantomReference objects. This undefined use of > weak global references should be avoided." > > This allows a WeakGlobalRef to be converted to a strong JNI ref after a > PhantomReference to the same object has been enqueued, thus resurrecting > the referent, and allowing access. > > The advice in the last sentence seems to be both essential and completely > impractical, since the WeakGlobalRef may point to another object, which may > then indirectly point ot the PhantomReference referent. Hence you can't > prevent this interaction without global, whole program knowledge of which > objects may indirectly reference PhantomReference referents. This is > essentially the same problem we had with (unordered) finalization, only now > confined to programs that use WeakGlobalRefs. > > Am I reading this correctly? Is it intended? It seems like it should be > fixable by giving WeakGlobalRefs essentially WeakReference behavior, as the > name implies? That quote from the JNI specification is, I think, left over from before JDK-8071507. Now that PhantomReferences are cleared when their referent is no longer referenced, the effective strength of phantoms and JNI weak references are equivalent, at least in Hotspot. The java.lang.ref and JNI specifications seem to allow the possibility that an implementation will clear references at a given strength without clearing references of a weaker strength, even if that would allow the referent of one of those stronger references to be obtained via one of those weaker references. (And indeed, that must be possible for finalize.) I'm not sure that's intentional though (except for finalize), and I've seen discussions [1] suggesting that it would be at least surprising to behave that way; Hotspot certainly doesn't, and those discussions suggested that neither do any of the other implementations. This suggests some specification tightening is called for, in order to address these concerns around post-Cleaner cleanup resurrection. [2] Giving WeakGlobalRefs essentially WeakReference behavior has been tried in the past, and doing so broke some code. [3] Whether that's still relevant is probably moot now, because of JDK-8071507. [1] http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/2016-January/016223.html [2] https://bugs.openjdk.java.net/browse/JDK-8188066 [3] https://bugs.openjdk.java.net/browse/JDK-4126360 From aleksej.efimov at oracle.com Wed Sep 27 21:28:28 2017 From: aleksej.efimov at oracle.com (Aleks Efimov) Date: Wed, 27 Sep 2017 22:28:28 +0100 Subject: [8u-dev][JAXB] Request for review and approval: 8159240: XSOM parser incorrectly processes type names with whitespaces Message-ID: <008ef343-c8f7-bb3d-8c51-5acec3e77a72@oracle.com> Hi, Can I, please, ask for review and approval of JDK-8159240 backport to JDK8? This bug was resolved in JDK9 as part of JAXWS-RI sync changeset (JDK-8164479) therefore separate review for the partially backported changes is needed: http://cr.openjdk.java.net/~aefimov/8159240/8/00/ File changes partially backported to JDK8 from JDK9 sync changeset: ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l37.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l38.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l39.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l40.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l41.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l42.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l43.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l44.1 ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l45.1 Testing: ??? New regression test and all jaxb/ws related JCK/JTREG tests shows no failures. JBS bug: ??? https://bugs.openjdk.java.net/browse/JDK-8159240 JAXWS-RI sync bug: ??? https://bugs.openjdk.java.net/browse/JDK-8164479 JDK9 JAXWS-RI sync changeset: ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052 JDK9 JAXWS-RI sync review threads: http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-September/043724.html http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-October/043920.html http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-November/044513.html JAXWS-RI changes for XSOM parser: https://github.com/javaee/jaxb-v2/commit/cc9c09a71d739989d1e250d9db8c1e011215abfd#diff-796464168dc0014203b00c9728d41de8 With Best Regards, Aleksei From mandy.chung at oracle.com Wed Sep 27 22:08:39 2017 From: mandy.chung at oracle.com (mandy chung) Date: Wed, 27 Sep 2017 15:08:39 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CB46AE.2000701@oracle.com> References: <59CB46AE.2000701@oracle.com> Message-ID: Comment on the CSR: On 9/26/17 11:35 PM, Xueming Shen wrote: > > csr:?????? https://bugs.openjdk.java.net/browse/JDK-8187485 > I think the @apiNote can be simpler. Deflater (similar comment for Inflater) |* @apiNote * In earlier versions, the {@link Object#finalize} method was overridden * to call the {@link #end} method when a {@code Deflater} object * becomes unreachable. * The {@link #finalize} method is no longer defined. If a subclass * overrides ||the {@code end} method, the overridden {@code end} method * is no longer invoked. ?*

* It is strongly recommended to explicitly call {@code end} to ||* discard any unprocessed input promptly to free up resources |* when |||the compressor |is no longer in use.| |ZipFile * @apiNote |* In earlier versions, the {@link Object#finalize} method was overridden * to call the {@link #close} method when a {@code ZipFile} object * becomes unreachable.| |* The {@link #finalize} method is no longer defined. If a subclass * overrides ||the {@code close} method, the overridden {@code close} method * is no longer invoked.| *

|* The recommended cleanup for |||{@code ZipFile}| is to explicitly call {@code close} * or use try-with-resources.| 657 *

658 * Since the time when the resources held by this object will be released 659 * is undetermined, if this method is not invoked explicitly, it is strongly 660 * recommended that applications invoke this method as soon they have 661 * finished accessing this {@code ZipFile}. This will prevent holding up 662 * system resources for an undetermined length of time. 663 *

I would suggest to drop this paragraph. @apiNote and @implNote in class spec cover that. Mandy || From xueming.shen at oracle.com Wed Sep 27 23:41:25 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Wed, 27 Sep 2017 16:41:25 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: References: <59CB46AE.2000701@oracle.com> Message-ID: <59CC3725.7080505@oracle.com> Thanks Mandy! I removed the ln#657-#663, and updated the @apiNote in deflter, inflater and zipfile accordingly, mainly combined your comment and the approach for the fis/fo. they are "simpler" and straightforward now, at least for me. https://bugs.openjdk.java.net/browse/JDK-8187485 http://cr.openjdk.java.net/~sherman/8185582/webrev -Sherman On 9/27/17, 3:08 PM, mandy chung wrote: > > Comment on the CSR: > > On 9/26/17 11:35 PM, Xueming Shen wrote: >> >> csr: https://bugs.openjdk.java.net/browse/JDK-8187485 >> > I think the @apiNote can be simpler. > > Deflater (similar comment for Inflater) > | * @apiNote > * In earlier versions, the {@link Object#finalize} method was overridden > * to call the {@link #end} method when a {@code Deflater} object > * becomes unreachable. > * The {@link #finalize} method is no longer defined. If a subclass > * overrides||the {@code end} method, the overridden {@code end} method > * is no longer invoked. > *

> * It is strongly recommended to explicitly call {@code end} to > || * discard any unprocessed input promptly to free up resources > | * when|||the compressor|is no longer in use.| > > > |ZipFile > > * @apiNote > | * In earlier versions, the {@link Object#finalize} method was overridden > * to call the {@link #close} method when a {@code ZipFile} object > * becomes unreachable.| > | * The {@link #finalize} method is no longer defined. If a subclass > * overrides||the {@code close} method, the overridden {@code close} method > * is no longer invoked.| > *

> | * The recommended cleanup for|||{@code ZipFile}| is to explicitly call {@code close} > * or use try-with-resources.| > > 657 *

> 658 * Since the time when the resources held by this object will be released > 659 * is undetermined, if this method is not invoked explicitly, it is strongly > 660 * recommended that applications invoke this method as soon they have > 661 * finished accessing this {@code ZipFile}. This will prevent holding up > 662 * system resources for an undetermined length of time. > 663 *

> > I would suggest to drop this paragraph. @apiNote and @implNote in > class spec cover that. > > Mandy > || From Alan.Bateman at oracle.com Thu Sep 28 06:18:28 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Thu, 28 Sep 2017 07:18:28 +0100 Subject: Review Request: JDK-6373396: (cl spec) clarify spec of ClassLoader.getPackages() about run-time package In-Reply-To: <902c2df2-c8ae-fd8e-f830-8be4e1b8d86c@oracle.com> References: <902c2df2-c8ae-fd8e-f830-8be4e1b8d86c@oracle.com> Message-ID: On 26/09/2017 21:13, mandy chung wrote: > Minor update to the spec of ClassLoader::getPackages and other > relevant methods to clarify that the Package(s) are the packages that > *have been* defined.? Also include a link to JVMS 5.3 about run-time > packages, as in Package class spec. > > http://cr.openjdk.java.net/~mchung/jdk10/webrevs/6373396/webrev.00/ This looks okay to me. -Alan From frank.yuan at oracle.com Thu Sep 28 08:37:41 2017 From: frank.yuan at oracle.com (Frank Yuan) Date: Thu, 28 Sep 2017 16:37:41 +0800 Subject: [10] [testbug] RFR of JDK-8187700 SetAuthenticator tests should handle the proxy port Message-ID: <011301d33835$0e0929a0$2a1b7ce0$@oracle.com> Hi Daniel and all Would you like to review http://cr.openjdk.java.net/~fyuan/8187700/webrev.00/? Bug: https://bugs.openjdk.java.net/browse/JDK-8187700 I applied the fix for proxy port reusing issue, which was reviewed in bug JDK-8187507. And made a few code cleaning in HTTPSetAuthenticatorTest.java Thanks Frank From jason_mehrens at hotmail.com Thu Sep 28 14:22:42 2017 From: jason_mehrens at hotmail.com (Jason Mehrens) Date: Thu, 28 Sep 2017 14:22:42 +0000 Subject: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator In-Reply-To: References: <92ca3601-f228-026a-8378-16c331ab9cb5@oracle.com> <08f39675-ba33-70f6-7f35-467569825989@oracle.com> <37e162ca-bf08-9211-afce-7fbd85484208@oracle.com>, Message-ID: Ivan, Am I correct that subtraction of code points is safe from underflow due to the range of Character.MIN_CODE_POINT and Character.MAX_CODE_POINT? That would explain why you are not using Integer.compare. One alternative to calling CharSequence.subSequence is to use CharBuffer.wrap(CharSequence csq, int start, int end). The sub-sequences are short lived so that may be faster in the String case. Admittedly this is more of a Claes Redestad faster boot up type change but, the use of the AlphaDecimalComparator constructor in Comparator might force the bytecode verifier to force load AlphaDecimalComparator just to check the return type. If you make factory methods in AlphaDecimalComparator you can usually craft the return type to match and the verify of Comparator will not force load the AlphaDecimalComparator. Otherwise, the more ugly solution is to wrap 'new' with Comparator.class.cast. Jason ________________________________________ From: core-libs-dev on behalf of Ivan Gerasimov Sent: Monday, September 25, 2017 12:49 PM To: core-libs-dev Subject: Re: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator Hello! Could you please review at your convenience? In the latest webrev I took all suggestions into account (unless I missed something.) http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ I think, if the suggested comparator is found useful by the users, then it may make sense to create the String-oriented variant, which can be implemented through the CharSequence-oriented one as: class String { ... @SuppressWarnings("unchecked") public static Comparator comparingAlphaDecimal(Comparator alphaComparator) { return (Comparator) (Comparator) new Comparators.AlphaDecimalComparator<>(Objects.requireNonNull( (Comparator) alphaComparator), false); } } This will be safe, since the specification guarantees that String.subSequence() returns a String. Then in the application code it would be possible to instantiate the comparators as String.comparingAlphaDecimal(String::compareTo); String.comparingAlphaDecimal(String::compareToIgnoreCase); or, alternatively, String.comparingAlphaDecimal(Comparator.naturalOrder()); String.comparingAlphaDecimal(String.CASE_INSENSITIVE_ORDER); But this could be deferred for later, of course. With kind regards, Ivan On 8/27/17 1:38 PM, Ivan Gerasimov wrote: > Hello everyone! > > Here's another iteration of the comparator with suggested improvements. > > Now, there is the only input argument -- the alpha-comparator for > comparing the non-decimal-digit sub-sequences. > > For the javadoc I used the text suggested by Peter with some > modifications, additional example and API/implementation notes. > Overall, the javadoc looks heavier than need to me, so I'd love to > hear comments about how to make it shorter and cleaner. > > Also, I adopted the name AlphaDecimal, suggested by Peter. This name > is one of popular in the list of variants found in the wild. So, there > are higher chances the users can find the routine by its name. > > For testing if a code point is a decimal digit, I used > (Character.getType(cp) == Character.DECIMAL_DIGIT_NUMBER), which seem > to be more appropriate than Character.isDigit(). (The later is true > for things like a digit in a circle, superscript, etc., which do not > seem to be a part of a decimal number composed of several digits.) > > The updated webrev: > http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ > > Please review at your convenience. > > With kind regards, > Ivan > > On 8/9/17 4:59 PM, Stuart Marks wrote: >> On 8/1/17 11:56 PM, Ivan Gerasimov wrote: >>> I've tried to go one step further and created even more abstract >>> comparator: It >>> uses a supplied predicate to decompose the input sequences into >>> odd/even >>> subsequences (e.g. alpha/numeric) and then uses two separate >>> comparator to >>> compare them. Additionally, a comparator for comparing sequences, >>> consisting >>> only of digits is provided. For example, to build a case-insensitive >>> AlphaDecimal comparator one could use: 1) Character::isDigit -- as >>> the predicate >>> for decomposing, 2) String::compareToIgnoreCase -- to compare alpha >>> (i.e. odd >>> parts); to work with CharSequences one would need to make it >>> Comparator.comparing(CharSequence::toString, >>> String::compareToIgnoreCase), 3) >>> The special decimal-only comparator, which compares the decimal >>> representation >>> of the sequences. Here's the file with all the comparators and a >>> simple test: >>> http://cr.openjdk.java.net/~igerasim/8134512/test/Test.java >> >> Hi, a couple follow-up thoughts on this. >> >> 1) Supplementary characters >> >> The current code uses Character.isDigit(char), which works only for >> char values in the BMP (basic multilingual plane, values <= U+FFFF). >> It won't work for supplementary characters. There are several blocks >> of digits in the BMP, but there are several more in the supplementary >> character range. >> >> I don't see any reason not to handle the supplementary characters as >> well, except that it spoils the nice char-by-char technique of >> processing the string. Instead, it'd have to pull in code point >> values, which might be comprised of two surrogate chars. There are a >> variety of methods on Character that help with this. Note that there >> is an overload Character.isDigit(int) which takes any code point >> value, including supplementary characters. >> >> 2) Too much generality? >> >> This version includes Predicate for determining whether a >> character is part of the alphabetic or decimal portion of the string. >> I'm thinking this might be overkill. It might be sufficient to >> "hardwire" the partitioning predicate to be Character::isDigit and >> the value mapping function to use Character::digit. >> >> The problem is that adding a predicate opens the door to a lot more >> complexity, while providing dimishing value. First, the predicate >> would have to handle code points (per the above) so it'd need to be >> an IntPredicate. Second, there would also need to be a mapping >> function from the code point value to a numeric value. This might be >> an IntUnaryOperator. This would allow someone to sort based on Roman >> numerals, using Character::getNumericValue. (Yes, Roman numerals are >> in Unicode.) Or maybe the mapping function should return any >> Comparable value, not an int. ... See where I'm going here? >> >> Since this kind of sorting is intended to be viewed by people, it's >> probably worth providing full internationalization support >> (supplementary characters, and delegation to sub-comparators, to >> allow locale-specific collating sequences). But I start to question >> any complexity beyond that. >> >> s'marks >> > -- With kind regards, Ivan Gerasimov From sean.coffey at oracle.com Thu Sep 28 17:02:35 2017 From: sean.coffey at oracle.com (=?UTF-8?Q?Se=c3=a1n_Coffey?=) Date: Thu, 28 Sep 2017 18:02:35 +0100 Subject: [8u-dev][JAXB] Request for review and approval: 8159240: XSOM parser incorrectly processes type names with whitespaces In-Reply-To: <008ef343-c8f7-bb3d-8c51-5acec3e77a72@oracle.com> References: <008ef343-c8f7-bb3d-8c51-5acec3e77a72@oracle.com> Message-ID: This looks fine Aleksei.? Approved for jdk8u-dev. The JDK-8159240 record is currently closed as a duplicate. I'd suggest you reopen that master record for your 8u-dev port and mark it 9-na. regards, Sean. On 27/09/2017 22:28, Aleks Efimov wrote: > Hi, > > Can I, please, ask for review and approval of JDK-8159240 backport to > JDK8? This bug was resolved in JDK9 as part of JAXWS-RI sync changeset > (JDK-8164479) therefore separate review for the partially backported > changes is needed: http://cr.openjdk.java.net/~aefimov/8159240/8/00/ > > File changes partially backported to JDK8 from JDK9 sync changeset: > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l37.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l38.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l39.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l40.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l41.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l42.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l43.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l44.1 > http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052#l45.1 > > Testing: > ??? New regression test and all jaxb/ws related JCK/JTREG tests shows > no failures. > > JBS bug: > ??? https://bugs.openjdk.java.net/browse/JDK-8159240 > > JAXWS-RI sync bug: > ??? https://bugs.openjdk.java.net/browse/JDK-8164479 > > JDK9 JAXWS-RI sync changeset: > ??? http://hg.openjdk.java.net/jdk9/dev/jaxws/rev/26c9b9c51052 > > JDK9 JAXWS-RI sync review threads: > http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-September/043724.html > > http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-October/043920.html > > http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-November/044513.html > > > JAXWS-RI changes for XSOM parser: > https://github.com/javaee/jaxb-v2/commit/cc9c09a71d739989d1e250d9db8c1e011215abfd#diff-796464168dc0014203b00c9728d41de8 > > > With Best Regards, > Aleksei > From ivan.gerasimov at oracle.com Thu Sep 28 20:19:51 2017 From: ivan.gerasimov at oracle.com (Ivan Gerasimov) Date: Thu, 28 Sep 2017 13:19:51 -0700 Subject: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator In-Reply-To: References: <92ca3601-f228-026a-8378-16c331ab9cb5@oracle.com> <08f39675-ba33-70f6-7f35-467569825989@oracle.com> <37e162ca-bf08-9211-afce-7fbd85484208@oracle.com> Message-ID: Thank you Jason for valuable input! On 9/28/17 7:22 AM, Jason Mehrens wrote: > Ivan, > > Am I correct that subtraction of code points is safe from underflow due to the range of Character.MIN_CODE_POINT and Character.MAX_CODE_POINT? That would explain why you are not using Integer.compare. Right. Since codepoints are all positive, it should be safe to subtract them. > One alternative to calling CharSequence.subSequence is to use CharBuffer.wrap(CharSequence csq, int start, int end). The sub-sequences are short lived so that may be faster in the String case. Yes, it's a good point, given how expensive String.subSequence() is. The disadvantage of using CharBuffer.wrap() is that it wouldn't be possible to use the standard String comparators as the custom alphaComparator. With the current implementation, it is possible (with additional casts, of course) because we know that String.subSequence returns a String object. To be honest, I see no easy way to optimize the String case with the use of a custom comparator because we need to pass to it portions of the input as String objects. One possibility might be to recognize common cases, like using the standard comparators (for example, String.CASE_INSENSITIVE_ORDER) in place of the custom alphaComparator, and then execute special variant of the routine, which doesn't create explicit subsequences, but works on the entire sequence instead. At this point, however, it's probably too early to do such optimizations. > Admittedly this is more of a Claes Redestad faster boot up type change but, the use of the AlphaDecimalComparator constructor in Comparator might force the bytecode verifier to force load AlphaDecimalComparator just to check the return type. Hm, interesting. We can introduce another factory method in the Comparators class, so that AlphaDecimalComparator won't be mentioned in the Comparator at all. Please see the updated webrev: http://cr.openjdk.java.net/~igerasim/8134512/05/webrev/ With kind regards, Ivan > If you make factory methods in AlphaDecimalComparator you can usually craft the return type to match and the verify of Comparator will not force load the AlphaDecimalComparator. > Otherwise, the more ugly solution is to wrap 'new' with Comparator.class.cast. > > Jason > > > > ________________________________________ > From: core-libs-dev on behalf of Ivan Gerasimov > Sent: Monday, September 25, 2017 12:49 PM > To: core-libs-dev > Subject: Re: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator > > Hello! > > Could you please review at your convenience? > > In the latest webrev I took all suggestions into account (unless I > missed something.) > > http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ > > > I think, if the suggested comparator is found useful by the users, then > it may make sense to create the String-oriented variant, which can be > implemented through the CharSequence-oriented one as: > > class String { > ... > @SuppressWarnings("unchecked") > public static Comparator > comparingAlphaDecimal(Comparator alphaComparator) { > return (Comparator) (Comparator) > new > Comparators.AlphaDecimalComparator<>(Objects.requireNonNull( > (Comparator) alphaComparator), > false); > } > } > > This will be safe, since the specification guarantees that > String.subSequence() returns a String. > > Then in the application code it would be possible to instantiate the > comparators as > > String.comparingAlphaDecimal(String::compareTo); > > String.comparingAlphaDecimal(String::compareToIgnoreCase); > > or, alternatively, > String.comparingAlphaDecimal(Comparator.naturalOrder()); > > String.comparingAlphaDecimal(String.CASE_INSENSITIVE_ORDER); > > But this could be deferred for later, of course. > > With kind regards, > Ivan > > > On 8/27/17 1:38 PM, Ivan Gerasimov wrote: >> Hello everyone! >> >> Here's another iteration of the comparator with suggested improvements. >> >> Now, there is the only input argument -- the alpha-comparator for >> comparing the non-decimal-digit sub-sequences. >> >> For the javadoc I used the text suggested by Peter with some >> modifications, additional example and API/implementation notes. >> Overall, the javadoc looks heavier than need to me, so I'd love to >> hear comments about how to make it shorter and cleaner. >> >> Also, I adopted the name AlphaDecimal, suggested by Peter. This name >> is one of popular in the list of variants found in the wild. So, there >> are higher chances the users can find the routine by its name. >> >> For testing if a code point is a decimal digit, I used >> (Character.getType(cp) == Character.DECIMAL_DIGIT_NUMBER), which seem >> to be more appropriate than Character.isDigit(). (The later is true >> for things like a digit in a circle, superscript, etc., which do not >> seem to be a part of a decimal number composed of several digits.) >> >> The updated webrev: >> http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ >> >> Please review at your convenience. >> >> With kind regards, >> Ivan >> >> On 8/9/17 4:59 PM, Stuart Marks wrote: >>> On 8/1/17 11:56 PM, Ivan Gerasimov wrote: >>>> I've tried to go one step further and created even more abstract >>>> comparator: It >>>> uses a supplied predicate to decompose the input sequences into >>>> odd/even >>>> subsequences (e.g. alpha/numeric) and then uses two separate >>>> comparator to >>>> compare them. Additionally, a comparator for comparing sequences, >>>> consisting >>>> only of digits is provided. For example, to build a case-insensitive >>>> AlphaDecimal comparator one could use: 1) Character::isDigit -- as >>>> the predicate >>>> for decomposing, 2) String::compareToIgnoreCase -- to compare alpha >>>> (i.e. odd >>>> parts); to work with CharSequences one would need to make it >>>> Comparator.comparing(CharSequence::toString, >>>> String::compareToIgnoreCase), 3) >>>> The special decimal-only comparator, which compares the decimal >>>> representation >>>> of the sequences. Here's the file with all the comparators and a >>>> simple test: >>>> http://cr.openjdk.java.net/~igerasim/8134512/test/Test.java >>> Hi, a couple follow-up thoughts on this. >>> >>> 1) Supplementary characters >>> >>> The current code uses Character.isDigit(char), which works only for >>> char values in the BMP (basic multilingual plane, values <= U+FFFF). >>> It won't work for supplementary characters. There are several blocks >>> of digits in the BMP, but there are several more in the supplementary >>> character range. >>> >>> I don't see any reason not to handle the supplementary characters as >>> well, except that it spoils the nice char-by-char technique of >>> processing the string. Instead, it'd have to pull in code point >>> values, which might be comprised of two surrogate chars. There are a >>> variety of methods on Character that help with this. Note that there >>> is an overload Character.isDigit(int) which takes any code point >>> value, including supplementary characters. >>> >>> 2) Too much generality? >>> >>> This version includes Predicate for determining whether a >>> character is part of the alphabetic or decimal portion of the string. >>> I'm thinking this might be overkill. It might be sufficient to >>> "hardwire" the partitioning predicate to be Character::isDigit and >>> the value mapping function to use Character::digit. >>> >>> The problem is that adding a predicate opens the door to a lot more >>> complexity, while providing dimishing value. First, the predicate >>> would have to handle code points (per the above) so it'd need to be >>> an IntPredicate. Second, there would also need to be a mapping >>> function from the code point value to a numeric value. This might be >>> an IntUnaryOperator. This would allow someone to sort based on Roman >>> numerals, using Character::getNumericValue. (Yes, Roman numerals are >>> in Unicode.) Or maybe the mapping function should return any >>> Comparable value, not an int. ... See where I'm going here? >>> >>> Since this kind of sorting is intended to be viewed by people, it's >>> probably worth providing full internationalization support >>> (supplementary characters, and delegation to sub-comparators, to >>> allow locale-specific collating sequences). But I start to question >>> any complexity beyond that. >>> >>> s'marks >>> > -- > With kind regards, > Ivan Gerasimov > > -- With kind regards, Ivan Gerasimov From goetz.lindenmaier at sap.com Fri Sep 29 08:05:14 2017 From: goetz.lindenmaier at sap.com (Lindenmaier, Goetz) Date: Fri, 29 Sep 2017 08:05:14 +0000 Subject: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor FileDescriptor close implementation" Message-ID: <53dce614d564477398c96a9a66752e72@sap.com> Hi, please review this tiny fix for the build with Visual Studio 2010: http://cr.openjdk.java.net/~goetz/wr17/8188135-winBuild/webrev.01/ Best regards, Goetz. From david.holmes at oracle.com Fri Sep 29 08:33:23 2017 From: david.holmes at oracle.com (David Holmes) Date: Fri, 29 Sep 2017 18:33:23 +1000 Subject: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor FileDescriptor close implementation" In-Reply-To: <53dce614d564477398c96a9a66752e72@sap.com> References: <53dce614d564477398c96a9a66752e72@sap.com> Message-ID: <3f55d5fa-ce23-fc65-449a-d12038e7a582@oracle.com> On 29/09/2017 6:05 PM, Lindenmaier, Goetz wrote: > Hi, > > please review this tiny fix for the build with Visual Studio 2010: > http://cr.openjdk.java.net/~goetz/wr17/8188135-winBuild/webrev.01/ Looks fine. One day we'll stop getting bitten by archaic compilers :( Cheers, David > Best regards, > Goetz. > From Alan.Bateman at oracle.com Fri Sep 29 08:43:05 2017 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Fri, 29 Sep 2017 09:43:05 +0100 Subject: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor FileDescriptor close implementation" In-Reply-To: <53dce614d564477398c96a9a66752e72@sap.com> References: <53dce614d564477398c96a9a66752e72@sap.com> Message-ID: <5e24b3cb-df24-fc43-54d8-37ab8876723e@oracle.com> On 29/09/2017 09:05, Lindenmaier, Goetz wrote: > Hi, > > please review this tiny fix for the build with Visual Studio 2010: > http://cr.openjdk.java.net/~goetz/wr17/8188135-winBuild/webrev.01/ > Looks okay although I thought VS 2010 was dropped a long time ago. -Alan From goetz.lindenmaier at sap.com Fri Sep 29 09:13:49 2017 From: goetz.lindenmaier at sap.com (Lindenmaier, Goetz) Date: Fri, 29 Sep 2017 09:13:49 +0000 Subject: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor FileDescriptor close implementation" In-Reply-To: <3f55d5fa-ce23-fc65-449a-d12038e7a582@oracle.com> References: <53dce614d564477398c96a9a66752e72@sap.com> <3f55d5fa-ce23-fc65-449a-d12038e7a582@oracle.com> Message-ID: Thanks David! ... at least SAP got rid of gcc 4.1.2 :) Best regards, Goetz. > -----Original Message----- > From: David Holmes [mailto:david.holmes at oracle.com] > Sent: Freitag, 29. September 2017 10:33 > To: Lindenmaier, Goetz ; core-libs- > dev at openjdk.java.net > Subject: Re: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor > FileDescriptor close implementation" > > On 29/09/2017 6:05 PM, Lindenmaier, Goetz wrote: > > Hi, > > > > please review this tiny fix for the build with Visual Studio 2010: > > http://cr.openjdk.java.net/~goetz/wr17/8188135-winBuild/webrev.01/ > > Looks fine. > > One day we'll stop getting bitten by archaic compilers :( > > Cheers, > David > > > Best regards, > > Goetz. > > From goetz.lindenmaier at sap.com Fri Sep 29 09:14:36 2017 From: goetz.lindenmaier at sap.com (Lindenmaier, Goetz) Date: Fri, 29 Sep 2017 09:14:36 +0000 Subject: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor FileDescriptor close implementation" In-Reply-To: <5e24b3cb-df24-fc43-54d8-37ab8876723e@oracle.com> References: <53dce614d564477398c96a9a66752e72@sap.com> <5e24b3cb-df24-fc43-54d8-37ab8876723e@oracle.com> Message-ID: Thanks, Alan! Unfotunately SAP has to stick to VS 2010 a while. Best regards, Goetz. > -----Original Message----- > From: Alan Bateman [mailto:Alan.Bateman at oracle.com] > Sent: Freitag, 29. September 2017 10:43 > To: Lindenmaier, Goetz ; core-libs- > dev at openjdk.java.net > Subject: Re: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor > FileDescriptor close implementation" > > > > On 29/09/2017 09:05, Lindenmaier, Goetz wrote: > > Hi, > > > > please review this tiny fix for the build with Visual Studio 2010: > > http://cr.openjdk.java.net/~goetz/wr17/8188135-winBuild/webrev.01/ > > > Looks okay although I thought VS 2010 was dropped a long time ago. > > -Alan From Roger.Riggs at Oracle.com Fri Sep 29 13:07:16 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 29 Sep 2017 09:07:16 -0400 Subject: RFR(XS): 8188135: Fix VS 2010 build after "8187631: Refactor FileDescriptor close implementation" In-Reply-To: <5e24b3cb-df24-fc43-54d8-37ab8876723e@oracle.com> References: <53dce614d564477398c96a9a66752e72@sap.com> <5e24b3cb-df24-fc43-54d8-37ab8876723e@oracle.com> Message-ID: <9f5c54b9-867f-47cb-e9b4-07157c20a268@Oracle.com> +1 On 9/29/2017 4:43 AM, Alan Bateman wrote: > > > On 29/09/2017 09:05, Lindenmaier, Goetz wrote: >> Hi, >> >> please review this tiny fix for the build with Visual Studio 2010: >> http://cr.openjdk.java.net/~goetz/wr17/8188135-winBuild/webrev.01/ >> > Looks okay although I thought VS 2010 was dropped a long time ago. > > -Alan From jason_mehrens at hotmail.com Fri Sep 29 14:42:01 2017 From: jason_mehrens at hotmail.com (Jason Mehrens) Date: Fri, 29 Sep 2017 14:42:01 +0000 Subject: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator In-Reply-To: References: <92ca3601-f228-026a-8378-16c331ab9cb5@oracle.com> <08f39675-ba33-70f6-7f35-467569825989@oracle.com> <37e162ca-bf08-9211-afce-7fbd85484208@oracle.com> , Message-ID: Makes sense on the sub-sequences having to be string. Looks good. Jason ________________________________________ From: Ivan Gerasimov Sent: Thursday, September 28, 2017 3:19 PM To: Jason Mehrens; core-libs-dev Subject: Re: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator Thank you Jason for valuable input! On 9/28/17 7:22 AM, Jason Mehrens wrote: > Ivan, > > Am I correct that subtraction of code points is safe from underflow due to the range of Character.MIN_CODE_POINT and Character.MAX_CODE_POINT? That would explain why you are not using Integer.compare. Right. Since codepoints are all positive, it should be safe to subtract them. > One alternative to calling CharSequence.subSequence is to use CharBuffer.wrap(CharSequence csq, int start, int end). The sub-sequences are short lived so that may be faster in the String case. Yes, it's a good point, given how expensive String.subSequence() is. The disadvantage of using CharBuffer.wrap() is that it wouldn't be possible to use the standard String comparators as the custom alphaComparator. With the current implementation, it is possible (with additional casts, of course) because we know that String.subSequence returns a String object. To be honest, I see no easy way to optimize the String case with the use of a custom comparator because we need to pass to it portions of the input as String objects. One possibility might be to recognize common cases, like using the standard comparators (for example, String.CASE_INSENSITIVE_ORDER) in place of the custom alphaComparator, and then execute special variant of the routine, which doesn't create explicit subsequences, but works on the entire sequence instead. At this point, however, it's probably too early to do such optimizations. > Admittedly this is more of a Claes Redestad faster boot up type change but, the use of the AlphaDecimalComparator constructor in Comparator might force the bytecode verifier to force load AlphaDecimalComparator just to check the return type. Hm, interesting. We can introduce another factory method in the Comparators class, so that AlphaDecimalComparator won't be mentioned in the Comparator at all. Please see the updated webrev: http://cr.openjdk.java.net/~igerasim/8134512/05/webrev/ With kind regards, Ivan > If you make factory methods in AlphaDecimalComparator you can usually craft the return type to match and the verify of Comparator will not force load the AlphaDecimalComparator. > Otherwise, the more ugly solution is to wrap 'new' with Comparator.class.cast. > > Jason > > > > ________________________________________ > From: core-libs-dev on behalf of Ivan Gerasimov > Sent: Monday, September 25, 2017 12:49 PM > To: core-libs-dev > Subject: Re: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator > > Hello! > > Could you please review at your convenience? > > In the latest webrev I took all suggestions into account (unless I > missed something.) > > http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ > > > I think, if the suggested comparator is found useful by the users, then > it may make sense to create the String-oriented variant, which can be > implemented through the CharSequence-oriented one as: > > class String { > ... > @SuppressWarnings("unchecked") > public static Comparator > comparingAlphaDecimal(Comparator alphaComparator) { > return (Comparator) (Comparator) > new > Comparators.AlphaDecimalComparator<>(Objects.requireNonNull( > (Comparator) alphaComparator), > false); > } > } > > This will be safe, since the specification guarantees that > String.subSequence() returns a String. > > Then in the application code it would be possible to instantiate the > comparators as > > String.comparingAlphaDecimal(String::compareTo); > > String.comparingAlphaDecimal(String::compareToIgnoreCase); > > or, alternatively, > String.comparingAlphaDecimal(Comparator.naturalOrder()); > > String.comparingAlphaDecimal(String.CASE_INSENSITIVE_ORDER); > > But this could be deferred for later, of course. > > With kind regards, > Ivan > > > On 8/27/17 1:38 PM, Ivan Gerasimov wrote: >> Hello everyone! >> >> Here's another iteration of the comparator with suggested improvements. >> >> Now, there is the only input argument -- the alpha-comparator for >> comparing the non-decimal-digit sub-sequences. >> >> For the javadoc I used the text suggested by Peter with some >> modifications, additional example and API/implementation notes. >> Overall, the javadoc looks heavier than need to me, so I'd love to >> hear comments about how to make it shorter and cleaner. >> >> Also, I adopted the name AlphaDecimal, suggested by Peter. This name >> is one of popular in the list of variants found in the wild. So, there >> are higher chances the users can find the routine by its name. >> >> For testing if a code point is a decimal digit, I used >> (Character.getType(cp) == Character.DECIMAL_DIGIT_NUMBER), which seem >> to be more appropriate than Character.isDigit(). (The later is true >> for things like a digit in a circle, superscript, etc., which do not >> seem to be a part of a decimal number composed of several digits.) >> >> The updated webrev: >> http://cr.openjdk.java.net/~igerasim/8134512/04/webrev/ >> >> Please review at your convenience. >> >> With kind regards, >> Ivan >> >> On 8/9/17 4:59 PM, Stuart Marks wrote: >>> On 8/1/17 11:56 PM, Ivan Gerasimov wrote: >>>> I've tried to go one step further and created even more abstract >>>> comparator: It >>>> uses a supplied predicate to decompose the input sequences into >>>> odd/even >>>> subsequences (e.g. alpha/numeric) and then uses two separate >>>> comparator to >>>> compare them. Additionally, a comparator for comparing sequences, >>>> consisting >>>> only of digits is provided. For example, to build a case-insensitive >>>> AlphaDecimal comparator one could use: 1) Character::isDigit -- as >>>> the predicate >>>> for decomposing, 2) String::compareToIgnoreCase -- to compare alpha >>>> (i.e. odd >>>> parts); to work with CharSequences one would need to make it >>>> Comparator.comparing(CharSequence::toString, >>>> String::compareToIgnoreCase), 3) >>>> The special decimal-only comparator, which compares the decimal >>>> representation >>>> of the sequences. Here's the file with all the comparators and a >>>> simple test: >>>> http://cr.openjdk.java.net/~igerasim/8134512/test/Test.java >>> Hi, a couple follow-up thoughts on this. >>> >>> 1) Supplementary characters >>> >>> The current code uses Character.isDigit(char), which works only for >>> char values in the BMP (basic multilingual plane, values <= U+FFFF). >>> It won't work for supplementary characters. There are several blocks >>> of digits in the BMP, but there are several more in the supplementary >>> character range. >>> >>> I don't see any reason not to handle the supplementary characters as >>> well, except that it spoils the nice char-by-char technique of >>> processing the string. Instead, it'd have to pull in code point >>> values, which might be comprised of two surrogate chars. There are a >>> variety of methods on Character that help with this. Note that there >>> is an overload Character.isDigit(int) which takes any code point >>> value, including supplementary characters. >>> >>> 2) Too much generality? >>> >>> This version includes Predicate for determining whether a >>> character is part of the alphabetic or decimal portion of the string. >>> I'm thinking this might be overkill. It might be sufficient to >>> "hardwire" the partitioning predicate to be Character::isDigit and >>> the value mapping function to use Character::digit. >>> >>> The problem is that adding a predicate opens the door to a lot more >>> complexity, while providing dimishing value. First, the predicate >>> would have to handle code points (per the above) so it'd need to be >>> an IntPredicate. Second, there would also need to be a mapping >>> function from the code point value to a numeric value. This might be >>> an IntUnaryOperator. This would allow someone to sort based on Roman >>> numerals, using Character::getNumericValue. (Yes, Roman numerals are >>> in Unicode.) Or maybe the mapping function should return any >>> Comparable value, not an int. ... See where I'm going here? >>> >>> Since this kind of sorting is intended to be viewed by people, it's >>> probably worth providing full internationalization support >>> (supplementary characters, and delegation to sub-comparators, to >>> allow locale-specific collating sequences). But I start to question >>> any complexity beyond that. >>> >>> s'marks >>> > -- > With kind regards, > Ivan Gerasimov > > -- With kind regards, Ivan Gerasimov From claes.redestad at oracle.com Fri Sep 29 15:09:16 2017 From: claes.redestad at oracle.com (Claes Redestad) Date: Fri, 29 Sep 2017 17:09:16 +0200 Subject: [10] RFR 8134512 : provide Alpha-Numeric (logical) Comparator In-Reply-To: References: <92ca3601-f228-026a-8378-16c331ab9cb5@oracle.com> <08f39675-ba33-70f6-7f35-467569825989@oracle.com> <37e162ca-bf08-9211-afce-7fbd85484208@oracle.com> Message-ID: <903b4600-ebf7-5672-8ab1-73261d937b16@oracle.com> On 2017-09-28 16:22, Jason Mehrens wrote: > Admittedly this is more of a Claes Redestad faster boot up type change but, the use of the AlphaDecimalComparator constructor in Comparator might force the bytecode verifier to force load AlphaDecimalComparator just to check the return type. > > If you make factory methods in AlphaDecimalComparator you can usually craft the return type to match and the verify of Comparator will not force load the AlphaDecimalComparator. > Otherwise, the more ugly solution is to wrap 'new' with Comparator.class.cast. > > Jason ... you called? :-) You're probably right in the general case, but I think we avoid this particular startup issue here since the (HotSpot) bytecode verifier by default doesn't check classes defined to the the boot loader. /Claes From martinrb at google.com Fri Sep 29 16:32:59 2017 From: martinrb at google.com (Martin Buchholz) Date: Fri, 29 Sep 2017 09:32:59 -0700 Subject: RFR: jsr166 jdk10 integration wave 3 In-Reply-To: References: <1b83cdc7-7c23-0534-650b-fa4e343e321d@oracle.com> <7A0F7B6A-6B10-4BCB-9C2A-BC2135D936A1@oracle.com> <9F0F9A64-1F0C-4EB2-A087-9898B933A447@oracle.com> Message-ID: On Wed, Sep 27, 2017 at 1:44 PM, Doug Lea

wrote: > On 09/27/2017 02:38 PM, Paul Sandoz wrote: > >> Looks good, i just need to look a little more closely at the > ConcurrentSkipListMap changes. > >> > > > > > > 328 * Note that, with VarHandles, a boolean result of > > 329 * compareAndSet must be declared even if not used. > > This should not be necessary, since for such methods the return is not > polymorphic. Did you observe some performance or code generation issues? > > > > It was necessary at the time I started rewriting this in June, > but apparently not now. I'll get rid of the annoying unnecessary > declarations. Thanks to whoever fixed this! The latest webrev no longer has the unneeded boolean locals. From Roger.Riggs at Oracle.com Fri Sep 29 17:17:34 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 29 Sep 2017 13:17:34 -0400 Subject: RFR 8080225: FileInputStream cleanup should be improved Message-ID: Replacing finalizers in FileInputStream, FileOutputStream, and adding cleanup to RandomAccessFile and NIO File Channels with Cleaner based implementations required changes to FileDescriptor. The specification of FileInputStream and FileOutputStream is changed to remove the finalizer behavior that required their respective close methods to be called. This change to the behavior is tracked with CSR 8187325 [3]. The FileDescriptor implementations (Unix and Windows) provide a cleanup function that is now used by FIS, FOS, RAF, and async and normal FileChannels.? Each requests FileDescriptor to register a cleanup function when the fd or handle is assigned and delegates to FileDescriptor.close.? If the respective FileDescriptor.close method is not called, the fd or handle will be closed when the FileDescriptor is determined to be phantom reachable. The other uses of FileDescriptor are not intended to be changed, for example in sockets and datagrams. Some tests were modified to not rely on finalization; new tests are provided. Comments are appreciated on both the CSR [3] and the implementation [1]. [1] webrev: http://cr.openjdk.java.net/~rriggs/webrev-fis-cleanup-8080225/ [2] Issue:?? https://bugs.openjdk.java.net/browse/JDK-8080225 [3] CSR:? 8187325? FileInputStream/FileOutputStream should use the Cleaner instead of finalize ? https://bugs.openjdk.java.net/browse/JDK-8187325 Thanks, Roger From brian.burkhalter at oracle.com Fri Sep 29 20:02:41 2017 From: brian.burkhalter at oracle.com (Brian Burkhalter) Date: Fri, 29 Sep 2017 13:02:41 -0700 Subject: RFR 8080225: FileInputStream cleanup should be improved In-Reply-To: References: Message-ID: <88B9DF82-DEFB-42FB-9047-4F44B2D0A35A@oracle.com> Hi Roger, Looks good overall; total nitpicks here: FileInputStream (similar story in FileOutputStream) 48-49: ?explicitly" is used twice 53: could probably drop ?explicitly? here altogether. The ?Shd? in a couple of test names is kind of annoying; perhaps s/Shd/Should/ ? Copyright dates are not update in a few places. Thanks, Brian On Sep 29, 2017, at 10:17 AM, Roger Riggs wrote: > Comments are appreciated on [?] the implementation [1]. > > [1] webrev: http://cr.openjdk.java.net/~rriggs/webrev-fis-cleanup-8080225/ From peter.levart at gmail.com Fri Sep 29 20:18:59 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Sep 2017 22:18:59 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CC3725.7080505@oracle.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> Message-ID: <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> Hi Sherman, I looked into ZipFile as promised. One thing I noticed is that FinalizeZipFile.java test fails compilation: test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: unreported exception Throwable; must be caught or declared to be thrown super.finalize(); ^ (the overridden finalize() in InstrumentedZipFile should now declare throws Throwable, since it overrides Object.finalize() and not ZipFile.finalize() which is gone). The other thing I noticed is that Releaser 1st closes the streams (that are still reachable via streams WeakHashMap) and also ends the associated inflaters. But closing the stream will already release the inflater (in case it is a ZipFileInflaterInputStream) into the inflaters cache and the cache is scanned and inflaters ended later. So we don't need a stream -> inflater association outside the stream in the form of WeekHashMap. But we still need to keep the set of input streams weakly reachable from ZipFile in case we want to close the ZipFile explicitly (and there is no harm although useless if this also happens as a result of automatic ZipFile cleaner processing). This could be implemented in a form of: final Set streams = Collections.newSetFromMap(new WeakHashMap<>()); I also noticed that it is useless to test whether the inflater is ended() when obtaining it from or releasing it into cache if the code keeps the invariant that it never ends inflaters while they are still in cache or associated with the open stream (the only place where inflaters should be ended explicitly is in the Releaser). To make this even more obvious, it might be good to move the obtaining/releasing logic directly into the ZipFileInflaterInputStream constructor which would be passed a reference to the inflatersCache instead of the Inflater instance. Here's what I have in mind (I cahnged just the ZipFile and FinalizeZipFile): http://cr.openjdk.java.net/~plevart/jdk10-dev/8185582_ZIP.cleaner/webrev.01/ What do you think? Because Inflaters used in ZipFile will never be automatically ended by their own cleaners (they are kept strongly reachable in the cache of inflaters, which is strongly reachable from the registered ZipFile cleanup function), it might be useful to add a special package-private constructor to Inflater which would not register its own cleaner. But this could be left as an exercise for some later time. Regards, Peter On 09/28/17 01:41, Xueming Shen wrote: > Thanks Mandy! > > I removed the ln#657-#663, and updated the @apiNote in deflter, inflater > and zipfile accordingly, mainly combined your comment and the approach > for the fis/fo. they are "simpler" and straightforward now, at least > for me. > > https://bugs.openjdk.java.net/browse/JDK-8187485 > http://cr.openjdk.java.net/~sherman/8185582/webrev > > -Sherman > > On 9/27/17, 3:08 PM, mandy chung wrote: >> >> Comment on the CSR: >> >> On 9/26/17 11:35 PM, Xueming Shen wrote: >>> >>> csr: https://bugs.openjdk.java.net/browse/JDK-8187485 >>> >> I think the @apiNote can be simpler. >> >> Deflater (similar comment for Inflater) >> |? * @apiNote >> ? * In earlier versions, the {@link Object#finalize} method was >> overridden >> ? * to call the {@link #end} method when a {@code Deflater} object >> ? * becomes unreachable. >> ? * The {@link #finalize} method is no longer defined.? If a subclass >> ? * overrides||the {@code end} method, the overridden {@code end} method >> ? * is no longer invoked. >> ? *

>> ? * It is strongly recommended to explicitly call {@code end} to >> ||? * discard any unprocessed input promptly to free up resources >> |? * when|||the compressor|is no longer in use.| >> >> >> |ZipFile >> ? ? * @apiNote >> |? * In earlier versions, the {@link Object#finalize} method was >> overridden >> ? * to call the {@link #close} method when a {@code ZipFile} object >> ? * becomes unreachable.| >> |? * The {@link #finalize} method is no longer defined.? If a subclass >> ? * overrides||the {@code close} method, the overridden {@code close} >> method >> ? * is no longer invoked.| >> ? *

>> |? * The recommended cleanup for|||{@code ZipFile}|? is to explicitly >> call {@code close} >> ? * or use try-with-resources.| >> >> ? 657????? *

>> ? 658????? * Since the time when the resources held by this object >> will be released >> ? 659????? * is undetermined, if this method is not invoked >> explicitly, it is strongly >> ? 660????? * recommended that applications invoke this method as soon >> they have >> ? 661????? * finished accessing this {@code ZipFile}. This will >> prevent holding up >> ? 662????? * system resources for an undetermined length of time. >> ? 663????? *

>> >> I would suggest to drop this paragraph.? @apiNote and @implNote in >> class spec cover that. >> >> Mandy >> || > From mandy.chung at oracle.com Fri Sep 29 20:34:52 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 29 Sep 2017 13:34:52 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <23d51a9d-6b25-4324-c293-556215169401@gmail.com> References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Message-ID: On 9/27/17 2:31 AM, Peter Levart wrote: > > Up to a point where 'this' is dereferenced to obtain the 'zsRef' value > (line 261), the Deflater instance is reachable. But after that, even > ensureOpen() may be inlined and 'this' is not needed any more. After > that point, obtaining zsRef.address() and calling setDictionaly on the > obtained address may be racing with Cleaner thread invoking > ZStreamRef.run(): What about making the native setDictionary method as an instance method (currently it's a static method) so that this object remains strongly reachable until the method returns? Mandy From xueming.shen at oracle.com Fri Sep 29 20:49:04 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 29 Sep 2017 13:49:04 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> Message-ID: <59CEB1C0.2030502@oracle.com> On 9/29/17, 1:18 PM, Peter Levart wrote: > Hi Sherman, > > I looked into ZipFile as promised. > > One thing I noticed is that FinalizeZipFile.java test fails compilation: > > test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: unreported exception Throwable; must be caught or declared to be thrown > super.finalize(); > ^ > (the overridden finalize() in InstrumentedZipFile should now declare > throws Throwable, since it overrides Object.finalize() and not > ZipFile.finalize() which is gone). > > Yes, it's the expected source incompatibility issue specified in the CSR request. I think I had it changed somewhere but obviously it's not in the webrev. Thanks for catching it. Yes, the test needs to update to be catch the throwable. Will return to the other comments later. Thanks! -sherman From forax at univ-mlv.fr Fri Sep 29 20:49:32 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Fri, 29 Sep 2017 22:49:32 +0200 (CEST) Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Message-ID: <42344256.6227374.1506718172110.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "mandy chung" > ?: "Peter Levart" , "Xueming Shen" , "core-libs-dev" > > Envoy?: Vendredi 29 Septembre 2017 22:34:52 > Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers > On 9/27/17 2:31 AM, Peter Levart wrote: >> >> Up to a point where 'this' is dereferenced to obtain the 'zsRef' value >> (line 261), the Deflater instance is reachable. But after that, even >> ensureOpen() may be inlined and 'this' is not needed any more. After >> that point, obtaining zsRef.address() and calling setDictionaly on the >> obtained address may be racing with Cleaner thread invoking >> ZStreamRef.run(): > What about making the native setDictionary method as an instance method > (currently it's a static method) so that this object remains strongly > reachable until the method returns? Mandy, unlike in C or C++, in Java a reference is garbage collected as soon as you do not need it anymore, so using an instance method will not change the issue here. one way to be sure that a referenced object is not garbage collected is to use http://docs.oracle.com/javase/9/docs/api/java/lang/ref/Reference.html#reachabilityFence-java.lang.Object- > > Mandy R?mi From mandy.chung at oracle.com Fri Sep 29 20:50:59 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 29 Sep 2017 13:50:59 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CEB1C0.2030502@oracle.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> Message-ID: <9cce9c8f-7315-29a9-8e1b-ff9bcc7e9eda@oracle.com> On 9/29/17 1:49 PM, Xueming Shen wrote: > On 9/29/17, 1:18 PM, Peter Levart wrote: >> Hi Sherman, >> >> I looked into ZipFile as promised. >> >> One thing I noticed is that FinalizeZipFile.java test fails compilation: >> >> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: unreported exception Throwable; must be caught or declared to be thrown >> super.finalize(); >> ^ >> (the overridden finalize() in InstrumentedZipFile should now declare >> throws Throwable, since it overrides Object.finalize() and not >> ZipFile.finalize() which is gone). >> >> > Yes, it's the expected source incompatibility issue specified in the > CSR request. > I think I had it changed somewhere but obviously it's not in the > webrev. Thanks > for catching it. Yes, the test needs to update to be catch the throwable. > I would suggest to update InstrumentedZipFile to migrate away from the finalizer. ? I can override the close method instead of the finalize method.?? It can test explicitly calling close (that's what the test is currently doing) and try-with-resource. Mandy From peter.levart at gmail.com Fri Sep 29 20:53:01 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Sep 2017 22:53:01 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> Message-ID: <2dc6c340-aa71-ce41-de81-b7cb2433588a@gmail.com> On 09/29/17 22:34, mandy chung wrote: > > > On 9/27/17 2:31 AM, Peter Levart wrote: >> >> Up to a point where 'this' is dereferenced to obtain the 'zsRef' >> value (line 261), the Deflater instance is reachable. But after that, >> even ensureOpen() may be inlined and 'this' is not needed any more. >> After that point, obtaining zsRef.address() and calling setDictionaly >> on the obtained address may be racing with Cleaner thread invoking >> ZStreamRef.run(): > What about making the native setDictionary method as an instance > method (currently it's a static method) so that this object remains > strongly reachable until the method returns? > > Mandy This is a possibility too, yes. In general there might be other places where the same could be performed. It is equivalent to puting Reference.reachabilityFence(this) after the invocation of setDictionary() static native method. But this would only fix public setDictionary() instance method. There might be other public methods with similar problems. Synchronizing the ZStreamRef.run() method fixes all of them in one place. Regards, Peter From mandy.chung at oracle.com Fri Sep 29 20:54:02 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 29 Sep 2017 13:54:02 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <42344256.6227374.1506718172110.JavaMail.zimbra@u-pem.fr> References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> <42344256.6227374.1506718172110.JavaMail.zimbra@u-pem.fr> Message-ID: On 9/29/17 1:49 PM, Remi Forax wrote: >> On 9/27/17 2:31 AM, Peter Levart wrote: >>> Up to a point where 'this' is dereferenced to obtain the 'zsRef' value >>> (line 261), the Deflater instance is reachable. But after that, even >>> ensureOpen() may be inlined and 'this' is not needed any more. After >>> that point, obtaining zsRef.address() and calling setDictionaly on the >>> obtained address may be racing with Cleaner thread invoking >>> ZStreamRef.run(): >> What about making the native setDictionary method as an instance method >> (currently it's a static method) so that this object remains strongly >> reachable until the method returns? > Mandy, > unlike in C or C++, in Java a reference is garbage collected as soon as you do not need it anymore, > so using an instance method will not change the issue here. > The case that Peter observed is when "this" is being optimized out and becomes unreachable before setDictionary is called.? Since setDictionary is a JNI function, the caller has to pass this (as jobject) to the native function.?? Would that cover this special case? Mandy From Roger.Riggs at Oracle.com Fri Sep 29 20:55:43 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Fri, 29 Sep 2017 16:55:43 -0400 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CEB1C0.2030502@oracle.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> Message-ID: <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> fyi, The proposed[1]? changes to FileInputStream and FileOutputStream remove the finalize method exposing Object.finalize (throws Throwable) to subclasses.? We may need retain the finalize methods (with empty bodies) to mitigate source compatibility. Roger [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-September/049351.html On 9/29/2017 4:49 PM, Xueming Shen wrote: > On 9/29/17, 1:18 PM, Peter Levart wrote: >> Hi Sherman, >> >> I looked into ZipFile as promised. >> >> One thing I noticed is that FinalizeZipFile.java test fails compilation: >> >> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: >> unreported exception Throwable; must be caught or declared to be thrown >> ???????????? super.finalize(); >> ?????????????????????????? ^ >> (the overridden finalize() in InstrumentedZipFile should now declare >> throws Throwable, since it overrides Object.finalize() and not >> ZipFile.finalize() which is gone). >> >> > Yes, it's the expected source incompatibility issue specified in the > CSR request. > I think I had it changed somewhere but obviously it's not in the > webrev. Thanks > for catching it. Yes, the test needs to update to be catch the throwable. > > Will return to the other comments later. > > Thanks! > -sherman > > From peter.levart at gmail.com Fri Sep 29 20:56:26 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Sep 2017 22:56:26 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <42344256.6227374.1506718172110.JavaMail.zimbra@u-pem.fr> References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> <42344256.6227374.1506718172110.JavaMail.zimbra@u-pem.fr> Message-ID: <52195fe2-29cc-d433-9031-84f3efeec109@gmail.com> Hi Remi, On 09/29/17 22:49, Remi Forax wrote: > ----- Mail original ----- >> De: "mandy chung" >> ?: "Peter Levart" , "Xueming Shen" , "core-libs-dev" >> >> Envoy?: Vendredi 29 Septembre 2017 22:34:52 >> Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers >> On 9/27/17 2:31 AM, Peter Levart wrote: >>> Up to a point where 'this' is dereferenced to obtain the 'zsRef' value >>> (line 261), the Deflater instance is reachable. But after that, even >>> ensureOpen() may be inlined and 'this' is not needed any more. After >>> that point, obtaining zsRef.address() and calling setDictionaly on the >>> obtained address may be racing with Cleaner thread invoking >>> ZStreamRef.run(): >> What about making the native setDictionary method as an instance method >> (currently it's a static method) so that this object remains strongly >> reachable until the method returns? > Mandy, > unlike in C or C++, in Java a reference is garbage collected as soon as you do not need it anymore, > so using an instance method will not change the issue here. I might be wrong, but native instance method is an exception. It can't be inlined. The preparation for native method invocation makes sure 'this' is kept reachable because it can be dereferenced from the native code then and native code is out-of-bounds for JIT optimization. Regards, Peter > one way to be sure that a referenced object is not garbage collected is to use > http://docs.oracle.com/javase/9/docs/api/java/lang/ref/Reference.html#reachabilityFence-java.lang.Object- > >> Mandy > R?mi From mandy.chung at oracle.com Fri Sep 29 20:58:27 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 29 Sep 2017 13:58:27 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CC3725.7080505@oracle.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> Message-ID: On 9/27/17 4:41 PM, Xueming Shen wrote: > Thanks Mandy! > > I removed the ln#657-#663, and updated the @apiNote in deflter, inflater > and zipfile accordingly, mainly combined your comment and the approach > for the fis/fo. they are "simpler" and straightforward now, at least > for me. > > https://bugs.openjdk.java.net/browse/JDK-8187485 > http://cr.openjdk.java.net/~sherman/8185582/webrev > || 76 * specified to call the {@code end} method to close the {@code deflater} and s/deflater/Deflater 80 * The recommended cleanup for compressor is to explicitly call {@code end} 81 * method when it is no longer in use. Existing subclasses of {@code Deflater} 82 * that override {@code end} and require {@code end} to be invoked when the 83 * instance is unreachable should explicitly override {@link Object#finalize} 84 * and call {@code end}. I suggest not to recommend "explicitly override Object.finalize" (in fact, we should discourage it) and the overridden end method should be called explicitly.? This was what I suggested in the previous mail:|| |* It is strongly recommended to explicitly call {@code end} to ||* discard any unprocessed input promptly to free up resources |* when |||the compressor |is no longer in use.| ||Same comment applies to Inflater. 75 * specified to call the {@code end} method to close the {@code inflater} and | s/inflater/Inflater FinalizeZipFile.zip (I have mentioned this in the other mail): I suggest to update InstrumentedZipFile to migrate away from the finalizer. ? I can override the close method instead of the finalize method.?? It can test explicitly calling close (that's what the test is currently doing) and try-with-resource. TestCleaner.java ?130 throw new RuntimeException("'ZipFile.Source.zfile' is not accesible"); s/accesible/accessible Mandy From forax at univ-mlv.fr Fri Sep 29 21:03:56 2017 From: forax at univ-mlv.fr (forax at univ-mlv.fr) Date: Fri, 29 Sep 2017 23:03:56 +0200 (CEST) Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <52195fe2-29cc-d433-9031-84f3efeec109@gmail.com> References: <59CB46AE.2000701@oracle.com> <23d51a9d-6b25-4324-c293-556215169401@gmail.com> <42344256.6227374.1506718172110.JavaMail.zimbra@u-pem.fr> <52195fe2-29cc-d433-9031-84f3efeec109@gmail.com> Message-ID: <47490564.6243100.1506719036146.JavaMail.zimbra@u-pem.fr> > De: "Peter Levart" > ?: "Remi Forax" , "mandy chung" > Cc: "Xueming Shen" , "core-libs-dev" > > Envoy?: Vendredi 29 Septembre 2017 22:56:26 > Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not > finalizers > Hi Remi, Hi Peter, > On 09/29/17 22:49, Remi Forax wrote: >> ----- Mail original ----- >>> De: "mandy chung" [ mailto:mandy.chung at oracle.com | ] >>> ?: "Peter Levart" [ mailto:peter.levart at gmail.com | ] >>> , "Xueming Shen" [ mailto:xueming.shen at oracle.com | ] >>> , "core-libs-dev" [ mailto:core-libs-dev at openjdk.java.net | >>> ] Envoy?: Vendredi 29 Septembre 2017 22:34:52 >>> Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not >>> finalizers >>> On 9/27/17 2:31 AM, Peter Levart wrote: >>>> Up to a point where 'this' is dereferenced to obtain the 'zsRef' value >>>> (line 261), the Deflater instance is reachable. But after that, even >>>> ensureOpen() may be inlined and 'this' is not needed any more. After >>>> that point, obtaining zsRef.address() and calling setDictionaly on the >>>> obtained address may be racing with Cleaner thread invoking >>>> ZStreamRef.run(): >>> What about making the native setDictionary method as an instance method >>> (currently it's a static method) so that this object remains strongly >>> reachable until the method returns? >> Mandy, >> unlike in C or C++, in Java a reference is garbage collected as soon as you do >> not need it anymore, >> so using an instance method will not change the issue here. > I might be wrong, but native instance method is an exception. It can't be > inlined. The preparation for native method invocation makes sure 'this' is kept > reachable because it can be dereferenced from the native code then and native > code is out-of-bounds for JIT optimization. I do not think that you are wrong now but this is a property (a side effect) of the current implementation, Panama and Metropolis may change that. I think it's better to keep the reference available with a reachability fence. > Regards, Peter R?mi >> one way to be sure that a referenced object is not garbage collected is to use [ >> http://docs.oracle.com/javase/9/docs/api/java/lang/ref/Reference.html#reachabilityFence-java.lang.Object >> | >> http://docs.oracle.com/javase/9/docs/api/java/lang/ref/Reference.html#reachabilityFence-java.lang.Object >> ] - >>> Mandy >> R?mi From peter.levart at gmail.com Fri Sep 29 21:11:50 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Sep 2017 23:11:50 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> Message-ID: <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> Hi Roger, On 09/29/17 22:55, Roger Riggs wrote: > fyi, > > The proposed[1]? changes to FileInputStream and FileOutputStream > remove the finalize method > exposing Object.finalize (throws Throwable) to subclasses.? We may > need retain > the finalize methods (with empty bodies) to mitigate source > compatibility. The problem is that empty finalize() method that throws anything other than Throwable will not compile. Regards, Peter > > Roger > > > [1] > http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-September/049351.html > > On 9/29/2017 4:49 PM, Xueming Shen wrote: >> On 9/29/17, 1:18 PM, Peter Levart wrote: >>> Hi Sherman, >>> >>> I looked into ZipFile as promised. >>> >>> One thing I noticed is that FinalizeZipFile.java test fails >>> compilation: >>> >>> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: >>> unreported exception Throwable; must be caught or declared to be thrown >>> ???????????? super.finalize(); >>> ?????????????????????????? ^ >>> (the overridden finalize() in InstrumentedZipFile should now declare >>> throws Throwable, since it overrides Object.finalize() and not >>> ZipFile.finalize() which is gone). >>> >>> >> Yes, it's the expected source incompatibility issue specified in the >> CSR request. >> I think I had it changed somewhere but obviously it's not in the >> webrev. Thanks >> for catching it. Yes, the test needs to update to be catch the >> throwable. >> >> Will return to the other comments later. >> >> Thanks! >> -sherman >> >> > From peter.levart at gmail.com Fri Sep 29 21:14:33 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Sep 2017 23:14:33 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> Message-ID: On 09/29/17 23:11, Peter Levart wrote: > Hi Roger, > > On 09/29/17 22:55, Roger Riggs wrote: >> fyi, >> >> The proposed[1]? changes to FileInputStream and FileOutputStream >> remove the finalize method >> exposing Object.finalize (throws Throwable) to subclasses.? We may >> need retain >> the finalize methods (with empty bodies) to mitigate source >> compatibility. > > The problem is that empty finalize() method that throws anything other > than Throwable will not compile. Correction - it will compile (I was thinking about a method calling just super.finalize() which is not empty, of course). Yes, this is the solution to source compatibility. > > Regards, Peter > >> >> Roger >> >> >> [1] >> http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-September/049351.html >> >> On 9/29/2017 4:49 PM, Xueming Shen wrote: >>> On 9/29/17, 1:18 PM, Peter Levart wrote: >>>> Hi Sherman, >>>> >>>> I looked into ZipFile as promised. >>>> >>>> One thing I noticed is that FinalizeZipFile.java test fails >>>> compilation: >>>> >>>> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: >>>> unreported exception Throwable; must be caught or declared to be >>>> thrown >>>> ???????????? super.finalize(); >>>> ?????????????????????????? ^ >>>> (the overridden finalize() in InstrumentedZipFile should now >>>> declare throws Throwable, since it overrides Object.finalize() and >>>> not ZipFile.finalize() which is gone). >>>> >>>> >>> Yes, it's the expected source incompatibility issue specified in the >>> CSR request. >>> I think I had it changed somewhere but obviously it's not in the >>> webrev. Thanks >>> for catching it. Yes, the test needs to update to be catch the >>> throwable. >>> >>> Will return to the other comments later. >>> >>> Thanks! >>> -sherman >>> >>> >> > From xueming.shen at oracle.com Fri Sep 29 21:14:49 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 29 Sep 2017 14:14:49 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> Message-ID: <59CEB7C9.8050104@oracle.com> On 9/29/17, 1:58 PM, mandy chung wrote: > > > On 9/27/17 4:41 PM, Xueming Shen wrote: >> Thanks Mandy! >> >> I removed the ln#657-#663, and updated the @apiNote in deflter, inflater >> and zipfile accordingly, mainly combined your comment and the approach >> for the fis/fo. they are "simpler" and straightforward now, at least >> for me. >> >> https://bugs.openjdk.java.net/browse/JDK-8187485 >> http://cr.openjdk.java.net/~sherman/8185582/webrev >> || > > 76 * specified to call the {@code end} method to close the {@code deflater} and > > s/deflater/Deflater > 80 * The recommended cleanup for compressor is to explicitly call {@code end} > 81 * method when it is no longer in use. Existing subclasses of {@code Deflater} > 82 * that override {@code end} and require {@code end} to be invoked when the > 83 * instance is unreachable should explicitly override {@link Object#finalize} > 84 * and call {@code end}. > I suggest not to recommend "explicitly override Object.finalize" (in > fact, we should discourage it) and the overridden end method should be > called explicitly. This was what I suggested in the previous mail: "calling end() directly/explicitly to release the resource" is being recommended at the first sentence. The second sentence here is meant to provide a possible alternative if any existing subclass is implemented the way that it has the dependency on the old mechanism that its own "end()" being called, for situation that the Cleaner is not possible, or difficult to implement. No value at all? -Sherman > || > | * It is strongly recommended to explicitly call {@code end} to > || * discard any unprocessed input promptly to free up resources > | * when|||the compressor|is no longer in use.| > > ||Same comment applies to Inflater. > > 75 * specified to call the {@code end} method to close the {@code inflater} and > | > From forax at univ-mlv.fr Fri Sep 29 21:23:21 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Fri, 29 Sep 2017 23:23:21 +0200 (CEST) Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> Message-ID: <335122608.6249049.1506720201183.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Peter Levart" > ?: "Roger Riggs" , "core-libs-dev" > Envoy?: Vendredi 29 Septembre 2017 23:14:33 > Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers > On 09/29/17 23:11, Peter Levart wrote: >> Hi Roger, >> >> On 09/29/17 22:55, Roger Riggs wrote: >>> fyi, >>> >>> The proposed[1]? changes to FileInputStream and FileOutputStream >>> remove the finalize method >>> exposing Object.finalize (throws Throwable) to subclasses.? We may >>> need retain >>> the finalize methods (with empty bodies) to mitigate source >>> compatibility. >> >> The problem is that empty finalize() method that throws anything other >> than Throwable will not compile. > > Correction - it will compile (I was thinking about a method calling just > super.finalize() which is not empty, of course). Yes, this is the > solution to source compatibility. > Overriding finalize() will make the object not to be GCed as soon as it should. > >> >> Regards, Peter >> R?mi >>> >>> Roger >>> >>> >>> [1] >>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-September/049351.html >>> >>> On 9/29/2017 4:49 PM, Xueming Shen wrote: >>>> On 9/29/17, 1:18 PM, Peter Levart wrote: >>>>> Hi Sherman, >>>>> >>>>> I looked into ZipFile as promised. >>>>> >>>>> One thing I noticed is that FinalizeZipFile.java test fails >>>>> compilation: >>>>> >>>>> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: >>>>> unreported exception Throwable; must be caught or declared to be >>>>> thrown >>>>> ???????????? super.finalize(); >>>>> ?????????????????????????? ^ >>>>> (the overridden finalize() in InstrumentedZipFile should now >>>>> declare throws Throwable, since it overrides Object.finalize() and >>>>> not ZipFile.finalize() which is gone). >>>>> >>>>> >>>> Yes, it's the expected source incompatibility issue specified in the >>>> CSR request. >>>> I think I had it changed somewhere but obviously it's not in the >>>> webrev. Thanks >>>> for catching it. Yes, the test needs to update to be catch the >>>> throwable. >>>> >>>> Will return to the other comments later. >>>> >>>> Thanks! >>>> -sherman >>>> >>>> >>> From peter.levart at gmail.com Fri Sep 29 21:38:22 2017 From: peter.levart at gmail.com (Peter Levart) Date: Fri, 29 Sep 2017 23:38:22 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <335122608.6249049.1506720201183.JavaMail.zimbra@u-pem.fr> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> <335122608.6249049.1506720201183.JavaMail.zimbra@u-pem.fr> Message-ID: <8e22caab-0ee1-97e0-7aa5-8018f56c5b36@gmail.com> On 09/29/17 23:23, Remi Forax wrote: > ----- Mail original ----- >> De: "Peter Levart" >> ?: "Roger Riggs" , "core-libs-dev" >> Envoy?: Vendredi 29 Septembre 2017 23:14:33 >> Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers >> On 09/29/17 23:11, Peter Levart wrote: >>> Hi Roger, >>> >>> On 09/29/17 22:55, Roger Riggs wrote: >>>> fyi, >>>> >>>> The proposed[1]? changes to FileInputStream and FileOutputStream >>>> remove the finalize method >>>> exposing Object.finalize (throws Throwable) to subclasses.? We may >>>> need retain >>>> the finalize methods (with empty bodies) to mitigate source >>>> compatibility. >>> The problem is that empty finalize() method that throws anything other >>> than Throwable will not compile. >> Correction - it will compile (I was thinking about a method calling just >> super.finalize() which is not empty, of course). Yes, this is the >> solution to source compatibility. >> > Overriding finalize() will make the object not to be GCed as soon as it should. I think the hotspot has an optimization and detects that finalize() has no bytecodes and treats the object as not needing finalization. Regards, Peter >>> Regards, Peter >>> > R?mi > >>>> Roger >>>> >>>> >>>> [1] >>>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-September/049351.html >>>> >>>> On 9/29/2017 4:49 PM, Xueming Shen wrote: >>>>> On 9/29/17, 1:18 PM, Peter Levart wrote: >>>>>> Hi Sherman, >>>>>> >>>>>> I looked into ZipFile as promised. >>>>>> >>>>>> One thing I noticed is that FinalizeZipFile.java test fails >>>>>> compilation: >>>>>> >>>>>> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: >>>>>> unreported exception Throwable; must be caught or declared to be >>>>>> thrown >>>>>> ???????????? super.finalize(); >>>>>> ?????????????????????????? ^ >>>>>> (the overridden finalize() in InstrumentedZipFile should now >>>>>> declare throws Throwable, since it overrides Object.finalize() and >>>>>> not ZipFile.finalize() which is gone). >>>>>> >>>>>> >>>>> Yes, it's the expected source incompatibility issue specified in the >>>>> CSR request. >>>>> I think I had it changed somewhere but obviously it's not in the >>>>> webrev. Thanks >>>>> for catching it. Yes, the test needs to update to be catch the >>>>> throwable. >>>>> >>>>> Will return to the other comments later. >>>>> >>>>> Thanks! >>>>> -sherman >>>>> >>>>> From mandy.chung at oracle.com Fri Sep 29 21:45:18 2017 From: mandy.chung at oracle.com (mandy chung) Date: Fri, 29 Sep 2017 14:45:18 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <8e22caab-0ee1-97e0-7aa5-8018f56c5b36@gmail.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEB1C0.2030502@oracle.com> <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> <335122608.6249049.1506720201183.JavaMail.zimbra@u-pem.fr> <8e22caab-0ee1-97e0-7aa5-8018f56c5b36@gmail.com> Message-ID: <0628f0e3-1fa1-16c0-8f27-d4990c7b3ed1@oracle.com> On 9/29/17 2:38 PM, Peter Levart wrote: > I think the hotspot has an optimization and detects that finalize() > has no bytecodes and treats the object as not needing finalization. http://hg.openjdk.java.net/jdk10/master/file/7d67bb6b0599/src/hotspot/share/classfile/classFileParser.cpp#l4250 ? // Check if this klass has an empty finalize method (i.e. one with return bytecode only), ? // in which case we don't have to register objects as finalizable ? if (!_has_empty_finalizer) { ??? if (_has_finalizer || ??????? (super != NULL && super->has_finalizer())) { ????? ik->set_has_finalizer(); ??? } ? } Mandy From forax at univ-mlv.fr Fri Sep 29 22:00:23 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Sat, 30 Sep 2017 00:00:23 +0200 (CEST) Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <0628f0e3-1fa1-16c0-8f27-d4990c7b3ed1@oracle.com> References: <59CB46AE.2000701@oracle.com> <59CEB1C0.2030502@oracle.com> <19fe961c-756e-ff24-7da7-475f1cf8e70e@Oracle.com> <773b32d5-a26d-ab44-551e-53b466d46bef@gmail.com> <335122608.6249049.1506720201183.JavaMail.zimbra@u-pem.fr> <8e22caab-0ee1-97e0-7aa5-8018f56c5b36@gmail.com> <0628f0e3-1fa1-16c0-8f27-d4990c7b3ed1@oracle.com> Message-ID: <1971601616.6254974.1506722423732.JavaMail.zimbra@u-pem.fr> Very cool, i learn something today :) R?mi ----- Mail original ----- > De: "mandy chung" > ?: "core-libs-dev" > Envoy?: Vendredi 29 Septembre 2017 23:45:18 > Objet: Re: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers > On 9/29/17 2:38 PM, Peter Levart wrote: >> I think the hotspot has an optimization and detects that finalize() >> has no bytecodes and treats the object as not needing finalization. > http://hg.openjdk.java.net/jdk10/master/file/7d67bb6b0599/src/hotspot/share/classfile/classFileParser.cpp#l4250 > > ? // Check if this klass has an empty finalize method (i.e. one with > return bytecode only), > ? // in which case we don't have to register objects as finalizable > ? if (!_has_empty_finalizer) { > ??? if (_has_finalizer || > ??????? (super != NULL && super->has_finalizer())) { > ????? ik->set_has_finalizer(); > ??? } > ? } > > Mandy From xueming.shen at oracle.com Fri Sep 29 22:18:08 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 29 Sep 2017 15:18:08 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> Message-ID: <59CEC6A0.9000601@oracle.com> On 9/29/17, 1:18 PM, Peter Levart wrote: > Hi Sherman, > putStream> streams = Collections.newSetFromMap(new WeakHashMap<>()); > > I also noticed that it is useless to test whether the inflater is > ended() when obtaining it from or releasing it into cache if the code > keeps the invariant that it never ends inflaters while they are still > in cache or associated with the open stream (the only place where > inflaters should be ended explicitly is in the Releaser). To make this > even more obvious, it might be good to move the obtaining/releasing > logic directly into the ZipFileInflaterInputStream constructor which > would be passed a reference to the inflatersCache instead of the > Inflater instance. > If my memory serves me correctly, this "ended()" check was for the situation that the ZipfileInflaterStream is getting finalized (close() is not called explicitly/directly) and its inflater is also getting finalized at the same time/pass, and the inflater.end() gets called (by its finalize()) first, so when the zfis tries to release the inflater back to the cache, it has been "ended" already. We had some nasty finalize() and object resurrection timing issue in earlier releases, that probably is part of the fix (since it's a timing issue, we also do the same "ended()" check in getInflater() when lease it out) So my question is that do we have the similar situation under the Cleaner? mean the zfis and its inflater both are phantom reachable and the inflater's cleaner gets called first? I'm still reading your proposed change to remove the "inflater" from the stream->inflater mapping to see if there is any loophole, will reply that separately later. -sherman From xueming.shen at oracle.com Sat Sep 30 00:02:46 2017 From: xueming.shen at oracle.com (Xueming Shen) Date: Fri, 29 Sep 2017 17:02:46 -0700 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> Message-ID: <59CEDF26.60301@oracle.com> On 9/29/17, 1:18 PM, Peter Levart wrote: > Hi Sherman, > > I looked into ZipFile as promised. > > One thing I noticed is that FinalizeZipFile.java test fails compilation: > > test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: unreported exception Throwable; must be caught or declared to be thrown > super.finalize(); > ^ > (the overridden finalize() in InstrumentedZipFile should now declare > throws Throwable, since it overrides Object.finalize() and not > ZipFile.finalize() which is gone). > > > The other thing I noticed is that Releaser 1st closes the streams > (that are still reachable via streams WeakHashMap) and also ends the > associated inflaters. But closing the stream will already release the > inflater (in case it is a ZipFileInflaterInputStream) into the > inflaters cache and the cache is scanned and inflaters ended later. > > So we don't need a stream -> inflater association outside the stream > in the form of WeekHashMap. But we still need to keep the set of input > streams weakly reachable from ZipFile in case we want to close the > ZipFile explicitly (and there is no harm although useless if this also > happens as a result of automatic ZipFile cleaner processing). > > This could be implemented in a form of: > > final Set streams = Collections.newSetFromMap(new > WeakHashMap<>()); > > I also noticed that it is useless to test whether the inflater is > ended() when obtaining it from or releasing it into cache if the code > keeps the invariant that it never ends inflaters while they are still > in cache or associated with the open stream (the only place where > inflaters should be ended explicitly is in the Releaser). To make this > even more obvious, it might be good to move the obtaining/releasing > logic directly into the ZipFileInflaterInputStream constructor which > would be passed a reference to the inflatersCache instead of the > Inflater instance. > > Here's what I have in mind (I cahnged just the ZipFile and > FinalizeZipFile): > > http://cr.openjdk.java.net/~plevart/jdk10-dev/8185582_ZIP.cleaner/webrev.01/ > > What do you think? > Peter, I read those old emails back to 2011 on why we put the "Inflater" into the streams as the value of the map entry. It appears the main (only) purpose is to keep the finalization of in order. As I explained in previous email, stream and its inflater can be phantom reachable at same round, if inflater gets finalized/ended first, then it can no longer be reused/cached and has to be thrown away, which means the caching mechanism is actually broken/not functioning. We do have use scenario depends on it to avoid too many "new Inflater()' that might pressure the memory usage. Putting the pair in a weakhashmap appears to solve this problem back then (the ended() checks are still there just in case there is rare case, the inflater still gets cleaned up first). The situation might be changed now in Cleaner case, as the cleaner object itself now holds a strong reference, which in theory will/should prevent the inflater from being phantom reachable before stream is cleaned, so we might no longer need this pair in a map to have a "ordered" cleanup. Just wanted to make sure my assumption is correct here. sherman From zheng.jun.li at oracle.com Sat Sep 30 02:55:36 2017 From: zheng.jun.li at oracle.com (Jack Li) Date: Sat, 30 Sep 2017 10:55:36 +0800 Subject: RFR: 8187954 Update JAX-WS RI integration to latest version Message-ID: <12668CC3-A8DB-4BDC-9F21-5068CA559DA8@oracle.com> Hi, Please review standalone JAXB/JAXWS changes, synced to jdk/jaxws repo. JBS: https://bugs.openjdk.java.net/browse/JDK-8187954 Webrev: http://cr.openjdk.java.net/~aefimov/jaxws-integrations/8187954/10/00/ Summary of changes: jaxws/src/java.xml.bind/share/classes/javax/xml/bind/* JDK-8186946 - Fix accessibility and other issues in the java.xml.bind module jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/** JDK-8186314 - code at c.s.x.i.m.saaj.soap.MessageImpl must be modified to avoid crash after javac change And also contains the fixes for importing nodes for SOAPDocumentFragment Patch also contains several small bugfixes, not tracked in JBS. ---------------- Best regards Jack Li From ecki at zusammenkunft.net Sat Sep 30 04:34:51 2017 From: ecki at zusammenkunft.net (Bernd Eckenfels) Date: Sat, 30 Sep 2017 04:34:51 +0000 Subject: RFR 8080225: FileInputStream cleanup should be improved In-Reply-To: References: Message-ID: Hello, if UnreferencedRAFClosesFd.java is supposed to test the behavior of unreachable ?raf? I wonder how it works as it hold on raf with a reachabilityFence at the end of the main method? Maybe that asks for an explanative comment? Gruss Bernd -- http://bernd.eckenfels.net ________________________________ From: core-libs-dev on behalf of Roger Riggs Sent: Friday, September 29, 2017 7:17:34 PM To: Core-Libs-Dev Subject: RFR 8080225: FileInputStream cleanup should be improved Replacing finalizers in FileInputStream, FileOutputStream, and adding cleanup to RandomAccessFile and NIO File Channels with Cleaner based implementations required changes to FileDescriptor. The specification of FileInputStream and FileOutputStream is changed to remove the finalizer behavior that required their respective close methods to be called. This change to the behavior is tracked with CSR 8187325 [3]. The FileDescriptor implementations (Unix and Windows) provide a cleanup function that is now used by FIS, FOS, RAF, and async and normal FileChannels. Each requests FileDescriptor to register a cleanup function when the fd or handle is assigned and delegates to FileDescriptor.close. If the respective FileDescriptor.close method is not called, the fd or handle will be closed when the FileDescriptor is determined to be phantom reachable. The other uses of FileDescriptor are not intended to be changed, for example in sockets and datagrams. Some tests were modified to not rely on finalization; new tests are provided. Comments are appreciated on both the CSR [3] and the implementation [1]. [1] webrev: http://cr.openjdk.java.net/~rriggs/webrev-fis-cleanup-8080225/ [2] Issue: https://bugs.openjdk.java.net/browse/JDK-8080225 [3] CSR: 8187325 FileInputStream/FileOutputStream should use the Cleaner instead of finalize https://bugs.openjdk.java.net/browse/JDK-8187325 Thanks, Roger From peter.levart at gmail.com Sat Sep 30 07:41:41 2017 From: peter.levart at gmail.com (Peter Levart) Date: Sat, 30 Sep 2017 09:41:41 +0200 Subject: RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers In-Reply-To: <59CEDF26.60301@oracle.com> References: <59CB46AE.2000701@oracle.com> <59CC3725.7080505@oracle.com> <32f3d1cc-0423-f28e-279f-900a8df564e2@gmail.com> <59CEDF26.60301@oracle.com> Message-ID: Hi Sherman, On 09/30/17 02:02, Xueming Shen wrote: > On 9/29/17, 1:18 PM, Peter Levart wrote: >> Hi Sherman, >> >> I looked into ZipFile as promised. >> >> One thing I noticed is that FinalizeZipFile.java test fails compilation: >> >> test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java:49: error: unreported exception Throwable; must be caught or declared to be thrown >> super.finalize(); >> ^ >> (the overridden finalize() in InstrumentedZipFile should now declare >> throws Throwable, since it overrides Object.finalize() and not >> ZipFile.finalize() which is gone). >> >> >> The other thing I noticed is that Releaser 1st closes the streams >> (that are still reachable via streams WeakHashMap) and also ends the >> associated inflaters. But closing the stream will already release the >> inflater (in case it is a ZipFileInflaterInputStream) into the >> inflaters cache and the cache is scanned and inflaters ended later. >> >> So we don't need a stream -> inflater association outside the stream >> in the form of WeekHashMap. But we still need to keep the set of >> input streams weakly reachable from ZipFile in case we want to close >> the ZipFile explicitly (and there is no harm although useless if this >> also happens as a result of automatic ZipFile cleaner processing). >> >> This could be implemented in a form of: >> >> final Set streams = Collections.newSetFromMap(new >> WeakHashMap<>()); >> >> I also noticed that it is useless to test whether the inflater is >> ended() when obtaining it from or releasing it into cache if the code >> keeps the invariant that it never ends inflaters while they are still >> in cache or associated with the open stream (the only place where >> inflaters should be ended explicitly is in the Releaser). To make >> this even more obvious, it might be good to move the >> obtaining/releasing logic directly into the >> ZipFileInflaterInputStream constructor which would be passed a >> reference to the inflatersCache instead of the Inflater instance. >> >> Here's what I have in mind (I cahnged just the ZipFile and >> FinalizeZipFile): >> >> http://cr.openjdk.java.net/~plevart/jdk10-dev/8185582_ZIP.cleaner/webrev.01/ >> >> What do you think? >> > Peter, > > I read those old emails back to 2011 on why we put the "Inflater" into > the streams as > the value of the map entry. It appears the main (only) purpose is to > keep the finalization > of in order. As I explained in previous email, > stream and its inflater > can be phantom reachable at same round, if inflater gets > finalized/ended first, then it > can no longer be reused/cached and has to be thrown away, which means > the caching > mechanism is actually broken/not functioning. We do have use scenario > depends on it > to avoid too many "new Inflater()' that might pressure the memory > usage. Putting the > pair in a weakhashmap appears to solve this problem back then (the > ended() checks are > still there just in case there is rare case, the inflater still gets > cleaned up first). > > The situation might be changed now in Cleaner case, as the cleaner > object itself now > holds a strong reference, which in theory will/should prevent the > inflater from being > phantom reachable before stream is cleaned, so we might no longer need > this > pair in a map to have a "ordered" cleanup. Just > wanted to make sure > my assumption is correct here. > > sherman > Right, the Inflater is captured by the cleaning function for the ZipFileInflaterInputStream and is kept strongly reachable until the function fires, which may happen automatically or manually. At that time, it is returned to the inflaters cache, which is rooted at the ZipFile instance and also captured by the ZipFile cleaning function - the Releaser, which is strongly reachable until fired. So I claim that there is no possibility for Inflaters used in ZipFile to ever get cleaned-up (ended) automatically by their cleaner functions as a result of getting phantom reachable. The situation has changed. It could even be beneficial to create a package-private Inflater constructor for this case, which creates Inflaters without cleaner registration. Regards, Peter From Roger.Riggs at Oracle.com Sat Sep 30 15:55:32 2017 From: Roger.Riggs at Oracle.com (Roger Riggs) Date: Sat, 30 Sep 2017 11:55:32 -0400 Subject: RFR 8080225: FileInputStream cleanup should be improved In-Reply-To: References: Message-ID: Hi Bernd, The reachabilityFence only ensures that the local variable 'ref' is not prematurely deemed to be out of scope? by the hotspot compiler. The value of 'raf' is set to null before the gc is triggered (usually) on the first iteration of the loop. I'll add a comment. Regards, Roger On 9/30/2017 12:34 AM, Bernd Eckenfels wrote: > Hello, > > if UnreferencedRAFClosesFd.java is supposed to test the behavior of > unreachable ?raf? I wonder how it works as it hold on raf with a > reachabilityFence at the end of the main method? Maybe that asks for > an explanative comment? > > Gruss > Bernd > -- > http://bernd.eckenfels.net > ------------------------------------------------------------------------ > *From:* core-libs-dev on > behalf of Roger Riggs > *Sent:* Friday, September 29, 2017 7:17:34 PM > *To:* Core-Libs-Dev > *Subject:* RFR 8080225: FileInputStream cleanup should be improved > Replacing finalizers in FileInputStream, FileOutputStream, and adding > cleanup to RandomAccessFile > and NIO File Channels with Cleaner based implementations required > changes to FileDescriptor. > > The specification of FileInputStream and FileOutputStream is changed to > remove the finalizer > behavior that required their respective close methods to be called. > This change to the behavior is tracked with CSR 8187325 [3]. > > The FileDescriptor implementations (Unix and Windows) provide a cleanup > function that is now used by > FIS, FOS, RAF, and async and normal FileChannels.? Each requests > FileDescriptor to register a cleanup function > when the fd or handle is assigned and delegates to > FileDescriptor.close.? If the respective > FileDescriptor.close method is not called, the fd or handle will be > closed when the FileDescriptor > is determined to be phantom reachable. > > The other uses of FileDescriptor are not intended to be changed, for > example in sockets and datagrams. > > Some tests were modified to not rely on finalization; new tests are > provided. > > Comments are appreciated on both the CSR [3] and the implementation [1]. > > [1] webrev: > http://cr.openjdk.java.net/~rriggs/webrev-fis-cleanup-8080225/ > > > [2] Issue: https://bugs.openjdk.java.net/browse/JDK-8080225 > > [3] CSR:? 8187325? FileInputStream/FileOutputStream should use the > Cleaner instead of finalize > https://bugs.openjdk.java.net/browse/JDK-8187325 > > Thanks, Roger > >