Revert "Temporarily disable lazy class-file-load-hook"

An ASAN failure was caused by a rare interaction between the
fault-handler and updating the internal book-keeping for the
ClassFileLoadHook. When we update the current definition for the
ClassFileLoadHook we check to see if the definition has actually
changed. This causes a read from the previous dex-file buffer. If the
buffer is lazy and the agent never accessed it (very rare outside of
testing) the SEGV will occur within art code in the kRunnable state.
This caused the runtime to think the SEGV was coming from java code
and perform some illegal reads prior to figuring out that the SEGV did
not come from java.

To fix this we simply make sure all the code that can cause the SEGV
occurs while the runtime is in kNative state.

We add an assert for this in the fault handler itself.

Reason for revert: Fixed issue causing ASAN failure with lazy dex-file
                   load hook.

This reverts commit 37977705dc6cfa3e77299ae97675f80b59f2fcf0.


Bug: 72909916
Test: ./test/testrunner/run-_build_test_target.py -j50 art-asan

Change-Id: I8b2d2fda8092a379e0019db15ec360a5a63d8b3f
diff --git a/openjdkjvmti/transform.cc b/openjdkjvmti/transform.cc
index 7b19a24..dc9f69a 100644
--- a/openjdkjvmti/transform.cc
+++ b/openjdkjvmti/transform.cc
@@ -128,6 +128,11 @@
       }
     }
 
+    if (LIKELY(self != nullptr)) {
+      CHECK_EQ(self->GetState(), art::ThreadState::kNative)
+          << "Transformation fault handler occurred outside of native mode";
+    }
+
     VLOG(signals) << "Lazy initialization of dex file for transformation of " << res->GetName()
                   << " during SEGV";
     res->InitializeMemory();
@@ -250,6 +255,10 @@
   static_assert(kEvent == ArtJvmtiEvent::kClassFileLoadHookNonRetransformable ||
                 kEvent == ArtJvmtiEvent::kClassFileLoadHookRetransformable,
                 "bad event type");
+  // We don't want to do transitions between calling the event and setting the new data so change to
+  // native state early. This also avoids any problems that the FaultHandler might have in
+  // determining if an access to the dex_data is from generated code or not.
+  art::ScopedThreadStateChange stsc(self, art::ThreadState::kNative);
   ScopedDefinitionHandler handler(def);
   jint new_len = -1;
   unsigned char* new_data = nullptr;