blob: d74dbe714d7dbabcba38a66df3c1f7ab5509310f [file] [log] [blame]
Shih-wei Liao21d28f52012-06-12 05:55:00 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "greenland/runtime_entry_points.h"
18
19#include "runtime_utils.h"
20#include "runtime_support.h"
21
22using namespace art;
23using namespace art::greenland;
24
25namespace {
26
27void art_check_put_array_element_from_code(const Object* element,
28 const Object* array) {
29 if (element == NULL) {
30 return;
31 }
32 DCHECK(array != NULL);
33 Class* array_class = array->GetClass();
34 DCHECK(array_class != NULL);
35 Class* component_type = array_class->GetComponentType();
36 Class* element_class = element->GetClass();
37 if (UNLIKELY(!component_type->IsAssignableFrom(element_class))) {
38 Thread* thread = art_get_current_thread();
39 thread->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
40 "%s cannot be stored in an array of type %s",
41 PrettyDescriptor(element_class).c_str(),
42 PrettyDescriptor(array_class).c_str());
43 }
44 return;
45}
46
47} // anonymous namespace
48
49namespace art {
50namespace greenland {
51
52void InitCastRuntimes(RuntimeEntryPoints* entry_points) {
53 entry_points->CheckPutArrayElement = art_check_put_array_element_from_code;
54}
55
56} // namespace greenland
57} // namespace art