Use findClassStatic instead of findClassLocal

Summary: We are saving the class reference in a static variable to should be using findClassStatic to ensure the reference is always valid.

Reviewed By: mhorowitz

Differential Revision: D4420352

fbshipit-source-id: 8c66c1b2213fe295334a9bdc4e1dd7e1a4285aae
This commit is contained in:
Emil Sjolander
2017-01-24 15:45:26 -08:00
committed by Facebook Github Bot
parent ab28ecf31b
commit d391323129

View File

@@ -75,7 +75,8 @@ static void YGPrint(YGNodeRef node) {
static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) { static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) {
if (auto obj = YGNodeJobject(node)->lockLocal()) { if (auto obj = YGNodeJobject(node)->lockLocal()) {
return findClassLocal("com/facebook/yoga/YogaNode")->getMethod<jfloat(jfloat, jfloat)>("baseline")(obj, width, height); static auto baselineFunc = findClassStatic("com/facebook/yoga/YogaNode")->getMethod<jfloat(jfloat, jfloat)>("baseline");
return baselineFunc(obj, width, height);
} else { } else {
return height; return height;
} }
@@ -87,7 +88,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
if (auto obj = YGNodeJobject(node)->lockLocal()) { if (auto obj = YGNodeJobject(node)->lockLocal()) {
static auto measureFunc = findClassLocal("com/facebook/yoga/YogaNode") static auto measureFunc = findClassStatic("com/facebook/yoga/YogaNode")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure"); ->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
YGTransferLayoutDirection(node, obj); YGTransferLayoutDirection(node, obj);
@@ -121,7 +122,7 @@ static int YGLog(YGLogLevel level, const char *format, va_list args) {
char buffer[256]; char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args); int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = findClassLocal("com/facebook/yoga/YogaLogger") static auto logFunc = findClassStatic("com/facebook/yoga/YogaLogger")
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log"); ->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt = static auto logLevelFromInt =