Commit 85bada05 authored by Max Kellermann's avatar Max Kellermann

java/Class: use DiscardException() in FindOptional()

Sometimes, the JVM returns a non-nullptr value with an exception pending (seen on Android 1.6, maybe a Dalvik bug?). Let's catch all such cases.
parent cf961351
/*
* Copyright (C) 2010-2011 Max Kellermann <max.kellermann@gmail.com>
* Copyright (C) 2010-2018 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -31,6 +31,7 @@
#define JAVA_CLASS_HXX
#include "Ref.hxx"
#include "Exception.hxx"
#include <assert.h>
......@@ -68,10 +69,8 @@ namespace Java {
assert(name != nullptr);
jclass cls = env->FindClass(name);
if (cls == nullptr) {
env->ExceptionClear();
if (DiscardException(env))
return false;
}
Set(env, cls);
env->DeleteLocalRef(cls);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment