blob: 4cdb148ff42b480988c2c14aa26460cb98bbe832 [file] [log] [blame]
Andreas Gampee492ae32016-10-28 19:34:57 -07001/* Copyright (C) 2016 The Android Open Source Project
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This file implements interfaces from the file jvmti.h. This implementation
5 * is licensed under the same terms as the file jvmti.h. The
6 * copyright and license information for the file jvmti.h follows.
7 *
8 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Oracle designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Oracle in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28 * or visit www.oracle.com if you need additional information or have any
29 * questions.
30 */
31
32#include "ti_class.h"
33
Alex Light440b5d92017-01-24 15:32:25 -080034#include "android-base/stringprintf.h"
35
Andreas Gampee6377462017-01-20 17:37:50 -080036#include <mutex>
37#include <unordered_set>
38
Andreas Gampee492ae32016-10-28 19:34:57 -070039#include "art_jvmti.h"
Andreas Gampee6377462017-01-20 17:37:50 -080040#include "base/macros.h"
Andreas Gampe70f16392017-01-16 14:20:10 -080041#include "class_table-inl.h"
42#include "class_linker.h"
Alex Light440b5d92017-01-24 15:32:25 -080043#include "common_throws.h"
Andreas Gampe0eb36432017-02-15 18:36:14 -080044#include "dex_file_annotations.h"
Andreas Gampee6377462017-01-20 17:37:50 -080045#include "events-inl.h"
Alex Light40528472017-03-28 09:07:36 -070046#include "fixed_up_dex_file.h"
Andreas Gampe691051b2017-02-09 09:15:24 -080047#include "gc/heap.h"
48#include "gc_root.h"
Andreas Gampee6377462017-01-20 17:37:50 -080049#include "handle.h"
50#include "jni_env_ext-inl.h"
Andreas Gampeac587272017-01-05 15:21:34 -080051#include "jni_internal.h"
Alex Light440b5d92017-01-24 15:32:25 -080052#include "mirror/array-inl.h"
53#include "mirror/class-inl.h"
54#include "mirror/class_ext.h"
Andreas Gampe0eb36432017-02-15 18:36:14 -080055#include "mirror/object_array-inl.h"
Andreas Gampea67354b2017-02-10 16:18:30 -080056#include "mirror/object_reference.h"
57#include "mirror/object-inl.h"
Andreas Gampe52784ac2017-02-13 18:10:09 -080058#include "mirror/reference.h"
Alex Light6a656312017-03-29 17:18:00 -070059#include "primitive.h"
60#include "reflection.h"
Andreas Gampe70f16392017-01-16 14:20:10 -080061#include "runtime.h"
Andreas Gampee6377462017-01-20 17:37:50 -080062#include "runtime_callbacks.h"
63#include "ScopedLocalRef.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070064#include "scoped_thread_state_change-inl.h"
65#include "thread-inl.h"
Andreas Gampee6377462017-01-20 17:37:50 -080066#include "thread_list.h"
Alex Lighteb98b082017-01-25 13:02:32 -080067#include "ti_class_loader.h"
Alex Lightd8ce4e72017-02-27 10:52:29 -080068#include "ti_phase.h"
Alex Light440b5d92017-01-24 15:32:25 -080069#include "ti_redefine.h"
70#include "utils.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070071
72namespace openjdkjvmti {
73
Alex Light440b5d92017-01-24 15:32:25 -080074using android::base::StringPrintf;
75
76static std::unique_ptr<const art::DexFile> MakeSingleDexFile(art::Thread* self,
77 const char* descriptor,
78 const std::string& orig_location,
79 jint final_len,
80 const unsigned char* final_dex_data)
81 REQUIRES_SHARED(art::Locks::mutator_lock_) {
82 // Make the mmap
83 std::string error_msg;
84 std::unique_ptr<art::MemMap> map(Redefiner::MoveDataToMemMap(orig_location,
85 final_len,
86 final_dex_data,
87 &error_msg));
88 if (map.get() == nullptr) {
89 LOG(WARNING) << "Unable to allocate mmap for redefined dex file! Error was: " << error_msg;
90 self->ThrowOutOfMemoryError(StringPrintf(
91 "Unable to allocate dex file for transformation of %s", descriptor).c_str());
92 return nullptr;
93 }
94
95 // Make a dex-file
96 if (map->Size() < sizeof(art::DexFile::Header)) {
97 LOG(WARNING) << "Could not read dex file header because dex_data was too short";
98 art::ThrowClassFormatError(nullptr,
99 "Unable to read transformed dex file of %s",
100 descriptor);
101 return nullptr;
102 }
103 uint32_t checksum = reinterpret_cast<const art::DexFile::Header*>(map->Begin())->checksum_;
104 std::unique_ptr<const art::DexFile> dex_file(art::DexFile::Open(map->GetName(),
105 checksum,
106 std::move(map),
107 /*verify*/true,
108 /*verify_checksum*/true,
109 &error_msg));
110 if (dex_file.get() == nullptr) {
111 LOG(WARNING) << "Unable to load modified dex file for " << descriptor << ": " << error_msg;
112 art::ThrowClassFormatError(nullptr,
113 "Unable to read transformed dex file of %s because %s",
114 descriptor,
115 error_msg.c_str());
116 return nullptr;
117 }
118 if (dex_file->NumClassDefs() != 1) {
119 LOG(WARNING) << "Dex file contains more than 1 class_def. Ignoring.";
120 // TODO Throw some other sort of error here maybe?
121 art::ThrowClassFormatError(
122 nullptr,
123 "Unable to use transformed dex file of %s because it contained too many classes",
124 descriptor);
125 return nullptr;
126 }
127 return dex_file;
128}
129
Andreas Gampee6377462017-01-20 17:37:50 -0800130struct ClassCallback : public art::ClassLoadCallback {
Alex Light440b5d92017-01-24 15:32:25 -0800131 void ClassPreDefine(const char* descriptor,
132 art::Handle<art::mirror::Class> klass,
133 art::Handle<art::mirror::ClassLoader> class_loader,
134 const art::DexFile& initial_dex_file,
135 const art::DexFile::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
136 /*out*/art::DexFile const** final_dex_file,
137 /*out*/art::DexFile::ClassDef const** final_class_def)
138 OVERRIDE REQUIRES_SHARED(art::Locks::mutator_lock_) {
139 bool is_enabled =
140 event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kClassFileLoadHookRetransformable) ||
141 event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kClassFileLoadHookNonRetransformable);
142 if (!is_enabled) {
143 return;
144 }
145 if (descriptor[0] != 'L') {
146 // It is a primitive or array. Just return
147 return;
148 }
Alex Lightd8ce4e72017-02-27 10:52:29 -0800149 jvmtiPhase phase = PhaseUtil::GetPhaseUnchecked();
150 if (UNLIKELY(phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE)) {
151 // We want to wait until we are at least in the START phase so that all WellKnownClasses and
152 // mirror classes have been initialized and loaded. The runtime relies on these classes having
153 // specific fields and methods present. Since PreDefine hooks don't need to abide by this
154 // restriction we will simply not send the event for these classes.
155 LOG(WARNING) << "Ignoring load of class <" << descriptor << "> as it is being loaded during "
156 << "runtime initialization.";
157 return;
158 }
159
160 // Strip the 'L' and ';' from the descriptor
Alex Light28027122017-01-26 17:21:51 -0800161 std::string name(std::string(descriptor).substr(1, strlen(descriptor) - 2));
Alex Light440b5d92017-01-24 15:32:25 -0800162
163 art::Thread* self = art::Thread::Current();
164 art::JNIEnvExt* env = self->GetJniEnv();
165 ScopedLocalRef<jobject> loader(
166 env, class_loader.IsNull() ? nullptr : env->AddLocalReference<jobject>(class_loader.Get()));
Alex Light40528472017-03-28 09:07:36 -0700167 std::unique_ptr<FixedUpDexFile> dex_file_copy(FixedUpDexFile::Create(initial_dex_file));
168
Alex Light440b5d92017-01-24 15:32:25 -0800169 // Go back to native.
170 art::ScopedThreadSuspension sts(self, art::ThreadState::kNative);
171 // Call all Non-retransformable agents.
172 jint post_no_redefine_len = 0;
173 unsigned char* post_no_redefine_dex_data = nullptr;
174 std::unique_ptr<const unsigned char> post_no_redefine_unique_ptr(nullptr);
175 event_handler->DispatchEvent<ArtJvmtiEvent::kClassFileLoadHookNonRetransformable>(
176 self,
177 static_cast<JNIEnv*>(env),
178 static_cast<jclass>(nullptr), // The class doesn't really exist yet so send null.
179 loader.get(),
180 name.c_str(),
181 static_cast<jobject>(nullptr), // Android doesn't seem to have protection domains
Alex Light40528472017-03-28 09:07:36 -0700182 static_cast<jint>(dex_file_copy->Size()),
183 static_cast<const unsigned char*>(dex_file_copy->Begin()),
Alex Light440b5d92017-01-24 15:32:25 -0800184 static_cast<jint*>(&post_no_redefine_len),
185 static_cast<unsigned char**>(&post_no_redefine_dex_data));
186 if (post_no_redefine_dex_data == nullptr) {
187 DCHECK_EQ(post_no_redefine_len, 0);
Alex Light40528472017-03-28 09:07:36 -0700188 post_no_redefine_dex_data = const_cast<unsigned char*>(dex_file_copy->Begin());
189 post_no_redefine_len = dex_file_copy->Size();
Alex Light440b5d92017-01-24 15:32:25 -0800190 } else {
191 post_no_redefine_unique_ptr = std::unique_ptr<const unsigned char>(post_no_redefine_dex_data);
192 DCHECK_GT(post_no_redefine_len, 0);
193 }
194 // Call all retransformable agents.
195 jint final_len = 0;
196 unsigned char* final_dex_data = nullptr;
197 std::unique_ptr<const unsigned char> final_dex_unique_ptr(nullptr);
198 event_handler->DispatchEvent<ArtJvmtiEvent::kClassFileLoadHookRetransformable>(
199 self,
200 static_cast<JNIEnv*>(env),
201 static_cast<jclass>(nullptr), // The class doesn't really exist yet so send null.
202 loader.get(),
203 name.c_str(),
204 static_cast<jobject>(nullptr), // Android doesn't seem to have protection domains
205 static_cast<jint>(post_no_redefine_len),
206 static_cast<const unsigned char*>(post_no_redefine_dex_data),
207 static_cast<jint*>(&final_len),
208 static_cast<unsigned char**>(&final_dex_data));
209 if (final_dex_data == nullptr) {
210 DCHECK_EQ(final_len, 0);
211 final_dex_data = post_no_redefine_dex_data;
212 final_len = post_no_redefine_len;
213 } else {
214 final_dex_unique_ptr = std::unique_ptr<const unsigned char>(final_dex_data);
215 DCHECK_GT(final_len, 0);
216 }
217
Alex Light40528472017-03-28 09:07:36 -0700218 if (final_dex_data != dex_file_copy->Begin()) {
Alex Light440b5d92017-01-24 15:32:25 -0800219 LOG(WARNING) << "Changing class " << descriptor;
220 art::ScopedObjectAccess soa(self);
221 art::StackHandleScope<2> hs(self);
222 // Save the results of all the non-retransformable agents.
223 // First allocate the ClassExt
224 art::Handle<art::mirror::ClassExt> ext(hs.NewHandle(klass->EnsureExtDataPresent(self)));
225 // Make sure we have a ClassExt. This is fine even though we are a temporary since it will
226 // get copied.
227 if (ext.IsNull()) {
228 // We will just return failure if we fail to allocate
229 LOG(WARNING) << "Could not allocate ext-data for class '" << descriptor << "'. "
230 << "Aborting transformation since we will be unable to store it.";
231 self->AssertPendingOOMException();
232 return;
233 }
234
235 // Allocate the byte array to store the dex file bytes in.
Alex Light6a656312017-03-29 17:18:00 -0700236 art::MutableHandle<art::mirror::Object> arr(hs.NewHandle<art::mirror::Object>(nullptr));
237 if (post_no_redefine_dex_data == dex_file_copy->Begin() && name != "java/lang/Long") {
238 // we didn't have any non-retransformable agents. We can just cache a pointer to the
239 // initial_dex_file. It will be kept live by the class_loader.
240 jlong dex_ptr = reinterpret_cast<uintptr_t>(&initial_dex_file);
241 art::JValue val;
242 val.SetJ(dex_ptr);
243 arr.Assign(art::BoxPrimitive(art::Primitive::kPrimLong, val));
244 } else {
245 arr.Assign(art::mirror::ByteArray::AllocateAndFill(
246 self,
247 reinterpret_cast<const signed char*>(post_no_redefine_dex_data),
248 post_no_redefine_len));
249 }
Alex Light440b5d92017-01-24 15:32:25 -0800250 if (arr.IsNull()) {
Alex Light6a656312017-03-29 17:18:00 -0700251 LOG(WARNING) << "Unable to allocate memory for initial dex-file. Aborting transformation";
Alex Light440b5d92017-01-24 15:32:25 -0800252 self->AssertPendingOOMException();
253 return;
254 }
255
256 std::unique_ptr<const art::DexFile> dex_file(MakeSingleDexFile(self,
257 descriptor,
258 initial_dex_file.GetLocation(),
259 final_len,
260 final_dex_data));
261 if (dex_file.get() == nullptr) {
262 return;
263 }
264
Alex Lighteb98b082017-01-25 13:02:32 -0800265 // TODO Check Redefined dex file for all invariants.
Alex Light440b5d92017-01-24 15:32:25 -0800266 LOG(WARNING) << "Dex file created by class-definition time transformation of "
267 << descriptor << " is not checked for all retransformation invariants.";
Alex Lighteb98b082017-01-25 13:02:32 -0800268
269 if (!ClassLoaderHelper::AddToClassLoader(self, class_loader, dex_file.get())) {
270 LOG(ERROR) << "Unable to add " << descriptor << " to class loader!";
271 return;
272 }
273
Alex Light440b5d92017-01-24 15:32:25 -0800274 // Actually set the ClassExt's original bytes once we have actually succeeded.
Alex Light2f814aa2017-03-24 15:21:34 +0000275 ext->SetOriginalDexFile(arr.Get());
Alex Light440b5d92017-01-24 15:32:25 -0800276 // Set the return values
277 *final_class_def = &dex_file->GetClassDef(0);
278 *final_dex_file = dex_file.release();
279 }
280 }
281
Andreas Gampee6377462017-01-20 17:37:50 -0800282 void ClassLoad(art::Handle<art::mirror::Class> klass) REQUIRES_SHARED(art::Locks::mutator_lock_) {
283 if (event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kClassLoad)) {
284 art::Thread* thread = art::Thread::Current();
285 ScopedLocalRef<jclass> jklass(thread->GetJniEnv(),
286 thread->GetJniEnv()->AddLocalReference<jclass>(klass.Get()));
Andreas Gampe983c1752017-01-23 19:46:56 -0800287 ScopedLocalRef<jthread> thread_jni(
288 thread->GetJniEnv(), thread->GetJniEnv()->AddLocalReference<jthread>(thread->GetPeer()));
Andreas Gampee6377462017-01-20 17:37:50 -0800289 {
290 art::ScopedThreadSuspension sts(thread, art::ThreadState::kNative);
Andreas Gampe983c1752017-01-23 19:46:56 -0800291 event_handler->DispatchEvent<ArtJvmtiEvent::kClassLoad>(
292 thread,
293 static_cast<JNIEnv*>(thread->GetJniEnv()),
294 thread_jni.get(),
295 jklass.get());
Andreas Gampee6377462017-01-20 17:37:50 -0800296 }
Andreas Gampe691051b2017-02-09 09:15:24 -0800297 if (klass->IsTemp()) {
298 AddTempClass(thread, jklass.get());
299 }
Andreas Gampee6377462017-01-20 17:37:50 -0800300 }
301 }
302
Andreas Gampe691051b2017-02-09 09:15:24 -0800303 void ClassPrepare(art::Handle<art::mirror::Class> temp_klass,
Andreas Gampee6377462017-01-20 17:37:50 -0800304 art::Handle<art::mirror::Class> klass)
305 REQUIRES_SHARED(art::Locks::mutator_lock_) {
306 if (event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kClassPrepare)) {
307 art::Thread* thread = art::Thread::Current();
Andreas Gampe691051b2017-02-09 09:15:24 -0800308 if (temp_klass.Get() != klass.Get()) {
309 DCHECK(temp_klass->IsTemp());
310 DCHECK(temp_klass->IsRetired());
311 HandleTempClass(thread, temp_klass, klass);
312 }
Andreas Gampee6377462017-01-20 17:37:50 -0800313 ScopedLocalRef<jclass> jklass(thread->GetJniEnv(),
314 thread->GetJniEnv()->AddLocalReference<jclass>(klass.Get()));
Andreas Gampe983c1752017-01-23 19:46:56 -0800315 ScopedLocalRef<jthread> thread_jni(
316 thread->GetJniEnv(), thread->GetJniEnv()->AddLocalReference<jthread>(thread->GetPeer()));
Andreas Gampee6377462017-01-20 17:37:50 -0800317 art::ScopedThreadSuspension sts(thread, art::ThreadState::kNative);
Andreas Gampe983c1752017-01-23 19:46:56 -0800318 event_handler->DispatchEvent<ArtJvmtiEvent::kClassPrepare>(
319 thread,
320 static_cast<JNIEnv*>(thread->GetJniEnv()),
321 thread_jni.get(),
322 jklass.get());
Andreas Gampee6377462017-01-20 17:37:50 -0800323 }
324 }
325
Andreas Gampe7619b5b2017-02-10 11:49:12 -0800326 // To support parallel class-loading, we need to perform some locking dances here. Namely,
327 // the fixup stage must not be holding the temp_classes lock when it fixes up the system
328 // (as that requires suspending all mutators).
329
Andreas Gampee6377462017-01-20 17:37:50 -0800330 void AddTempClass(art::Thread* self, jclass klass) {
331 std::unique_lock<std::mutex> mu(temp_classes_lock);
Andreas Gampe691051b2017-02-09 09:15:24 -0800332 jclass global_klass = reinterpret_cast<jclass>(self->GetJniEnv()->NewGlobalRef(klass));
333 temp_classes.push_back(global_klass);
Andreas Gampee6377462017-01-20 17:37:50 -0800334 }
335
Andreas Gampe691051b2017-02-09 09:15:24 -0800336 void HandleTempClass(art::Thread* self,
337 art::Handle<art::mirror::Class> temp_klass,
Andreas Gampee6377462017-01-20 17:37:50 -0800338 art::Handle<art::mirror::Class> klass)
339 REQUIRES_SHARED(art::Locks::mutator_lock_) {
Andreas Gampe7619b5b2017-02-10 11:49:12 -0800340 bool requires_fixup = false;
341 {
342 std::unique_lock<std::mutex> mu(temp_classes_lock);
343 if (temp_classes.empty()) {
344 return;
Andreas Gampee6377462017-01-20 17:37:50 -0800345 }
Andreas Gampe7619b5b2017-02-10 11:49:12 -0800346
347 for (auto it = temp_classes.begin(); it != temp_classes.end(); ++it) {
348 if (temp_klass.Get() == art::ObjPtr<art::mirror::Class>::DownCast(self->DecodeJObject(*it))) {
349 self->GetJniEnv()->DeleteGlobalRef(*it);
350 temp_classes.erase(it);
351 requires_fixup = true;
352 break;
353 }
354 }
355 }
356 if (requires_fixup) {
357 FixupTempClass(self, temp_klass, klass);
Andreas Gampee6377462017-01-20 17:37:50 -0800358 }
359 }
360
Andreas Gampe691051b2017-02-09 09:15:24 -0800361 void FixupTempClass(art::Thread* self,
362 art::Handle<art::mirror::Class> temp_klass,
363 art::Handle<art::mirror::Class> klass)
Andreas Gampee6377462017-01-20 17:37:50 -0800364 REQUIRES_SHARED(art::Locks::mutator_lock_) {
Andreas Gampe691051b2017-02-09 09:15:24 -0800365 // Suspend everything.
366 art::gc::Heap* heap = art::Runtime::Current()->GetHeap();
367 if (heap->IsGcConcurrentAndMoving()) {
368 // Need to take a heap dump while GC isn't running. See the
369 // comment in Heap::VisitObjects().
370 heap->IncrementDisableMovingGC(self);
371 }
372 {
373 art::ScopedThreadSuspension sts(self, art::kWaitingForVisitObjects);
374 art::ScopedSuspendAll ssa("FixupTempClass");
375
376 art::mirror::Class* input = temp_klass.Get();
377 art::mirror::Class* output = klass.Get();
378
379 FixupGlobalReferenceTables(input, output);
Andreas Gampe94dda932017-02-09 18:19:21 -0800380 FixupLocalReferenceTables(self, input, output);
Andreas Gampea67354b2017-02-10 16:18:30 -0800381 FixupHeap(input, output);
Andreas Gampe691051b2017-02-09 09:15:24 -0800382 }
383 if (heap->IsGcConcurrentAndMoving()) {
384 heap->DecrementDisableMovingGC(self);
385 }
386 }
387
Andreas Gampe94dda932017-02-09 18:19:21 -0800388 class RootUpdater : public art::RootVisitor {
389 public:
390 RootUpdater(const art::mirror::Class* input, art::mirror::Class* output)
391 : input_(input), output_(output) {}
392
393 void VisitRoots(art::mirror::Object*** roots,
394 size_t count,
395 const art::RootInfo& info ATTRIBUTE_UNUSED)
396 OVERRIDE {
397 for (size_t i = 0; i != count; ++i) {
398 if (*roots[i] == input_) {
399 *roots[i] = output_;
400 }
401 }
402 }
403
404 void VisitRoots(art::mirror::CompressedReference<art::mirror::Object>** roots,
405 size_t count,
406 const art::RootInfo& info ATTRIBUTE_UNUSED)
407 OVERRIDE REQUIRES_SHARED(art::Locks::mutator_lock_) {
408 for (size_t i = 0; i != count; ++i) {
409 if (roots[i]->AsMirrorPtr() == input_) {
410 roots[i]->Assign(output_);
411 }
412 }
413 }
414
415 private:
416 const art::mirror::Class* input_;
417 art::mirror::Class* output_;
418 };
419
Andreas Gampea67354b2017-02-10 16:18:30 -0800420 void FixupGlobalReferenceTables(art::mirror::Class* input, art::mirror::Class* output)
Andreas Gampe691051b2017-02-09 09:15:24 -0800421 REQUIRES(art::Locks::mutator_lock_) {
422 art::JavaVMExt* java_vm = art::Runtime::Current()->GetJavaVM();
423
424 // Fix up the global table with a root visitor.
Andreas Gampe94dda932017-02-09 18:19:21 -0800425 RootUpdater global_update(input, output);
Andreas Gampe691051b2017-02-09 09:15:24 -0800426 java_vm->VisitRoots(&global_update);
427
428 class WeakGlobalUpdate : public art::IsMarkedVisitor {
429 public:
430 WeakGlobalUpdate(art::mirror::Class* root_input, art::mirror::Class* root_output)
431 : input_(root_input), output_(root_output) {}
432
433 art::mirror::Object* IsMarked(art::mirror::Object* obj) OVERRIDE {
434 if (obj == input_) {
435 return output_;
436 }
437 return obj;
438 }
439
440 private:
441 const art::mirror::Class* input_;
442 art::mirror::Class* output_;
443 };
444 WeakGlobalUpdate weak_global_update(input, output);
445 java_vm->SweepJniWeakGlobals(&weak_global_update);
Andreas Gampee6377462017-01-20 17:37:50 -0800446 }
447
Andreas Gampe94dda932017-02-09 18:19:21 -0800448 void FixupLocalReferenceTables(art::Thread* self,
449 art::mirror::Class* input,
450 art::mirror::Class* output)
451 REQUIRES(art::Locks::mutator_lock_) {
452 class LocalUpdate {
453 public:
454 LocalUpdate(const art::mirror::Class* root_input, art::mirror::Class* root_output)
455 : input_(root_input), output_(root_output) {}
456
457 static void Callback(art::Thread* t, void* arg) REQUIRES(art::Locks::mutator_lock_) {
458 LocalUpdate* local = reinterpret_cast<LocalUpdate*>(arg);
459
460 // Fix up the local table with a root visitor.
461 RootUpdater local_update(local->input_, local->output_);
462 t->GetJniEnv()->locals.VisitRoots(
463 &local_update, art::RootInfo(art::kRootJNILocal, t->GetThreadId()));
464 }
465
466 private:
467 const art::mirror::Class* input_;
468 art::mirror::Class* output_;
469 };
470 LocalUpdate local_upd(input, output);
471 art::MutexLock mu(self, *art::Locks::thread_list_lock_);
472 art::Runtime::Current()->GetThreadList()->ForEach(LocalUpdate::Callback, &local_upd);
473 }
474
Andreas Gampea67354b2017-02-10 16:18:30 -0800475 void FixupHeap(art::mirror::Class* input, art::mirror::Class* output)
476 REQUIRES(art::Locks::mutator_lock_) {
477 class HeapFixupVisitor {
478 public:
479 HeapFixupVisitor(const art::mirror::Class* root_input, art::mirror::Class* root_output)
480 : input_(root_input), output_(root_output) {}
481
482 void operator()(art::mirror::Object* src,
483 art::MemberOffset field_offset,
484 bool is_static ATTRIBUTE_UNUSED) const
485 REQUIRES_SHARED(art::Locks::mutator_lock_) {
486 art::mirror::HeapReference<art::mirror::Object>* trg =
487 src->GetFieldObjectReferenceAddr(field_offset);
488 if (trg->AsMirrorPtr() == input_) {
489 DCHECK_NE(field_offset.Uint32Value(), 0u); // This shouldn't be the class field of
490 // an object.
491 trg->Assign(output_);
492 }
493 }
494
Andreas Gampe52784ac2017-02-13 18:10:09 -0800495 void operator()(art::ObjPtr<art::mirror::Class> klass ATTRIBUTE_UNUSED,
496 art::ObjPtr<art::mirror::Reference> reference) const
497 REQUIRES_SHARED(art::Locks::mutator_lock_) {
498 art::mirror::Object* val = reference->GetReferent();
499 if (val == input_) {
500 reference->SetReferent<false>(output_);
501 }
502 }
503
Andreas Gampea67354b2017-02-10 16:18:30 -0800504 void VisitRoot(art::mirror::CompressedReference<art::mirror::Object>* root ATTRIBUTE_UNUSED)
Andreas Gampe52784ac2017-02-13 18:10:09 -0800505 const {
Andreas Gampea67354b2017-02-10 16:18:30 -0800506 LOG(FATAL) << "Unreachable";
507 }
508
509 void VisitRootIfNonNull(
510 art::mirror::CompressedReference<art::mirror::Object>* root ATTRIBUTE_UNUSED) const {
511 LOG(FATAL) << "Unreachable";
512 }
513
514 static void AllObjectsCallback(art::mirror::Object* obj, void* arg)
515 REQUIRES_SHARED(art::Locks::mutator_lock_) {
516 HeapFixupVisitor* hfv = reinterpret_cast<HeapFixupVisitor*>(arg);
517
518 // Visit references, not native roots.
Andreas Gampe52784ac2017-02-13 18:10:09 -0800519 obj->VisitReferences<false>(*hfv, *hfv);
Andreas Gampea67354b2017-02-10 16:18:30 -0800520 }
521
522 private:
523 const art::mirror::Class* input_;
524 art::mirror::Class* output_;
525 };
526 HeapFixupVisitor hfv(input, output);
527 art::Runtime::Current()->GetHeap()->VisitObjectsPaused(HeapFixupVisitor::AllObjectsCallback,
528 &hfv);
529 }
530
Andreas Gampee6377462017-01-20 17:37:50 -0800531 // A set of all the temp classes we have handed out. We have to fix up references to these.
532 // For simplicity, we store the temp classes as JNI global references in a vector. Normally a
533 // Prepare event will closely follow, so the vector should be small.
534 std::mutex temp_classes_lock;
535 std::vector<jclass> temp_classes;
536
537 EventHandler* event_handler = nullptr;
538};
539
540ClassCallback gClassCallback;
541
542void ClassUtil::Register(EventHandler* handler) {
543 gClassCallback.event_handler = handler;
544 art::ScopedThreadStateChange stsc(art::Thread::Current(),
545 art::ThreadState::kWaitingForDebuggerToAttach);
546 art::ScopedSuspendAll ssa("Add load callback");
547 art::Runtime::Current()->GetRuntimeCallbacks()->AddClassLoadCallback(&gClassCallback);
548}
549
550void ClassUtil::Unregister() {
551 art::ScopedThreadStateChange stsc(art::Thread::Current(),
552 art::ThreadState::kWaitingForDebuggerToAttach);
553 art::ScopedSuspendAll ssa("Remove thread callback");
554 art::Runtime* runtime = art::Runtime::Current();
555 runtime->GetRuntimeCallbacks()->RemoveClassLoadCallback(&gClassCallback);
556}
557
Andreas Gampeac587272017-01-05 15:21:34 -0800558jvmtiError ClassUtil::GetClassFields(jvmtiEnv* env,
559 jclass jklass,
560 jint* field_count_ptr,
561 jfieldID** fields_ptr) {
562 art::ScopedObjectAccess soa(art::Thread::Current());
563 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
564 if (klass == nullptr) {
565 return ERR(INVALID_CLASS);
566 }
567
568 if (field_count_ptr == nullptr || fields_ptr == nullptr) {
569 return ERR(NULL_POINTER);
570 }
571
Andreas Gampeac587272017-01-05 15:21:34 -0800572 art::IterationRange<art::StrideIterator<art::ArtField>> ifields = klass->GetIFields();
573 art::IterationRange<art::StrideIterator<art::ArtField>> sfields = klass->GetSFields();
574 size_t array_size = klass->NumInstanceFields() + klass->NumStaticFields();
575
576 unsigned char* out_ptr;
577 jvmtiError allocError = env->Allocate(array_size * sizeof(jfieldID), &out_ptr);
578 if (allocError != ERR(NONE)) {
579 return allocError;
580 }
581 jfieldID* field_array = reinterpret_cast<jfieldID*>(out_ptr);
582
583 size_t array_idx = 0;
584 for (art::ArtField& field : sfields) {
585 field_array[array_idx] = art::jni::EncodeArtField(&field);
586 ++array_idx;
587 }
588 for (art::ArtField& field : ifields) {
589 field_array[array_idx] = art::jni::EncodeArtField(&field);
590 ++array_idx;
591 }
592
593 *field_count_ptr = static_cast<jint>(array_size);
594 *fields_ptr = field_array;
595
596 return ERR(NONE);
597}
598
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800599jvmtiError ClassUtil::GetClassMethods(jvmtiEnv* env,
600 jclass jklass,
601 jint* method_count_ptr,
602 jmethodID** methods_ptr) {
603 art::ScopedObjectAccess soa(art::Thread::Current());
604 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
605 if (klass == nullptr) {
606 return ERR(INVALID_CLASS);
607 }
608
609 if (method_count_ptr == nullptr || methods_ptr == nullptr) {
610 return ERR(NULL_POINTER);
611 }
612
613 size_t array_size = klass->NumDeclaredVirtualMethods() + klass->NumDirectMethods();
614 unsigned char* out_ptr;
615 jvmtiError allocError = env->Allocate(array_size * sizeof(jmethodID), &out_ptr);
616 if (allocError != ERR(NONE)) {
617 return allocError;
618 }
619 jmethodID* method_array = reinterpret_cast<jmethodID*>(out_ptr);
620
621 if (art::kIsDebugBuild) {
622 size_t count = 0;
623 for (auto& m ATTRIBUTE_UNUSED : klass->GetDeclaredMethods(art::kRuntimePointerSize)) {
624 count++;
625 }
626 CHECK_EQ(count, klass->NumDirectMethods() + klass->NumDeclaredVirtualMethods());
627 }
628
629 size_t array_idx = 0;
630 for (auto& m : klass->GetDeclaredMethods(art::kRuntimePointerSize)) {
631 method_array[array_idx] = art::jni::EncodeArtMethod(&m);
632 ++array_idx;
633 }
634
635 *method_count_ptr = static_cast<jint>(array_size);
636 *methods_ptr = method_array;
637
638 return ERR(NONE);
639}
640
Andreas Gampe8b07e472017-01-06 14:20:39 -0800641jvmtiError ClassUtil::GetImplementedInterfaces(jvmtiEnv* env,
642 jclass jklass,
643 jint* interface_count_ptr,
644 jclass** interfaces_ptr) {
645 art::ScopedObjectAccess soa(art::Thread::Current());
646 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
647 if (klass == nullptr) {
648 return ERR(INVALID_CLASS);
649 }
650
651 if (interface_count_ptr == nullptr || interfaces_ptr == nullptr) {
652 return ERR(NULL_POINTER);
653 }
654
655 // Need to handle array specifically. Arrays implement Serializable and Cloneable, but the
656 // spec says these should not be reported.
657 if (klass->IsArrayClass()) {
658 *interface_count_ptr = 0;
659 *interfaces_ptr = nullptr; // TODO: Should we allocate a dummy here?
660 return ERR(NONE);
661 }
662
663 size_t array_size = klass->NumDirectInterfaces();
664 unsigned char* out_ptr;
665 jvmtiError allocError = env->Allocate(array_size * sizeof(jclass), &out_ptr);
666 if (allocError != ERR(NONE)) {
667 return allocError;
668 }
669 jclass* interface_array = reinterpret_cast<jclass*>(out_ptr);
670
671 art::StackHandleScope<1> hs(soa.Self());
672 art::Handle<art::mirror::Class> h_klass(hs.NewHandle(klass));
673
674 for (uint32_t idx = 0; idx != array_size; ++idx) {
675 art::ObjPtr<art::mirror::Class> inf_klass =
676 art::mirror::Class::ResolveDirectInterface(soa.Self(), h_klass, idx);
677 if (inf_klass == nullptr) {
678 soa.Self()->ClearException();
679 env->Deallocate(out_ptr);
680 // TODO: What is the right error code here?
681 return ERR(INTERNAL);
682 }
683 interface_array[idx] = soa.AddLocalReference<jclass>(inf_klass);
684 }
685
686 *interface_count_ptr = static_cast<jint>(array_size);
687 *interfaces_ptr = interface_array;
688
689 return ERR(NONE);
690}
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800691
Andreas Gampee492ae32016-10-28 19:34:57 -0700692jvmtiError ClassUtil::GetClassSignature(jvmtiEnv* env,
693 jclass jklass,
694 char** signature_ptr,
695 char** generic_ptr) {
696 art::ScopedObjectAccess soa(art::Thread::Current());
697 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
698 if (klass == nullptr) {
699 return ERR(INVALID_CLASS);
700 }
701
Andreas Gampe54711412017-02-21 12:41:43 -0800702 JvmtiUniquePtr<char[]> sig_copy;
Andreas Gampee492ae32016-10-28 19:34:57 -0700703 if (signature_ptr != nullptr) {
704 std::string storage;
705 const char* descriptor = klass->GetDescriptor(&storage);
706
Andreas Gampe54711412017-02-21 12:41:43 -0800707 jvmtiError ret;
708 sig_copy = CopyString(env, descriptor, &ret);
709 if (sig_copy == nullptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700710 return ret;
711 }
Andreas Gampe54711412017-02-21 12:41:43 -0800712 *signature_ptr = sig_copy.get();
Andreas Gampee492ae32016-10-28 19:34:57 -0700713 }
714
Andreas Gampee6377462017-01-20 17:37:50 -0800715 if (generic_ptr != nullptr) {
716 *generic_ptr = nullptr;
Andreas Gampe0eb36432017-02-15 18:36:14 -0800717 if (!klass->IsProxyClass() && klass->GetDexCache() != nullptr) {
718 art::StackHandleScope<1> hs(soa.Self());
719 art::Handle<art::mirror::Class> h_klass = hs.NewHandle(klass);
720 art::mirror::ObjectArray<art::mirror::String>* str_array =
721 art::annotations::GetSignatureAnnotationForClass(h_klass);
722 if (str_array != nullptr) {
723 std::ostringstream oss;
724 for (int32_t i = 0; i != str_array->GetLength(); ++i) {
725 oss << str_array->Get(i)->ToModifiedUtf8();
726 }
727 std::string output_string = oss.str();
Andreas Gampe54711412017-02-21 12:41:43 -0800728 jvmtiError ret;
729 JvmtiUniquePtr<char[]> copy = CopyString(env, output_string.c_str(), &ret);
730 if (copy == nullptr) {
Andreas Gampe0eb36432017-02-15 18:36:14 -0800731 return ret;
732 }
Andreas Gampe54711412017-02-21 12:41:43 -0800733 *generic_ptr = copy.release();
Andreas Gampe0eb36432017-02-15 18:36:14 -0800734 } else if (soa.Self()->IsExceptionPending()) {
735 // TODO: Should we report an error here?
736 soa.Self()->ClearException();
737 }
738 }
Andreas Gampee6377462017-01-20 17:37:50 -0800739 }
Andreas Gampee492ae32016-10-28 19:34:57 -0700740
741 // Everything is fine, release the buffers.
742 sig_copy.release();
743
744 return ERR(NONE);
745}
746
Andreas Gampeff9d2092017-01-06 09:12:49 -0800747jvmtiError ClassUtil::GetClassStatus(jvmtiEnv* env ATTRIBUTE_UNUSED,
748 jclass jklass,
749 jint* status_ptr) {
750 art::ScopedObjectAccess soa(art::Thread::Current());
751 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
752 if (klass == nullptr) {
753 return ERR(INVALID_CLASS);
754 }
755
756 if (status_ptr == nullptr) {
757 return ERR(NULL_POINTER);
758 }
759
760 if (klass->IsArrayClass()) {
761 *status_ptr = JVMTI_CLASS_STATUS_ARRAY;
762 } else if (klass->IsPrimitive()) {
763 *status_ptr = JVMTI_CLASS_STATUS_PRIMITIVE;
764 } else {
765 *status_ptr = JVMTI_CLASS_STATUS_VERIFIED; // All loaded classes are structurally verified.
766 // This is finicky. If there's an error, we'll say it wasn't prepared.
767 if (klass->IsResolved()) {
768 *status_ptr |= JVMTI_CLASS_STATUS_PREPARED;
769 }
770 if (klass->IsInitialized()) {
771 *status_ptr |= JVMTI_CLASS_STATUS_INITIALIZED;
772 }
773 // Technically the class may be erroneous for other reasons, but we do not have enough info.
774 if (klass->IsErroneous()) {
775 *status_ptr |= JVMTI_CLASS_STATUS_ERROR;
776 }
777 }
778
779 return ERR(NONE);
780}
781
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800782template <typename T>
783static jvmtiError ClassIsT(jclass jklass, T test, jboolean* is_t_ptr) {
784 art::ScopedObjectAccess soa(art::Thread::Current());
785 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
786 if (klass == nullptr) {
787 return ERR(INVALID_CLASS);
788 }
789
790 if (is_t_ptr == nullptr) {
791 return ERR(NULL_POINTER);
792 }
793
794 *is_t_ptr = test(klass) ? JNI_TRUE : JNI_FALSE;
795 return ERR(NONE);
796}
797
798jvmtiError ClassUtil::IsInterface(jvmtiEnv* env ATTRIBUTE_UNUSED,
799 jclass jklass,
800 jboolean* is_interface_ptr) {
801 auto test = [](art::ObjPtr<art::mirror::Class> klass) REQUIRES_SHARED(art::Locks::mutator_lock_) {
802 return klass->IsInterface();
803 };
804 return ClassIsT(jklass, test, is_interface_ptr);
805}
806
807jvmtiError ClassUtil::IsArrayClass(jvmtiEnv* env ATTRIBUTE_UNUSED,
808 jclass jklass,
809 jboolean* is_array_class_ptr) {
810 auto test = [](art::ObjPtr<art::mirror::Class> klass) REQUIRES_SHARED(art::Locks::mutator_lock_) {
811 return klass->IsArrayClass();
812 };
813 return ClassIsT(jklass, test, is_array_class_ptr);
814}
815
Andreas Gampe64013e52017-01-06 13:07:19 -0800816// Keep this in sync with Class.getModifiers().
817static uint32_t ClassGetModifiers(art::Thread* self, art::ObjPtr<art::mirror::Class> klass)
818 REQUIRES_SHARED(art::Locks::mutator_lock_) {
819 if (klass->IsArrayClass()) {
820 uint32_t component_modifiers = ClassGetModifiers(self, klass->GetComponentType());
821 if ((component_modifiers & art::kAccInterface) != 0) {
822 component_modifiers &= ~(art::kAccInterface | art::kAccStatic);
823 }
824 return art::kAccAbstract | art::kAccFinal | component_modifiers;
825 }
826
827 uint32_t modifiers = klass->GetAccessFlags() & art::kAccJavaFlagsMask;
828
829 art::StackHandleScope<1> hs(self);
830 art::Handle<art::mirror::Class> h_klass(hs.NewHandle(klass));
831 return art::mirror::Class::GetInnerClassFlags(h_klass, modifiers);
832}
833
834jvmtiError ClassUtil::GetClassModifiers(jvmtiEnv* env ATTRIBUTE_UNUSED,
835 jclass jklass,
836 jint* modifiers_ptr) {
837 art::ScopedObjectAccess soa(art::Thread::Current());
838 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
839 if (klass == nullptr) {
840 return ERR(INVALID_CLASS);
841 }
842
843 if (modifiers_ptr == nullptr) {
844 return ERR(NULL_POINTER);
845 }
846
847 *modifiers_ptr = ClassGetModifiers(soa.Self(), klass);
848
849 return ERR(NONE);
850}
851
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800852jvmtiError ClassUtil::GetClassLoader(jvmtiEnv* env ATTRIBUTE_UNUSED,
853 jclass jklass,
854 jobject* classloader_ptr) {
855 art::ScopedObjectAccess soa(art::Thread::Current());
856 art::ObjPtr<art::mirror::Class> klass = soa.Decode<art::mirror::Class>(jklass);
857 if (klass == nullptr) {
858 return ERR(INVALID_CLASS);
859 }
860
861 if (classloader_ptr == nullptr) {
862 return ERR(NULL_POINTER);
863 }
864
865 *classloader_ptr = soa.AddLocalReference<jobject>(klass->GetClassLoader());
866
867 return ERR(NONE);
868}
869
Andreas Gampe70f16392017-01-16 14:20:10 -0800870jvmtiError ClassUtil::GetClassLoaderClasses(jvmtiEnv* env,
871 jobject initiating_loader,
872 jint* class_count_ptr,
873 jclass** classes_ptr) {
874 UNUSED(env, initiating_loader, class_count_ptr, classes_ptr);
875
876 if (class_count_ptr == nullptr || classes_ptr == nullptr) {
877 return ERR(NULL_POINTER);
878 }
879 art::Thread* self = art::Thread::Current();
880 if (!self->GetJniEnv()->IsInstanceOf(initiating_loader,
881 art::WellKnownClasses::java_lang_ClassLoader)) {
882 return ERR(ILLEGAL_ARGUMENT);
883 }
884 if (self->GetJniEnv()->IsInstanceOf(initiating_loader,
885 art::WellKnownClasses::java_lang_BootClassLoader)) {
886 // Need to use null for the BootClassLoader.
887 initiating_loader = nullptr;
888 }
889
890 art::ScopedObjectAccess soa(self);
891 art::ObjPtr<art::mirror::ClassLoader> class_loader =
892 soa.Decode<art::mirror::ClassLoader>(initiating_loader);
893
894 art::ClassLinker* class_linker = art::Runtime::Current()->GetClassLinker();
895
896 art::ReaderMutexLock mu(self, *art::Locks::classlinker_classes_lock_);
897
898 art::ClassTable* class_table = class_linker->ClassTableForClassLoader(class_loader);
899 if (class_table == nullptr) {
900 // Nothing loaded.
901 *class_count_ptr = 0;
902 *classes_ptr = nullptr;
903 return ERR(NONE);
904 }
905
906 struct ClassTableCount {
907 bool operator()(art::ObjPtr<art::mirror::Class> klass) {
908 DCHECK(klass != nullptr);
909 ++count;
910 return true;
911 }
912
913 size_t count = 0;
914 };
915 ClassTableCount ctc;
916 class_table->Visit(ctc);
917
918 if (ctc.count == 0) {
919 // Nothing loaded.
920 *class_count_ptr = 0;
921 *classes_ptr = nullptr;
922 return ERR(NONE);
923 }
924
925 unsigned char* data;
926 jvmtiError data_result = env->Allocate(ctc.count * sizeof(jclass), &data);
927 if (data_result != ERR(NONE)) {
928 return data_result;
929 }
930 jclass* class_array = reinterpret_cast<jclass*>(data);
931
932 struct ClassTableFill {
933 bool operator()(art::ObjPtr<art::mirror::Class> klass)
934 REQUIRES_SHARED(art::Locks::mutator_lock_) {
935 DCHECK(klass != nullptr);
936 DCHECK_LT(count, ctc_ref.count);
937 local_class_array[count++] = soa_ptr->AddLocalReference<jclass>(klass);
938 return true;
939 }
940
941 jclass* local_class_array;
942 const ClassTableCount& ctc_ref;
943 art::ScopedObjectAccess* soa_ptr;
944 size_t count;
945 };
946 ClassTableFill ctf = { class_array, ctc, &soa, 0 };
947 class_table->Visit(ctf);
948 DCHECK_EQ(ctc.count, ctf.count);
949
950 *class_count_ptr = ctc.count;
951 *classes_ptr = class_array;
952
953 return ERR(NONE);
954}
955
Andreas Gampe812a2442017-01-19 22:04:46 -0800956jvmtiError ClassUtil::GetClassVersionNumbers(jvmtiEnv* env ATTRIBUTE_UNUSED,
957 jclass jklass,
958 jint* minor_version_ptr,
959 jint* major_version_ptr) {
960 art::ScopedObjectAccess soa(art::Thread::Current());
961 if (jklass == nullptr) {
962 return ERR(INVALID_CLASS);
963 }
964 art::ObjPtr<art::mirror::Object> jklass_obj = soa.Decode<art::mirror::Object>(jklass);
965 if (!jklass_obj->IsClass()) {
966 return ERR(INVALID_CLASS);
967 }
968 art::ObjPtr<art::mirror::Class> klass = jklass_obj->AsClass();
969 if (klass->IsPrimitive() || klass->IsArrayClass()) {
970 return ERR(INVALID_CLASS);
971 }
972
973 if (minor_version_ptr == nullptr || major_version_ptr == nullptr) {
974 return ERR(NULL_POINTER);
975 }
976
977 // Note: proxies will show the dex file version of java.lang.reflect.Proxy, as that is
978 // what their dex cache copies from.
979 uint32_t version = klass->GetDexFile().GetHeader().GetVersion();
980
981 *major_version_ptr = static_cast<jint>(version);
982 *minor_version_ptr = 0;
983
984 return ERR(NONE);
985}
986
Andreas Gampee492ae32016-10-28 19:34:57 -0700987} // namespace openjdkjvmti