blob: 3c7f8c8e63dba98e95ecca208fb793c568fa06fb [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
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -070019#include "art_method.h"
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -070020#include "gc_root-inl.h"
21
Fred Shih4ee7a662014-07-11 09:59:27 -070022namespace art {
23namespace mirror {
24
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070025GcRoot<Class> Reference::java_lang_ref_Reference_;
Fred Shih4ee7a662014-07-11 09:59:27 -070026
27void Reference::SetClass(Class* java_lang_ref_Reference) {
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070028 CHECK(java_lang_ref_Reference_.IsNull());
Fred Shih4ee7a662014-07-11 09:59:27 -070029 CHECK(java_lang_ref_Reference != nullptr);
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070030 java_lang_ref_Reference_ = GcRoot<Class>(java_lang_ref_Reference);
Fred Shih4ee7a662014-07-11 09:59:27 -070031}
32
33void Reference::ResetClass() {
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070034 CHECK(!java_lang_ref_Reference_.IsNull());
35 java_lang_ref_Reference_ = GcRoot<Class>(nullptr);
Fred Shih4ee7a662014-07-11 09:59:27 -070036}
37
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -070038void Reference::VisitRoots(RootVisitor* visitor) {
39 java_lang_ref_Reference_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
Fred Shih4ee7a662014-07-11 09:59:27 -070040}
41
42} // namespace mirror
43} // namespace art