diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-28 13:00:08 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-28 13:00:08 +0200 |
commit | 85bada05059cae5e50e3ab20d8ea1bc9a1d26061 (patch) | |
tree | 771fbbdc0b2646c903fd1f74b771b045fcc7d363 /src/java | |
parent | cf9613512515956bfca699ee23529ec9e459551a (diff) |
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.
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/Class.hxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/java/Class.hxx b/src/java/Class.hxx index 44425d1b7..860f156b6 100644 --- a/src/java/Class.hxx +++ b/src/java/Class.hxx @@ -1,5 +1,5 @@ /* - * 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); |