Re: make it possible to compile bouncycastle with jdk21

From: Olivier Certner <olce_at_freebsd.org>
Date: Thu, 04 Dec 2025 18:00:06 UTC
Hi,

I have the same changes as yours plus an old patch that I did a while ago to enable building with openjdk11.  I guess it is not needed for jdk21, but it shouldn't hurt:

diff --git a/java/bouncycastle/files/patch-ant_bc+-build.xml b/java/bouncycastle/files/patch-ant_bc+-build.xml
new file mode 100644
index 000000000000..d8c18203edf1
--- /dev/null
+++ b/java/bouncycastle/files/patch-ant_bc+-build.xml
@@ -0,0 +1,26 @@
+--- ant/bc+-build.xml.orig     2022-01-31 06:50:53 UTC
++++ ant/bc+-build.xml
+@@ -118,6 +118,7 @@
+                 <mkdir dir="${artifacts.dir}/@{target}" />
+ 
+                 <javac source="${bc.javac.source}" target="${bc.javac.target}"
++                    encoding="UTF-8"
+                     srcdir="${artifacts.dir}/@{target}/src"
+                     destdir="${build.dir}/@{target}/classes"
+                     memoryMaximumSize="512m"
+@@ -155,6 +156,7 @@
+                 <mkdir dir="${artifacts.dir}/@{target}" />
+ 
+                 <javac source="${bc.javac.source}" target="${bc.javac.target}"
++                    encoding="UTF-8"
+                     srcdir="${artifacts.dir}/@{target}/src"
+                     destdir="${build.dir}/@{target}/classes"
+                     memoryMaximumSize="512m"
+@@ -302,6 +304,7 @@
+         </copy>
+ 
+         <javac source="${bc.javac.source}" target="${bc.javac.target}"
++            encoding="UTF-8"
+             srcdir="${lcrypto.target.src.dir}"
+             destdir="${lcrypto.target.classes.dir}"
+           memoryMaximumSize="512m"

Without it, I get errors like:

/wrkdirs/usr/ports/java/bouncycastle/work/crypto-171/build/artifacts/jdk1.8/bcprov-jdk18on-171/src/org/bouncycastle/crypto/generators/Argon2BytesGenerator.java:489: error: unmappable character (0xCF) for encoding US-ASCII
         * H0 = H64(p, ??, m, t, v, y, |P|, P, |S|, S, |L|, K, |X|, X)

Could you test building with this patch?  I'm not versed in Java building, so maybe there is some better way than that.  Perhaps it's openjdk11 itself that should be compiled differently to default to UTF-8?

Thanks and regards.

-- 
Olivier Certner