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