From jonathan.gibbons at oracle.com Fri Oct 12 17:21:23 2018 From: jonathan.gibbons at oracle.com (jonathan.gibbons at oracle.com) Date: Fri, 12 Oct 2018 17:21:23 +0000 Subject: hg: code-tools/jcov: 7902334: JCov fails to instrument JDK 11 classfiles with NestHost/NestMates attributes Message-ID: <201810121721.w9CHLNBi022260@aojmv0008.oracle.com> Changeset: 7ffe29bde4fe Author: jjg Date: 2018-10-11 10:20 -0700 URL: http://hg.openjdk.java.net/code-tools/jcov/rev/7ffe29bde4fe 7902334: JCov fails to instrument JDK 11 classfiles with NestHost/NestMates attributes Reviewed-by: lkuskov Contributed-by: jan.lahoda at oracle.com ! src/classes/com/sun/tdk/jcov/JREInstr.java ! src/classes/com/sun/tdk/jcov/instrument/DeferringMethodClassAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/EntryCodeMethodAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/FieldAnnotationVisitor.java ! src/classes/com/sun/tdk/jcov/instrument/ForkingMethodAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/InstrumentedAttributeClassAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/InvokeClassAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/InvokeMethodAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/MethodAnnotationAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/OffsetRecordingMethodAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/SavePointsMethodAdapter.java ! src/classes/com/sun/tdk/jcov/instrument/StaticInvokeMethodAdapter.java ! src/classes/com/sun/tdk/jcov/util/Utils.java + test/unit/com/sun/tdk/jcov/instrument/IntrumentNestHostTest.java From jonathan.gibbons at oracle.com Fri Oct 12 17:38:21 2018 From: jonathan.gibbons at oracle.com (jonathan.gibbons at oracle.com) Date: Fri, 12 Oct 2018 17:38:21 +0000 Subject: hg: code-tools/jcov: 2 new changesets Message-ID: <201810121738.w9CHcL36029528@aojmv0008.oracle.com> Changeset: 3d6e43ef0636 Author: jjg Date: 2018-10-11 10:37 -0700 URL: http://hg.openjdk.java.net/code-tools/jcov/rev/3d6e43ef0636 fix line endings ! build/build.properties Changeset: dc39eb43dfda Author: jjg Date: 2018-10-11 10:37 -0700 URL: http://hg.openjdk.java.net/code-tools/jcov/rev/dc39eb43dfda 7902335: Simplified running of jcov tests Reviewed-by: lkuskov Contributed-by: jan.lahoda at oracle.com ! build/build.properties ! build/build.xml From alexandre.iline at oracle.com Tue Oct 23 20:58:16 2018 From: alexandre.iline at oracle.com (Alexandre (Shura) Iline) Date: Tue, 23 Oct 2018 13:58:16 -0700 Subject: RFR: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage In-Reply-To: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> References: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> Message-ID: <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> 1. Did you mean to use Objects.requireNonNull(Object) where you use Objects.nonNull(Object)? 2. I think it makes sense to close the resources in doCommand(String, File, String). Perhaps use try-with-resources. 3. In getJavaVersion(), the way I read it 3.1. VER9 will be returned for versions 16 or more, which is strange 3.2. For version 11, the return value will be 210 = 100 + 11*10 3.3. I would think just parsing the string with regex would give more transparent code Shura > On Oct 23, 2018, at 1:20 PM, Leonid Kuskov wrote: > > Please review and push the cosmetic fix for the > > Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902337 > Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.00/ > > Thanks, > Leonid > From jonathan.gibbons at oracle.com Tue Oct 23 21:03:31 2018 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Tue, 23 Oct 2018 14:03:31 -0700 Subject: RFR: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage In-Reply-To: <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> References: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> Message-ID: <57b0413c-620f-9479-961b-3a57d37112b2@oracle.com> In doCommand, the process could block if output is written to stderr, because you are not reading from stderr. Instead of using RUntime.exec, the easiest way to fix this is to use ProcessBuilder and then set stderr to redirect to stdout. -- Jon On 10/23/2018 01:58 PM, Alexandre (Shura) Iline wrote: > 1. Did you mean to use Objects.requireNonNull(Object) where you use Objects.nonNull(Object)? > 2. I think it makes sense to close the resources in doCommand(String, File, String). Perhaps use try-with-resources. > 3. In getJavaVersion(), the way I read it > 3.1. VER9 will be returned for versions 16 or more, which is strange > 3.2. For version 11, the return value will be 210 = 100 + 11*10 > 3.3. I would think just parsing the string with regex would give more transparent code > > Shura > >> On Oct 23, 2018, at 1:20 PM, Leonid Kuskov wrote: >> >> Please review and push the cosmetic fix for the >> >> Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902337 >> Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.00/ >> >> Thanks, >> Leonid >> From Leonid.Kuskov at Oracle.com Tue Oct 23 22:22:56 2018 From: Leonid.Kuskov at Oracle.com (Leonid Kuskov) Date: Tue, 23 Oct 2018 15:22:56 -0700 Subject: RFR: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage In-Reply-To: <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> References: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> Message-ID: <52e1ca4a-8b58-bb20-95fb-e876cbd6a306@Oracle.com> Thanks for the review, I've fixed? issues. Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.01/ Leonid On 10/23/18 13:58, Alexandre (Shura) Iline wrote: > 1. Did you mean to use Objects.requireNonNull(Object) where you use Objects.nonNull(Object)? > 2. I think it makes sense to close the resources in doCommand(String, File, String). Perhaps use try-with-resources. > 3. In getJavaVersion(), the way I read it > 3.1. VER9 will be returned for versions 16 or more, which is strange > 3.2. For version 11, the return value will be 210 = 100 + 11*10 > 3.3. I would think just parsing the string with regex would give more transparent code > > Shura > >> On Oct 23, 2018, at 1:20 PM, Leonid Kuskov wrote: >> >> Please review and push the cosmetic fix for the >> >> Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902337 >> Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.00/ >> >> Thanks, >> Leonid >> From alexandre.iline at oracle.com Tue Oct 23 23:06:32 2018 From: alexandre.iline at oracle.com (alexandre.iline at oracle.com) Date: Tue, 23 Oct 2018 23:06:32 +0000 Subject: hg: code-tools/jcov: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage Message-ID: <201810232306.w9NN6WoE021824@aojmv0008.oracle.com> Changeset: 27376699db35 Author: lkuskov Date: 2018-10-23 15:15 -0700 URL: http://hg.openjdk.java.net/code-tools/jcov/rev/27376699db35 CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage ! src/classes/com/sun/tdk/jcov/JREInstr.java ! src/classes/com/sun/tdk/jcov/util/Utils.java From alexandre.iline at oracle.com Tue Oct 23 23:06:58 2018 From: alexandre.iline at oracle.com (Alexandre (Shura) Iline) Date: Tue, 23 Oct 2018 16:06:58 -0700 Subject: RFR: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage In-Reply-To: <52e1ca4a-8b58-bb20-95fb-e876cbd6a306@Oracle.com> References: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> <52e1ca4a-8b58-bb20-95fb-e876cbd6a306@Oracle.com> Message-ID: Looks good. Pushed. Shura > On Oct 23, 2018, at 3:22 PM, Leonid Kuskov wrote: > > Thanks for the review, I've fixed issues. > > Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.01/ > > Leonid > > On 10/23/18 13:58, Alexandre (Shura) Iline wrote: >> 1. Did you mean to use Objects.requireNonNull(Object) where you use Objects.nonNull(Object)? >> 2. I think it makes sense to close the resources in doCommand(String, File, String). Perhaps use try-with-resources. >> 3. In getJavaVersion(), the way I read it >> 3.1. VER9 will be returned for versions 16 or more, which is strange >> 3.2. For version 11, the return value will be 210 = 100 + 11*10 >> 3.3. I would think just parsing the string with regex would give more transparent code >> >> Shura >> >>> On Oct 23, 2018, at 1:20 PM, Leonid Kuskov wrote: >>> >>> Please review and push the cosmetic fix for the >>> >>> Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902337 >>> Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.00/ >>> >>> Thanks, >>> Leonid >>> > From jonathan.gibbons at oracle.com Wed Oct 24 17:07:12 2018 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Wed, 24 Oct 2018 10:07:12 -0700 Subject: RFR: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage In-Reply-To: <52e1ca4a-8b58-bb20-95fb-e876cbd6a306@Oracle.com> References: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> <52e1ca4a-8b58-bb20-95fb-e876cbd6a306@Oracle.com> Message-ID: <5d96265a-dba4-c463-bf84-373931123a57@oracle.com> Leonid, Your use of Runtime.exec may cause problems. In particular, you call Process.waitFor before reading any output from stdout, and not reading anything from stderr. This means that the process may block if there is a lot of output from the command which exceeds the available buffering. To avoid blocking, you should follow these rules: 1. Read from stdout and stderr in a timely manner, i.e. before calling Process.waitFor 2. If you don't want to read from stdout and stderr separately, which requires multiple threads, you should start the process with ProcessBuilder, and set stderr to redirect to stdout using ProcessBuilder.redirectErrorStream(boolean) https://download.java.net/java/early_access/jdk11/docs/api/java.base/java/lang/ProcessBuilder.html#redirectErrorStream(boolean) 3. Read the streams to completion before calling Process.waitFor -- Jon On 10/23/18 3:22 PM, Leonid Kuskov wrote: > Thanks for the review, I've fixed? issues. > > Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.01/ > > Leonid > > On 10/23/18 13:58, Alexandre (Shura) Iline wrote: >> 1. Did you mean to use Objects.requireNonNull(Object) where you use >> Objects.nonNull(Object)? >> 2. I think it makes sense to close the resources in doCommand(String, >> File, String). Perhaps use try-with-resources. >> 3. In getJavaVersion(), the way I read it >> 3.1. VER9 will be returned for versions 16 or more, which is strange >> 3.2. For version 11, the return value will be 210 = 100 + 11*10 >> 3.3. I would think just parsing the string with regex would give more >> transparent code >> >> Shura >> >>> On Oct 23, 2018, at 1:20 PM, Leonid Kuskov >>> wrote: >>> >>> Please review and push the cosmetic fix for the >>> >>> Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902337 >>> Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.00/ >>> >>> Thanks, >>> Leonid >>> > From Leonid.Kuskov at Oracle.com Thu Oct 25 20:22:28 2018 From: Leonid.Kuskov at Oracle.com (Leonid Kuskov) Date: Thu, 25 Oct 2018 13:22:28 -0700 Subject: RFR: CODETOOLS-7902337 jcov (JREInstr) hides results of running java commands: jlink, jimage In-Reply-To: <5d96265a-dba4-c463-bf84-373931123a57@oracle.com> References: <9b0adcb9-885e-5242-9d4b-9b7c3801855b@Oracle.com> <4F57F907-8F32-4FB6-BD9E-4B4CFD59C682@oracle.com> <52e1ca4a-8b58-bb20-95fb-e876cbd6a306@Oracle.com> <5d96265a-dba4-c463-bf84-373931123a57@oracle.com> Message-ID: Jon, Thank you for so detailed review and comments. I've updated the method: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.02 Please take a look at the issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902338 and the fix: http://cr.openjdk.java.net/~lkuskov/7902338/webrev.00/ Thank you, Leonid On 10/24/18 10:07, Jonathan Gibbons wrote: > Leonid, > > Your use of Runtime.exec may cause problems. > > In particular, you call Process.waitFor before reading any output from > stdout, and not reading anything from stderr. This means that the > process may block if there is a lot of output from the command which > exceeds the available buffering. > > To avoid blocking, you should follow these rules: > > 1. Read from stdout and stderr in a timely manner, i.e. before calling > Process.waitFor > > 2. If you don't want to read from stdout and stderr separately, which > requires multiple threads, you should start the process with > ProcessBuilder, and set stderr to redirect to stdout using > ProcessBuilder.redirectErrorStream(boolean) > https://download.java.net/java/early_access/jdk11/docs/api/java.base/java/lang/ProcessBuilder.html#redirectErrorStream(boolean) > > > 3. Read the streams to completion before calling Process.waitFor > > -- Jon > > > On 10/23/18 3:22 PM, Leonid Kuskov wrote: >> Thanks for the review, I've fixed? issues. >> >> Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.01/ >> >> Leonid >> >> On 10/23/18 13:58, Alexandre (Shura) Iline wrote: >>> 1. Did you mean to use Objects.requireNonNull(Object) where you use >>> Objects.nonNull(Object)? >>> 2. I think it makes sense to close the resources in >>> doCommand(String, File, String). Perhaps use try-with-resources. >>> 3. In getJavaVersion(), the way I read it >>> 3.1. VER9 will be returned for versions 16 or more, which is strange >>> 3.2. For version 11, the return value will be 210 = 100 + 11*10 >>> 3.3. I would think just parsing the string with regex would give >>> more transparent code >>> >>> Shura >>> >>>> On Oct 23, 2018, at 1:20 PM, Leonid Kuskov >>>> wrote: >>>> >>>> Please review and push the cosmetic fix for the >>>> >>>> Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902337 >>>> Webrev: http://cr.openjdk.java.net/~lkuskov/7902337/webrev.00/ >>>> >>>> Thanks, >>>> Leonid >>>> >> > From alexandre.iline at oracle.com Wed Oct 31 00:15:55 2018 From: alexandre.iline at oracle.com (alexandre.iline at oracle.com) Date: Wed, 31 Oct 2018 00:15:55 +0000 Subject: hg: code-tools/jcov: 2 new changesets Message-ID: <201810310015.w9V0Ft95020625@aojmv0008.oracle.com> Changeset: de986bc9529d Author: lkuskov Date: 2018-10-25 12:45 -0700 URL: http://hg.openjdk.java.net/code-tools/jcov/rev/de986bc9529d Fix CODETOOLS-7902337 correcting use of Process ! src/classes/com/sun/tdk/jcov/JREInstr.java Changeset: 18b0a143e1c2 Author: lkuskov Date: 2018-10-25 12:56 -0700 URL: http://hg.openjdk.java.net/code-tools/jcov/rev/18b0a143e1c2 CODETOOLS-7902338 Switch JCov to use asm 7.0 and support JDK 11/12 ! build/build.properties ! src/classes/com/sun/tdk/jcov/util/Utils.java