blob: 4f1c448b56fb0c63ec8e1350248e09cab43f7732 [file] [log] [blame]
Narayan Kamathafa48272016-08-03 12:46:58 +01001/*
2 * Copyright (C) 2016 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 "method_handle_impl.h"
18
19#include "class-inl.h"
20#include "gc_root-inl.h"
21
22namespace art {
23namespace mirror {
24
Orion Hodsoncfa325e2016-10-13 10:25:54 +010025mirror::Class* MethodHandle::StaticClass() {
26 mirror::Class* klass = MethodHandleImpl::StaticClass()->GetSuperClass();
27 DCHECK(klass->DescriptorEquals("Ljava/lang/invoke/MethodHandle;"));
28 return klass;
29}
30
Narayan Kamathafa48272016-08-03 12:46:58 +010031GcRoot<mirror::Class> MethodHandleImpl::static_class_;
32
33void MethodHandleImpl::SetClass(Class* klass) {
34 CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
35 CHECK(klass != nullptr);
36 static_class_ = GcRoot<Class>(klass);
37}
38
39void MethodHandleImpl::ResetClass() {
40 CHECK(!static_class_.IsNull());
41 static_class_ = GcRoot<Class>(nullptr);
42}
43
44void MethodHandleImpl::VisitRoots(RootVisitor* visitor) {
45 static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
46}
47
48} // namespace mirror
49} // namespace art