On Thu, 5 Nov 2020 09:02:55 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:

>> …AccessorImpl object
>> 
>> We met real problem when using protobuf with option optimized for code size, 
>> detail in JBS https://bugs.openjdk.java.net/browse/JDK-8255883
>> 
>> Optimize solution is adding a new boolean field to detect concurrent method 
>> accessor generation in same NativeMethodAccessorImpl object, only one thread 
>> is allowed to generate accessor, other threads still invoke in jni way until 
>> parent's delegator is updated from NativeMethodAccessorImpl  to generated 
>> accessor.
>> 
>> In common case, extra overhead is an atomic operation, compared with method 
>> accessor generate, this cost is trivial.
>
> src/java.base/share/classes/jdk/internal/reflect/NativeMethodAccessorImpl.java
>  line 80:
> 
>> 78:                 succ = true;
>> 79:             } finally {
>> 80:                 if (succ == false) {
> 
> Why `succ` variable, if you can just `catch (Throwable e)` and restore the 
> `accessorGenerated`?

Good suggest! Will update.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1070

Reply via email to