Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/prims/jvm.h
32285 views
1
/*
2
* Copyright (c) 1997, 2018, 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_VM_PRIMS_JVM_H
26
#define SHARE_VM_PRIMS_JVM_H
27
28
#include "prims/jni.h"
29
#ifdef TARGET_OS_FAMILY_linux
30
# include "jvm_linux.h"
31
#endif
32
#ifdef TARGET_OS_FAMILY_solaris
33
# include "jvm_solaris.h"
34
#endif
35
#ifdef TARGET_OS_FAMILY_windows
36
# include "jvm_windows.h"
37
#endif
38
#ifdef TARGET_OS_FAMILY_aix
39
# include "jvm_aix.h"
40
#endif
41
#ifdef TARGET_OS_FAMILY_bsd
42
# include "jvm_bsd.h"
43
#endif
44
45
#ifndef _JAVASOFT_JVM_H_
46
#define _JAVASOFT_JVM_H_
47
48
// HotSpot integration note:
49
//
50
// This file and jvm.h used with the JDK are identical,
51
// except for the three includes removed below
52
53
// #include <sys/stat.h>
54
// #include "jni.h"
55
// #include "jvm_md.h"
56
57
58
#ifdef __cplusplus
59
extern "C" {
60
#endif
61
62
/*
63
* This file contains additional functions exported from the VM.
64
* These functions are complementary to the standard JNI support.
65
* There are three parts to this file:
66
*
67
* First, this file contains the VM-related functions needed by native
68
* libraries in the standard Java API. For example, the java.lang.Object
69
* class needs VM-level functions that wait for and notify monitors.
70
*
71
* Second, this file contains the functions and constant definitions
72
* needed by the byte code verifier and class file format checker.
73
* These functions allow the verifier and format checker to be written
74
* in a VM-independent way.
75
*
76
* Third, this file contains various I/O and nerwork operations needed
77
* by the standard Java I/O and network APIs.
78
*/
79
80
/*
81
* Bump the version number when either of the following happens:
82
*
83
* 1. There is a change in JVM_* functions.
84
*
85
* 2. There is a change in the contract between VM and Java classes.
86
* For example, if the VM relies on a new private field in Thread
87
* class.
88
*/
89
90
#define JVM_INTERFACE_VERSION 4
91
92
JNIEXPORT jobjectArray JNICALL
93
JVM_GetMethodParameters(JNIEnv *env, jobject method);
94
95
JNIEXPORT jint JNICALL
96
JVM_GetInterfaceVersion(void);
97
98
/*************************************************************************
99
PART 1: Functions for Native Libraries
100
************************************************************************/
101
/*
102
* java.lang.Object
103
*/
104
JNIEXPORT jint JNICALL
105
JVM_IHashCode(JNIEnv *env, jobject obj);
106
107
JNIEXPORT void JNICALL
108
JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
109
110
JNIEXPORT void JNICALL
111
JVM_MonitorNotify(JNIEnv *env, jobject obj);
112
113
JNIEXPORT void JNICALL
114
JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
115
116
JNIEXPORT jobject JNICALL
117
JVM_Clone(JNIEnv *env, jobject obj);
118
119
/*
120
* java.lang.String
121
*/
122
JNIEXPORT jstring JNICALL
123
JVM_InternString(JNIEnv *env, jstring str);
124
125
/*
126
* java.lang.System
127
*/
128
JNIEXPORT jlong JNICALL
129
JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
130
131
JNIEXPORT jlong JNICALL
132
JVM_NanoTime(JNIEnv *env, jclass ignored);
133
134
JNIEXPORT void JNICALL
135
JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
136
jobject dst, jint dst_pos, jint length);
137
138
JNIEXPORT jobject JNICALL
139
JVM_InitProperties(JNIEnv *env, jobject p);
140
141
/*
142
* java.io.File
143
*/
144
JNIEXPORT void JNICALL
145
JVM_OnExit(void (*func)(void));
146
147
/*
148
* java.nio.Bits
149
*/
150
JNIEXPORT void JNICALL
151
JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset,
152
jobject dstObj, jlong dstOffset, jlong size,
153
jlong elemSize);
154
155
/*
156
* java.lang.Runtime
157
*/
158
JNIEXPORT void JNICALL
159
JVM_Exit(jint code);
160
161
JNIEXPORT void JNICALL
162
JVM_BeforeHalt();
163
164
JNIEXPORT void JNICALL
165
JVM_Halt(jint code);
166
167
JNIEXPORT void JNICALL
168
JVM_GC(void);
169
170
/* Returns the number of real-time milliseconds that have elapsed since the
171
* least-recently-inspected heap object was last inspected by the garbage
172
* collector.
173
*
174
* For simple stop-the-world collectors this value is just the time
175
* since the most recent collection. For generational collectors it is the
176
* time since the oldest generation was most recently collected. Other
177
* collectors are free to return a pessimistic estimate of the elapsed time, or
178
* simply the time since the last full collection was performed.
179
*
180
* Note that in the presence of reference objects, a given object that is no
181
* longer strongly reachable may have to be inspected multiple times before it
182
* can be reclaimed.
183
*/
184
JNIEXPORT jlong JNICALL
185
JVM_MaxObjectInspectionAge(void);
186
187
JNIEXPORT void JNICALL
188
JVM_TraceInstructions(jboolean on);
189
190
JNIEXPORT void JNICALL
191
JVM_TraceMethodCalls(jboolean on);
192
193
JNIEXPORT jlong JNICALL
194
JVM_TotalMemory(void);
195
196
JNIEXPORT jlong JNICALL
197
JVM_FreeMemory(void);
198
199
JNIEXPORT jlong JNICALL
200
JVM_MaxMemory(void);
201
202
JNIEXPORT jint JNICALL
203
JVM_ActiveProcessorCount(void);
204
205
JNIEXPORT jboolean JNICALL
206
JVM_IsUseContainerSupport(void);
207
208
JNIEXPORT void * JNICALL
209
JVM_LoadLibrary(const char *name);
210
211
JNIEXPORT void JNICALL
212
JVM_UnloadLibrary(void * handle);
213
214
JNIEXPORT void * JNICALL
215
JVM_FindLibraryEntry(void *handle, const char *name);
216
217
JNIEXPORT jboolean JNICALL
218
JVM_IsSupportedJNIVersion(jint version);
219
220
/*
221
* java.lang.Float and java.lang.Double
222
*/
223
JNIEXPORT jboolean JNICALL
224
JVM_IsNaN(jdouble d);
225
226
/*
227
* java.lang.Throwable
228
*/
229
JNIEXPORT void JNICALL
230
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
231
232
JNIEXPORT jint JNICALL
233
JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
234
235
JNIEXPORT jobject JNICALL
236
JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
237
238
/*
239
* java.lang.Compiler
240
*/
241
JNIEXPORT void JNICALL
242
JVM_InitializeCompiler (JNIEnv *env, jclass compCls);
243
244
JNIEXPORT jboolean JNICALL
245
JVM_IsSilentCompiler(JNIEnv *env, jclass compCls);
246
247
JNIEXPORT jboolean JNICALL
248
JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls);
249
250
JNIEXPORT jboolean JNICALL
251
JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname);
252
253
JNIEXPORT jobject JNICALL
254
JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg);
255
256
JNIEXPORT void JNICALL
257
JVM_EnableCompiler(JNIEnv *env, jclass compCls);
258
259
JNIEXPORT void JNICALL
260
JVM_DisableCompiler(JNIEnv *env, jclass compCls);
261
262
/*
263
* java.lang.Thread
264
*/
265
JNIEXPORT void JNICALL
266
JVM_StartThread(JNIEnv *env, jobject thread);
267
268
JNIEXPORT void JNICALL
269
JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
270
271
JNIEXPORT jboolean JNICALL
272
JVM_IsThreadAlive(JNIEnv *env, jobject thread);
273
274
JNIEXPORT void JNICALL
275
JVM_SuspendThread(JNIEnv *env, jobject thread);
276
277
JNIEXPORT void JNICALL
278
JVM_ResumeThread(JNIEnv *env, jobject thread);
279
280
JNIEXPORT void JNICALL
281
JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
282
283
JNIEXPORT void JNICALL
284
JVM_Yield(JNIEnv *env, jclass threadClass);
285
286
JNIEXPORT void JNICALL
287
JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
288
289
JNIEXPORT jobject JNICALL
290
JVM_CurrentThread(JNIEnv *env, jclass threadClass);
291
292
JNIEXPORT jint JNICALL
293
JVM_CountStackFrames(JNIEnv *env, jobject thread);
294
295
JNIEXPORT void JNICALL
296
JVM_Interrupt(JNIEnv *env, jobject thread);
297
298
JNIEXPORT jboolean JNICALL
299
JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
300
301
JNIEXPORT jboolean JNICALL
302
JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
303
304
JNIEXPORT void JNICALL
305
JVM_DumpAllStacks(JNIEnv *env, jclass unused);
306
307
JNIEXPORT jobjectArray JNICALL
308
JVM_GetAllThreads(JNIEnv *env, jclass dummy);
309
310
JNIEXPORT void JNICALL
311
JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
312
313
/* getStackTrace() and getAllStackTraces() method */
314
JNIEXPORT jobjectArray JNICALL
315
JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
316
317
/*
318
* java.lang.SecurityManager
319
*/
320
JNIEXPORT jclass JNICALL
321
JVM_CurrentLoadedClass(JNIEnv *env);
322
323
JNIEXPORT jobject JNICALL
324
JVM_CurrentClassLoader(JNIEnv *env);
325
326
JNIEXPORT jobjectArray JNICALL
327
JVM_GetClassContext(JNIEnv *env);
328
329
JNIEXPORT jint JNICALL
330
JVM_ClassDepth(JNIEnv *env, jstring name);
331
332
JNIEXPORT jint JNICALL
333
JVM_ClassLoaderDepth(JNIEnv *env);
334
335
/*
336
* java.lang.Package
337
*/
338
JNIEXPORT jstring JNICALL
339
JVM_GetSystemPackage(JNIEnv *env, jstring name);
340
341
JNIEXPORT jobjectArray JNICALL
342
JVM_GetSystemPackages(JNIEnv *env);
343
344
/*
345
* java.io.ObjectInputStream
346
*/
347
JNIEXPORT jobject JNICALL
348
JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass,
349
jclass initClass);
350
351
JNIEXPORT jobject JNICALL
352
JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass,
353
jint length);
354
355
JNIEXPORT jobject JNICALL
356
JVM_LatestUserDefinedLoader(JNIEnv *env);
357
358
/*
359
* This function has been deprecated and should not be considered
360
* part of the specified JVM interface.
361
*/
362
JNIEXPORT jclass JNICALL
363
JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass,
364
jstring currClassName);
365
366
/*
367
* java.lang.reflect.Array
368
*/
369
JNIEXPORT jint JNICALL
370
JVM_GetArrayLength(JNIEnv *env, jobject arr);
371
372
JNIEXPORT jobject JNICALL
373
JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
374
375
JNIEXPORT jvalue JNICALL
376
JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
377
378
JNIEXPORT void JNICALL
379
JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
380
381
JNIEXPORT void JNICALL
382
JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
383
unsigned char vCode);
384
385
JNIEXPORT jobject JNICALL
386
JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
387
388
JNIEXPORT jobject JNICALL
389
JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
390
391
/*
392
* java.lang.Class and java.lang.ClassLoader
393
*/
394
395
#define JVM_CALLER_DEPTH -1
396
397
/*
398
* Returns the class in which the code invoking the native method
399
* belongs.
400
*
401
* Note that in JDK 1.1, native methods did not create a frame.
402
* In 1.2, they do. Therefore native methods like Class.forName
403
* can no longer look at the current frame for the caller class.
404
*/
405
JNIEXPORT jclass JNICALL
406
JVM_GetCallerClass(JNIEnv *env, int n);
407
408
/*
409
* Find primitive classes
410
* utf: class name
411
*/
412
JNIEXPORT jclass JNICALL
413
JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
414
415
/*
416
* Link the class
417
*/
418
JNIEXPORT void JNICALL
419
JVM_ResolveClass(JNIEnv *env, jclass cls);
420
421
/*
422
* Find a class from a given class loader. Throw ClassNotFoundException
423
* or NoClassDefFoundError depending on the value of the last
424
* argument.
425
*/
426
JNIEXPORT jclass JNICALL
427
JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
428
jobject loader, jboolean throwError);
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
* caller: initiating class. The initiating class may be null when a security
443
* manager is not installed.
444
*/
445
JNIEXPORT jclass JNICALL
446
JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
447
jobject loader, jclass caller);
448
449
/*
450
* Find a class from a given class.
451
*/
452
JNIEXPORT jclass JNICALL
453
JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
454
jclass from);
455
456
/* Find a loaded class cached by the VM */
457
JNIEXPORT jclass JNICALL
458
JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
459
460
/* Define a class */
461
JNIEXPORT jclass JNICALL
462
JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
463
jsize len, jobject pd);
464
465
/* Define a class with a source (added in JDK1.5) */
466
JNIEXPORT jclass JNICALL
467
JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
468
const jbyte *buf, jsize len, jobject pd,
469
const char *source);
470
471
/* Define a class with a source with conditional verification (added HSX 14)
472
* -Xverify:all will verify anyway, -Xverify:none will not verify,
473
* -Xverify:remote (default) will obey this conditional
474
* i.e. true = should_verify_class
475
*/
476
JNIEXPORT jclass JNICALL
477
JVM_DefineClassWithSourceCond(JNIEnv *env, const char *name,
478
jobject loader, const jbyte *buf,
479
jsize len, jobject pd, const char *source,
480
jboolean verify);
481
482
/*
483
* Reflection support functions
484
*/
485
486
JNIEXPORT jstring JNICALL
487
JVM_GetClassName(JNIEnv *env, jclass cls);
488
489
JNIEXPORT jobjectArray JNICALL
490
JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
491
492
JNIEXPORT jobject JNICALL
493
JVM_GetClassLoader(JNIEnv *env, jclass cls);
494
495
JNIEXPORT jboolean JNICALL
496
JVM_IsInterface(JNIEnv *env, jclass cls);
497
498
JNIEXPORT jobjectArray JNICALL
499
JVM_GetClassSigners(JNIEnv *env, jclass cls);
500
501
JNIEXPORT void JNICALL
502
JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
503
504
JNIEXPORT jobject JNICALL
505
JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
506
507
JNIEXPORT jboolean JNICALL
508
JVM_IsArrayClass(JNIEnv *env, jclass cls);
509
510
JNIEXPORT jboolean JNICALL
511
JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
512
513
JNIEXPORT jclass JNICALL
514
JVM_GetComponentType(JNIEnv *env, jclass cls);
515
516
JNIEXPORT jint JNICALL
517
JVM_GetClassModifiers(JNIEnv *env, jclass cls);
518
519
JNIEXPORT jobjectArray JNICALL
520
JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
521
522
JNIEXPORT jclass JNICALL
523
JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
524
525
/* Generics support (JDK 1.5) */
526
JNIEXPORT jstring JNICALL
527
JVM_GetClassSignature(JNIEnv *env, jclass cls);
528
529
/* Annotations support (JDK 1.5) */
530
JNIEXPORT jbyteArray JNICALL
531
JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
532
533
/* Annotations support (JDK 1.6) */
534
535
// field is a handle to a java.lang.reflect.Field object
536
JNIEXPORT jbyteArray JNICALL
537
JVM_GetFieldAnnotations(JNIEnv *env, jobject field);
538
539
// method is a handle to a java.lang.reflect.Method object
540
JNIEXPORT jbyteArray JNICALL
541
JVM_GetMethodAnnotations(JNIEnv *env, jobject method);
542
543
// method is a handle to a java.lang.reflect.Method object
544
JNIEXPORT jbyteArray JNICALL
545
JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method);
546
547
// method is a handle to a java.lang.reflect.Method object
548
JNIEXPORT jbyteArray JNICALL
549
JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method);
550
551
/* Type use annotations support (JDK 1.8) */
552
553
JNIEXPORT jbyteArray JNICALL
554
JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
555
556
// field is a handle to a java.lang.reflect.Field object
557
JNIEXPORT jbyteArray JNICALL
558
JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
559
560
// method is a handle to a java.lang.reflect.Method object
561
JNIEXPORT jbyteArray JNICALL
562
JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
563
564
/*
565
* New (JDK 1.4) reflection implementation
566
*/
567
568
JNIEXPORT jobjectArray JNICALL
569
JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
570
571
JNIEXPORT jobjectArray JNICALL
572
JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
573
574
JNIEXPORT jobjectArray JNICALL
575
JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
576
577
/* Differs from JVM_GetClassModifiers in treatment of inner classes.
578
This returns the access flags for the class as specified in the
579
class file rather than searching the InnerClasses attribute (if
580
present) to find the source-level access flags. Only the values of
581
the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
582
valid. */
583
JNIEXPORT jint JNICALL
584
JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
585
586
/*
587
* Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
588
*/
589
590
JNIEXPORT jobject JNICALL
591
JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
592
593
JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
594
(JNIEnv *env, jobject obj, jobject unused);
595
596
JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
597
(JNIEnv *env, jobject obj, jobject unused, jint index);
598
599
JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
600
(JNIEnv *env, jobject obj, jobject unused, jint index);
601
602
JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
603
(JNIEnv *env, jobject obj, jobject unused, jint index);
604
605
JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
606
(JNIEnv *env, jobject obj, jobject unused, jint index);
607
608
JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
609
(JNIEnv *env, jobject obj, jobject unused, jint index);
610
611
JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
612
(JNIEnv *env, jobject obj, jobject unused, jint index);
613
614
JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
615
(JNIEnv *env, jobject obj, jobject unused, jint index);
616
617
JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
618
(JNIEnv *env, jobject obj, jobject unused, jint index);
619
620
JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
621
(JNIEnv *env, jobject obj, jobject unused, jint index);
622
623
JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
624
(JNIEnv *env, jobject obj, jobject unused, jint index);
625
626
JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
627
(JNIEnv *env, jobject obj, jobject unused, jint index);
628
629
JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
630
(JNIEnv *env, jobject obj, jobject unused, jint index);
631
632
JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
633
(JNIEnv *env, jobject obj, jobject unused, jint index);
634
635
/*
636
* java.security.*
637
*/
638
639
JNIEXPORT jobject JNICALL
640
JVM_DoPrivileged(JNIEnv *env, jclass cls,
641
jobject action, jobject context, jboolean wrapException);
642
643
JNIEXPORT jobject JNICALL
644
JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
645
646
JNIEXPORT jobject JNICALL
647
JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
648
649
/*
650
* Signal support, used to implement the shutdown sequence. Every VM must
651
* support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
652
* (^C) and the latter for external termination (kill, system shutdown, etc.).
653
* Other platform-dependent signal values may also be supported.
654
*/
655
656
JNIEXPORT void * JNICALL
657
JVM_RegisterSignal(jint sig, void *handler);
658
659
JNIEXPORT jboolean JNICALL
660
JVM_RaiseSignal(jint sig);
661
662
JNIEXPORT jint JNICALL
663
JVM_FindSignal(const char *name);
664
665
/*
666
* Retrieve the assertion directives for the specified class.
667
*/
668
JNIEXPORT jboolean JNICALL
669
JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
670
671
/*
672
* Retrieve the assertion directives from the VM.
673
*/
674
JNIEXPORT jobject JNICALL
675
JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
676
677
/*
678
* java.util.concurrent.atomic.AtomicLong
679
*/
680
JNIEXPORT jboolean JNICALL
681
JVM_SupportsCX8(void);
682
683
JNIEXPORT jboolean JNICALL
684
JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fldID, jlong oldVal, jlong newVal);
685
686
/*
687
* com.sun.dtrace.jsdt support
688
*/
689
690
#define JVM_TRACING_DTRACE_VERSION 1
691
692
/*
693
* Structure to pass one probe description to JVM.
694
*
695
* The VM will overwrite the definition of the referenced method with
696
* code that will fire the probe.
697
*/
698
typedef struct {
699
jmethodID method;
700
jstring function;
701
jstring name;
702
void* reserved[4]; // for future use
703
} JVM_DTraceProbe;
704
705
/**
706
* Encapsulates the stability ratings for a DTrace provider field
707
*/
708
typedef struct {
709
jint nameStability;
710
jint dataStability;
711
jint dependencyClass;
712
} JVM_DTraceInterfaceAttributes;
713
714
/*
715
* Structure to pass one provider description to JVM
716
*/
717
typedef struct {
718
jstring name;
719
JVM_DTraceProbe* probes;
720
jint probe_count;
721
JVM_DTraceInterfaceAttributes providerAttributes;
722
JVM_DTraceInterfaceAttributes moduleAttributes;
723
JVM_DTraceInterfaceAttributes functionAttributes;
724
JVM_DTraceInterfaceAttributes nameAttributes;
725
JVM_DTraceInterfaceAttributes argsAttributes;
726
void* reserved[4]; // for future use
727
} JVM_DTraceProvider;
728
729
/*
730
* Get the version number the JVM was built with
731
*/
732
JNIEXPORT jint JNICALL
733
JVM_DTraceGetVersion(JNIEnv* env);
734
735
/*
736
* Register new probe with given signature, return global handle
737
*
738
* The version passed in is the version that the library code was
739
* built with.
740
*/
741
JNIEXPORT jlong JNICALL
742
JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
743
jint providers_count, JVM_DTraceProvider* providers);
744
745
/*
746
* Check JSDT probe
747
*/
748
JNIEXPORT jboolean JNICALL
749
JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
750
751
/*
752
* Destroy custom DOF
753
*/
754
JNIEXPORT void JNICALL
755
JVM_DTraceDispose(JNIEnv* env, jlong handle);
756
757
/*
758
* Check to see if DTrace is supported by OS
759
*/
760
JNIEXPORT jboolean JNICALL
761
JVM_DTraceIsSupported(JNIEnv* env);
762
763
/*************************************************************************
764
PART 2: Support for the Verifier and Class File Format Checker
765
************************************************************************/
766
/*
767
* Return the class name in UTF format. The result is valid
768
* until JVM_ReleaseUTf is called.
769
*
770
* The caller must treat the string as a constant and not modify it
771
* in any way.
772
*/
773
JNIEXPORT const char * JNICALL
774
JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
775
776
/*
777
* Returns the constant pool types in the buffer provided by "types."
778
*/
779
JNIEXPORT void JNICALL
780
JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
781
782
/*
783
* Returns the number of Constant Pool entries.
784
*/
785
JNIEXPORT jint JNICALL
786
JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
787
788
/*
789
* Returns the number of *declared* fields or methods.
790
*/
791
JNIEXPORT jint JNICALL
792
JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
793
794
JNIEXPORT jint JNICALL
795
JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
796
797
/*
798
* Returns the CP indexes of exceptions raised by a given method.
799
* Places the result in the given buffer.
800
*
801
* The method is identified by method_index.
802
*/
803
JNIEXPORT void JNICALL
804
JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
805
unsigned short *exceptions);
806
/*
807
* Returns the number of exceptions raised by a given method.
808
* The method is identified by method_index.
809
*/
810
JNIEXPORT jint JNICALL
811
JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
812
813
/*
814
* Returns the byte code sequence of a given method.
815
* Places the result in the given buffer.
816
*
817
* The method is identified by method_index.
818
*/
819
JNIEXPORT void JNICALL
820
JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
821
unsigned char *code);
822
823
/*
824
* Returns the length of the byte code sequence of a given method.
825
* The method is identified by method_index.
826
*/
827
JNIEXPORT jint JNICALL
828
JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
829
830
/*
831
* A structure used to a capture exception table entry in a Java method.
832
*/
833
typedef struct {
834
jint start_pc;
835
jint end_pc;
836
jint handler_pc;
837
jint catchType;
838
} JVM_ExceptionTableEntryType;
839
840
/*
841
* Returns the exception table entry at entry_index of a given method.
842
* Places the result in the given buffer.
843
*
844
* The method is identified by method_index.
845
*/
846
JNIEXPORT void JNICALL
847
JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
848
jint entry_index,
849
JVM_ExceptionTableEntryType *entry);
850
851
/*
852
* Returns the length of the exception table of a given method.
853
* The method is identified by method_index.
854
*/
855
JNIEXPORT jint JNICALL
856
JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
857
858
/*
859
* Returns the modifiers of a given field.
860
* The field is identified by field_index.
861
*/
862
JNIEXPORT jint JNICALL
863
JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
864
865
/*
866
* Returns the modifiers of a given method.
867
* The method is identified by method_index.
868
*/
869
JNIEXPORT jint JNICALL
870
JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
871
872
/*
873
* Returns the number of local variables of a given method.
874
* The method is identified by method_index.
875
*/
876
JNIEXPORT jint JNICALL
877
JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
878
879
/*
880
* Returns the number of arguments (including this pointer) of a given method.
881
* The method is identified by method_index.
882
*/
883
JNIEXPORT jint JNICALL
884
JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
885
886
/*
887
* Returns the maximum amount of stack (in words) used by a given method.
888
* The method is identified by method_index.
889
*/
890
JNIEXPORT jint JNICALL
891
JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
892
893
/*
894
* Is a given method a constructor.
895
* The method is identified by method_index.
896
*/
897
JNIEXPORT jboolean JNICALL
898
JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
899
900
/*
901
* Is the given method generated by the VM.
902
* The method is identified by method_index.
903
*/
904
JNIEXPORT jboolean JNICALL
905
JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
906
907
/*
908
* Returns the name of a given method in UTF format.
909
* The result remains valid until JVM_ReleaseUTF is called.
910
*
911
* The caller must treat the string as a constant and not modify it
912
* in any way.
913
*/
914
JNIEXPORT const char * JNICALL
915
JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
916
917
/*
918
* Returns the signature of a given method in UTF format.
919
* The result remains valid until JVM_ReleaseUTF is called.
920
*
921
* The caller must treat the string as a constant and not modify it
922
* in any way.
923
*/
924
JNIEXPORT const char * JNICALL
925
JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
926
927
/*
928
* Returns the name of the field refered to at a given constant pool
929
* index.
930
*
931
* The result is in UTF format and remains valid until JVM_ReleaseUTF
932
* is called.
933
*
934
* The caller must treat the string as a constant and not modify it
935
* in any way.
936
*/
937
JNIEXPORT const char * JNICALL
938
JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
939
940
/*
941
* Returns the name of the method refered to at a given constant pool
942
* index.
943
*
944
* The result is in UTF format and remains valid until JVM_ReleaseUTF
945
* is called.
946
*
947
* The caller must treat the string as a constant and not modify it
948
* in any way.
949
*/
950
JNIEXPORT const char * JNICALL
951
JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
952
953
/*
954
* Returns the signature of the method refered to at a given constant pool
955
* index.
956
*
957
* The result is in UTF format and remains valid until JVM_ReleaseUTF
958
* is called.
959
*
960
* The caller must treat the string as a constant and not modify it
961
* in any way.
962
*/
963
JNIEXPORT const char * JNICALL
964
JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
965
966
/*
967
* Returns the signature of the field refered to at a given constant pool
968
* index.
969
*
970
* The result is in UTF format and remains valid until JVM_ReleaseUTF
971
* is called.
972
*
973
* The caller must treat the string as a constant and not modify it
974
* in any way.
975
*/
976
JNIEXPORT const char * JNICALL
977
JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
978
979
/*
980
* Returns the class name refered to at a given constant pool index.
981
*
982
* The result is in UTF format and remains valid until JVM_ReleaseUTF
983
* is called.
984
*
985
* The caller must treat the string as a constant and not modify it
986
* in any way.
987
*/
988
JNIEXPORT const char * JNICALL
989
JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
990
991
/*
992
* Returns the class name refered to at a given constant pool index.
993
*
994
* The constant pool entry must refer to a CONSTANT_Fieldref.
995
*
996
* The result is in UTF format and remains valid until JVM_ReleaseUTF
997
* is called.
998
*
999
* The caller must treat the string as a constant and not modify it
1000
* in any way.
1001
*/
1002
JNIEXPORT const char * JNICALL
1003
JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
1004
1005
/*
1006
* Returns the class name refered to at a given constant pool index.
1007
*
1008
* The constant pool entry must refer to CONSTANT_Methodref or
1009
* CONSTANT_InterfaceMethodref.
1010
*
1011
* The result is in UTF format and remains valid until JVM_ReleaseUTF
1012
* is called.
1013
*
1014
* The caller must treat the string as a constant and not modify it
1015
* in any way.
1016
*/
1017
JNIEXPORT const char * JNICALL
1018
JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1019
1020
/*
1021
* Returns the modifiers of a field in calledClass. The field is
1022
* referred to in class cb at constant pool entry index.
1023
*
1024
* The caller must treat the string as a constant and not modify it
1025
* in any way.
1026
*
1027
* Returns -1 if the field does not exist in calledClass.
1028
*/
1029
JNIEXPORT jint JNICALL
1030
JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1031
1032
/*
1033
* Returns the modifiers of a method in calledClass. The method is
1034
* referred to in class cb at constant pool entry index.
1035
*
1036
* Returns -1 if the method does not exist in calledClass.
1037
*/
1038
JNIEXPORT jint JNICALL
1039
JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1040
1041
/*
1042
* Releases the UTF string obtained from the VM.
1043
*/
1044
JNIEXPORT void JNICALL
1045
JVM_ReleaseUTF(const char *utf);
1046
1047
/*
1048
* Compare if two classes are in the same package.
1049
*/
1050
JNIEXPORT jboolean JNICALL
1051
JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1052
1053
/* Constants in class files */
1054
1055
#define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */
1056
#define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */
1057
#define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */
1058
#define JVM_ACC_STATIC 0x0008 /* instance variable is static */
1059
#define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */
1060
#define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */
1061
#define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */
1062
#define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */
1063
#define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */
1064
#define JVM_ACC_TRANSIENT 0x0080 /* not persistent */
1065
#define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */
1066
#define JVM_ACC_NATIVE 0x0100 /* implemented in C */
1067
#define JVM_ACC_INTERFACE 0x0200 /* class is an interface */
1068
#define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */
1069
#define JVM_ACC_STRICT 0x0800 /* strict floating point */
1070
#define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */
1071
#define JVM_ACC_ANNOTATION 0x2000 /* annotation type */
1072
#define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */
1073
1074
#define JVM_ACC_PUBLIC_BIT 0
1075
#define JVM_ACC_PRIVATE_BIT 1
1076
#define JVM_ACC_PROTECTED_BIT 2
1077
#define JVM_ACC_STATIC_BIT 3
1078
#define JVM_ACC_FINAL_BIT 4
1079
#define JVM_ACC_SYNCHRONIZED_BIT 5
1080
#define JVM_ACC_SUPER_BIT 5
1081
#define JVM_ACC_VOLATILE_BIT 6
1082
#define JVM_ACC_BRIDGE_BIT 6
1083
#define JVM_ACC_TRANSIENT_BIT 7
1084
#define JVM_ACC_VARARGS_BIT 7
1085
#define JVM_ACC_NATIVE_BIT 8
1086
#define JVM_ACC_INTERFACE_BIT 9
1087
#define JVM_ACC_ABSTRACT_BIT 10
1088
#define JVM_ACC_STRICT_BIT 11
1089
#define JVM_ACC_SYNTHETIC_BIT 12
1090
#define JVM_ACC_ANNOTATION_BIT 13
1091
#define JVM_ACC_ENUM_BIT 14
1092
1093
// NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java
1094
enum {
1095
JVM_CONSTANT_Utf8 = 1,
1096
JVM_CONSTANT_Unicode, /* unused */
1097
JVM_CONSTANT_Integer,
1098
JVM_CONSTANT_Float,
1099
JVM_CONSTANT_Long,
1100
JVM_CONSTANT_Double,
1101
JVM_CONSTANT_Class,
1102
JVM_CONSTANT_String,
1103
JVM_CONSTANT_Fieldref,
1104
JVM_CONSTANT_Methodref,
1105
JVM_CONSTANT_InterfaceMethodref,
1106
JVM_CONSTANT_NameAndType,
1107
JVM_CONSTANT_MethodHandle = 15, // JSR 292
1108
JVM_CONSTANT_MethodType = 16, // JSR 292
1109
//JVM_CONSTANT_(unused) = 17, // JSR 292 early drafts only
1110
JVM_CONSTANT_InvokeDynamic = 18, // JSR 292
1111
JVM_CONSTANT_ExternalMax = 18 // Last tag found in classfiles
1112
};
1113
1114
/* JVM_CONSTANT_MethodHandle subtypes */
1115
enum {
1116
JVM_REF_getField = 1,
1117
JVM_REF_getStatic = 2,
1118
JVM_REF_putField = 3,
1119
JVM_REF_putStatic = 4,
1120
JVM_REF_invokeVirtual = 5,
1121
JVM_REF_invokeStatic = 6,
1122
JVM_REF_invokeSpecial = 7,
1123
JVM_REF_newInvokeSpecial = 8,
1124
JVM_REF_invokeInterface = 9
1125
};
1126
1127
/* Used in the newarray instruction. */
1128
1129
#define JVM_T_BOOLEAN 4
1130
#define JVM_T_CHAR 5
1131
#define JVM_T_FLOAT 6
1132
#define JVM_T_DOUBLE 7
1133
#define JVM_T_BYTE 8
1134
#define JVM_T_SHORT 9
1135
#define JVM_T_INT 10
1136
#define JVM_T_LONG 11
1137
1138
/* JVM method signatures */
1139
1140
#define JVM_SIGNATURE_ARRAY '['
1141
#define JVM_SIGNATURE_BYTE 'B'
1142
#define JVM_SIGNATURE_CHAR 'C'
1143
#define JVM_SIGNATURE_CLASS 'L'
1144
#define JVM_SIGNATURE_ENDCLASS ';'
1145
#define JVM_SIGNATURE_ENUM 'E'
1146
#define JVM_SIGNATURE_FLOAT 'F'
1147
#define JVM_SIGNATURE_DOUBLE 'D'
1148
#define JVM_SIGNATURE_FUNC '('
1149
#define JVM_SIGNATURE_ENDFUNC ')'
1150
#define JVM_SIGNATURE_INT 'I'
1151
#define JVM_SIGNATURE_LONG 'J'
1152
#define JVM_SIGNATURE_SHORT 'S'
1153
#define JVM_SIGNATURE_VOID 'V'
1154
#define JVM_SIGNATURE_BOOLEAN 'Z'
1155
1156
/*
1157
* A function defined by the byte-code verifier and called by the VM.
1158
* This is not a function implemented in the VM.
1159
*
1160
* Returns JNI_FALSE if verification fails. A detailed error message
1161
* will be places in msg_buf, whose length is specified by buf_len.
1162
*/
1163
typedef jboolean (*verifier_fn_t)(JNIEnv *env,
1164
jclass cb,
1165
char * msg_buf,
1166
jint buf_len);
1167
1168
1169
/*
1170
* Support for a VM-independent class format checker.
1171
*/
1172
typedef struct {
1173
unsigned long code; /* byte code */
1174
unsigned long excs; /* exceptions */
1175
unsigned long etab; /* catch table */
1176
unsigned long lnum; /* line number */
1177
unsigned long lvar; /* local vars */
1178
} method_size_info;
1179
1180
typedef struct {
1181
unsigned int constants; /* constant pool */
1182
unsigned int fields;
1183
unsigned int methods;
1184
unsigned int interfaces;
1185
unsigned int fields2; /* number of static 2-word fields */
1186
unsigned int innerclasses; /* # of records in InnerClasses attr */
1187
1188
method_size_info clinit; /* memory used in clinit */
1189
method_size_info main; /* used everywhere else */
1190
} class_size_info;
1191
1192
/*
1193
* Functions defined in libjava.so to perform string conversions.
1194
*
1195
*/
1196
1197
typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
1198
1199
typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
1200
1201
/* This is the function defined in libjava.so that performs class
1202
* format checks. This functions fills in size information about
1203
* the class file and returns:
1204
*
1205
* 0: good
1206
* -1: out of memory
1207
* -2: bad format
1208
* -3: unsupported version
1209
* -4: bad class name
1210
*/
1211
1212
typedef jint (*check_format_fn_t)(char *class_name,
1213
unsigned char *data,
1214
unsigned int data_size,
1215
class_size_info *class_size,
1216
char *message_buffer,
1217
jint buffer_length,
1218
jboolean measure_only,
1219
jboolean check_relaxed);
1220
1221
#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
1222
JVM_ACC_FINAL | \
1223
JVM_ACC_SUPER | \
1224
JVM_ACC_INTERFACE | \
1225
JVM_ACC_ABSTRACT | \
1226
JVM_ACC_ANNOTATION | \
1227
JVM_ACC_ENUM | \
1228
JVM_ACC_SYNTHETIC)
1229
1230
#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
1231
JVM_ACC_PRIVATE | \
1232
JVM_ACC_PROTECTED | \
1233
JVM_ACC_STATIC | \
1234
JVM_ACC_FINAL | \
1235
JVM_ACC_VOLATILE | \
1236
JVM_ACC_TRANSIENT | \
1237
JVM_ACC_ENUM | \
1238
JVM_ACC_SYNTHETIC)
1239
1240
#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
1241
JVM_ACC_PRIVATE | \
1242
JVM_ACC_PROTECTED | \
1243
JVM_ACC_STATIC | \
1244
JVM_ACC_FINAL | \
1245
JVM_ACC_SYNCHRONIZED | \
1246
JVM_ACC_BRIDGE | \
1247
JVM_ACC_VARARGS | \
1248
JVM_ACC_NATIVE | \
1249
JVM_ACC_ABSTRACT | \
1250
JVM_ACC_STRICT | \
1251
JVM_ACC_SYNTHETIC)
1252
1253
/*
1254
* This is the function defined in libjava.so to perform path
1255
* canonicalization. VM call this function before opening jar files
1256
* to load system classes.
1257
*
1258
*/
1259
1260
typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
1261
1262
/*************************************************************************
1263
PART 3: I/O and Network Support
1264
************************************************************************/
1265
1266
/* Note that the JVM IO functions are expected to return JVM_IO_ERR
1267
* when there is any kind of error. The caller can then use the
1268
* platform specific support (e.g., errno) to get the detailed
1269
* error info. The JVM_GetLastErrorString procedure may also be used
1270
* to obtain a descriptive error string.
1271
*/
1272
#define JVM_IO_ERR (-1)
1273
1274
/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO
1275
* operation has been disrupted by Thread.interrupt. There are a
1276
* number of technical difficulties related to interruptible IO that
1277
* need to be solved. For example, most existing programs do not handle
1278
* InterruptedIOExceptions specially, they simply treat those as any
1279
* IOExceptions, which typically indicate fatal errors.
1280
*
1281
* There are also two modes of operation for interruptible IO. In the
1282
* resumption mode, an interrupted IO operation is guaranteed not to
1283
* have any side-effects, and can be restarted. In the termination mode,
1284
* an interrupted IO operation corrupts the underlying IO stream, so
1285
* that the only reasonable operation on an interrupted stream is to
1286
* close that stream. The resumption mode seems to be impossible to
1287
* implement on Win32 and Solaris. Implementing the termination mode is
1288
* easier, but it's not clear that's the right semantics.
1289
*
1290
* Interruptible IO is not supported on Win32.It can be enabled/disabled
1291
* using a compile-time flag on Solaris. Third-party JVM ports do not
1292
* need to implement interruptible IO.
1293
*/
1294
#define JVM_IO_INTR (-2)
1295
1296
/* Write a string into the given buffer, in the platform's local encoding,
1297
* that describes the most recent system-level error to occur in this thread.
1298
* Return the length of the string or zero if no error occurred.
1299
*/
1300
JNIEXPORT jint JNICALL
1301
JVM_GetLastErrorString(char *buf, int len);
1302
1303
/*
1304
* Convert a pathname into native format. This function does syntactic
1305
* cleanup, such as removing redundant separator characters. It modifies
1306
* the given pathname string in place.
1307
*/
1308
JNIEXPORT char * JNICALL
1309
JVM_NativePath(char *);
1310
1311
/*
1312
* JVM I/O error codes
1313
*/
1314
#define JVM_EEXIST -100
1315
1316
/*
1317
* Open a file descriptor. This function returns a negative error code
1318
* on error, and a non-negative integer that is the file descriptor on
1319
* success.
1320
*/
1321
JNIEXPORT jint JNICALL
1322
JVM_Open(const char *fname, jint flags, jint mode);
1323
1324
/*
1325
* Close a file descriptor. This function returns -1 on error, and 0
1326
* on success.
1327
*
1328
* fd the file descriptor to close.
1329
*/
1330
JNIEXPORT jint JNICALL
1331
JVM_Close(jint fd);
1332
1333
/*
1334
* Read data from a file decriptor into a char array.
1335
*
1336
* fd the file descriptor to read from.
1337
* buf the buffer where to put the read data.
1338
* nbytes the number of bytes to read.
1339
*
1340
* This function returns -1 on error, and 0 on success.
1341
*/
1342
JNIEXPORT jint JNICALL
1343
JVM_Read(jint fd, char *buf, jint nbytes);
1344
1345
/*
1346
* Write data from a char array to a file decriptor.
1347
*
1348
* fd the file descriptor to read from.
1349
* buf the buffer from which to fetch the data.
1350
* nbytes the number of bytes to write.
1351
*
1352
* This function returns -1 on error, and 0 on success.
1353
*/
1354
JNIEXPORT jint JNICALL
1355
JVM_Write(jint fd, char *buf, jint nbytes);
1356
1357
/*
1358
* Returns the number of bytes available for reading from a given file
1359
* descriptor
1360
*/
1361
JNIEXPORT jint JNICALL
1362
JVM_Available(jint fd, jlong *pbytes);
1363
1364
/*
1365
* Move the file descriptor pointer from whence by offset.
1366
*
1367
* fd the file descriptor to move.
1368
* offset the number of bytes to move it by.
1369
* whence the start from where to move it.
1370
*
1371
* This function returns the resulting pointer location.
1372
*/
1373
JNIEXPORT jlong JNICALL
1374
JVM_Lseek(jint fd, jlong offset, jint whence);
1375
1376
/*
1377
* Set the length of the file associated with the given descriptor to the given
1378
* length. If the new length is longer than the current length then the file
1379
* is extended; the contents of the extended portion are not defined. The
1380
* value of the file pointer is undefined after this procedure returns.
1381
*/
1382
JNIEXPORT jint JNICALL
1383
JVM_SetLength(jint fd, jlong length);
1384
1385
/*
1386
* Synchronize the file descriptor's in memory state with that of the
1387
* physical device. Return of -1 is an error, 0 is OK.
1388
*/
1389
JNIEXPORT jint JNICALL
1390
JVM_Sync(jint fd);
1391
1392
/*
1393
* Networking library support
1394
*/
1395
1396
JNIEXPORT jint JNICALL
1397
JVM_InitializeSocketLibrary(void);
1398
1399
struct sockaddr;
1400
1401
JNIEXPORT jint JNICALL
1402
JVM_Socket(jint domain, jint type, jint protocol);
1403
1404
JNIEXPORT jint JNICALL
1405
JVM_SocketClose(jint fd);
1406
1407
JNIEXPORT jint JNICALL
1408
JVM_SocketShutdown(jint fd, jint howto);
1409
1410
JNIEXPORT jint JNICALL
1411
JVM_Recv(jint fd, char *buf, jint nBytes, jint flags);
1412
1413
JNIEXPORT jint JNICALL
1414
JVM_Send(jint fd, char *buf, jint nBytes, jint flags);
1415
1416
JNIEXPORT jint JNICALL
1417
JVM_Timeout(int fd, long timeout);
1418
1419
JNIEXPORT jint JNICALL
1420
JVM_Listen(jint fd, jint count);
1421
1422
JNIEXPORT jint JNICALL
1423
JVM_Connect(jint fd, struct sockaddr *him, jint len);
1424
1425
JNIEXPORT jint JNICALL
1426
JVM_Bind(jint fd, struct sockaddr *him, jint len);
1427
1428
JNIEXPORT jint JNICALL
1429
JVM_Accept(jint fd, struct sockaddr *him, jint *len);
1430
1431
JNIEXPORT jint JNICALL
1432
JVM_RecvFrom(jint fd, char *buf, int nBytes,
1433
int flags, struct sockaddr *from, int *fromlen);
1434
1435
JNIEXPORT jint JNICALL
1436
JVM_SendTo(jint fd, char *buf, int len,
1437
int flags, struct sockaddr *to, int tolen);
1438
1439
JNIEXPORT jint JNICALL
1440
JVM_SocketAvailable(jint fd, jint *result);
1441
1442
1443
JNIEXPORT jint JNICALL
1444
JVM_GetSockName(jint fd, struct sockaddr *him, int *len);
1445
1446
JNIEXPORT jint JNICALL
1447
JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen);
1448
1449
JNIEXPORT jint JNICALL
1450
JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen);
1451
1452
JNIEXPORT int JNICALL
1453
JVM_GetHostName(char* name, int namelen);
1454
1455
/*
1456
* The standard printing functions supported by the Java VM. (Should they
1457
* be renamed to JVM_* in the future?
1458
*/
1459
1460
/*
1461
* BE CAREFUL! The following functions do not implement the
1462
* full feature set of standard C printf formats.
1463
*/
1464
JNIEXPORT int
1465
jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
1466
1467
JNIEXPORT int
1468
jio_snprintf(char *str, size_t count, const char *fmt, ...);
1469
1470
JNIEXPORT int
1471
jio_fprintf(FILE *, const char *fmt, ...);
1472
1473
JNIEXPORT int
1474
jio_vfprintf(FILE *, const char *fmt, va_list args);
1475
1476
1477
JNIEXPORT void * JNICALL
1478
JVM_RawMonitorCreate(void);
1479
1480
JNIEXPORT void JNICALL
1481
JVM_RawMonitorDestroy(void *mon);
1482
1483
JNIEXPORT jint JNICALL
1484
JVM_RawMonitorEnter(void *mon);
1485
1486
JNIEXPORT void JNICALL
1487
JVM_RawMonitorExit(void *mon);
1488
1489
/*
1490
* java.lang.reflect.Method
1491
*/
1492
JNIEXPORT jobject JNICALL
1493
JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
1494
1495
/*
1496
* java.lang.reflect.Constructor
1497
*/
1498
JNIEXPORT jobject JNICALL
1499
JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
1500
1501
/*
1502
* java.lang.management support
1503
*/
1504
JNIEXPORT void* JNICALL
1505
JVM_GetManagement(jint version);
1506
1507
/*
1508
* com.sun.tools.attach.VirtualMachine support
1509
*
1510
* Initialize the agent properties with the properties maintained in the VM.
1511
*/
1512
JNIEXPORT jobject JNICALL
1513
JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1514
1515
JNIEXPORT jstring JNICALL
1516
JVM_GetTemporaryDirectory(JNIEnv *env);
1517
1518
/* Generics reflection support.
1519
*
1520
* Returns information about the given class's EnclosingMethod
1521
* attribute, if present, or null if the class had no enclosing
1522
* method.
1523
*
1524
* If non-null, the returned array contains three elements. Element 0
1525
* is the java.lang.Class of which the enclosing method is a member,
1526
* and elements 1 and 2 are the java.lang.Strings for the enclosing
1527
* method's name and descriptor, respectively.
1528
*/
1529
JNIEXPORT jobjectArray JNICALL
1530
JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1531
1532
/*
1533
* Java thread state support
1534
*/
1535
enum {
1536
JAVA_THREAD_STATE_NEW = 0,
1537
JAVA_THREAD_STATE_RUNNABLE = 1,
1538
JAVA_THREAD_STATE_BLOCKED = 2,
1539
JAVA_THREAD_STATE_WAITING = 3,
1540
JAVA_THREAD_STATE_TIMED_WAITING = 4,
1541
JAVA_THREAD_STATE_TERMINATED = 5,
1542
JAVA_THREAD_STATE_COUNT = 6
1543
};
1544
1545
/*
1546
* Returns an array of the threadStatus values representing the
1547
* given Java thread state. Returns NULL if the VM version is
1548
* incompatible with the JDK or doesn't support the given
1549
* Java thread state.
1550
*/
1551
JNIEXPORT jintArray JNICALL
1552
JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState);
1553
1554
/*
1555
* Returns an array of the substate names representing the
1556
* given Java thread state. Returns NULL if the VM version is
1557
* incompatible with the JDK or the VM doesn't support
1558
* the given Java thread state.
1559
* values must be the jintArray returned from JVM_GetThreadStateValues
1560
* and javaThreadState.
1561
*/
1562
JNIEXPORT jobjectArray JNICALL
1563
JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values);
1564
1565
/*
1566
* Returns true if the JVM's lookup cache indicates that this class is
1567
* known to NOT exist for the given loader.
1568
*/
1569
JNIEXPORT jboolean JNICALL
1570
JVM_KnownToNotExist(JNIEnv *env, jobject loader, const char *classname);
1571
1572
/*
1573
* Returns an array of all URLs that are stored in the JVM's lookup cache
1574
* for the given loader. NULL if the lookup cache is unavailable.
1575
*/
1576
JNIEXPORT jobjectArray JNICALL
1577
JVM_GetResourceLookupCacheURLs(JNIEnv *env, jobject loader);
1578
1579
/*
1580
* Returns an array of all URLs that *may* contain the resource_name for the
1581
* given loader. This function returns an integer array, each element
1582
* of which can be used to index into the array returned by
1583
* JVM_GetResourceLookupCacheURLs of the same loader to determine the
1584
* URLs.
1585
*/
1586
JNIEXPORT jintArray JNICALL
1587
JVM_GetResourceLookupCache(JNIEnv *env, jobject loader, const char *resource_name);
1588
1589
1590
/* =========================================================================
1591
* The following defines a private JVM interface that the JDK can query
1592
* for the JVM version and capabilities. sun.misc.Version defines
1593
* the methods for getting the VM version and its capabilities.
1594
*
1595
* When a new bit is added, the following should be updated to provide
1596
* access to the new capability:
1597
* HS: JVM_GetVersionInfo and Abstract_VM_Version class
1598
* SDK: Version class
1599
*
1600
* Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
1601
* JVM to query for the JDK version and capabilities.
1602
*
1603
* When a new bit is added, the following should be updated to provide
1604
* access to the new capability:
1605
* HS: JDK_Version class
1606
* SDK: JDK_GetVersionInfo0
1607
*
1608
* ==========================================================================
1609
*/
1610
typedef struct {
1611
/* HotSpot Express VM version string:
1612
* <major>.<minor>-bxx[-<identifier>][-<debug_flavor>]
1613
*/
1614
unsigned int jvm_version; /* Consists of major.minor.0.build */
1615
unsigned int update_version : 8; /* 0 in HotSpot Express VM */
1616
unsigned int special_update_version : 8; /* 0 in HotSpot Express VM */
1617
unsigned int reserved1 : 16;
1618
unsigned int reserved2;
1619
1620
/* The following bits represents JVM supports that JDK has dependency on.
1621
* JDK can use these bits to determine which JVM version
1622
* and support it has to maintain runtime compatibility.
1623
*
1624
* When a new bit is added in a minor or update release, make sure
1625
* the new bit is also added in the main/baseline.
1626
*/
1627
unsigned int is_attachable : 1;
1628
unsigned int : 31;
1629
unsigned int : 32;
1630
unsigned int : 32;
1631
} jvm_version_info;
1632
1633
#define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1634
#define JVM_VERSION_MINOR(version) ((version & 0x00FFFF00) >> 8)
1635
// Micro version is 0 in HotSpot Express VM (set in jvm.cpp).
1636
#define JVM_VERSION_MICRO(version) 0
1637
/* Build number is available in all HotSpot Express VM builds.
1638
* It is defined in make/hotspot_version file.
1639
*/
1640
#define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
1641
1642
JNIEXPORT void JNICALL
1643
JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
1644
1645
typedef struct {
1646
// Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
1647
unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */
1648
/* and build number (xx) */
1649
unsigned int update_version : 16; /* Update release version (uu) */
1650
unsigned int special_update_version : 8; /* Special update release version (c)*/
1651
unsigned int reserved1 : 8;
1652
unsigned int reserved2;
1653
1654
/* The following bits represents new JDK supports that VM has dependency on.
1655
* VM implementation can use these bits to determine which JDK version
1656
* and support it has to maintain runtime compatibility.
1657
*
1658
* When a new bit is added in a minor or update release, make sure
1659
* the new bit is also added in the main/baseline.
1660
*/
1661
unsigned int thread_park_blocker : 1;
1662
unsigned int post_vm_init_hook_enabled : 1;
1663
unsigned int pending_list_uses_discovered_field : 1;
1664
unsigned int : 29;
1665
unsigned int : 32;
1666
unsigned int : 32;
1667
} jdk_version_info;
1668
1669
#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1670
#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1671
#define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1672
1673
/* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN)
1674
* It will be zero for internal builds.
1675
*/
1676
#define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
1677
1678
/*
1679
* This is the function JDK_GetVersionInfo0 defined in libjava.so
1680
* that is dynamically looked up by JVM.
1681
*/
1682
typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
1683
1684
/*
1685
* This structure is used by the launcher to get the default thread
1686
* stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1687
* version of 1.1. As it is not supported otherwise, it has been removed
1688
* from jni.h
1689
*/
1690
typedef struct JDK1_1InitArgs {
1691
jint version;
1692
1693
char **properties;
1694
jint checkSource;
1695
jint nativeStackSize;
1696
jint javaStackSize;
1697
jint minHeapSize;
1698
jint maxHeapSize;
1699
jint verifyMode;
1700
char *classpath;
1701
1702
jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1703
void (JNICALL *exit)(jint code);
1704
void (JNICALL *abort)(void);
1705
1706
jint enableClassGC;
1707
jint enableVerboseGC;
1708
jint disableAsyncGC;
1709
jint verbose;
1710
jboolean debugging;
1711
jint debugPort;
1712
} JDK1_1InitArgs;
1713
1714
#ifdef __cplusplus
1715
} /* extern "C" */
1716
#endif /* __cplusplus */
1717
1718
#endif /* !_JAVASOFT_JVM_H_ */
1719
1720
#endif // SHARE_VM_PRIMS_JVM_H
1721
1722