Narayan Kamath | afa4827 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 22 | namespace art { |
| 23 | namespace mirror { |
| 24 | |
Orion Hodson | cfa325e | 2016-10-13 10:25:54 +0100 | [diff] [blame] | 25 | mirror::Class* MethodHandle::StaticClass() { |
| 26 | mirror::Class* klass = MethodHandleImpl::StaticClass()->GetSuperClass(); |
| 27 | DCHECK(klass->DescriptorEquals("Ljava/lang/invoke/MethodHandle;")); |
| 28 | return klass; |
| 29 | } |
| 30 | |
Narayan Kamath | afa4827 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 31 | GcRoot<mirror::Class> MethodHandleImpl::static_class_; |
| 32 | |
| 33 | void 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 | |
| 39 | void MethodHandleImpl::ResetClass() { |
| 40 | CHECK(!static_class_.IsNull()); |
| 41 | static_class_ = GcRoot<Class>(nullptr); |
| 42 | } |
| 43 | |
| 44 | void MethodHandleImpl::VisitRoots(RootVisitor* visitor) { |
| 45 | static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass)); |
| 46 | } |
| 47 | |
| 48 | } // namespace mirror |
| 49 | } // namespace art |