*slow_path = true;
return nullptr; // Failure
}
+ if (UNLIKELY(klass->IsClassClass())) {
+ ThrowIllegalAccessError(nullptr, "Class %s is inaccessible", PrettyDescriptor(klass).c_str());
+ *slow_path = true;
+ return nullptr; // Failure
+ }
mirror::Class* referrer = method->GetDeclaringClass();
if (UNLIKELY(!referrer->CanAccess(klass))) {
ThrowIllegalAccessErrorClass(referrer, klass);
if (descriptor[0] != 'L') {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "can't call new-instance on type '" << descriptor << "'";
return false;
+ } else if (strcmp(descriptor, "Ljava/lang/Class;") == 0) {
+ // An unlikely new instance on Class is not allowed. Fall back to interpreter to ensure an
+ // exception is thrown when this statement is executed (compiled code would not do that).
+ Fail(VERIFY_ERROR_INSTANTIATION);
}
return true;
}
later on
(E) b/29068831:
access validation on method should occur prior to null reference check
+(F) b/29758098:
+ new-instance of java.lang.Class should throw an IllegalAccessError to
+ avoid interpreter crash on zero size object later
--- /dev/null
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+.class public LF;
+.super Ljava/lang/Object;
+
+.method public constructor <init>()V
+.registers 2
+ invoke-direct {v1}, Ljava/lang/Object;-><init>()V
+ new-instance v0, Ljava/lang/Class;
+ return-void
+.end method