[Git][java-team/scala][master] Fixed the build failure with OpenJDK 17 (Closes: #981951)

Emmanuel Bourg gitlab at salsa.debian.org
Sat Apr 17 23:34:34 BST 2021



Emmanuel Bourg pushed to branch master at Debian Java Maintainers / scala


Commits:
6e34d072 by Emmanuel Bourg at 2021-04-18T00:34:16+02:00
Fixed the build failure with OpenJDK 17 (Closes: #981951)

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/0019-java17-compatibility.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+scala (2.11.12-5) unstable; urgency=medium
+
+  * Team upload.
+  * Fixed the build failure with OpenJDK 17 (Closes: #981951)
+
+ -- Emmanuel Bourg <ebourg at apache.org>  Sun, 18 Apr 2021 00:34:04 +0200
+
 scala (2.11.12-4) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/patches/0019-java17-compatibility.patch
=====================================
@@ -0,0 +1,205 @@
+Description: Fixes the compatibility with OpenJDK 17
+Author: Emmanuel Bourg <ebourg at apache.org>
+Bug: https://github.com/scala/bug/issues/12172
+--- a/src/library/scala/collection/mutable/StringBuilder.scala
++++ b/src/library/scala/collection/mutable/StringBuilder.scala
+@@ -400,6 +400,14 @@
+    */
+   def lastIndexOf(str: String, fromIndex: Int): Int = underlying.lastIndexOf(str, fromIndex)
+ 
++  /** Tests whether this builder is empty.
++   *
++   *  This method is required for JDK15+ compatibility
++   *
++   *  @return  `true` if this builder contains nothing, `false` otherwise.
++   */
++  override def isEmpty: Boolean = underlying.length() == 0
++
+   /** Creates a new StringBuilder with the reversed contents of this one.
+    *  If surrogate pairs are present, they are treated as indivisible units: each
+    *  pair will appear in the same order in the updated sequence.
+--- a/src/compiler/scala/tools/ant/Pack200Task.scala
++++ /dev/null
+@@ -1,173 +0,0 @@
+-/*                     __                                               *\
+-**     ________ ___   / /  ___     Scala Ant Tasks                      **
+-**    / __/ __// _ | / /  / _ |    (c) 2005-2013, LAMP/EPFL             **
+-**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
+-** /____/\___/_/ |_/____/_/ | |                                         **
+-**                          |/                                          **
+-\*                                                                      */
+-
+-package scala.tools.ant
+-
+-import java.io.{BufferedOutputStream, File, FileInputStream,
+-       FileOutputStream, PipedInputStream, PipedOutputStream}
+-import java.util.jar.{JarFile, JarInputStream, JarOutputStream, Pack200}
+-import java.util.jar.Pack200.Packer._
+-
+-import org.apache.tools.ant.{BuildException, DirectoryScanner}
+-import org.apache.tools.ant.types.FileSet
+-
+-/** An [[http://ant.apache.org Ant]] task that applies the pack200 encoding
+- *  to a JAR file.
+- *
+- *  - `destdir` (mandatory),
+- *  - `dir` (defaults to project's basedir),
+- *  - `effort` (default 9),
+- *  - `keepFileOrder` (default `'''false'''`),
+- *  - `keepModificationTime` (default `'''false'''`),
+- *  - `repack` (default false),
+- *  - `segmentLimit` (default `-1` for no limit),
+- *  - `suffix` (default ".pack")
+- *
+- * @author  James Matlik
+- */
+-class Pack200Task extends ScalaMatchingTask {
+-
+-/*============================================================================*\
+-**                             Ant user-properties                            **
+-\*============================================================================*/
+-
+-  var destdir: Option[File] = None
+-  var srcdir: Option[File] = None
+-
+-  var effort = 9
+-  var keepFileOrder = false
+-  var keepModificationTime = false
+-  var repack = false
+-  var segmentLimit = -1
+-
+-  var packFileSuffix = ".pack"
+-
+-
+-/*============================================================================*\
+-**                             Properties setters                             **
+-\*============================================================================*/
+-
+-  def setDir(dir: File) {
+-    if (dir.exists && dir.isDirectory) srcdir = Some(dir)
+-    else buildError("Please specify a valid directory with Jar files for packing.")
+-  }
+-
+-  /** A level from 0 (none) to 9 (max) of effort for applying Pack200 */
+-  def setEffort(x: Int) {
+-    if (effort < 10 && effort > -1) effort = x
+-    else buildError("The effort level must be a value from 0 to 9")
+-  }
+-
+-  /** Set the flag to specify if file reordering should be performed. Reordering
+-    * is used to remove empty packages and improve pack200 optimization.
+-    * @param x
+-    *         `'''true'''` to retain file ordering.
+-    *         `'''false'''` to optimize directory structure (DEFAULT).  */
+-  def setKeepFileOrder(x: Boolean) { keepFileOrder = x }
+-
+-  /** If false, a single modification time is used for all contained files */
+-  def setKeepModificationTime(x: Boolean) { keepModificationTime = x }
+-
+-  /** A flag that tells the task to pack and then unpack the source JAR file
+-    * into another JAR file.  This resulting JAR file can then be signed,
+-    * packed again, compressed and distributed for securely distributed code.
+-    */
+-  def setRepack(r: Boolean) { repack = r }
+-
+-
+-  def setSegmentLimit(size: Int) { segmentLimit = size }
+-
+-  /** Set the output directory */
+-  def setDestdir(file: File) {
+-    if (file != null && file.exists && file.isDirectory) destdir = Some(file)
+-    else buildError("The destination directory is invalid: " + file.getAbsolutePath)
+-  }
+-
+-  def setSuffix(s: String) { packFileSuffix = s }
+-
+-/*============================================================================*\
+-**                             Properties getters                             **
+-\*============================================================================*/
+-
+-  /** Gets the list of individual JAR files for processing.
+-    * @return The list of JAR files */
+-  private def getFileList: List[File] = {
+-    var files: List[File] = Nil
+-    val fs = getImplicitFileSet
+-    val ds = fs.getDirectoryScanner(getProject())
+-    val dir = fs.getDir(getProject())
+-    for (filename <- ds.getIncludedFiles()
+-         if filename.toLowerCase.endsWith(".jar")) {
+-      val file = new File(dir, filename)
+-      if(files.exists(file.equals(_)) == false) files = file :: files
+-    }
+-    files.reverse
+-  }
+-
+-/*============================================================================*\
+-**                       Compilation and support methods                      **
+-\*============================================================================*/
+-
+-  private def makeJarOutputStream(file: File) =
+-    new JarOutputStream(makeOutputStream(file))
+-
+-  private def makeOutputStream(file: File) =
+-    new BufferedOutputStream(new FileOutputStream(file))
+-
+-/*============================================================================*\
+-**                           The big execute method                           **
+-\*============================================================================*/
+-
+-  /** Performs the tool creation. */
+-  override def execute() = {
+-    // Audits
+-    val packDir = destdir.getOrElse(buildError("No output directory specified"))
+-
+-    // Setup the inherited fileset for further processing
+-    fileset.setDir(srcdir.getOrElse(getProject.getBaseDir))
+-
+-    val files = getFileList
+-    if (files.isEmpty) buildError("No JAR files were selected for packing.")
+-
+-    // Setup the packer
+-    val packer = Pack200.newPacker
+-    val p = packer.properties
+-    p.put(EFFORT, effort.toString)
+-    p.put(SEGMENT_LIMIT, segmentLimit.toString)
+-    p.put(KEEP_FILE_ORDER, if(keepFileOrder) TRUE else FALSE)
+-    p.put(MODIFICATION_TIME, if(keepModificationTime) LATEST else KEEP)
+-
+-    for (file <- files) {
+-      if (repack) {
+-        val repackedFile = new File(packDir, file.getName)
+-        if (file.lastModified > repackedFile.lastModified) {
+-          println("Repacking " + file.toString + " to " + repackedFile.toString)
+-          val tmpFile = new File(packDir, file.getName + ".tmp")
+-          val os = makeOutputStream(tmpFile)
+-          packer.pack(new JarFile(file), os)
+-          os.close()
+-          val jos = makeJarOutputStream(repackedFile)
+-          Pack200.newUnpacker.unpack(tmpFile, jos)
+-          jos.close()
+-          tmpFile.delete()
+-        }
+-      }
+-      else {
+-        val packFile: File = {
+-          val name = file.getName.substring(0, file.getName.lastIndexOf("."))
+-          new File(packDir, name + packFileSuffix)
+-        }
+-        if(file.lastModified > packFile.lastModified) {
+-          println("Packing " + file.toString + " to " + packFile.toString)
+-          val os = makeOutputStream(packFile)
+-          packer.pack(new JarFile(file), os)
+-        }
+-      }
+-    }
+-  }
+-}
+--- a/src/compiler/scala/tools/ant/antlib.xml
++++ b/src/compiler/scala/tools/ant/antlib.xml
+@@ -11,6 +11,4 @@
+              classname="scala.tools.ant.Scaladoc"/>
+     <taskdef name="scalatool"
+              classname="scala.tools.ant.ScalaTool"/>
+-    <taskdef name="pack200"
+-             classname="scala.tools.ant.Pack200Task"/>
+ </antlib>


=====================================
debian/patches/series
=====================================
@@ -10,3 +10,4 @@
 0016-nobootcp-by-default.patch
 0017-bug912393.patch
 0018-bytebuffer-backward-compatibility.patch
+0019-java17-compatibility.patch



View it on GitLab: https://salsa.debian.org/java-team/scala/-/commit/6e34d072e4fb76b7d6f52ebaad484b5dcaecfe95

-- 
View it on GitLab: https://salsa.debian.org/java-team/scala/-/commit/6e34d072e4fb76b7d6f52ebaad484b5dcaecfe95
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210417/f56dd28e/attachment.htm>


More information about the pkg-java-commits mailing list