Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 52b3e2c

Browse files
committedFeb 27, 2025·
secp-api/secp-bouncy: backport to Java 8
* IDEs will see secp-api, secp-bouncy modules as Java 9 * apiModuleJavaCompatibility property is used with `org.beryx.jar` Gradle plugin to create Java 8 JARs with module-info on official builds * Remove usages of Java 9 API in secp-api and secp-bouncy Developers of secp-jdk using IDEs will need to be aware that the actual requirements are Java 8 API. But mistakes will be caught by CI.
1 parent 4b49c82 commit 52b3e2c

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed
 

‎.github/workflows/gradle.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
- name: Install secp256k1 with Nix
3838
run: nix profile install nixpkgs#secp256k1
3939
- name: Build with Gradle
40-
run: ./gradlew build
40+
run: ./gradlew -PapiModuleJavaCompatibility=8 build
4141
- name: Run Java & Kotlin Examples
42-
run: ./gradlew run runEcdsa
42+
run: ./gradlew -PapiModuleJavaCompatibility=8 run runEcdsa
4343

4444

4545
build_nix:
@@ -59,4 +59,4 @@ jobs:
5959
- name: Install secp256k1 with Nix
6060
run: nix profile install nixpkgs#secp256k1
6161
- name: Build in Nix development shell
62-
run: nix develop -c gradle build run runEcdsa
62+
run: nix develop -c gradle -PapiModuleJavaCompatibility=8 build run runEcdsa

‎.gitlab-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ nixos-devshell:
1010
- echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
1111
- nix profile install nixpkgs#secp256k1
1212
script:
13-
- nix develop .#minimum -c gradle build run runEcdsa
13+
- nix develop .#minimum -c gradle -PapiModuleJavaCompatibility=8 build run runEcdsa
1414
cache:
1515
key: "${CI_COMMIT_REF_SLUG}"
1616
paths:
@@ -26,4 +26,4 @@ trixie-gradlew:
2626
- echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
2727
- nix profile install nixpkgs#secp256k1
2828
script:
29-
- ./gradlew build run runEcdsa
29+
- ./gradlew -PapiModuleJavaCompatibility=8 build run runEcdsa

‎secp-api/build.gradle

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
plugins {
22
id 'java-library'
3+
id 'org.beryx.jar' version '2.0.0'
34
}
45

56
tasks.withType(JavaCompile).configureEach {
6-
options.release = 9
7+
// IDEs and other tools will see `9` by default, but CI and release builds
8+
// will set `-PapiModuleJavaCompatibility=8` to generate a Java 8 JAR
9+
// and the `org.beryx.jar` plugin will put `module-info.jar` in the Java 8 JAR.
10+
options.release = (findProperty('apiModuleJavaCompatibility') ?: 9) as int
711
}
812

913
ext.moduleName = 'org.bitcoinj.secp.api'
1014

15+
moduleConfig {
16+
version = project.version
17+
}
18+
1119
dependencies {
1220
api("org.jspecify:jspecify:1.0.0")
1321
}

‎secp-api/src/main/java/org/bitcoinj/secp/api/Secp256k1Provider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Optional;
2020
import java.util.ServiceLoader;
2121
import java.util.function.Predicate;
22+
import java.util.stream.StreamSupport;
2223

2324
/**
2425
*
@@ -65,8 +66,7 @@ static Secp256k1Provider find() {
6566
*/
6667
static Optional<Secp256k1Provider> findFirst(Predicate<Secp256k1Provider> filter) {
6768
ServiceLoader<Secp256k1Provider> loader = ServiceLoader.load(Secp256k1Provider.class);
68-
return loader.stream()
69-
.map(ServiceLoader.Provider::get)
69+
return StreamSupport.stream(loader.spliterator(),false)
7070
.filter(filter)
7171
.findFirst();
7272
}
@@ -76,7 +76,7 @@ static Optional<Secp256k1Provider> findFirst(Predicate<Secp256k1Provider> filter
7676
* @param provider a candidate provider
7777
* @return true if it should be "found"
7878
*/
79-
private static boolean defaultFilter(Secp256k1Provider provider) {
79+
/* private */ static boolean defaultFilter(Secp256k1Provider provider) {
8080
return provider.name().equals("ffm");
8181
}
8282
}

‎secp-bouncy/build.gradle

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
plugins {
22
id 'java-library'
3+
id 'org.beryx.jar' version '2.0.0'
34
}
45

56
tasks.withType(JavaCompile).configureEach {
6-
options.release = 9
7+
// IDEs and other tools will see `9` by default, but CI and release builds
8+
// will set `-PapiModuleJavaCompatibility=8` to generate a Java 8 JAR
9+
// and the `org.beryx.jar` plugin will put `module-info.jar` in the Java 8 JAR.
10+
options.release = (findProperty('apiModuleJavaCompatibility') ?: 9) as int
711
}
812

913
ext.moduleName = 'org.bitcoinj.secp.bouncy'
1014

15+
moduleConfig {
16+
version = project.version
17+
}
18+
1119
dependencies {
1220
api project(':secp-api')
1321
api 'org.bouncycastle:bcprov-jdk18on:1.78.1' // TODO: Make this a non-API dependency, see BouncyPrivKey

0 commit comments

Comments
 (0)