Allow jvmti Allocate & Deallocate function on unattached threads

Some real-world agents will call the JVMTI Allocate and Deallocate
functions on unattached threads and expect them to function correctly.
We change the error checking to allow them to be used in this way. This
is to make it easier to debug possible issues with agents.

Test: ./test.py --host -j50
Bug: 70918330
Change-Id: If1796773b198d171284c3e02f38504bf094b9e0d
diff --git a/openjdkjvmti/OpenjdkJvmTi.cc b/openjdkjvmti/OpenjdkJvmTi.cc
index 39e49d7..ffa1bd3 100644
--- a/openjdkjvmti/OpenjdkJvmTi.cc
+++ b/openjdkjvmti/OpenjdkJvmTi.cc
@@ -122,13 +122,21 @@
 
  public:
   static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
-    ENSURE_VALID_ENV(env);
+    jvmtiError err = getEnvironmentError(env);
+    // Allow UNATTACHED_THREAD since we don't really care about that for this function.
+    if (err != OK && err != ERR(UNATTACHED_THREAD)) {
+      return err;
+    }
     ENSURE_NON_NULL(mem_ptr);
     return AllocUtil::Allocate(env, size, mem_ptr);
   }
 
   static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
-    ENSURE_VALID_ENV(env);
+    jvmtiError err = getEnvironmentError(env);
+    // Allow UNATTACHED_THREAD since we don't really care about that for this function.
+    if (err != OK && err != ERR(UNATTACHED_THREAD)) {
+      return err;
+    }
     return AllocUtil::Deallocate(env, mem);
   }