blob: 35130e8b884820f99aaee04619e241ff04535b2e [file] [log] [blame]
Fred Shih4ee7a662014-07-11 09:59:27 -07001/*
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#include "reference.h"
18
19namespace art {
20namespace mirror {
21
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070022GcRoot<Class> Reference::java_lang_ref_Reference_;
Fred Shih4ee7a662014-07-11 09:59:27 -070023
24void Reference::SetClass(Class* java_lang_ref_Reference) {
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070025 CHECK(java_lang_ref_Reference_.IsNull());
Fred Shih4ee7a662014-07-11 09:59:27 -070026 CHECK(java_lang_ref_Reference != nullptr);
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070027 java_lang_ref_Reference_ = GcRoot<Class>(java_lang_ref_Reference);
Fred Shih4ee7a662014-07-11 09:59:27 -070028}
29
30void Reference::ResetClass() {
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070031 CHECK(!java_lang_ref_Reference_.IsNull());
32 java_lang_ref_Reference_ = GcRoot<Class>(nullptr);
Fred Shih4ee7a662014-07-11 09:59:27 -070033}
34
35void Reference::VisitRoots(RootCallback* callback, void* arg) {
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080036 java_lang_ref_Reference_.VisitRootIfNonNull(callback, arg, RootInfo(kRootStickyClass));
Fred Shih4ee7a662014-07-11 09:59:27 -070037}
38
39} // namespace mirror
40} // namespace art