uschindler edited a comment on pull request #1779:
URL: https://github.com/apache/lucene-solr/pull/1779#issuecomment-679311573
This is a limitation of the Java Compiler javac. Whenever you access an
instance field from a class (final or not doe snot matter), it created a lamda
bound to `this`. The lambda method then does a getfield and invokes method.
Here is the Bytecode of the lambda before this change:
```
private long lambda$advanceQueue$1();
Code:
0: aload_0
1: getfield #20 // Field
nextSeqNo:Ljava/util/concurrent/atomic/AtomicLong;
4: invokevirtual #75 // Method
java/util/concurrent/atomic/AtomicLong.get:()J
7: lconst_1
8: lsub
9: lreturn
```
As you see it's a non-static method. The generated lambda class therefor has
a reference to `this` (methodhandle bound to `this`).
After your patch, the lambda is static and instead gets one parameter:
```
private static long
lambda$getPrevMaxSeqIdSupplier$1(java.util.concurrent.atomic.AtomicLong);
Code:
0: aload_0
1: invokevirtual #75 // Method
java/util/concurrent/atomic/AtomicLong.get:()J
4: lconst_1
5: lsub
6: lreturn
```
The generated anonymous class will have just be bound to the `AtomicLong`
and not `this`.
The method signature of both MethodHandles is identical, one parameter
(`this` or `AtomicLong`
), returning `long`.
By analyzing the code we see that issue is fixed, test is not necessarily
needed, but it's hard to check the bytecode :-)
+1 for the fix!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]