From c0d988a9b5f2c34072fff100af9bd12464a6c55b Mon Sep 17 00:00:00 2001 From: Orion Hodson Date: Tue, 10 Apr 2018 14:32:35 +0100 Subject: ART: Stop Hidden API stackwalk for class initializers in j.l.i. Class initializers in java.lang.invoke retrieve field offsets. The hiddenapi stack walk does not need to progress past these initializers as they are permitted irrespective of how their invocation is triggered. Bug: 77631986 Test: art/test/run-test --host --64 674-hiddenapi (cherry picked from commit 29e64cfc32e17c9111a5ed2a6b141bebf891cbe3) Change-Id: I77a29999177850bd50ca4d043b0cd40c40692fe4 Merged-In: Iaabedc9c016d546e10072107d79c7b6701582c83 --- runtime/native/java_lang_Class.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'runtime/native/java_lang_Class.cc') diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 510c5de7ed..bfd7f69cef 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -77,11 +77,14 @@ static bool IsCallerInPlatformDex(Thread* self) REQUIRES_SHARED(Locks::mutator_l if (declaring_class->IsClassClass()) { return true; } + // Check classes in the java.lang.invoke package. At the time of writing, the + // classes of interest are MethodHandles and MethodHandles.Lookup, but this + // is subject to change so conservatively cover the entire package. + // NB Static initializers within java.lang.invoke are permitted and do not + // need further stack inspection. ObjPtr lookup_class = mirror::MethodHandlesLookup::StaticClass(); - if (declaring_class == lookup_class || declaring_class->IsInSamePackage(lookup_class)) { - // Check classes in the java.lang.invoke package. At the time of writing, the - // classes of interest are MethodHandles and MethodHandles.Lookup, but this - // is subject to change so conservatively cover the entire package. + if ((declaring_class == lookup_class || declaring_class->IsInSamePackage(lookup_class)) + && !m->IsClassInitializer()) { return true; } } -- cgit v1.2.3-59-g8ed1b