From 85bada05059cae5e50e3ab20d8ea1bc9a1d26061 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 28 Aug 2018 13:00:08 +0200 Subject: [PATCH 1/3] 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. --- src/java/Class.hxx | 7 +++---- 1 file 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 + * Copyright (C) 2010-2018 Max Kellermann * * 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 @@ -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); From fbeb5eefdc43c82394ba564f743128bb1f3116c8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 28 Aug 2018 13:01:01 +0200 Subject: [PATCH 2/3] java/Class: drop unnecessary namespace spec --- src/java/Class.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/Class.hxx b/src/java/Class.hxx index 860f156b6..82111f01e 100644 --- a/src/java/Class.hxx +++ b/src/java/Class.hxx @@ -39,7 +39,7 @@ namespace Java { /** * Wrapper for a local "jclass" reference. */ - class Class : public Java::LocalRef { + class Class : public LocalRef { public: Class(JNIEnv *env, jclass cls) :LocalRef(env, cls) {} From 282859a62a4f26093c7d602dbb39a9522d255ce0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 28 Aug 2018 13:07:28 +0200 Subject: [PATCH 3/3] java/String: include cleanup --- src/java/String.cxx | 2 +- src/java/String.hxx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/java/String.cxx b/src/java/String.cxx index c2525cc20..e30344c70 100644 --- a/src/java/String.cxx +++ b/src/java/String.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Max Kellermann + * Copyright 2010-2018 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/java/String.hxx b/src/java/String.hxx index 4832a905b..725be69c4 100644 --- a/src/java/String.hxx +++ b/src/java/String.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Max Kellermann + * Copyright 2010-2018 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -34,7 +34,6 @@ #include -#include #include namespace Java {