Missing increment of local counter variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Missing increment of local counter variable

Παύλος-Πέτρος Τουρνάρης
Hello everyone, 

First time posting here :) 

Stumbled upon a javac diff -> http://hg.openjdk.java.net/jdk/jdk/rev/89f6aa26fd6c resolving https://bugs.openjdk.java.net/browse/JDK-8177486https://bugs.openjdk.java.net/browse/JDK-8007720 and noticed that the previous implementation was using a local counter variable named `i` when looping through the parameter types, in order to construct the parameter name. The new implementation follows a similar path to construct the parameter name, using the `i` local counter variable but it does not increment it. 


Otherwise http://hg.openjdk.java.net/jdk/jdk/file/89f6aa26fd6c/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java#l1889 on that line the `fromString("arg" + i)` will always be called with `i` being 0 (zero). 

Not sure If I can submit a patch, or how it works in general, but I was suggested to report it in this list :) 

Thank you for your time!

--
Pavlos-Petros Tournaris
Android Software Engineer @ Workable

Reply | Threaded
Open this post in threaded view
|

Re: Missing increment of local counter variable

Liam Miller-Cushon
Thanks for pointing that out. It was an oversight, I filed https://bugs.openjdk.java.net/browse/JDK-8194268.

I don't think it's a regression, though. That branch is only taken for synthetic methods. They aren't visible during annotation processing, and their parameter names don't appear in bytecode, so it shouldn't be possible to observe the incorrect names.

If you saw this causing incorrect behaviour, can you share a complete example?

On Fri, Dec 29, 2017 at 12:23 PM, Παύλος-Πέτρος Τουρνάρης <[hidden email]> wrote:
Hello everyone, 

First time posting here :) 

Stumbled upon a javac diff -> http://hg.openjdk.java.net/jdk/jdk/rev/89f6aa26fd6c resolving https://bugs.openjdk.java.net/browse/JDK-8177486https://bugs.openjdk.java.net/browse/JDK-8007720 and noticed that the previous implementation was using a local counter variable named `i` when looping through the parameter types, in order to construct the parameter name. The new implementation follows a similar path to construct the parameter name, using the `i` local counter variable but it does not increment it. 


Otherwise http://hg.openjdk.java.net/jdk/jdk/file/89f6aa26fd6c/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java#l1889 on that line the `fromString("arg" + i)` will always be called with `i` being 0 (zero). 

Not sure If I can submit a patch, or how it works in general, but I was suggested to report it in this list :) 

Thank you for your time!

--
Pavlos-Petros Tournaris
Android Software Engineer @ Workable


Reply | Threaded
Open this post in threaded view
|

Re: Missing increment of local counter variable

Παύλος-Πέτρος Τουρνάρης
Nope, just saw that on the diff. Have not actually found an incorrect behaviour on an example! 

Thanks for filing it!

On Sat, Dec 30, 2017 at 12:12 AM, Liam Miller-Cushon <[hidden email]> wrote:
Thanks for pointing that out. It was an oversight, I filed https://bugs.openjdk.java.net/browse/JDK-8194268.

I don't think it's a regression, though. That branch is only taken for synthetic methods. They aren't visible during annotation processing, and their parameter names don't appear in bytecode, so it shouldn't be possible to observe the incorrect names.

If you saw this causing incorrect behaviour, can you share a complete example?

On Fri, Dec 29, 2017 at 12:23 PM, Παύλος-Πέτρος Τουρνάρης <[hidden email]> wrote:
Hello everyone, 

First time posting here :) 

Stumbled upon a javac diff -> http://hg.openjdk.java.net/jdk/jdk/rev/89f6aa26fd6c resolving https://bugs.openjdk.java.net/browse/JDK-8177486https://bugs.openjdk.java.net/browse/JDK-8007720 and noticed that the previous implementation was using a local counter variable named `i` when looping through the parameter types, in order to construct the parameter name. The new implementation follows a similar path to construct the parameter name, using the `i` local counter variable but it does not increment it. 


Otherwise http://hg.openjdk.java.net/jdk/jdk/file/89f6aa26fd6c/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java#l1889 on that line the `fromString("arg" + i)` will always be called with `i` being 0 (zero). 

Not sure If I can submit a patch, or how it works in general, but I was suggested to report it in this list :) 

Thank you for your time!

--
Pavlos-Petros Tournaris
Android Software Engineer @ Workable





--
Pavlos-Petros Tournaris
Android Software Engineer @ Workable