Github user franz1981 commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/2175#discussion_r205195338
--- Diff:
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/AtomicBooleanFieldUpdater.java
---
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.utils;
+
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import sun.reflect.CallerSensitive;
+
+public class AtomicBooleanFieldUpdater<T> {
+
+ /**
+ * Creates and returns an updater for objects with the given field.
+ * The Class argument is needed to check that reflective types and
+ * generic types match.
+ *
+ * @param tclass the class of the objects holding the field
+ * @param fieldName the name of the field to be updated
+ * @param <U> the type of instances of tclass
+ * @return the updater
+ * @throws IllegalArgumentException if the field is not a
+ * volatile long type
+ * @throws RuntimeException with a nested reflection-based
+ * exception if the class does not hold field or is the wrong type,
+ * or the field is inaccessible to the caller according to Java language
+ * access control
+ */
+ @CallerSensitive
+ public static <U> AtomicBooleanFieldUpdater<U> newUpdater(Class<U>
tclass, String fieldName) {
--- End diff --
I agree about the reasons but given that the JVM doesn't trust final fields
you won't get the same performance you would have just using the int updater.
Given that, I suppose that everything that let it works is ok for me: the PR is
well done as always :)
---