Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 22 | using namespace art; |
| 23 | using namespace art::greenland; |
| 24 | |
| 25 | namespace { |
| 26 | |
| 27 | void 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 | |
| 49 | namespace art { |
| 50 | namespace greenland { |
| 51 | |
| 52 | void InitCastRuntimes(RuntimeEntryPoints* entry_points) { |
| 53 | entry_points->CheckPutArrayElement = art_check_put_array_element_from_code; |
| 54 | } |
| 55 | |
| 56 | } // namespace greenland |
| 57 | } // namespace art |