mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
instance of checks for YogaNodeJniBase
Summary:
Changelog:
[Internal][Yoga] - Added instance of checks in `YogaNodeJNIBase` class to prevent `ClassCastException`s. This was happening for some NT android tests - Mocked Yoga Node object was being passed in the `addChildAt` api
Stack Trace of exception
java.lang.ClassCastException: com.facebook.yoga.YogaNode$MockitoMock$1408896622 cannot be cast to com.facebook.yoga.YogaNodeJNIBase
at com.facebook.yoga.YogaNodeJNIBase.addChildAt(YogaNodeJNIBase.java:86)
at com.facebook.litho.DefaultInternalNode.addChildAt(DefaultInternalNode.java:220)
at com.facebook.litho.DefaultInternalNode.child(DefaultInternalNode.java:377)
at com.facebook.litho.DefaultInternalNode.child(DefaultInternalNode.java:360)
at com.facebook.litho.Column.resolve(Column.java:118)
at com.facebook.litho.Layout.create(Layout.java:172)
Reviewed By: Andrey-Mishanin
Differential Revision: D26114992
fbshipit-source-id: 774a689609e67f9244b81c6788b62cd61cd96d14
This commit is contained in:
committed by
Facebook GitHub Bot
parent
95cab24a6e
commit
96bc33a1d7
@@ -83,6 +83,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
|
||||
public void addChildAt(YogaNode c, int i) {
|
||||
if (!(c instanceof YogaNodeJNIBase)) {
|
||||
return;
|
||||
}
|
||||
YogaNodeJNIBase child = (YogaNodeJNIBase) c;
|
||||
if (child.mOwner != null) {
|
||||
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
||||
@@ -105,6 +108,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
|
||||
public void swapChildAt(YogaNode newChild, int position) {
|
||||
if (!(newChild instanceof YogaNodeJNIBase)) {
|
||||
return;
|
||||
}
|
||||
YogaNodeJNIBase child = (YogaNodeJNIBase) newChild;
|
||||
mChildren.remove(position);
|
||||
mChildren.add(position, child);
|
||||
@@ -223,6 +229,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
@Override
|
||||
public void copyStyle(YogaNode srcNode) {
|
||||
if (!(srcNode instanceof YogaNodeJNIBase)) {
|
||||
return;
|
||||
}
|
||||
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user