GuardedBy: use internal annotation rather than from external library

Also remove the jcip-annotations dependency from core.
This commit is contained in:
Sean Gilligan 2025-02-27 04:14:38 -08:00 committed by Andreas Schildbach
parent e8ec153322
commit 8070bd80e6
6 changed files with 36 additions and 5 deletions

View file

@ -14,7 +14,6 @@ dependencies {
api 'com.google.guava:guava:33.4.0-android'
api 'com.google.protobuf:protobuf-javalite:4.29.3'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'net.jcip:jcip-annotations:1.0'
testImplementation project(':bitcoinj-test-support')
testImplementation 'junit:junit:4.13.2'

View file

@ -19,7 +19,7 @@ package org.bitcoinj.core;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import net.jcip.annotations.GuardedBy;
import org.bitcoinj.core.internal.GuardedBy;
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.base.internal.TimeUtils;

View file

@ -23,7 +23,7 @@ import com.google.common.collect.Ordering;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.Runnables;
import com.google.common.util.concurrent.Uninterruptibles;
import net.jcip.annotations.GuardedBy;
import org.bitcoinj.core.internal.GuardedBy;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.internal.InternalUtils;
import org.bitcoinj.base.internal.PlatformUtils;

View file

@ -0,0 +1,32 @@
/*
* Copyright by the original author or authors.
*
* Licensed 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.bitcoinj.core.internal;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Define which lock protects ("guards") the annotated field or method. A similar annotation exists
* in {@code net.jcip.annoations} and {@code javax.annotations.concurrent}. Since we want to minimize external
* dependencies, we define it locally.
*/
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface GuardedBy {
String value();
}

View file

@ -23,7 +23,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import org.bitcoinj.core.internal.GuardedBy;
import java.io.IOException;
import java.nio.Buffer;
import java.nio.ByteBuffer;

View file

@ -21,7 +21,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.math.IntMath;
import com.google.protobuf.ByteString;
import net.jcip.annotations.GuardedBy;
import org.bitcoinj.core.internal.GuardedBy;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.exceptions.AddressFormatException;