diff options
| author | 2022-09-28 08:30:41 +0000 | |
|---|---|---|
| committer | 2022-09-28 08:30:41 +0000 | |
| commit | aa54c808cd00f0951ee9c6290ae185d5fcad0d7c (patch) | |
| tree | d67db44aa0b2cc26255b7ca1b80117c551ebe193 /compiler/compiler_reflection_test.cc | |
| parent | 033d8590c034cf70ccc87a59151f9d7faf879f51 (diff) | |
| parent | f033a451bf35e3814a7f5c188d3e2051c1aafbe3 (diff) | |
Move ReflectionTest.StaticMainMethod to compiler/. am: 51d4445f21 am: f033a451bf
Original change: https://android-review.googlesource.com/c/platform/art/+/2232131
Change-Id: I7fdfc599ef97ebc7dcd254ac651e8ee48be1e6ff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'compiler/compiler_reflection_test.cc')
| -rw-r--r-- | compiler/compiler_reflection_test.cc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/compiler/compiler_reflection_test.cc b/compiler/compiler_reflection_test.cc new file mode 100644 index 0000000000..3b7b8b7369 --- /dev/null +++ b/compiler/compiler_reflection_test.cc @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "reflection.h" + +#include "class_linker.h" +#include "common_compiler_test.h" +#include "handle_scope-inl.h" +#include "jni/jni_internal.h" +#include "mirror/class.h" +#include "mirror/class_loader.h" + +namespace art { + +class CompilerReflectionTest : public CommonCompilerTest {}; + +TEST_F(CompilerReflectionTest, StaticMainMethod) { + ScopedObjectAccess soa(Thread::Current()); + jobject jclass_loader = LoadDex("Main"); + StackHandleScope<1> hs(soa.Self()); + Handle<mirror::ClassLoader> class_loader( + hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader))); + + ObjPtr<mirror::Class> klass = class_linker_->FindClass(soa.Self(), "LMain;", class_loader); + ASSERT_TRUE(klass != nullptr); + + ArtMethod* method = klass->FindClassMethod("main", + "([Ljava/lang/String;)V", + kRuntimePointerSize); + ASSERT_TRUE(method != nullptr); + ASSERT_TRUE(method->IsStatic()); + + CompileMethod(method); + + // Start runtime. + bool started = runtime_->Start(); + CHECK(started); + soa.Self()->TransitionFromSuspendedToRunnable(); + + jvalue args[1]; + args[0].l = nullptr; + InvokeWithJValues(soa, nullptr, jni::EncodeArtMethod(method), args); +} + +} // namespace art |