blob: 08a8d625674c62bae26698108be74fc1d88ca288 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
2 * Copyright (C) 2011 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#ifndef ART_SRC_MIRROR_OBJECT_ARRAY_H_
18#define ART_SRC_MIRROR_OBJECT_ARRAY_H_
19
20#include "array.h"
21
22namespace art {
23namespace mirror {
24
25template<class T>
26class MANAGED ObjectArray : public Array {
27 public:
28 static ObjectArray<T>* Alloc(Thread* self, Class* object_array_class, int32_t length)
29 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
30
31 T* Get(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
32
Sebastien Hertz6bdd8f42013-05-17 14:44:01 +020033 // Returns true if the object can be stored into the array. If not, throws
34 // an ArrayStoreException and returns false.
35 bool CheckAssignable(T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
36
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037 void Set(int32_t i, T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
38
39 // Set element without bound and element type checks, to be used in limited
40 // circumstances, such as during boot image writing
41 void SetWithoutChecks(int32_t i, T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
42
43 // Set element without bound and element type checks, to be used in limited circumstances, such
44 // as during boot image writing. Does not do write barrier.
45 void SetPtrWithoutChecks(int32_t i, T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
46
47 T* GetWithoutChecks(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
48
49 static void Copy(const ObjectArray<T>* src, int src_pos,
50 ObjectArray<T>* dst, int dst_pos,
51 size_t length)
52 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
53
54 ObjectArray<T>* CopyOf(Thread* self, int32_t new_length)
55 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
56
57 private:
58 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectArray);
59};
60
61} // namespace mirror
62} // namespace art
63
64#endif // ART_SRC_MIRROR_OBJECT_ARRAY_H_