Skip to content

Commit 4636413

Browse files
authored
Merge pull request scala-js#3231 from sjrd/remove-jdk8-bridge-hacks
Remove hacks to build on older JDKs.
2 parents 98d3b4e + f6fb820 commit 4636413

File tree

9 files changed

+18
-192
lines changed

9 files changed

+18
-192
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package java.lang
2+
3+
trait AutoCloseable {
4+
def close(): Unit
5+
}

javalanglib/src/main/scala/java/lang/MathJDK8Bridge.scala

-81
This file was deleted.

javalib/src/main/scala/java/lang/AutoCloseable.scala

-11
This file was deleted.

javalib/src/main/scala/java/lang/MathJDK8Bridge.scala

-74
This file was deleted.

javalib/src/main/scala/java/math/Conversion.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private[math] object Conversion {
159159
if (sign == 0) {
160160
"0"
161161
} else if (numberLength == 1) {
162-
val absStr = MathJDK8Bridge.toUnsignedString(digits(0))
162+
val absStr = Integer.toUnsignedString(digits(0))
163163
if (sign < 0) "-" + absStr
164164
else absStr
165165
} else {
@@ -175,7 +175,7 @@ private[math] object Conversion {
175175
var i: Int = tempLen - 1
176176
while (i >= 0) {
177177
val temp1 = (rem.toLong << 32) + (temp(i) & 0xFFFFFFFFL)
178-
val quot = MathJDK8Bridge.divideUnsigned(temp1, 1000000000L).toInt
178+
val quot = java.lang.Long.divideUnsigned(temp1, 1000000000L).toInt
179179
temp(i) = quot
180180
rem = (temp1 - quot * 1000000000L).toInt
181181
i -= 1

javalib/src/main/scala/java/math/Division.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private[math] object Division {
110110
((normA(j) & UINT_MAX) << 32) + (normA(j - 1) & UINT_MAX)
111111
val firstDivisorDigitLong = firstDivisorDigit & UINT_MAX
112112
val quotient =
113-
MathJDK8Bridge.divideUnsigned(product, firstDivisorDigitLong)
113+
java.lang.Long.divideUnsigned(product, firstDivisorDigitLong)
114114
guessDigit = quotient.toInt
115115
var rem = (product - quotient * firstDivisorDigitLong).toInt
116116

@@ -190,8 +190,8 @@ private[math] object Division {
190190
val valSign = bi.sign
191191
if (valLen == 1) {
192192
val valDigit = valDigits(0)
193-
var quo = MathJDK8Bridge.divideUnsigned(valDigit, divisor) & UINT_MAX
194-
var rem = MathJDK8Bridge.remainderUnsigned(valDigit, divisor) & UINT_MAX
193+
var quo = Integer.divideUnsigned(valDigit, divisor) & UINT_MAX
194+
var rem = Integer.remainderUnsigned(valDigit, divisor) & UINT_MAX
195195
if (valSign != divisorSign)
196196
quo = -quo
197197
if (valSign < 0)
@@ -229,7 +229,7 @@ private[math] object Division {
229229
var i = srcLength - 1
230230
while (i >= 0) {
231231
val temp: Long = (rem.toLong << 32) | (src(i) & UINT_MAX)
232-
val quot = MathJDK8Bridge.divideUnsigned(temp, bLong)
232+
val quot = java.lang.Long.divideUnsigned(temp, bLong)
233233
rem = (temp - quot * bLong).toInt
234234
dest(i) = quot.toInt
235235
i -= 1
@@ -743,7 +743,7 @@ private[math] object Division {
743743
var i = srcLength - 1
744744
while (i >= 0) {
745745
val temp = (result.toLong << 32) | (src(i).toLong & UINT_MAX)
746-
result = MathJDK8Bridge.remainderUnsigned(temp, longDivisor).toInt
746+
result = java.lang.Long.remainderUnsigned(temp, longDivisor).toInt
747747
i -= 1
748748
}
749749
result

junit-runtime/src/main/scala/org/junit/internal/ArrayComparisonFailure.scala

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ package org.junit.internal
55

66
object ArrayComparisonFailure
77

8-
/* Attention: AssertionError does not have a (String, Throwable) constructor
9-
* in JDK 6. If we try to call that one, compilation *succeeds* because of
10-
* auto-boxing, but it does not do the right thing. See #3154.
11-
*/
128
class ArrayComparisonFailure(message: String, cause: AssertionError, index: Int)
13-
extends AssertionError(message) {
14-
15-
initCause(cause)
9+
extends AssertionError(message, cause) {
1610

1711
private var fIndices: List[Int] = index :: Nil
1812

@@ -29,7 +23,7 @@ class ArrayComparisonFailure(message: String, cause: AssertionError, index: Int)
2923
val indices =
3024
if (fIndices == null) s"[$index]" // see #3148
3125
else fIndices.map(index => s"[$index]").mkString
32-
val causeMessage = cause.getMessage // do not use getCause(), see #3148
26+
val causeMessage = getCause.getMessage
3327
s"${msg}arrays first differed at element $indices; $causeMessage"
3428
}
3529

library/src/main/scala/scala/scalajs/runtime/RuntimeLong.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,7 @@ object RuntimeLong {
724724
if (isUInt32(ahi)) {
725725
if (isUInt32(bhi)) {
726726
hiReturn = 0
727-
// Integer.divideUnsigned(alo, blo), inaccessible when compiling on JDK < 8
728-
rawToInt(alo.toUint / blo.toUint)
727+
Integer.divideUnsigned(alo, blo)
729728
} else {
730729
// a < b
731730
hiReturn = 0
@@ -819,8 +818,7 @@ object RuntimeLong {
819818
if (isUInt32(ahi)) {
820819
if (isUInt32(bhi)) {
821820
hiReturn = 0
822-
// Integer.remainderUnsigned(alo, blo), inaccessible when compiling on JDK < 8
823-
rawToInt(alo.toUint % blo.toUint)
821+
Integer.remainderUnsigned(alo, blo)
824822
} else {
825823
// a < b
826824
hiReturn = ahi

project/Build.scala

+2-7
Original file line numberDiff line numberDiff line change
@@ -1105,20 +1105,15 @@ object Build {
11051105

11061106
val filter = ("*.sjsir": NameFilter)
11071107

1108-
val javalibProducts = (products in LocalProject("javalib")).value
1109-
val javalibMappings =
1110-
javalibProducts.flatMap(base => Path.selectSubpaths(base, filter))
1111-
val javalibFilteredMappings = javalibMappings.filter(
1112-
_._2.replace('\\', '/') != "java/lang/MathJDK8Bridge$.sjsir")
1113-
11141108
val otherProducts = (
11151109
(products in LocalProject("javalanglib")).value ++
1110+
(products in LocalProject("javalib")).value ++
11161111
(products in LocalProject("scalalib")).value ++
11171112
(products in LocalProject("libraryAux")).value)
11181113
val otherMappings =
11191114
otherProducts.flatMap(base => Path.selectSubpaths(base, filter))
11201115

1121-
libraryMappings ++ otherMappings ++ javalibFilteredMappings
1116+
libraryMappings ++ otherMappings
11221117
}
11231118
))
11241119
).withScalaJSCompiler

0 commit comments

Comments
 (0)