Re: JavaHL jar file containing class files for unit tests

Daniel Sahlberg <[email protected]> Sun, 2 Aug 2026 15:07:37 +0200
Newsgroups gmane.comp.version-control.subversion.devel
Message-ID <CAMHy98PcjxWoHATCKQUGJvXL2Bj0=cXOXvmsOv_SdMAaVUw5zw@mail.gmail.com>
--0000000000000ad1410658101ce0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Den ons 29 juli 2026 kl 12:52 skrev Branko =C4=8Cibej <[email protected]>:

> On 29. 7. 2026 10:58, Daniel Sahlberg wrote:
>
>
>
> Den ons 29 juli 2026 kl 04:32 skrev Jun Omae <[email protected]>:
>
>> On 2026/07/28 23:58, Daniel Sahlberg wrote:
>> > Den m=C3=A5n 27 juli 2026 kl 00:09 skrev Jun Omae <[email protected]
>> <mailto:[email protected]>>:
>> >
>> >     > Is there a problem if we include the test classes?
>> >
>> >     No direct issues have been found so far. However, static
>> initializers within test classes are executed simply by loading the clas=
s.
>> >
>> >     [[[
>> >     $ grep -r 'static *{' subversion/bindings/javahl
>> >
>>  subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests=
.java:
>>    static {
>> >
>>  subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests=
.java:
>>    static {
>> >     ]]]
>> >
>> >
>> > Thank you!
>> >
>> > I think I got it working on 1.14.x, successfully created a JAR file
>> without the tests.
>> >
>> > It still seems to fail on trunk. Can you do the same steps above on
>> trunk?
>> >
>> > Cheers,
>> > Daniel
>> >
>>
>> Hm, I get the same failures on trunk.
>> It seems that the changes of the behavior is introduced in r1933892.
>> At least, ./configure should stop and/or warn it if the junit is NOT
>> optional when javahl enabled.
>>
>> [[[
>> $ /bin/sh autogen.sh
>> $ ./configure --prefix=3D/dev/shm/svn/trunk --without-apxs --without-swi=
g
>> --without-swig-{perl,python,ruby} --enable-javahl
>> --with-jdk=3D/usr/lib/jvm/java-11-openjdk-amd64 --without-junit
>> PYTHON=3D/usr/bin/python3
>> $ make -j$(nproc) all
>> $ make javahl
>>
>> $ find subversion/bindings/javahl -name '*.class' | wc -l
>> 277
>> $ find subversion/bindings/javahl -name '*Test*.class' | wc -l
>> 0    #=3D=3D> tests/**/*.java are compiled yet.
>>
>> $ make install
>> $ make install-javahl    # Why this task builds tests/**/*.java?
>> ...
>> /dev/shm/subversion-trunk/subversion/bindings/javahl/tests/org/tigris/su=
bversion/javahl/BasicTests.java:1708:
>> error: cannot find symbol
>>         assertEquals("wrong revision from commit",
>>         ^
>>   symbol:   method assertEquals(String,long,int)
>>   location: class BasicTests
>> /dev/shm/subversion-trunk/subversion/bindings/javahl/tests/org/tigris/su=
bversion/javahl/BasicTests.java:1756:
>> error: cannot find symbol
>>         assertEquals("wrong revision from update",
>>         ^
>>   symbol:   method assertEquals(String,long,int)
>>   location: class BasicTests
>> Note: Some input files use or override a deprecated API.
>> Note: Recompile with -Xlint:deprecation for details.
>> 100 errors
>> ]]]
>>
>
> Thanks for confirming! It seems like 1.15.x is also affected by this (I'l=
l
> bring it up on the release thread).
>
> To add three more data points to the discussion, I checked Fedora 43, 44
> and FreeBSD 14. The tests are present in Fedora's svn-javahl.jar but not =
in
> FreeBSD's svn-javahl.jar. Obviously different distributors use different
> options when building. That is unfortunate since we are distributing
> different ABIs.
>
> I think it would be cleaner to have the tests in svn-javahl-tests.jar if
> built. Maybe we want to install this alongside svn-javahl.jar. That way
> Fedora and Ubuntu can keep distributing the tests and FreeBSD not, while
> everyone's svn-javahl.jar is the same.
>
> Does that make sense?
>
>
>
> The following makes sense:
>
> 1. There is no regression in autotools. It is what it is. Note that
> putting test classes in a separate jar has wider consequences than just t=
he
> ABI. For example, JavaHL tests would fail in autotools builds. We'd have =
to
> change the way the classpath is constructed in `make check-*-javahl`.
>
> 2. No change is needed in 1.15.x. Autotools are consistent with earlier
> releases and CMake doesn't build JavaHL. IFF we want to change this in
> CMake for 1.15, then we have further questions to consider:
>
> 2.1. CMake and Autotools/vcxproj should produce identical results given
> identical options. In this case specifically I mean that the CMake build
> should create the same lib/dll names and the same JavaHL jar (singular) a=
s
> the vcxproj generator.
>
>
> 3. Regardless of the answer to 2: If we decide to not include test classe=
s
> in svn-javhl.jar, then we have to consider how to mitigate the ABI change=
.
>
> Personally I'd prefer changing the build requirements to changing the ABI
> in svn-javahl.jar. That means that --enable-javahl implies that JUnit is
> mandatory.
>
> -- Brane
>
>
Is the patch below an acceptable way of requiring --with-junit?

Cheers,
Daniel


 [[[
Index: configure.ac
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- configure.ac        (revision 1936330)
+++ configure.ac        (working copy)
@@ -1748,6 +1748,7 @@

 dnl Possibly compile JavaHL
 do_javahl_build=3Dno
+has_junit=3Dno
 AC_ARG_ENABLE(javahl,
   AS_HELP_STRING([--enable-javahl],
              [Enable compilation of Java high-level bindings (requires
C++)]),
@@ -1755,6 +1756,21 @@
         do_javahl_build=3D"yes"
     fi
   ])
+AC_ARG_WITH(junit,
+AS_HELP_STRING([--with-junit=3DPATH],
+               [Specify a path to the junit JAR file.]),
+[
+    if test "$withval" !=3D "no"; then
+      if test -n "$JAVA_CLASSPATH"; then
+        JAVA_CLASSPATH=3D"$withval:$JAVA_CLASSPATH"
+      else
+        JAVA_CLASSPATH=3D"$withval"
+      fi
+      JAVAHL_TESTS_TARGET=3D"javahl-tests"
+      JAVAHL_COMPAT_TESTS_TARGET=3D"javahl-compat-tests"
+      has_junit=3D"yes"
+    fi
+])

 JAVAHL_OBJDIR=3D""
 INSTALL_EXTRA_JAVAHL_LIB=3D""
@@ -1763,6 +1779,12 @@
 JAVAHL_COMPAT_TESTS_TARGET=3D""
 LT_CXX_LIBADD=3D""
 if test "$do_javahl_build" =3D "yes"; then
+  dnl Since r1933892 junit is required to build the JavaHL bindings
+  if test "$has_junit" =3D "no"; then
+    AC_MSG_ERROR([--with-junit must be specified if building the Java
high-level
+                  bindings.])
+  fi
+
   dnl Check for suitable JDK
   if test "$JDK_SUITABLE" =3D "no"; then
     AC_MSG_ERROR([Cannot compile JavaHL without a suitable JDK.
@@ -1802,21 +1824,6 @@
 AC_SUBST(JAVAHL_OBJDIR)
 AC_SUBST(FIX_JAVAHL_LIB)
 AC_SUBST(LT_CXX_LIBADD)
-
-AC_ARG_WITH(junit,
-AS_HELP_STRING([--with-junit=3DPATH],
-               [Specify a path to the junit JAR file.]),
-[
-    if test "$withval" !=3D "no"; then
-      if test -n "$JAVA_CLASSPATH"; then
-        JAVA_CLASSPATH=3D"$withval:$JAVA_CLASSPATH"
-      else
-        JAVA_CLASSPATH=3D"$withval"
-      fi
-      JAVAHL_TESTS_TARGET=3D"javahl-tests"
-      JAVAHL_COMPAT_TESTS_TARGET=3D"javahl-compat-tests"
-    fi
-])
 AC_SUBST(JAVA_CLASSPATH)
 AC_SUBST(JAVAHL_TESTS_TARGET)
 AC_SUBST(JAVAHL_COMPAT_TESTS_TARGET)
]]]

--0000000000000ad1410658101ce0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><span style=3D"background-color:transpare=
nt">Den ons 29 juli 2026 kl 12:52 skrev Branko =C4=8Cibej &lt;<a href=3D"ma=
ilto:[email protected]">[email protected]</a>&gt;:</span></div><div class=3D"=
gmail_quote gmail_quote_container"><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><u></u>

 =20
   =20
 =20
  <div>
    <div>On 29. 7. 2026 10:58, Daniel Sahlberg
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      <div dir=3D"ltr">
        <div dir=3D"ltr"><br>
        </div>
        <br>
        <div class=3D"gmail_quote">
          <div dir=3D"ltr" class=3D"gmail_attr">Den ons 29 juli 2026 kl
            04:32 skrev Jun Omae &lt;<a href=3D"mailto:[email protected]" t=
arget=3D"_blank">[email protected]</a>&gt;:<br>
          </div>
          <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
            2026/07/28 23:58, Daniel Sahlberg wrote:<br>
            &gt; Den m=C3=A5n 27 juli 2026 kl 00:09 skrev Jun Omae &lt;<a h=
ref=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>
            &lt;mailto:<a href=3D"mailto:[email protected]" target=3D"_blan=
k">[email protected]</a>&gt;&gt;:<br>
            &gt; <br>
            &gt;=C2=A0 =C2=A0 =C2=A0&gt; Is there a problem if we include t=
he test
            classes?<br>
            &gt; <br>
            &gt;=C2=A0 =C2=A0 =C2=A0No direct issues have been found so far=
. However,
            static initializers within test classes are executed simply
            by loading the class.<br>
            &gt; <br>
            &gt;=C2=A0 =C2=A0 =C2=A0[[[<br>
            &gt;=C2=A0 =C2=A0 =C2=A0$ grep -r &#39;static *{&#39; subversio=
n/bindings/javahl<br>
            &gt;=C2=A0 =C2=A0
=C2=A0subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTes=
ts.java:
            =C2=A0 =C2=A0static {<br>
            &gt;=C2=A0 =C2=A0
=C2=A0subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTes=
ts.java:
            =C2=A0 =C2=A0static {<br>
            &gt;=C2=A0 =C2=A0 =C2=A0]]]<br>
            &gt; <br>
            &gt; <br>
            &gt; Thank you!<br>
            &gt; <br>
            &gt; I think I got it working on 1.14.x, successfully
            created a JAR file without the tests.<br>
            &gt; <br>
            &gt; It still seems to fail on trunk. Can you do the same
            steps above on trunk?<br>
            &gt; <br>
            &gt; Cheers,<br>
            &gt; Daniel<br>
            &gt; <br>
            <br>
            Hm, I get the same failures on trunk.<br>
            It seems that the changes of the behavior is introduced in
            r1933892.<br>
            At least, ./configure should stop and/or warn it if the
            junit is NOT optional when javahl enabled.<br>
            <br>
            [[[<br>
            $ /bin/sh autogen.sh<br>
            $ ./configure --prefix=3D/dev/shm/svn/trunk --without-apxs
            --without-swig --without-swig-{perl,python,ruby}
            --enable-javahl
            --with-jdk=3D/usr/lib/jvm/java-11-openjdk-amd64
            --without-junit PYTHON=3D/usr/bin/python3<br>
            $ make -j$(nproc) all<br>
            $ make javahl<br>
            <br>
            $ find subversion/bindings/javahl -name &#39;*.class&#39; | wc =
-l<br>
            277<br>
            $ find subversion/bindings/javahl -name &#39;*Test*.class&#39; =
| wc
            -l<br>
            0=C2=A0 =C2=A0 #=3D=3D&gt; tests/**/*.java are compiled yet.<br=
>
            <br>
            $ make install<br>
            $ make install-javahl=C2=A0 =C2=A0 # Why this task builds
            tests/**/*.java?<br>
            ...<br>
/dev/shm/subversion-trunk/subversion/bindings/javahl/tests/org/tigris/subve=
rsion/javahl/BasicTests.java:1708:
            error: cannot find symbol<br>
            =C2=A0 =C2=A0 =C2=A0 =C2=A0 assertEquals(&quot;wrong revision f=
rom commit&quot;,<br>
            =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^<br>
            =C2=A0 symbol:=C2=A0 =C2=A0method assertEquals(String,long,int)=
<br>
            =C2=A0 location: class BasicTests<br>
/dev/shm/subversion-trunk/subversion/bindings/javahl/tests/org/tigris/subve=
rsion/javahl/BasicTests.java:1756:
            error: cannot find symbol<br>
            =C2=A0 =C2=A0 =C2=A0 =C2=A0 assertEquals(&quot;wrong revision f=
rom update&quot;,<br>
            =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^<br>
            =C2=A0 symbol:=C2=A0 =C2=A0method assertEquals(String,long,int)=
<br>
            =C2=A0 location: class BasicTests<br>
            Note: Some input files use or override a deprecated API.<br>
            Note: Recompile with -Xlint:deprecation for details.<br>
            100 errors<br>
            ]]]<br>
          </blockquote>
          <div><br>
          </div>
          <div>Thanks for confirming! It seems like 1.15.x is also
            affected by this (I&#39;ll bring it up on the release thread).<=
/div>
          <div><br>
          </div>
          <div>
            <div>To add three more data points to the discussion, I
              checked Fedora 43, 44 and FreeBSD 14. The tests are
              present in Fedora&#39;s svn-javahl.jar but not in FreeBSD&#39=
;s
              svn-javahl.jar. Obviously different distributors use
              different options when building. That is unfortunate since
              we are distributing different ABIs.</div>
            <div><br>
            </div>
            <div><span style=3D"background-color:transparent">I think it
                would be cleaner to have the tests in
                svn-javahl-tests.jar if built. Maybe we want to install
                this alongside svn-javahl.jar. That way Fedora and
                Ubuntu can keep distributing the tests and FreeBSD not,
                while everyone&#39;s svn-javahl.jar is the same.</span></di=
v>
            <div><span style=3D"background-color:transparent"><br>
              </span></div>
            <div><span style=3D"background-color:transparent">Does that
                make sense?</span></div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <br>
    The following makes sense:<br>
    <br>
    1. There is no regression in autotools. It is what it is. Note that
    putting test classes in a separate jar has wider consequences than
    just the ABI. For example, JavaHL tests would fail in autotools
    builds. We&#39;d have to change the way the classpath is constructed in
    `make check-*-javahl`.<br>
    <br>
    2. No change is needed in 1.15.x. Autotools are consistent with
    earlier releases and CMake doesn&#39;t build JavaHL. IFF we want to
    change this in CMake for 1.15, then we have further questions to
    consider:<br>
    <br>
    <blockquote>2.1. CMake and Autotools/vcxproj should produce
      identical results given identical options. In this case
      specifically I mean that the CMake build should create the same
      lib/dll names and the same JavaHL jar (singular) as the vcxproj
      generator.<br>
    </blockquote>
    <br>
    3. Regardless of the answer to 2: If we decide to not include test
    classes in svn-javhl.jar, then we have to consider how to mitigate
    the ABI change.<br>
    <br>
    Personally I&#39;d prefer changing the build requirements to changing
    the ABI in svn-javahl.jar. That means that --enable-javahl implies
    that JUnit is mandatory.<br>
    <br>
    -- Brane<br>
    <br></div></blockquote><div><br></div><div>Is the patch below an accept=
able way of requiring --with-junit?</div><div><br></div><div>Cheers,</div><=
div>Daniel</div><div><br></div><div><br></div><div>=C2=A0[[[</div>Index: <a=
 href=3D"http://configure.ac">configure.ac</a><br>=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>--- <a href=3D"http://configure.ac">configur=
e.ac</a> =C2=A0 =C2=A0 =C2=A0 =C2=A0(revision 1936330)<br>+++ <a href=3D"ht=
tp://configure.ac">configure.ac</a> =C2=A0 =C2=A0 =C2=A0 =C2=A0(working cop=
y)<br>@@ -1748,6 +1748,7 @@<br><br>=C2=A0dnl Possibly compile JavaHL<br>=C2=
=A0do_javahl_build=3Dno<br>+has_junit=3Dno<br>=C2=A0AC_ARG_ENABLE(javahl,<b=
r>=C2=A0 =C2=A0AS_HELP_STRING([--enable-javahl],<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [Enable compilation of Java high-level bindings=
 (requires C++)]),<br>@@ -1755,6 +1756,21 @@<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0do_javahl_build=3D&quot;yes&quot;<br>=C2=A0 =C2=A0 =C2=A0fi<br>=C2=
=A0 =C2=A0])<br>+AC_ARG_WITH(junit,<br>+AS_HELP_STRING([--with-junit=3DPATH=
],<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [Specify a path to=
 the junit JAR file.]),<br>+[<br>+ =C2=A0 =C2=A0if test &quot;$withval&quot=
; !=3D &quot;no&quot;; then<br>+ =C2=A0 =C2=A0 =C2=A0if test -n &quot;$JAVA=
_CLASSPATH&quot;; then<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JAVA_CLASSPATH=3D&qu=
ot;$withval:$JAVA_CLASSPATH&quot;<br>+ =C2=A0 =C2=A0 =C2=A0else<br>+ =C2=A0=
 =C2=A0 =C2=A0 =C2=A0JAVA_CLASSPATH=3D&quot;$withval&quot;<br>+ =C2=A0 =C2=
=A0 =C2=A0fi<br>+ =C2=A0 =C2=A0 =C2=A0JAVAHL_TESTS_TARGET=3D&quot;javahl-te=
sts&quot;<br>+ =C2=A0 =C2=A0 =C2=A0JAVAHL_COMPAT_TESTS_TARGET=3D&quot;javah=
l-compat-tests&quot;<br>+ =C2=A0 =C2=A0 =C2=A0has_junit=3D&quot;yes&quot;<b=
r>+ =C2=A0 =C2=A0fi<br>+])<br><br>=C2=A0JAVAHL_OBJDIR=3D&quot;&quot;<br>=C2=
=A0INSTALL_EXTRA_JAVAHL_LIB=3D&quot;&quot;<br>@@ -1763,6 +1779,12 @@<br>=C2=
=A0JAVAHL_COMPAT_TESTS_TARGET=3D&quot;&quot;<br>=C2=A0LT_CXX_LIBADD=3D&quot=
;&quot;<br>=C2=A0if test &quot;$do_javahl_build&quot; =3D &quot;yes&quot;; =
then<br>+ =C2=A0dnl Since r1933892 junit is required to build the JavaHL bi=
ndings<br>+ =C2=A0if test &quot;$has_junit&quot; =3D &quot;no&quot;; then<b=
r>+ =C2=A0 =C2=A0AC_MSG_ERROR([--with-junit must be specified if building t=
he Java high-level<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0bindings.])<br>+ =C2=A0fi<br>+<br>=C2=A0 =C2=A0dnl Check for s=
uitable JDK<br>=C2=A0 =C2=A0if test &quot;$JDK_SUITABLE&quot; =3D &quot;no&=
quot;; then<br>=C2=A0 =C2=A0 =C2=A0AC_MSG_ERROR([Cannot compile JavaHL with=
out a suitable JDK.<br>@@ -1802,21 +1824,6 @@<br>=C2=A0AC_SUBST(JAVAHL_OBJD=
IR)<br>=C2=A0AC_SUBST(FIX_JAVAHL_LIB)<br>=C2=A0AC_SUBST(LT_CXX_LIBADD)<br>-=
<br>-AC_ARG_WITH(junit,<br>-AS_HELP_STRING([--with-junit=3DPATH],<br>- =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [Specify a path to the junit =
JAR file.]),<br>-[<br>- =C2=A0 =C2=A0if test &quot;$withval&quot; !=3D &quo=
t;no&quot;; then<br>- =C2=A0 =C2=A0 =C2=A0if test -n &quot;$JAVA_CLASSPATH&=
quot;; then<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0JAVA_CLASSPATH=3D&quot;$withval=
:$JAVA_CLASSPATH&quot;<br>- =C2=A0 =C2=A0 =C2=A0else<br>- =C2=A0 =C2=A0 =C2=
=A0 =C2=A0JAVA_CLASSPATH=3D&quot;$withval&quot;<br>- =C2=A0 =C2=A0 =C2=A0fi=
<br>- =C2=A0 =C2=A0 =C2=A0JAVAHL_TESTS_TARGET=3D&quot;javahl-tests&quot;<br=
>- =C2=A0 =C2=A0 =C2=A0JAVAHL_COMPAT_TESTS_TARGET=3D&quot;javahl-compat-tes=
ts&quot;<br>- =C2=A0 =C2=A0fi<br>-])<br>=C2=A0AC_SUBST(JAVA_CLASSPATH)<br>=
=C2=A0AC_SUBST(JAVAHL_TESTS_TARGET)<br><div><span style=3D"background-color=
:transparent">=C2=A0AC_SUBST(JAVAHL_COMPAT_TESTS_TARGET)</span></div><div>]=
]]</div><div><br></div></div></div>

--0000000000000ad1410658101ce0--