• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 #ifndef ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
18 #define ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
19 
20 #include "base/utils.h"
21 #include "handle.h"
22 #include "obj_ptr.h"
23 #include "object.h"
24 
25 namespace art {
26 
27 struct MethodHandlesLookupOffsets;
28 class RootVisitor;
29 
30 namespace mirror {
31 
32 class MethodHandle;
33 class MethodType;
34 
35 // C++ mirror of java.lang.invoke.MethodHandles.Lookup
36 class MANAGED MethodHandlesLookup : public Object {
37  public:
38   MIRROR_CLASS("Ljava/lang/invoke/MethodHandles$Lookup;");
39 
40   static ObjPtr<mirror::MethodHandlesLookup> Create(Thread* const self, Handle<Class> lookup_class)
41       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
42 
43   // Returns the result of java.lang.invoke.MethodHandles.lookup().
44   static ObjPtr<mirror::MethodHandlesLookup> GetDefault(Thread* const self)
45       REQUIRES_SHARED(Locks::mutator_lock_);
46 
47   // Find constructor using java.lang.invoke.MethodHandles$Lookup.findConstructor().
48   ObjPtr<mirror::MethodHandle> FindConstructor(Thread* const self,
49                                                Handle<Class> klass,
50                                                Handle<MethodType> method_type)
51       REQUIRES_SHARED(Locks::mutator_lock_);
52 
53  private:
54   static MemberOffset AllowedModesOffset() {
55     return MemberOffset(OFFSETOF_MEMBER(MethodHandlesLookup, allowed_modes_));
56   }
57 
58   static MemberOffset LookupClassOffset() {
59     return MemberOffset(OFFSETOF_MEMBER(MethodHandlesLookup, lookup_class_));
60   }
61 
62   HeapReference<mirror::Class> lookup_class_;
63 
64   int32_t allowed_modes_;
65 
66   friend struct art::MethodHandlesLookupOffsets;  // for verifying offset information
67   DISALLOW_IMPLICIT_CONSTRUCTORS(MethodHandlesLookup);
68 };
69 
70 }  // namespace mirror
71 }  // namespace art
72 
73 #endif  // ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
74