Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Fix removeX callsites (4/N)
Browse files Browse the repository at this point in the history
Summary: Because of a Kotlin bug with JDK21 when using SDK 35, removeFirst() and removeLast() cause a runtime `NoSuchMethodError` when called with a MutableList, List or ArrayList. So fixing these callsites before the SDK 35 upgrade

Reviewed By: jselbo

Differential Revision: D59592734

fbshipit-source-id: 33c5a253917143c59ee9315f2f1a60c4fd88ea60
  • Loading branch information
Abel Del Pino authored and facebook-github-bot committed Jul 10, 2024
1 parent 3f50470 commit c5bc741
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class AttributeEditor(

val stack = mutableListOf<Any>(applicationRef)
while (stack.isNotEmpty()) {
val curNode = stack.removeLast()
// Workaround for a JDK21/Kotlin bug, see KT-66044
val curNode = checkNotNull(stack.removeLastOrNull())
val curDescriptor = descriptorRegister.descriptorForClassUnsafe(curNode.javaClass)
if (curDescriptor.getId(curNode) == nodeId) {
return curNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class BitmapPool(private val config: Bitmap.Config = Bitmap.Config.RGB_565) {
return if (bitmaps == null || bitmaps.isEmpty()) {
LeasedBitmap(Bitmap.createBitmap(width, height, config))
} else {
LeasedBitmap(bitmaps.removeLast())
// Workaround for a JDK21/Kotlin bug, see KT-66044
LeasedBitmap(checkNotNull(bitmaps.removeLastOrNull()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class LayoutTraversal(
val shallow = mutableSetOf<Any>()

while (stack.isNotEmpty()) {
val (node, parentId) = stack.removeLast()
// Workaround for a JDK21/Kotlin bug, see KT-66044
val (node, parentId) = checkNotNull(stack.removeLastOrNull())

try {

Expand Down

0 comments on commit c5bc741

Please sign in to comment.