File: 0018-bytebuffer-backward-compatibility.patch

package info (click to toggle)
scala 2.11.12-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 62,828 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,250; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (58 lines) | stat: -rw-r--r-- 2,435 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: Preserves the compatibility with Java 8 when compiling with Java 11
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/src/compiler/scala/tools/nsc/io/SourceReader.scala
+++ b/src/compiler/scala/tools/nsc/io/SourceReader.scala
@@ -8,7 +8,7 @@
 package io
 
 import java.io.{ FileInputStream, InputStream, IOException }
-import java.nio.{ByteBuffer, CharBuffer}
+import java.nio.{Buffer, ByteBuffer, CharBuffer}
 import java.nio.channels.{ ReadableByteChannel, Channels }
 import java.nio.charset.{CharsetDecoder, CoderResult}
 import scala.tools.nsc.reporters._
@@ -58,13 +58,13 @@
   /** Reads the specified byte channel. */
   protected def read(input: ReadableByteChannel): Array[Char] = {
     val decoder: CharsetDecoder = this.decoder.reset()
-    val bytes: ByteBuffer       = this.bytes; bytes.clear()
-    var chars: CharBuffer       = this.chars; chars.clear()
+    val bytes: ByteBuffer       = this.bytes; bytes.asInstanceOf[Buffer].clear().asInstanceOf[ByteBuffer]
+    var chars: CharBuffer       = this.chars; chars.asInstanceOf[Buffer].clear().asInstanceOf[CharBuffer]
     var endOfInput              = false
 
     while (!endOfInput ) {
       endOfInput = input.read(bytes) < 0
-      bytes.flip()
+      bytes.asInstanceOf[Buffer].flip()
       chars = decode(decoder, bytes, chars, endOfInput)
     }
     terminate(flush(decoder, chars))
@@ -73,7 +73,7 @@
   /** Reads the specified byte buffer. */
   protected def read(bytes: ByteBuffer): Array[Char] = {
     val decoder: CharsetDecoder = this.decoder.reset()
-    val chars: CharBuffer = this.chars; chars.clear()
+    val chars: CharBuffer = this.chars; chars.asInstanceOf[Buffer].clear().asInstanceOf[CharBuffer]
     terminate(flush(decoder, decode(decoder, bytes, chars, endOfInput = true)))
   }
 
@@ -125,7 +125,7 @@
   def flush(decoder: CharsetDecoder, chars: CharBuffer): CharBuffer = {
     val result: CoderResult = decoder.flush(chars)
     if (result.isUnderflow()) {
-      chars.flip()
+      chars.asInstanceOf[Buffer].flip()
       chars
     } else {
       if (result.isError()) throw new IOException(result.toString())
@@ -139,7 +139,7 @@
    * content but with an increased capacity.
    */
   private def increaseCapacity(buffer: CharBuffer): CharBuffer = {
-    buffer.flip()
+    buffer.asInstanceOf[Buffer].flip()
     val capacity = 2 * buffer.capacity()
     CharBuffer.allocate(capacity).put(buffer)
   }