summaryrefslogtreecommitdiff
path: root/runtime/jni/jni_internal.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jni/jni_internal.cc')
-rw-r--r--runtime/jni/jni_internal.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/jni/jni_internal.cc b/runtime/jni/jni_internal.cc
index 1dde2de741..9129d9ed41 100644
--- a/runtime/jni/jni_internal.cc
+++ b/runtime/jni/jni_internal.cc
@@ -922,6 +922,13 @@ class JNI {
if (c == nullptr) {
return nullptr;
}
+ if (UNLIKELY(!c->IsInstantiable())) {
+ soa.Self()->ThrowNewExceptionF(
+ "Ljava/lang/InstantiationException;", "Can't instantiate %s %s",
+ c->IsInterface() ? "interface" : "abstract class",
+ c->PrettyDescriptor().c_str());
+ return nullptr;
+ }
if (c->IsStringClass()) {
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
return soa.AddLocalReference<jobject>(
@@ -949,6 +956,13 @@ class JNI {
if (c == nullptr) {
return nullptr;
}
+ if (UNLIKELY(!c->IsInstantiable())) {
+ soa.Self()->ThrowNewExceptionF(
+ "Ljava/lang/InstantiationException;", "Can't instantiate %s %s",
+ c->IsInterface() ? "interface" : "abstract class",
+ c->PrettyDescriptor().c_str());
+ return nullptr;
+ }
if (c->IsStringClass()) {
// Replace calls to String.<init> with equivalent StringFactory call.
jmethodID sf_mid = jni::EncodeArtMethod<kEnableIndexIds>(
@@ -975,6 +989,13 @@ class JNI {
if (c == nullptr) {
return nullptr;
}
+ if (UNLIKELY(!c->IsInstantiable())) {
+ soa.Self()->ThrowNewExceptionF(
+ "Ljava/lang/InstantiationException;", "Can't instantiate %s %s",
+ c->IsInterface() ? "interface" : "abstract class",
+ c->PrettyDescriptor().c_str());
+ return nullptr;
+ }
if (c->IsStringClass()) {
// Replace calls to String.<init> with equivalent StringFactory call.
jmethodID sf_mid = jni::EncodeArtMethod<kEnableIndexIds>(