/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "method_handles_lookup.h" #include "class-alloc-inl.h" #include "class_root-inl.h" #include "dex/modifiers.h" #include "handle_scope.h" #include "mirror/method_handle_impl.h" #include "obj_ptr-inl.h" #include "object-inl.h" #include "well_known_classes.h" namespace art HIDDEN { namespace mirror { ObjPtr MethodHandlesLookup::Create(Thread* const self, Handle lookup_class) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) { static constexpr uint32_t kAllModes = kAccPublic | kAccPrivate | kAccProtected | kAccStatic; ObjPtr mhl = ObjPtr::DownCast( GetClassRoot()->AllocObject(self)); mhl->SetFieldObject(LookupClassOffset(), lookup_class.Get()); mhl->SetField32(AllowedModesOffset(), kAllModes); return mhl; } ObjPtr MethodHandlesLookup::GetDefault(Thread* const self) { ArtMethod* lookup = WellKnownClasses::java_lang_invoke_MethodHandles_lookup; return ObjPtr::DownCast(lookup->InvokeStatic<'L'>(self)); } ObjPtr MethodHandlesLookup::FindConstructor(Thread* const self, Handle klass, Handle method_type) { ArtMethod* find_constructor = WellKnownClasses::java_lang_invoke_MethodHandles_Lookup_findConstructor; return ObjPtr::DownCast( find_constructor->InvokeFinal<'L', 'L', 'L'>(self, this, klass.Get(), method_type.Get())); } } // namespace mirror } // namespace art