MethodHandles: Support and tests for revealDirect / reflectAs.
We need runtime support to materialize a Constructor, Field or
Method object from a MethodHandle and its associated ArtField
or ArtMethod pointer.
An alternate approach might be to have all handles hold a reference
to their associated Field or Method object (in addition to the
raw ArtField or ArtMethod) but that seems unnecessary given that
these APIs are not expected to be called often.
Test: test-art-host
Change-Id: I9450706b9c30359edebf2e8a7afbc8d89bd68b26
diff --git a/runtime/mirror/method_handle_impl.h b/runtime/mirror/method_handle_impl.h
index 2f26a22..dca3062 100644
--- a/runtime/mirror/method_handle_impl.h
+++ b/runtime/mirror/method_handle_impl.h
@@ -25,6 +25,7 @@
namespace art {
+struct MethodHandleOffsets;
struct MethodHandleImplOffsets;
namespace mirror {
@@ -105,7 +106,7 @@
return MemberOffset(OFFSETOF_MEMBER(MethodHandle, handle_kind_));
}
- friend struct art::MethodHandleImplOffsets; // for verifying offset information
+ friend struct art::MethodHandleOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(MethodHandle);
};
@@ -121,6 +122,11 @@
static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
private:
+ static MemberOffset InfoOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(MethodHandleImpl, info_));
+ }
+
+ HeapReference<mirror::Object> info_; // Unused by the runtime.
static GcRoot<mirror::Class> static_class_; // java.lang.invoke.MethodHandleImpl.class
friend struct art::MethodHandleImplOffsets; // for verifying offset information