diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff864ee010..4b6f029de4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,15 +33,6 @@ jobs: restore-keys: ${{ runner.os }}-gradle - name: Run tests run: ./.github/scripts/test.sh - - name: Set up JDK 17.0.1 - if: matrix.java == env.MAX_JVM - uses: actions/setup-java@v2 - with: - distribution: 'zulu' - java-version: 17.0.1 - - name: Run JDK-8274349 tests - if: matrix.java == env.MAX_JVM - run: ./gradlew jdk8274349Test - name: Publish Coverage if: > matrix.java == env.MIN_JVM @@ -72,3 +63,18 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} run: ./gradlew publishToSonatype + jdk8274349: + runs-on: ubuntu-latest + env: + JAVA_VERSION: 17 + steps: + - uses: actions/checkout@v2.4.0 + - name: Set up JDK 17.0.1 + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 17.0.1 + - name: Run JDK-8274349 tests + uses: gradle/gradle-build-action@v2 + with: + arguments: jdk8274349Test diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/AddValue.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/AddValue.java index 339998c3fd..ff063d0844 100644 --- a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/AddValue.java +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/AddValue.java @@ -77,7 +77,7 @@ private MethodSpec makeGetValue() { var code = CodeBlock.builder() .beginControlFlow("for (;;)") - .addStatement("$1T ref = ($1T) $2L.get(this)", Reference.class, handle) + .addStatement("$1T ref = ($1T) $2L.getOpaque(this)", Reference.class, handle) .addStatement("V referent = ref.get()") .beginControlFlow("if ((referent != null) || (ref == $L.getAcquire(this)))", handle) .addStatement("return referent") diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeRule.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeRule.java index 57293ea9f4..9a729341d2 100644 --- a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeRule.java +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/NodeRule.java @@ -132,7 +132,7 @@ protected final MethodSpec newGetter(Strength strength, TypeName varType, .addModifiers(context.publicFinalModifiers()) .returns(varType); if (strength == Strength.STRONG) { - if ((visibility == Visibility.PLAIN) || (visibility == Visibility.OPAQUE)) { + if (visibility == Visibility.PLAIN) { var template = String.format("return (%s) $L.get(this)", varType.isPrimitive() ? "$L" : "$T"); getter.addStatement(template, varType, varHandleName(varName)); diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java index 59ccdc7af3..de5e103775 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java @@ -67,7 +67,7 @@ public RingBuffer(E e) { @Override public int offer(E e) { long head = readCounter; - long tail = relaxedWriteCounter(); + long tail = writeCounterOpaque(); long size = (tail - head); if (size >= BUFFER_SIZE) { return Buffer.FULL; @@ -83,14 +83,14 @@ public int offer(E e) { @Override public void drainTo(Consumer consumer) { long head = readCounter; - long tail = relaxedWriteCounter(); + long tail = writeCounterOpaque(); long size = (tail - head); if (size == 0) { return; } do { int index = (int) (head & MASK); - E e = (E) BUFFER.getVolatile(buffer, index); + E e = (E) BUFFER.getAcquire(buffer, index); if (e == null) { // not published yet break; @@ -99,7 +99,7 @@ public void drainTo(Consumer consumer) { consumer.accept(e); head++; } while (head != tail); - lazySetReadCounter(head); + setReadCounterOpaque(head); } @Override @@ -169,12 +169,12 @@ abstract static class ReadAndWriteCounterRef extends PadWriteCounter { WRITE.setOpaque(this, 1); } - void lazySetReadCounter(long count) { + void setReadCounterOpaque(long count) { READ.setOpaque(this, count); } - long relaxedWriteCounter() { - return (long) WRITE.get(this); + long writeCounterOpaque() { + return (long) WRITE.getOpaque(this); } boolean casWriteCounter(long expect, long update) { diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 039515f373..9edf7f0b5b 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -85,7 +85,7 @@ ext { ] pluginVersions = [ bnd: '6.1.0', - checkstyle: '9.1', + checkstyle: '9.2', coveralls: '2.12.0', errorprone: '2.0.2', findsecbugs: '1.11.0',