1 /*
2 * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef _JAVASOFT_JVM_H_
27 #define _JAVASOFT_JVM_H_
28
29 #include <sys/stat.h>
30
31 #include "jni.h"
32 #include "jvm_constants.h"
33 #include "jvm_io.h"
34 #include "jvm_md.h"
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /*
41 * This file contains additional functions exported from the VM.
42 * These functions are complementary to the standard JNI support.
43 * There are three parts to this file:
44 *
45 * First, this file contains the VM-related functions needed by native
46 * libraries in the standard Java API. For example, the java.lang.Object
47 * class needs VM-level functions that wait for and notify monitors.
48 *
49 * Second, (included from jvm_constants.h) constant definitions
50 * needed by the byte code verifier and class file format checker.
51 * These definitions allow the verifier and format checker to be written
52 * in a VM-independent way.
53 *
54 * Third, this file contains various I/O and network operations needed
55 * by the standard Java I/O and network APIs. A part of these APIs,
56 * namely the jio_xxxprintf functions, are included from jvm_io.h.
57 */
58
59
60 /*************************************************************************
61 PART 1: Functions for Native Libraries
62 ************************************************************************/
63 /*
64 * java.lang.Object
65 */
66 JNIEXPORT jint JNICALL
67 JVM_IHashCode(JNIEnv *env, jobject obj);
68
69 JNIEXPORT void JNICALL
70 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
71
72 JNIEXPORT void JNICALL
73 JVM_MonitorNotify(JNIEnv *env, jobject obj);
74
75 JNIEXPORT void JNICALL
76 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
77
78 JNIEXPORT jobject JNICALL
79 JVM_Clone(JNIEnv *env, jobject obj);
80
81 /*
82 * java.lang.String
83 */
84 JNIEXPORT jstring JNICALL
85 JVM_InternString(JNIEnv *env, jstring str);
86
87 /*
88 * java.lang.System
89 */
90 JNIEXPORT jboolean JNICALL
91 JVM_AOTIsTraining(JNIEnv *env);
92
93 JNIEXPORT jboolean JNICALL
94 JVM_AOTEndTraining(JNIEnv *env);
95
96 JNIEXPORT jstring JNICALL
97 JVM_AOTGetMode(JNIEnv *env);
98
99 JNIEXPORT jlong JNICALL
100 JVM_AOTGetRecordingDuration(JNIEnv *env);
101
102 JNIEXPORT jlong JNICALL
103 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
104
105 JNIEXPORT jlong JNICALL
106 JVM_NanoTime(JNIEnv *env, jclass ignored);
107
108 JNIEXPORT jlong JNICALL
109 JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
110
111 JNIEXPORT void JNICALL
112 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
113 jobject dst, jint dst_pos, jint length);
114
115 /*
116 * Return an array of all properties as alternating name and value pairs.
117 */
118 JNIEXPORT jobjectArray JNICALL
119 JVM_GetProperties(JNIEnv *env);
120
121 /*
122 * java.lang.Runtime
123 */
124 JNIEXPORT void JNICALL
125 JVM_BeforeHalt();
126
127 JNIEXPORT void JNICALL
128 JVM_Halt(jint code);
129
130 JNIEXPORT void JNICALL
131 JVM_GC(void);
132
133 /* Returns the number of real-time milliseconds that have elapsed since the
134 * least-recently-inspected heap object was last inspected by the garbage
135 * collector.
136 *
137 * For simple stop-the-world collectors this value is just the time
138 * since the most recent collection. For generational collectors it is the
139 * time since the oldest generation was most recently collected. Other
140 * collectors are free to return a pessimistic estimate of the elapsed time, or
141 * simply the time since the last full collection was performed.
142 *
143 * Note that in the presence of reference objects, a given object that is no
144 * longer strongly reachable may have to be inspected multiple times before it
145 * can be reclaimed.
146 */
147 JNIEXPORT jlong JNICALL
148 JVM_MaxObjectInspectionAge(void);
149
150 JNIEXPORT jlong JNICALL
151 JVM_TotalMemory(void);
152
153 JNIEXPORT jlong JNICALL
154 JVM_FreeMemory(void);
155
156 JNIEXPORT jlong JNICALL
157 JVM_MaxMemory(void);
158
159 JNIEXPORT jint JNICALL
160 JVM_ActiveProcessorCount(void);
161
162 JNIEXPORT jboolean JNICALL
163 JVM_IsUseContainerSupport(void);
164
165 JNIEXPORT jboolean JNICALL
166 JVM_IsContainerized(void);
167
168 JNIEXPORT void * JNICALL
169 JVM_LoadZipLibrary();
170
171 JNIEXPORT void * JNICALL
172 JVM_LoadLibrary(const char *name, jboolean throwException);
173
174 JNIEXPORT void JNICALL
175 JVM_UnloadLibrary(void * handle);
176
177 JNIEXPORT void * JNICALL
178 JVM_FindLibraryEntry(void *handle, const char *name);
179
180 JNIEXPORT jboolean JNICALL
181 JVM_IsSupportedJNIVersion(jint version);
182
183 JNIEXPORT jobjectArray JNICALL
184 JVM_GetVmArguments(JNIEnv *env);
185
186 JNIEXPORT jboolean JNICALL
187 JVM_IsPreviewEnabled(void);
188
189 JNIEXPORT jboolean JNICALL
190 JVM_IsContinuationsSupported(void);
191
192 JNIEXPORT jboolean JNICALL
193 JVM_IsForeignLinkerSupported(void);
194
195 JNIEXPORT jboolean JNICALL
196 JVM_IsStaticallyLinked(void);
197
198 JNIEXPORT void JNICALL
199 JVM_InitializeFromArchive(JNIEnv* env, jclass cls);
200
201 JNIEXPORT void JNICALL
202 JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env, jclass caller,
203 jstring interfaceMethodName,
204 jobject factoryType,
205 jobject interfaceMethodType,
206 jobject implementationMember,
207 jobject dynamicMethodType,
208 jclass lambdaProxyClass);
209
210 JNIEXPORT jclass JNICALL
211 JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jclass caller,
212 jstring interfaceMethodName,
213 jobject factoryType,
214 jobject interfaceMethodType,
215 jobject implementationMember,
216 jobject dynamicMethodType);
217
218 JNIEXPORT jint JNICALL
219 JVM_GetCDSConfigStatus();
220
221 JNIEXPORT jlong JNICALL
222 JVM_GetRandomSeedForDumping();
223
224 JNIEXPORT void JNICALL
225 JVM_LogLambdaFormInvoker(JNIEnv* env, jstring line);
226
227 JNIEXPORT void JNICALL
228 JVM_LogDynamicProxy(JNIEnv *env, jobject loader, jstring proxy_name, jobjectArray interfaces, jint accessFlags);
229
230 JNIEXPORT void JNICALL
231 JVM_DumpClassListToFile(JNIEnv* env, jstring fileName);
232
233 JNIEXPORT void JNICALL
234 JVM_DumpDynamicArchive(JNIEnv* env, jstring archiveName);
235
236 JNIEXPORT jboolean JNICALL
237 JVM_NeedsClassInitBarrierForCDS(JNIEnv* env, jclass cls);
238
239 /*
240 * java.lang.Throwable
241 */
242 JNIEXPORT void JNICALL
243 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
244
245 /*
246 * java.lang.StackTraceElement
247 */
248 JNIEXPORT void JNICALL
249 JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject backtrace, jint depth);
250
251 JNIEXPORT void JNICALL
252 JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
253
254 /*
255 * java.lang.NullPointerException
256 */
257
258 JNIEXPORT jstring JNICALL
259 JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable);
260
261 /*
262 * java.lang.StackWalker
263 */
264 enum {
265 JVM_STACKWALK_CLASS_INFO_ONLY = 0x2,
266 JVM_STACKWALK_SHOW_HIDDEN_FRAMES = 0x20,
267 JVM_STACKWALK_FILL_LIVE_STACK_FRAMES = 0x100
268 };
269
270 JNIEXPORT void JNICALL
271 JVM_ExpandStackFrameInfo(JNIEnv *env, jobject obj);
272
273 JNIEXPORT jobject JNICALL
274 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jint mode,
275 jint skip_frames, jobject contScope, jobject cont,
276 jint buffer_size, jint start_index, jobjectArray frames);
277
278 JNIEXPORT jint JNICALL
279 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jint mode, jlong anchor,
280 jint last_batch_count, jint buffer_size, jint start_index,
281 jobjectArray frames);
282
283 JNIEXPORT void JNICALL
284 JVM_SetStackWalkContinuation(JNIEnv *env, jobject stackStream, jlong anchor, jobjectArray frames, jobject cont);
285
286 /*
287 * java.lang.Thread
288 */
289 JNIEXPORT void JNICALL
290 JVM_StartThread(JNIEnv *env, jobject thread);
291
292 JNIEXPORT void JNICALL
293 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
294
295 JNIEXPORT void JNICALL
296 JVM_Yield(JNIEnv *env, jclass threadClass);
297
298 JNIEXPORT void JNICALL
299 JVM_SleepNanos(JNIEnv *env, jclass threadClass, jlong nanos);
300
301 JNIEXPORT jobject JNICALL
302 JVM_CurrentCarrierThread(JNIEnv *env, jclass threadClass);
303
304 JNIEXPORT jobject JNICALL
305 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
306
307 JNIEXPORT void JNICALL
308 JVM_SetCurrentThread(JNIEnv *env, jobject thisThread, jobject theThread);
309
310 JNIEXPORT void JNICALL
311 JVM_Interrupt(JNIEnv *env, jobject thread);
312
313 JNIEXPORT jboolean JNICALL
314 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
315
316 JNIEXPORT jobject JNICALL
317 JVM_GetStackTrace(JNIEnv *env, jobject thread);
318
319 JNIEXPORT jobject JNICALL
320 JVM_CreateThreadSnapshot(JNIEnv* env, jobject thread);
321
322 JNIEXPORT jobjectArray JNICALL
323 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
324
325 JNIEXPORT void JNICALL
326 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
327
328 /* getStackTrace() and getAllStackTraces() method */
329 JNIEXPORT jobjectArray JNICALL
330 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
331
332 JNIEXPORT jobject JNICALL
333 JVM_ScopedValueCache(JNIEnv *env, jclass threadClass);
334
335 JNIEXPORT void JNICALL
336 JVM_SetScopedValueCache(JNIEnv *env, jclass threadClass, jobject theCache);
337
338 JNIEXPORT jobject JNICALL
339 JVM_FindScopedValueBindings(JNIEnv *env, jclass threadClass);
340
341 JNIEXPORT jlong JNICALL
342 JVM_GetNextThreadIdOffset(JNIEnv *env, jclass threadClass);
343
344 /*
345 * jdk.internal.vm.Continuation
346 */
347 JNIEXPORT void JNICALL
348 JVM_RegisterContinuationMethods(JNIEnv *env, jclass cls);
349
350 /*
351 * java.lang.Package
352 */
353 JNIEXPORT jstring JNICALL
354 JVM_GetSystemPackage(JNIEnv *env, jstring name);
355
356 JNIEXPORT jobjectArray JNICALL
357 JVM_GetSystemPackages(JNIEnv *env);
358
359 /*
360 * java.lang.ref.Reference
361 */
362 JNIEXPORT jobject JNICALL
363 JVM_GetAndClearReferencePendingList(JNIEnv *env);
364
365 JNIEXPORT jboolean JNICALL
366 JVM_HasReferencePendingList(JNIEnv *env);
367
368 JNIEXPORT void JNICALL
369 JVM_WaitForReferencePendingList(JNIEnv *env);
370
371 JNIEXPORT jobject JNICALL
372 JVM_ReferenceGet(JNIEnv *env, jobject ref);
373
374 JNIEXPORT jboolean JNICALL
375 JVM_ReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
376
377 JNIEXPORT void JNICALL
378 JVM_ReferenceClear(JNIEnv *env, jobject ref);
379
380 /*
381 * java.lang.ref.PhantomReference
382 */
383 JNIEXPORT jboolean JNICALL
384 JVM_PhantomReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
385
386 /*
387 * java.io.ObjectInputStream
388 */
389 JNIEXPORT jobject JNICALL
390 JVM_LatestUserDefinedLoader(JNIEnv *env);
391
392 /*
393 * java.lang.reflect.Array
394 */
395 JNIEXPORT jint JNICALL
396 JVM_GetArrayLength(JNIEnv *env, jobject arr);
397
398 JNIEXPORT jobject JNICALL
399 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
400
401 JNIEXPORT jvalue JNICALL
402 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
403
404 JNIEXPORT void JNICALL
405 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
406
407 JNIEXPORT void JNICALL
408 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
409 unsigned char vCode);
410
411 JNIEXPORT jobject JNICALL
412 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
413
414 JNIEXPORT jobject JNICALL
415 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
416
417
418 /*
419 * Returns the immediate caller class of the native method invoking
420 * JVM_GetCallerClass. The Method.invoke and other frames due to
421 * reflection machinery are skipped.
422 *
423 * The caller is expected to be marked with
424 * jdk.internal.reflect.CallerSensitive. The JVM will throw an
425 * error if it is not marked properly.
426 */
427 JNIEXPORT jclass JNICALL
428 JVM_GetCallerClass(JNIEnv *env);
429
430
431 /*
432 * Find primitive classes
433 * utf: class name
434 */
435 JNIEXPORT jclass JNICALL
436 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
437
438
439 /*
440 * Find a class from a boot class loader. Returns null if class not found.
441 */
442 JNIEXPORT jclass JNICALL
443 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
444
445 /*
446 * Find a class from a given class loader. Throws ClassNotFoundException.
447 * name: name of class
448 * init: whether initialization is done
449 * loader: class loader to look up the class. This may not be the same as the caller's
450 * class loader.
451 * caller: initiating class. The initiating class may be null when a security
452 * manager is not installed.
453 */
454 JNIEXPORT jclass JNICALL
455 JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
456 jobject loader, jclass caller);
457
458 /*
459 * Find a class from a given class.
460 */
461 JNIEXPORT jclass JNICALL
462 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
463 jclass from);
464
465 /* Find a loaded class cached by the VM */
466 JNIEXPORT jclass JNICALL
467 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
468
469 /* Define a class */
470 JNIEXPORT jclass JNICALL
471 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
472 jsize len, jobject pd);
473
474 /* Define a class with a source (added in JDK1.5) */
475 JNIEXPORT jclass JNICALL
476 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
477 const jbyte *buf, jsize len, jobject pd,
478 const char *source);
479
480 /*
481 * Define a class with the specified lookup class.
482 * lookup: Lookup class
483 * name: the name of the class
484 * buf: class bytes
485 * len: length of class bytes
486 * pd: protection domain
487 * init: initialize the class
488 * flags: properties of the class
489 * classData: private static pre-initialized field; may be null
490 */
491 JNIEXPORT jclass JNICALL
492 JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf,
493 jsize len, jobject pd, jboolean init, int flags, jobject classData);
494
495 /*
496 * Module support functions
497 */
498
499 /*
500 * Define a module with the specified packages and bind the module to the
501 * given class loader.
502 * module: module to define
503 * is_open: specifies if module is open (currently ignored)
504 * version: the module version
505 * location: the module location
506 * packages: array of packages in the module
507 */
508 JNIEXPORT void JNICALL
509 JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
510 jstring location, jobjectArray packages);
511
512 /*
513 * Set the boot loader's unnamed module.
514 * module: boot loader's unnamed module
515 */
516 JNIEXPORT void JNICALL
517 JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
518
519 /*
520 * Do a qualified export of a package.
521 * from_module: module containing the package to export
522 * package: name of the package to export
523 * to_module: module to export the package to
524 */
525 JNIEXPORT void JNICALL
526 JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
527
528 /*
529 * Do an export of a package to all unnamed modules.
530 * from_module: module containing the package to export
531 * package: name of the package to export to all unnamed modules
532 */
533 JNIEXPORT void JNICALL
534 JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, jstring package);
535
536 /*
537 * Do an unqualified export of a package.
538 * from_module: module containing the package to export
539 * package: name of the package to export
540 */
541 JNIEXPORT void JNICALL
542 JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, jstring package);
543
544 /*
545 * Add a module to the list of modules that a given module can read.
546 * from_module: module requesting read access
547 * source_module: module that from_module wants to read
548 */
549 JNIEXPORT void JNICALL
550 JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
551
552 /*
553 * Define all modules that have been stored in the CDS archived heap.
554 * platform_loader: the built-in platform class loader
555 * system_loader: the built-in system class loader
556 */
557 JNIEXPORT void JNICALL
558 JVM_DefineArchivedModules(JNIEnv *env, jobject platform_loader, jobject system_loader);
559
560 /*
561 * Reflection support functions
562 */
563
564 JNIEXPORT jstring JNICALL
565 JVM_InitClassName(JNIEnv *env, jclass cls);
566
567 JNIEXPORT jobjectArray JNICALL
568 JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
569
570 JNIEXPORT jboolean JNICALL
571 JVM_IsInterface(JNIEnv *env, jclass cls);
572
573 JNIEXPORT jboolean JNICALL
574 JVM_IsHiddenClass(JNIEnv *env, jclass cls);
575
576 JNIEXPORT jobjectArray JNICALL
577 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
578
579 JNIEXPORT jclass JNICALL
580 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
581
582 JNIEXPORT jstring JNICALL
583 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
584
585 /* Generics support (JDK 1.5) */
586 JNIEXPORT jstring JNICALL
587 JVM_GetClassSignature(JNIEnv *env, jclass cls);
588
589 /* Annotations support (JDK 1.5) */
590 JNIEXPORT jbyteArray JNICALL
591 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
592
593 /* Type use annotations support (JDK 1.8) */
594
595 JNIEXPORT jbyteArray JNICALL
596 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
597
598 JNIEXPORT jbyteArray JNICALL
599 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
600
601 JNIEXPORT jbyteArray JNICALL
602 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
603
604 /*
605 * New (JDK 1.4) reflection implementation
606 */
607
608 JNIEXPORT jobjectArray JNICALL
609 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
610
611 JNIEXPORT jobjectArray JNICALL
612 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
613
614 JNIEXPORT jobjectArray JNICALL
615 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
616
617 /* Nestmates - since JDK 11 */
618
619 JNIEXPORT jboolean JNICALL
620 JVM_AreNestMates(JNIEnv *env, jclass current, jclass member);
621
622 JNIEXPORT jclass JNICALL
623 JVM_GetNestHost(JNIEnv *env, jclass current);
624
625 JNIEXPORT jobjectArray JNICALL
626 JVM_GetNestMembers(JNIEnv *env, jclass current);
627
628 /* Records - since JDK 16 */
629
630 JNIEXPORT jboolean JNICALL
631 JVM_IsRecord(JNIEnv *env, jclass cls);
632
633 JNIEXPORT jobjectArray JNICALL
634 JVM_GetRecordComponents(JNIEnv *env, jclass ofClass);
635
636 /* Sealed classes - since JDK 17 */
637
638 JNIEXPORT jobjectArray JNICALL
639 JVM_GetPermittedSubclasses(JNIEnv *env, jclass current);
640
641 /* The following two reflection routines are still needed due to startup time issues */
642 /*
643 * java.lang.reflect.Method
644 */
645 JNIEXPORT jobject JNICALL
646 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
647
648 /*
649 * java.lang.reflect.Constructor
650 */
651 JNIEXPORT jobject JNICALL
652 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
653
654 /*
655 * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
656 */
657
658 JNIEXPORT jobject JNICALL
659 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
660
661 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
662 (JNIEnv *env, jobject jcpool);
663
664 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
665 (JNIEnv *env, jobject jcpool, jint index);
666
667 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
668 (JNIEnv *env, jobject jcpool, jint index);
669
670 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
671 (JNIEnv *env, jobject jcpool, jint index);
672
673 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
674 (JNIEnv *env, jobject jcpool, jint index);
675
676 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
677 (JNIEnv *env, jobject jcpool, jint index);
678
679 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
680 (JNIEnv *env, jobject jcpool, jint index);
681
682 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
683 (JNIEnv *env, jobject jcpool, jint index);
684
685 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
686 (JNIEnv *env, jobject jcpool, jint index);
687
688 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
689 (JNIEnv *env, jobject jcpool, jint index);
690
691 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
692 (JNIEnv *env, jobject jcpool, jint index);
693
694 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
695 (JNIEnv *env, jobject jcpool, jint index);
696
697 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
698 (JNIEnv *env, jobject jcpool, jint index);
699
700 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
701 (JNIEnv *env, jobject jcpool, jint index);
702
703 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
704 (JNIEnv *env, jobject jcpool, jint index);
705
706 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
707 (JNIEnv *env, jobject jcpool, jint index);
708
709 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
710 (JNIEnv *env, jobject jcpool, jint index);
711
712 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
713 (JNIEnv *env, jobject jcpool, jint index);
714
715 /*
716 * Parameter reflection
717 */
718
719 JNIEXPORT jobjectArray JNICALL
720 JVM_GetMethodParameters(JNIEnv *env, jobject method);
721
722 /*
723 * Ensure that code doing a stackwalk and using javaVFrame::locals() to
724 * get the value will see a materialized value and not a scalar-replaced
725 * null value.
726 */
727 #define JVM_EnsureMaterializedForStackWalk(env, value) \
728 do {} while(0) // Nothing to do. The fact that the value escaped
729 // through a native method is enough.
730 JNIEXPORT void JNICALL
731 JVM_EnsureMaterializedForStackWalk_func(JNIEnv* env, jobject vthread, jobject value);
732
733 /*
734 * Signal support, used to implement the shutdown sequence. Every VM must
735 * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
736 * (^C) and the latter for external termination (kill, system shutdown, etc.).
737 * Other platform-dependent signal values may also be supported.
738 */
739
740 JNIEXPORT void * JNICALL
741 JVM_RegisterSignal(jint sig, void *handler);
742
743 JNIEXPORT jboolean JNICALL
744 JVM_RaiseSignal(jint sig);
745
746 JNIEXPORT jint JNICALL
747 JVM_FindSignal(const char *name);
748
749 /*
750 * Retrieve the assertion directives for the specified class.
751 */
752 JNIEXPORT jboolean JNICALL
753 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
754
755 /*
756 * Retrieve the assertion directives from the VM.
757 */
758 JNIEXPORT jobject JNICALL
759 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
760
761 /*
762 * java.lang.ref.Finalizer
763 */
764 JNIEXPORT void JNICALL
765 JVM_ReportFinalizationComplete(JNIEnv *env, jobject finalizee);
766
767 JNIEXPORT jboolean JNICALL
768 JVM_IsFinalizationEnabled(JNIEnv *env);
769
770 /*************************************************************************
771 PART 2: Support for the Verifier and Class File Format Checker
772 ************************************************************************/
773 /*
774 * Return the class name in UTF format. The result is valid
775 * until JVM_ReleaseUTf is called.
776 *
777 * The caller must treat the string as a constant and not modify it
778 * in any way.
779 */
780 JNIEXPORT const char * JNICALL
781 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
782
783 /*
784 * Returns the constant pool types in the buffer provided by "types."
785 */
786 JNIEXPORT void JNICALL
787 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
788
789 /*
790 * Returns the number of Constant Pool entries.
791 */
792 JNIEXPORT jint JNICALL
793 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
794
795 /*
796 * Returns the number of *declared* fields or methods.
797 */
798 JNIEXPORT jint JNICALL
799 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
800
801 JNIEXPORT jint JNICALL
802 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
803
804 /*
805 * Returns the CP indexes of exceptions raised by a given method.
806 * Places the result in the given buffer.
807 *
808 * The method is identified by method_index.
809 */
810 JNIEXPORT void JNICALL
811 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
812 unsigned short *exceptions);
813 /*
814 * Returns the number of exceptions raised by a given method.
815 * The method is identified by method_index.
816 */
817 JNIEXPORT jint JNICALL
818 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
819
820 /*
821 * Returns the byte code sequence of a given method.
822 * Places the result in the given buffer.
823 *
824 * The method is identified by method_index.
825 */
826 JNIEXPORT void JNICALL
827 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
828 unsigned char *code);
829
830 /*
831 * Returns the length of the byte code sequence of a given method.
832 * The method is identified by method_index.
833 */
834 JNIEXPORT jint JNICALL
835 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
836
837 /*
838 * A structure used to a capture exception table entry in a Java method.
839 */
840 typedef struct {
841 jint start_pc;
842 jint end_pc;
843 jint handler_pc;
844 jint catchType;
845 } JVM_ExceptionTableEntryType;
846
847 /*
848 * Returns the exception table entry at entry_index of a given method.
849 * Places the result in the given buffer.
850 *
851 * The method is identified by method_index.
852 */
853 JNIEXPORT void JNICALL
854 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
855 jint entry_index,
856 JVM_ExceptionTableEntryType *entry);
857
858 /*
859 * Returns the length of the exception table of a given method.
860 * The method is identified by method_index.
861 */
862 JNIEXPORT jint JNICALL
863 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
864
865 /*
866 * Returns the modifiers of a given field.
867 * The field is identified by field_index.
868 */
869 JNIEXPORT jint JNICALL
870 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
871
872 /*
873 * Returns the modifiers of a given method.
874 * The method is identified by method_index.
875 */
876 JNIEXPORT jint JNICALL
877 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
878
879 /*
880 * Returns the number of local variables of a given method.
881 * The method is identified by method_index.
882 */
883 JNIEXPORT jint JNICALL
884 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
885
886 /*
887 * Returns the number of arguments (including this pointer) of a given method.
888 * The method is identified by method_index.
889 */
890 JNIEXPORT jint JNICALL
891 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
892
893 /*
894 * Returns the maximum amount of stack (in words) used by a given method.
895 * The method is identified by method_index.
896 */
897 JNIEXPORT jint JNICALL
898 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
899
900 /*
901 * Is a given method a constructor.
902 * The method is identified by method_index.
903 */
904 JNIEXPORT jboolean JNICALL
905 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
906
907 /*
908 * Is the given method generated by the VM.
909 * The method is identified by method_index.
910 */
911 JNIEXPORT jboolean JNICALL
912 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
913
914 /*
915 * Returns the name of a given method in UTF format.
916 * The result remains valid until JVM_ReleaseUTF is called.
917 *
918 * The caller must treat the string as a constant and not modify it
919 * in any way.
920 */
921 JNIEXPORT const char * JNICALL
922 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
923
924 /*
925 * Returns the signature of a given method in UTF format.
926 * The result remains valid until JVM_ReleaseUTF is called.
927 *
928 * The caller must treat the string as a constant and not modify it
929 * in any way.
930 */
931 JNIEXPORT const char * JNICALL
932 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
933
934 /*
935 * Returns the name of the field referred to at a given constant pool
936 * index.
937 *
938 * The result is in UTF format and remains valid until JVM_ReleaseUTF
939 * is called.
940 *
941 * The caller must treat the string as a constant and not modify it
942 * in any way.
943 */
944 JNIEXPORT const char * JNICALL
945 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
946
947 /*
948 * Returns the name of the method referred to at a given constant pool
949 * index.
950 *
951 * The result is in UTF format and remains valid until JVM_ReleaseUTF
952 * is called.
953 *
954 * The caller must treat the string as a constant and not modify it
955 * in any way.
956 */
957 JNIEXPORT const char * JNICALL
958 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
959
960 /*
961 * Returns the signature of the method referred to at a given constant pool
962 * index.
963 *
964 * The result is in UTF format and remains valid until JVM_ReleaseUTF
965 * is called.
966 *
967 * The caller must treat the string as a constant and not modify it
968 * in any way.
969 */
970 JNIEXPORT const char * JNICALL
971 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
972
973 /*
974 * Returns the signature of the field referred to at a given constant pool
975 * index.
976 *
977 * The result is in UTF format and remains valid until JVM_ReleaseUTF
978 * is called.
979 *
980 * The caller must treat the string as a constant and not modify it
981 * in any way.
982 */
983 JNIEXPORT const char * JNICALL
984 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
985
986 /*
987 * Returns the class name referred to at a given constant pool index.
988 *
989 * The result is in UTF format and remains valid until JVM_ReleaseUTF
990 * is called.
991 *
992 * The caller must treat the string as a constant and not modify it
993 * in any way.
994 */
995 JNIEXPORT const char * JNICALL
996 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
997
998 /*
999 * Returns the class name referred to at a given constant pool index.
1000 *
1001 * The constant pool entry must refer to a CONSTANT_Fieldref.
1002 *
1003 * The result is in UTF format and remains valid until JVM_ReleaseUTF
1004 * is called.
1005 *
1006 * The caller must treat the string as a constant and not modify it
1007 * in any way.
1008 */
1009 JNIEXPORT const char * JNICALL
1010 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
1011
1012 /*
1013 * Returns the class name referred to at a given constant pool index.
1014 *
1015 * The constant pool entry must refer to CONSTANT_Methodref or
1016 * CONSTANT_InterfaceMethodref.
1017 *
1018 * The result is in UTF format and remains valid until JVM_ReleaseUTF
1019 * is called.
1020 *
1021 * The caller must treat the string as a constant and not modify it
1022 * in any way.
1023 */
1024 JNIEXPORT const char * JNICALL
1025 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1026
1027 /*
1028 * Returns the modifiers of a field in calledClass. The field is
1029 * referred to in class cb at constant pool entry index.
1030 *
1031 * The caller must treat the string as a constant and not modify it
1032 * in any way.
1033 *
1034 * Returns -1 if the field does not exist in calledClass.
1035 */
1036 JNIEXPORT jint JNICALL
1037 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1038
1039 /*
1040 * Returns the modifiers of a method in calledClass. The method is
1041 * referred to in class cb at constant pool entry index.
1042 *
1043 * Returns -1 if the method does not exist in calledClass.
1044 */
1045 JNIEXPORT jint JNICALL
1046 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1047
1048 /*
1049 * Releases the UTF string obtained from the VM.
1050 */
1051 JNIEXPORT void JNICALL
1052 JVM_ReleaseUTF(const char *utf);
1053
1054 /*
1055 * Compare if two classes are in the same package.
1056 */
1057 JNIEXPORT jboolean JNICALL
1058 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1059
1060
1061 /*************************************************************************
1062 PART 3: I/O and Network Support
1063 ************************************************************************/
1064
1065 /*
1066 * Convert a pathname into native format. This function does syntactic
1067 * cleanup, such as removing redundant separator characters. It modifies
1068 * the given pathname string in place.
1069 */
1070 JNIEXPORT char * JNICALL
1071 JVM_NativePath(char *);
1072
1073 JNIEXPORT void * JNICALL
1074 JVM_RawMonitorCreate(void);
1075
1076 JNIEXPORT void JNICALL
1077 JVM_RawMonitorDestroy(void *mon);
1078
1079 JNIEXPORT jint JNICALL
1080 JVM_RawMonitorEnter(void *mon);
1081
1082 JNIEXPORT void JNICALL
1083 JVM_RawMonitorExit(void *mon);
1084
1085 /*
1086 * java.lang.management support
1087 */
1088 JNIEXPORT void* JNICALL
1089 JVM_GetManagement(jint version);
1090
1091 /*
1092 * com.sun.tools.attach.VirtualMachine support
1093 *
1094 * Initialize the agent properties with the properties maintained in the VM.
1095 */
1096 JNIEXPORT jobject JNICALL
1097 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1098
1099 JNIEXPORT jstring JNICALL
1100 JVM_GetTemporaryDirectory(JNIEnv *env);
1101
1102 /* Generics reflection support.
1103 *
1104 * Returns information about the given class's EnclosingMethod
1105 * attribute, if present, or null if the class had no enclosing
1106 * method.
1107 *
1108 * If non-null, the returned array contains three elements. Element 0
1109 * is the java.lang.Class of which the enclosing method is a member,
1110 * and elements 1 and 2 are the java.lang.Strings for the enclosing
1111 * method's name and descriptor, respectively.
1112 */
1113 JNIEXPORT jobjectArray JNICALL
1114 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1115
1116 /*
1117 * Virtual thread support.
1118 */
1119 JNIEXPORT void JNICALL
1120 JVM_VirtualThreadStart(JNIEnv* env, jobject vthread);
1121
1122 JNIEXPORT void JNICALL
1123 JVM_VirtualThreadEnd(JNIEnv* env, jobject vthread);
1124
1125 JNIEXPORT void JNICALL
1126 JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hide);
1127
1128 JNIEXPORT void JNICALL
1129 JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean hide);
1130
1131 JNIEXPORT void JNICALL
1132 JVM_VirtualThreadDisableSuspend(JNIEnv* env, jclass clazz, jboolean enter);
1133
1134 JNIEXPORT void JNICALL
1135 JVM_VirtualThreadPinnedEvent(JNIEnv* env, jclass clazz, jstring op);
1136
1137 JNIEXPORT jobject JNICALL
1138 JVM_TakeVirtualThreadListToUnblock(JNIEnv* env, jclass ignored);
1139
1140 /*
1141 * Core reflection support.
1142 */
1143 JNIEXPORT jint JNICALL
1144 JVM_GetClassFileVersion(JNIEnv *env, jclass current);
1145
1146 /*
1147 * Return JNI_TRUE if warnings are printed when agents are dynamically loaded.
1148 */
1149 JNIEXPORT jboolean JNICALL
1150 JVM_PrintWarningAtDynamicAgentLoad(void);
1151
1152 /*
1153 * This structure is used by the launcher to get the default thread
1154 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1155 * version of 1.1. As it is not supported otherwise, it has been removed
1156 * from jni.h
1157 */
1158 typedef struct JDK1_1InitArgs {
1159 jint version;
1160
1161 char **properties;
1162 jint checkSource;
1163 jint nativeStackSize;
1164 jint javaStackSize;
1165 jint minHeapSize;
1166 jint maxHeapSize;
1167 jint verifyMode;
1168 char *classpath;
1169
1170 jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1171 void (JNICALL *exit)(jint code);
1172 void (JNICALL *abort)(void);
1173
1174 jint enableClassGC;
1175 jint enableVerboseGC;
1176 jint disableAsyncGC;
1177 jint verbose;
1178 jboolean debugging;
1179 jint debugPort;
1180 } JDK1_1InitArgs;
1181
1182
1183 #ifdef __cplusplus
1184 } /* extern "C" */
1185
1186 #endif /* __cplusplus */
1187
1188 #endif /* !_JAVASOFT_JVM_H_ */