Package: plexus-compiler
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: origin-ubuntu mantic ubuntu-patch
X-Debbugs-Cc: [email protected]

Dear Maintainer,

Java 21 no longer supports release level 7. The attached patch changes auto-
adjust-language-level.patch to use release level 8 when Java 21 is used. It
still keeps 7 for the previous Java releases.

Changes:
  * d/p/auto-adjust-language-level.patch: Use release level 8 for Java 21.

Thanks for considering the patch.


-- System Information:
Debian Release: bookworm/sid
  APT prefers lunar-updates
  APT policy: (500, 'lunar-updates'), (500, 'lunar-security'), (500, 'lunar'), 
(100, 'lunar-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.2.0-24-generic (SMP w/32 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
plexus-compiler-2.12.1/debian/patches/auto-adjust-language-level.patch 
plexus-compiler-2.12.1/debian/patches/auto-adjust-language-level.patch
--- plexus-compiler-2.12.1/debian/patches/auto-adjust-language-level.patch      
2022-10-03 05:19:36.000000000 +1300
+++ plexus-compiler-2.12.1/debian/patches/auto-adjust-language-level.patch      
2023-06-30 17:01:58.000000000 +1200
@@ -3,11 +3,11 @@
 Forwarded: not-needed
 --- 
a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java
 +++ 
b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java
-@@ -208,6 +208,23 @@
+@@ -208,6 +208,29 @@
          }
      }
  
-+    private static boolean isJava21()
++    private static boolean isAtLeastJava21()
 +    {
 +        try
 +        {
@@ -21,23 +21,24 @@
 +
 +    private static String getMinRelease()
 +    {
-+        return isJava21() ? "8" : "7";
++        return isAtLeastJava21() ? "8" : "7";
++    }
++
++    private static boolean isUnsupportedRelease(String version)
++    {
++        final List<String> unsupportedLanguageLevels = 
java.util.Arrays.asList(new String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5", 
"1.6", "6", "1.7", "7" });
++        return unsupportedLanguageLevels.contains( version ) && !( 
getMinRelease().equals( version ) );
 +    }
 +
      public String[] createCommandLine( CompilerConfiguration config )
          throws CompilerException
      {
-@@ -375,10 +392,20 @@
-             args.add( "-Werror" );
-         }
- 
-+        List<String> unsupportedLanguageLevels = java.util.Arrays.asList(new 
String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5", "1.6", "6", "1.7", "7" });
-+
+@@ -378,7 +401,15 @@
          if ( !StringUtils.isEmpty( config.getReleaseVersion() ) )
          {
              args.add( "--release" );
 -            args.add( config.getReleaseVersion() );
-+            if ( unsupportedLanguageLevels.contains( 
config.getReleaseVersion() ) && 
!(getMinRelease().equals(config.getReleaseVersion()))  )
++            if ( isUnsupportedRelease( config.getReleaseVersion() ) )
 +            {
 +                System.err.println( "Use of release " + 
config.getReleaseVersion() + " is no longer supported, switching to " + 
getMinRelease() );
 +                args.add( getMinRelease() );
@@ -49,14 +50,14 @@
          }
          else
          {
-@@ -387,7 +414,13 @@
+@@ -387,7 +418,13 @@
              {
                  // Required, or it defaults to the target of your JDK (eg 1.5)
                  args.add( "-target" );
 -                args.add( "1.1" );
 +                args.add( getMinRelease() );
 +            }
-+            else if ( unsupportedLanguageLevels.contains( 
config.getTargetVersion() ) )
++            else if ( isUnsupportedRelease( config.getTargetVersion() ) )
 +            {
 +                System.err.println( "Use of target " + 
config.getTargetVersion() + " is no longer supported, switching to " + 
getMinRelease() );
 +                args.add( "-target" );
@@ -64,16 +65,16 @@
              }
              else
              {
-@@ -399,7 +432,13 @@
+@@ -399,7 +436,13 @@
              {
                  // If omitted, later JDKs complain about a 1.1 target
                  args.add( "-source" );
 -                args.add( "1.3" );
 +                args.add( getMinRelease() );
 +            }
-+            else if ( !suppressSource( config ) && 
unsupportedLanguageLevels.contains( config.getSourceVersion() ) )
++            else if ( !suppressSource( config ) && isUnsupportedRelease( 
config.getSourceVersion() ) )
 +            {
-+                System.err.println( "Use of source " + 
config.getSourceVersion() + " is no longer supported, switching to 7" );
++                System.err.println( "Use of source " + 
config.getSourceVersion() + " is no longer supported, switching to " + 
getMinRelease() );
 +                args.add( "-source" );
 +                args.add( getMinRelease() );
              }
__
This is the maintainer address of Debian's Java team
<https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-java-maintainers>.
 Please use
[email protected] for discussions and questions.

Reply via email to