You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2026/05/04 02:19:20 UTC

svn commit: r1933796 - subversion/trunk/build/ac-macros

Author: brane
Date: Mon May  4 02:19:20 2026
New Revision: 1933796

Log:
Silence JavaHL compiler warnings about missing bootstrap classpath.
Use the --release option instead of -source and -target if the Java
compiler supports it.

* build/ac-macros/java.m4
  (SVN_FIND_JDK): Check the javac version and adjust flags accordingly.
   If debugging is enabled, silence warnings about the target JVM version
   8 (1.8) being deprecated.

Modified:
   subversion/trunk/build/ac-macros/java.m4

Modified: subversion/trunk/build/ac-macros/java.m4
==============================================================================
--- subversion/trunk/build/ac-macros/java.m4	Mon May  4 00:35:48 2026	(r1933795)
+++ subversion/trunk/build/ac-macros/java.m4	Mon May  4 02:19:20 2026	(r1933796)
@@ -166,12 +166,27 @@ AC_DEFUN(SVN_FIND_JDK,
     # The release for "-source" could actually be greater than that
     # of "-target", if we want to cross-compile for lesser JVMs.
     if test -z "$JAVAC_FLAGS"; then
-      JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
+      java_version=[`"$JDK/bin/javac" -version 2>&1 | $SED -e 's/^[^0-9]*//' -e 's/\.[^.]*$//'`]
+      java_major=[`echo $java_version | $SED -e 's/\.[^.]*$//'`]
+      java_minor=[`echo $java_version | $SED -e 's/^[^.]*\.//'`]
+      if test "$java_major" -eq 1 && test "$java_minor" -lt 9; then
+        JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
+      else
+        java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^[^.]*\.//'`]
+        JAVAC_FLAGS="--release $java_release"
+      fi
+
       if test "$enable_debugging" = "yes"; then
         JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
         if test -z "$JAVAC_COMPAT_FLAGS"; then
           JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
         fi
+      else
+        dnl Ignore warnings about deprecated version 8 (from --release 8)
+        JAVAC_FLAGS="-Xlint:options"
+        if test -z "$JAVAC_COMPAT_FLAGS"; then
+          JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS"
+        fi
       fi
     fi
 


Re: svn commit: r1933796 - subversion/trunk/build/ac-macros

Posted by Branko Čibej <br...@apache.org>.
On 19. 5. 26 00:53, Johan Corveleyn wrote:
> On Mon, May 4, 2026 at 4:19 AM<br...@apache.org> wrote:
>> Author: brane
>> Date: Mon May  4 02:19:20 2026
>> New Revision: 1933796
>>
>> Log:
>> Silence JavaHL compiler warnings about missing bootstrap classpath.
>> Use the --release option instead of -source and -target if the Java
>> compiler supports it.
>>
>> * build/ac-macros/java.m4
>>    (SVN_FIND_JDK): Check the javac version and adjust flags accordingly.
>>     If debugging is enabled, silence warnings about the target JVM version
>>     8 (1.8) being deprecated.
>>
>> Modified:
>>     subversion/trunk/build/ac-macros/java.m4
>>
>> Modified: subversion/trunk/build/ac-macros/java.m4
>> ==============================================================================
>> --- subversion/trunk/build/ac-macros/java.m4    Mon May  4 00:35:48 2026        (r1933795)
>> +++ subversion/trunk/build/ac-macros/java.m4    Mon May  4 02:19:20 2026        (r1933796)
>> @@ -166,12 +166,27 @@ AC_DEFUN(SVN_FIND_JDK,
>>       # The release for "-source" could actually be greater than that
>>       # of "-target", if we want to cross-compile for lesser JVMs.
>>       if test -z "$JAVAC_FLAGS"; then
>> -      JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
>> +      java_version=[`"$JDK/bin/javac" -version 2>&1 | $SED -e 's/^[^0-9]*//' -e 's/\.[^.]*$//'`]
>> +      java_major=[`echo $java_version | $SED -e 's/\.[^.]*$//'`]
>> +      java_minor=[`echo $java_version | $SED -e 's/^[^.]*\.//'`]
>> +      if test "$java_major" -eq 1 && test "$java_minor" -lt 9; then
>> +        JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
>> +      else
>> +        java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^[^.]*\.//'`]
>> +        JAVAC_FLAGS="--release $java_release"
> The sed pattern looks a bit tricky to me, it will only work as long as
> $JAVA_OLDEST_WORKING_VER is of the form 1.x, or if there would be no
> '.' at all.

Yes. This is how Java version numbers are reported by the JVM. It was 
1.X.y up to 1.10.y, then 11.x.y, 12.x.y etc. from then on. [1] The value 
of this variable is completely under our control.

>
> I see this value is only set in configure.ac:
> [[[
> # The minimum version for the JVM runtime for our Java bytecode.
> JAVA_OLDEST_WORKING_VER='1.8'
> # SVN_CHECK_JDK sets $JAVA_CLASSPATH
> SVN_CHECK_JDK($JAVA_OLDEST_WORKING_VER)
> ]]]
>
> I suppose whoever updates this someday will put '11' or '21' in there,
> and not '11.0' or somesuch, but who knows.

We know, it's our variable and the build will fail if it's not properly 
formatted. I assume that whoever changes this value — it has never 
changed since it was introduced – will have the presence of mind to test 
if the new value works.


> Maybe (only converting 1.x to x):
>      java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^1\.//'`]
> ?

That's inconsistent with how the JRE reports its version number, see above.

>> +      fi
>> +
>>         if test "$enable_debugging" = "yes"; then
>>           JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
>>           if test -z "$JAVAC_COMPAT_FLAGS"; then
>>             JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
>>           fi
>> +      else
>> +        dnl Ignore warnings about deprecated version 8 (from --release 8)
>> +        JAVAC_FLAGS="-Xlint:options"
>> +        if test -z "$JAVAC_COMPAT_FLAGS"; then
>> +          JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS"
>> +        fi
> I'm a bit confused. In the commit message you said: "If debugging is
> enabled, silence warnings about the target JVM version 8 (1.8) being
> deprecated.". But the change above is in the else branch of checking
> for $enable_debugging. Did you mean to say "If debugging is *not*
> enabled" in your commit message?

It's a psychic comment ... and a bug in the code. The current state of 
that conditional block, also proposed for backport, is:

       if test "$enable_debugging" = "yes"; then
         JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
       else
         dnl Ignore warnings about deprecated version 8 (from --release 8)
         JAVAC_FLAGS="-Xlint:-options $JAVAC_FLAGS"
       fi
       if test -z "$JAVAC_COMPAT_FLAGS"; then
         JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
       fi


The main purpose was to start using the --release 8 instead of -source 
1.8 -target 1.8 flags from JDK 9 onwards. That removed the bootclasspath 
warnings, but added warnings about release 8 being deprecated when 
compiled with a newer JDK. I accidentally reversed the meaning of the 
-Xlint:options flag in this commit but fixed it later.

> Or ... IIUC -Xlint:options does warn about problems with command line
> options. From "javac --help-lint" (with openjdk 21):
>      options              Warn about issues relating to use of command
> line options.
>
> So perhaps here you intentionally enable warnings for "options" when
> debugging is not enabled (and leave it to the recommended lint options
> + (unchecked, serial, path) if debugging is enabled)?

Options warnings are enabled by default, so they're on when configured 
with --enable-debug or in maintainer mode.

-- Brane

[1] https://en.wikipedia.org/wiki/Java_version_history

Re: svn commit: r1933796 - subversion/trunk/build/ac-macros

Posted by Branko Čibej <br...@apache.org>.
On 19. 5. 26 01:10, Johan Corveleyn wrote:
> On Tue, May 19, 2026 at 12:53 AM Johan Corveleyn<jc...@gmail.com> wrote:
>> On Mon, May 4, 2026 at 4:19 AM<br...@apache.org> wrote:
>>> Author: brane
>>> Date: Mon May  4 02:19:20 2026
>>> New Revision: 1933796
>>>
>>> Log:
>>> Silence JavaHL compiler warnings about missing bootstrap classpath.
>>> Use the --release option instead of -source and -target if the Java
>>> compiler supports it.
>>>
>>> * build/ac-macros/java.m4
>>>    (SVN_FIND_JDK): Check the javac version and adjust flags accordingly.
>>>     If debugging is enabled, silence warnings about the target JVM version
>>>     8 (1.8) being deprecated.
>>>
>>> Modified:
>>>     subversion/trunk/build/ac-macros/java.m4
>>>
>>> Modified: subversion/trunk/build/ac-macros/java.m4
>>> ==============================================================================
>>> --- subversion/trunk/build/ac-macros/java.m4    Mon May  4 00:35:48 2026        (r1933795)
>>> +++ subversion/trunk/build/ac-macros/java.m4    Mon May  4 02:19:20 2026        (r1933796)
>>> @@ -166,12 +166,27 @@ AC_DEFUN(SVN_FIND_JDK,
>>>       # The release for "-source" could actually be greater than that
>>>       # of "-target", if we want to cross-compile for lesser JVMs.
>>>       if test -z "$JAVAC_FLAGS"; then
>>> -      JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
>>> +      java_version=[`"$JDK/bin/javac" -version 2>&1 | $SED -e 's/^[^0-9]*//' -e 's/\.[^.]*$//'`]
>>> +      java_major=[`echo $java_version | $SED -e 's/\.[^.]*$//'`]
>>> +      java_minor=[`echo $java_version | $SED -e 's/^[^.]*\.//'`]
>>> +      if test "$java_major" -eq 1 && test "$java_minor" -lt 9; then
>>> +        JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
>>> +      else
>>> +        java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^[^.]*\.//'`]
>>> +        JAVAC_FLAGS="--release $java_release"
>> The sed pattern looks a bit tricky to me, it will only work as long as
>> $JAVA_OLDEST_WORKING_VER is of the form 1.x, or if there would be no
>> '.' at all.
>>
>> I see this value is only set in configure.ac:
>> [[[
>> # The minimum version for the JVM runtime for our Java bytecode.
>> JAVA_OLDEST_WORKING_VER='1.8'
>> # SVN_CHECK_JDK sets $JAVA_CLASSPATH
>> SVN_CHECK_JDK($JAVA_OLDEST_WORKING_VER)
>> ]]]
>>
>> I suppose whoever updates this someday will put '11' or '21' in there,
>> and not '11.0' or somesuch, but who knows.
>>
>> Maybe (only converting 1.x to x):
>>      java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^1\.//'`]
>> ?
>>
>>> +      fi
>>> +
>>>         if test "$enable_debugging" = "yes"; then
>>>           JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
>>>           if test -z "$JAVAC_COMPAT_FLAGS"; then
>>>             JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
>>>           fi
>>> +      else
>>> +        dnl Ignore warnings about deprecated version 8 (from --release 8)
>>> +        JAVAC_FLAGS="-Xlint:options"
>>> +        if test -z "$JAVAC_COMPAT_FLAGS"; then
>>> +          JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS"
>>> +        fi
>> I'm a bit confused. In the commit message you said: "If debugging is
>> enabled, silence warnings about the target JVM version 8 (1.8) being
>> deprecated.". But the change above is in the else branch of checking
>> for $enable_debugging. Did you mean to say "If debugging is *not*
>> enabled" in your commit message?
>>
>> Or ... IIUC -Xlint:options does warn about problems with command line
>> options. From "javac --help-lint" (with openjdk 21):
>>      options              Warn about issues relating to use of command
>> line options.
>>
>> So perhaps here you intentionally enable warnings for "options" when
>> debugging is not enabled (and leave it to the recommended lint options
>> + (unchecked, serial, path) if debugging is enabled)?
> Ah, upon further crawling through the backport proposals I saw you
> changed this some more in r1933877. After that, I think it makes more
> sense. Still, I'd like to understand whether you wanted to suppress
> this warning for debug (as your commit message of r1933796 seems to
> say) or for non-debug mode (as r1933877 seems to implement) :-).

I should probably have gone back in time and fixed the log message...

-- Brane

Re: svn commit: r1933796 - subversion/trunk/build/ac-macros

Posted by Johan Corveleyn <jc...@gmail.com>.
On Tue, May 19, 2026 at 1:10 AM Johan Corveleyn <jc...@gmail.com> wrote:
>
> On Tue, May 19, 2026 at 12:53 AM Johan Corveleyn <jc...@gmail.com> wrote:
> >
> > On Mon, May 4, 2026 at 4:19 AM <br...@apache.org> wrote:
> > >
> > > Author: brane
> > > Date: Mon May  4 02:19:20 2026
> > > New Revision: 1933796
> > >
> > > Log:
> > > Silence JavaHL compiler warnings about missing bootstrap classpath.
> > > Use the --release option instead of -source and -target if the Java
> > > compiler supports it.
> > >
> > > * build/ac-macros/java.m4
> > >   (SVN_FIND_JDK): Check the javac version and adjust flags accordingly.
> > >    If debugging is enabled, silence warnings about the target JVM version
> > >    8 (1.8) being deprecated.
> > >
> > > Modified:
> > >    subversion/trunk/build/ac-macros/java.m4
> > >
> > > Modified: subversion/trunk/build/ac-macros/java.m4
> > > ==============================================================================
> > > --- subversion/trunk/build/ac-macros/java.m4    Mon May  4 00:35:48 2026        (r1933795)
> > > +++ subversion/trunk/build/ac-macros/java.m4    Mon May  4 02:19:20 2026        (r1933796)
> > > @@ -166,12 +166,27 @@ AC_DEFUN(SVN_FIND_JDK,
> > >      # The release for "-source" could actually be greater than that
> > >      # of "-target", if we want to cross-compile for lesser JVMs.
> > >      if test -z "$JAVAC_FLAGS"; then
> > > -      JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
> > > +      java_version=[`"$JDK/bin/javac" -version 2>&1 | $SED -e 's/^[^0-9]*//' -e 's/\.[^.]*$//'`]
> > > +      java_major=[`echo $java_version | $SED -e 's/\.[^.]*$//'`]
> > > +      java_minor=[`echo $java_version | $SED -e 's/^[^.]*\.//'`]
> > > +      if test "$java_major" -eq 1 && test "$java_minor" -lt 9; then
> > > +        JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
> > > +      else
> > > +        java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^[^.]*\.//'`]
> > > +        JAVAC_FLAGS="--release $java_release"
> >
> > The sed pattern looks a bit tricky to me, it will only work as long as
> > $JAVA_OLDEST_WORKING_VER is of the form 1.x, or if there would be no
> > '.' at all.
> >
> > I see this value is only set in configure.ac:
> > [[[
> > # The minimum version for the JVM runtime for our Java bytecode.
> > JAVA_OLDEST_WORKING_VER='1.8'
> > # SVN_CHECK_JDK sets $JAVA_CLASSPATH
> > SVN_CHECK_JDK($JAVA_OLDEST_WORKING_VER)
> > ]]]
> >
> > I suppose whoever updates this someday will put '11' or '21' in there,
> > and not '11.0' or somesuch, but who knows.
> >
> > Maybe (only converting 1.x to x):
> >     java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^1\.//'`]
> > ?

Doh, you changed this in r1933892, so after that it looks perfect.
I should read all your backport proposals one after the other in the future :-).
(with that I've converted my -1 to +1 for this backport)

> >
> > > +      fi
> > > +
> > >        if test "$enable_debugging" = "yes"; then
> > >          JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
> > >          if test -z "$JAVAC_COMPAT_FLAGS"; then
> > >            JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
> > >          fi
> > > +      else
> > > +        dnl Ignore warnings about deprecated version 8 (from --release 8)
> > > +        JAVAC_FLAGS="-Xlint:options"
> > > +        if test -z "$JAVAC_COMPAT_FLAGS"; then
> > > +          JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS"
> > > +        fi
> >
> > I'm a bit confused. In the commit message you said: "If debugging is
> > enabled, silence warnings about the target JVM version 8 (1.8) being
> > deprecated.". But the change above is in the else branch of checking
> > for $enable_debugging. Did you mean to say "If debugging is *not*
> > enabled" in your commit message?
> >
> > Or ... IIUC -Xlint:options does warn about problems with command line
> > options. From "javac --help-lint" (with openjdk 21):
> >     options              Warn about issues relating to use of command
> > line options.
> >
> > So perhaps here you intentionally enable warnings for "options" when
> > debugging is not enabled (and leave it to the recommended lint options
> > + (unchecked, serial, path) if debugging is enabled)?
>
> Ah, upon further crawling through the backport proposals I saw you
> changed this some more in r1933877. After that, I think it makes more
> sense. Still, I'd like to understand whether you wanted to suppress
> this warning for debug (as your commit message of r1933796 seems to
> say) or for non-debug mode (as r1933877 seems to implement) :-).

-- 
Johan

Re: svn commit: r1933796 - subversion/trunk/build/ac-macros

Posted by Johan Corveleyn <jc...@gmail.com>.
On Tue, May 19, 2026 at 12:53 AM Johan Corveleyn <jc...@gmail.com> wrote:
>
> On Mon, May 4, 2026 at 4:19 AM <br...@apache.org> wrote:
> >
> > Author: brane
> > Date: Mon May  4 02:19:20 2026
> > New Revision: 1933796
> >
> > Log:
> > Silence JavaHL compiler warnings about missing bootstrap classpath.
> > Use the --release option instead of -source and -target if the Java
> > compiler supports it.
> >
> > * build/ac-macros/java.m4
> >   (SVN_FIND_JDK): Check the javac version and adjust flags accordingly.
> >    If debugging is enabled, silence warnings about the target JVM version
> >    8 (1.8) being deprecated.
> >
> > Modified:
> >    subversion/trunk/build/ac-macros/java.m4
> >
> > Modified: subversion/trunk/build/ac-macros/java.m4
> > ==============================================================================
> > --- subversion/trunk/build/ac-macros/java.m4    Mon May  4 00:35:48 2026        (r1933795)
> > +++ subversion/trunk/build/ac-macros/java.m4    Mon May  4 02:19:20 2026        (r1933796)
> > @@ -166,12 +166,27 @@ AC_DEFUN(SVN_FIND_JDK,
> >      # The release for "-source" could actually be greater than that
> >      # of "-target", if we want to cross-compile for lesser JVMs.
> >      if test -z "$JAVAC_FLAGS"; then
> > -      JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
> > +      java_version=[`"$JDK/bin/javac" -version 2>&1 | $SED -e 's/^[^0-9]*//' -e 's/\.[^.]*$//'`]
> > +      java_major=[`echo $java_version | $SED -e 's/\.[^.]*$//'`]
> > +      java_minor=[`echo $java_version | $SED -e 's/^[^.]*\.//'`]
> > +      if test "$java_major" -eq 1 && test "$java_minor" -lt 9; then
> > +        JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
> > +      else
> > +        java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^[^.]*\.//'`]
> > +        JAVAC_FLAGS="--release $java_release"
>
> The sed pattern looks a bit tricky to me, it will only work as long as
> $JAVA_OLDEST_WORKING_VER is of the form 1.x, or if there would be no
> '.' at all.
>
> I see this value is only set in configure.ac:
> [[[
> # The minimum version for the JVM runtime for our Java bytecode.
> JAVA_OLDEST_WORKING_VER='1.8'
> # SVN_CHECK_JDK sets $JAVA_CLASSPATH
> SVN_CHECK_JDK($JAVA_OLDEST_WORKING_VER)
> ]]]
>
> I suppose whoever updates this someday will put '11' or '21' in there,
> and not '11.0' or somesuch, but who knows.
>
> Maybe (only converting 1.x to x):
>     java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^1\.//'`]
> ?
>
> > +      fi
> > +
> >        if test "$enable_debugging" = "yes"; then
> >          JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
> >          if test -z "$JAVAC_COMPAT_FLAGS"; then
> >            JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
> >          fi
> > +      else
> > +        dnl Ignore warnings about deprecated version 8 (from --release 8)
> > +        JAVAC_FLAGS="-Xlint:options"
> > +        if test -z "$JAVAC_COMPAT_FLAGS"; then
> > +          JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS"
> > +        fi
>
> I'm a bit confused. In the commit message you said: "If debugging is
> enabled, silence warnings about the target JVM version 8 (1.8) being
> deprecated.". But the change above is in the else branch of checking
> for $enable_debugging. Did you mean to say "If debugging is *not*
> enabled" in your commit message?
>
> Or ... IIUC -Xlint:options does warn about problems with command line
> options. From "javac --help-lint" (with openjdk 21):
>     options              Warn about issues relating to use of command
> line options.
>
> So perhaps here you intentionally enable warnings for "options" when
> debugging is not enabled (and leave it to the recommended lint options
> + (unchecked, serial, path) if debugging is enabled)?

Ah, upon further crawling through the backport proposals I saw you
changed this some more in r1933877. After that, I think it makes more
sense. Still, I'd like to understand whether you wanted to suppress
this warning for debug (as your commit message of r1933796 seems to
say) or for non-debug mode (as r1933877 seems to implement) :-).

-- 
Johan

Re: svn commit: r1933796 - subversion/trunk/build/ac-macros

Posted by Johan Corveleyn <jc...@gmail.com>.
On Mon, May 4, 2026 at 4:19 AM <br...@apache.org> wrote:
>
> Author: brane
> Date: Mon May  4 02:19:20 2026
> New Revision: 1933796
>
> Log:
> Silence JavaHL compiler warnings about missing bootstrap classpath.
> Use the --release option instead of -source and -target if the Java
> compiler supports it.
>
> * build/ac-macros/java.m4
>   (SVN_FIND_JDK): Check the javac version and adjust flags accordingly.
>    If debugging is enabled, silence warnings about the target JVM version
>    8 (1.8) being deprecated.
>
> Modified:
>    subversion/trunk/build/ac-macros/java.m4
>
> Modified: subversion/trunk/build/ac-macros/java.m4
> ==============================================================================
> --- subversion/trunk/build/ac-macros/java.m4    Mon May  4 00:35:48 2026        (r1933795)
> +++ subversion/trunk/build/ac-macros/java.m4    Mon May  4 02:19:20 2026        (r1933796)
> @@ -166,12 +166,27 @@ AC_DEFUN(SVN_FIND_JDK,
>      # The release for "-source" could actually be greater than that
>      # of "-target", if we want to cross-compile for lesser JVMs.
>      if test -z "$JAVAC_FLAGS"; then
> -      JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
> +      java_version=[`"$JDK/bin/javac" -version 2>&1 | $SED -e 's/^[^0-9]*//' -e 's/\.[^.]*$//'`]
> +      java_major=[`echo $java_version | $SED -e 's/\.[^.]*$//'`]
> +      java_minor=[`echo $java_version | $SED -e 's/^[^.]*\.//'`]
> +      if test "$java_major" -eq 1 && test "$java_minor" -lt 9; then
> +        JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.8"
> +      else
> +        java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^[^.]*\.//'`]
> +        JAVAC_FLAGS="--release $java_release"

The sed pattern looks a bit tricky to me, it will only work as long as
$JAVA_OLDEST_WORKING_VER is of the form 1.x, or if there would be no
'.' at all.

I see this value is only set in configure.ac:
[[[
# The minimum version for the JVM runtime for our Java bytecode.
JAVA_OLDEST_WORKING_VER='1.8'
# SVN_CHECK_JDK sets $JAVA_CLASSPATH
SVN_CHECK_JDK($JAVA_OLDEST_WORKING_VER)
]]]

I suppose whoever updates this someday will put '11' or '21' in there,
and not '11.0' or somesuch, but who knows.

Maybe (only converting 1.x to x):
    java_release=[`echo $JAVA_OLDEST_WORKING_VER | $SED -e 's/^1\.//'`]
?

> +      fi
> +
>        if test "$enable_debugging" = "yes"; then
>          JAVAC_FLAGS="-g -Xlint -Xlint:unchecked -Xlint:serial -Xlint:path $JAVAC_FLAGS"
>          if test -z "$JAVAC_COMPAT_FLAGS"; then
>            JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS -Xlint:-unchecked -Xlint:-deprecation -Xlint:-dep-ann -Xlint:-rawtypes"
>          fi
> +      else
> +        dnl Ignore warnings about deprecated version 8 (from --release 8)
> +        JAVAC_FLAGS="-Xlint:options"
> +        if test -z "$JAVAC_COMPAT_FLAGS"; then
> +          JAVAC_COMPAT_FLAGS="$JAVAC_FLAGS"
> +        fi

I'm a bit confused. In the commit message you said: "If debugging is
enabled, silence warnings about the target JVM version 8 (1.8) being
deprecated.". But the change above is in the else branch of checking
for $enable_debugging. Did you mean to say "If debugging is *not*
enabled" in your commit message?

Or ... IIUC -Xlint:options does warn about problems with command line
options. From "javac --help-lint" (with openjdk 21):
    options              Warn about issues relating to use of command
line options.

So perhaps here you intentionally enable warnings for "options" when
debugging is not enabled (and leave it to the recommended lint options
+ (unchecked, serial, path) if debugging is enabled)?

-- 
Johan