1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
4 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
5 Free Software Foundation
7 This file is part of libgcj.
9 This software is copyrighted work licensed under the terms of the
10 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
13 #ifndef __JAVAPRIMS_H__
14 #define __JAVAPRIMS_H__
16 // Force C++ compiler to use Java-style exceptions.
17 #pragma GCC java_exceptions
19 #include <gcj/libgcj-config.h>
21 // FIXME: this is a hack until we get a proper gcjh.
22 // It is needed to work around system header files that define TRUE
29 // To force selection of correct types that will mangle consistently
33 typedef __java_byte jbyte
;
34 typedef __java_short jshort
;
35 typedef __java_int jint
;
36 typedef __java_long jlong
;
37 typedef __java_float jfloat
;
38 typedef __java_double jdouble
;
39 typedef __java_char jchar
;
40 typedef __java_boolean jboolean
;
43 // The following class declarations are automatically generated by
44 // the `classes.pl' script.
49 class BufferedInputStream
;
50 class BufferedOutputStream
;
53 class ByteArrayInputStream
;
54 class ByteArrayOutputStream
;
55 class CharArrayReader
;
56 class CharArrayWriter
;
57 class CharConversionException
;
59 class DataInputStream
;
61 class DataOutputStream
;
67 class FileInputStream
;
68 class FileNotFoundException
;
69 class FileOutputStream
;
74 class FilterInputStream
;
75 class FilterOutputStream
;
80 class InputStreamReader
;
81 class InterfaceComparator
;
82 class InterruptedIOException
;
83 class InvalidClassException
;
84 class InvalidObjectException
;
85 class LineNumberInputStream
;
86 class LineNumberReader
;
87 class MemberComparator
;
89 class NotActiveException
;
90 class NotSerializableException
;
92 class ObjectInputStream
;
93 class ObjectInputStream$GetField
;
94 class ObjectInputValidation
;
96 class ObjectOutputStream
;
97 class ObjectOutputStream$PutField
;
98 class ObjectStreamClass
;
99 class ObjectStreamConstants
;
100 class ObjectStreamException
;
101 class ObjectStreamField
;
102 class OptionalDataException
;
104 class OutputStreamWriter
;
105 class PipedInputStream
;
106 class PipedOutputStream
;
111 class PushbackInputStream
;
112 class PushbackReader
;
113 class RandomAccessFile
;
115 class SequenceInputStream
;
117 class SerializablePermission
;
118 class StreamCorruptedException
;
119 class StreamTokenizer
;
120 class StringBufferInputStream
;
123 class SyncFailedException
;
124 class UTFDataFormatException
;
125 class UnsupportedEncodingException
;
126 class VMObjectStreamClass
;
127 class ValidatorAndPriority
;
128 class WriteAbortedException
;
134 class AbstractMethodError
;
135 class ArithmeticException
;
136 class ArrayIndexOutOfBoundsException
;
137 class ArrayStoreException
;
138 class AssertionError
;
143 class Character$Subset
;
144 class Character$UnicodeBlock
;
146 class ClassCastException
;
147 class ClassCircularityError
;
148 class ClassFormatError
;
150 class ClassNotFoundException
;
151 class CloneNotSupportedException
;
155 class ConcreteProcess
;
156 class ConcreteProcess$EOFInputStream
;
157 class ConcreteProcess$ProcessManager
;
161 class ExceptionInInitializerError
;
163 class IllegalAccessError
;
164 class IllegalAccessException
;
165 class IllegalArgumentException
;
166 class IllegalMonitorStateException
;
167 class IllegalStateException
;
168 class IllegalThreadStateException
;
169 class IncompatibleClassChangeError
;
170 class IndexOutOfBoundsException
;
171 class InheritableThreadLocal
;
172 class InstantiationError
;
173 class InstantiationException
;
176 class InterruptedException
;
180 class NegativeArraySizeException
;
181 class NoClassDefFoundError
;
182 class NoSuchFieldError
;
183 class NoSuchFieldException
;
184 class NoSuchMethodError
;
185 class NoSuchMethodException
;
186 class NullPointerException
;
188 class NumberFormatException
;
190 class OutOfMemoryError
;
195 class RuntimeException
;
196 class RuntimePermission
;
197 class SecurityContext
;
198 class SecurityException
;
199 class SecurityManager
;
201 class StackOverflowError
;
202 class StackTraceElement
;
205 class String$CaseInsensitiveComparator
;
207 class StringIndexOutOfBoundsException
;
215 class UnsatisfiedLinkError
;
216 class UnsupportedClassVersionError
;
217 class UnsupportedOperationException
;
220 class VMSecurityManager
;
223 class VirtualMachineError
;
227 class PhantomReference
;
229 class ReferenceQueue
;
236 class AccessibleObject
;
240 class InvocationHandler
;
241 class InvocationTargetException
;
246 class Proxy$ClassFactory
;
247 class Proxy$ProxyData
;
248 class Proxy$ProxySignature
;
249 class Proxy$ProxyType
;
250 class ReflectPermission
;
251 class UndeclaredThrowableException
;
257 class AbstractCollection
;
260 class AbstractMap$BasicMapEntry
;
261 class AbstractSequentialList
;
265 class Arrays$ArrayList
;
270 class Collections$CopiesList
;
271 class Collections$EmptyList
;
272 class Collections$EmptyMap
;
273 class Collections$EmptySet
;
274 class Collections$ReverseComparator
;
275 class Collections$SingletonList
;
276 class Collections$SingletonMap
;
277 class Collections$SingletonSet
;
278 class Collections$SynchronizedCollection
;
279 class Collections$SynchronizedIterator
;
280 class Collections$SynchronizedList
;
281 class Collections$SynchronizedListIterator
;
282 class Collections$SynchronizedMap
;
283 class Collections$SynchronizedMapEntry
;
284 class Collections$SynchronizedRandomAccessList
;
285 class Collections$SynchronizedSet
;
286 class Collections$SynchronizedSortedMap
;
287 class Collections$SynchronizedSortedSet
;
288 class Collections$UnmodifiableCollection
;
289 class Collections$UnmodifiableEntrySet
;
290 class Collections$UnmodifiableIterator
;
291 class Collections$UnmodifiableList
;
292 class Collections$UnmodifiableListIterator
;
293 class Collections$UnmodifiableMap
;
294 class Collections$UnmodifiableRandomAccessList
;
295 class Collections$UnmodifiableSet
;
296 class Collections$UnmodifiableSortedMap
;
297 class Collections$UnmodifiableSortedSet
;
299 class ConcurrentModificationException
;
303 class EmptyStackException
;
306 class EventListenerProxy
;
308 class GregorianCalendar
;
310 class HashMap$HashEntry
;
311 class HashMap$HashIterator
;
314 class Hashtable$Enumerator
;
315 class Hashtable$HashEntry
;
316 class Hashtable$HashIterator
;
317 class IdentityHashMap
;
318 class IdentityHashMap$IdentityEntry
;
319 class IdentityHashMap$IdentityIterator
;
322 class LinkedHashMap$LinkedHashEntry
;
325 class LinkedList$Entry
;
326 class LinkedList$LinkedListItr
;
329 class ListResourceBundle
;
334 class MissingResourceException
;
336 class NoSuchElementException
;
340 class PropertyPermission
;
341 class PropertyPermissionCollection
;
342 class PropertyResourceBundle
;
345 class RandomAccessSubList
;
346 class ResourceBundle
;
347 class ResourceBundle$BundleKey
;
349 class SimpleTimeZone
;
353 class StringTokenizer
;
357 class Timer$Scheduler
;
358 class Timer$TaskQueue
;
360 class TooManyListenersException
;
363 class TreeMap$SubMap
;
364 class TreeMap$TreeIterator
;
369 class WeakHashMap$WeakBucket
;
370 class WeakHashMap$WeakEntry
;
371 class WeakHashMap$WeakEntrySet
;
375 class Attributes$Name
;
379 class JarFile$JarEnumeration
;
380 class JarInputStream
;
381 class JarOutputStream
;
387 class ConsoleHandler
;
397 class LoggingPermission
;
399 class SimpleFormatter
;
407 class AbstractPreferences
;
408 class BackingStoreException
;
409 class InvalidPreferencesFormatException
;
410 class NodeChangeEvent
;
411 class NodeChangeListener
;
412 class PreferenceChangeEvent
;
413 class PreferenceChangeListener
;
415 class PreferencesFactory
;
422 class PatternSyntaxException
;
429 class CheckedInputStream
;
430 class CheckedOutputStream
;
432 class DataFormatException
;
434 class DeflaterOutputStream
;
435 class GZIPInputStream
;
436 class GZIPOutputStream
;
438 class InflaterInputStream
;
443 class ZipFile$PartialInputStream
;
444 class ZipFile$ZipEntryEnumeration
;
445 class ZipInputStream
;
446 class ZipOutputStream
;
452 typedef struct java::lang::Object
* jobject
;
453 typedef class java::lang::Class
* jclass
;
454 typedef class java::lang::Throwable
* jthrowable
;
455 typedef class java::lang::String
* jstring
;
458 typedef struct _Jv_Field
*jfieldID
;
459 typedef struct _Jv_Method
*jmethodID
;
461 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
462 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
463 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
464 #ifdef JV_HASH_SYNCHRONIZATION
465 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
466 __attribute__((__malloc__
));
468 // Collector still needs to scan sync_info
469 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
471 return _Jv_AllocObject(klass
);
474 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
475 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
476 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
477 __attribute__((__malloc__
));
478 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
479 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
480 extern "C" void _Jv_MonitorEnter (jobject
);
481 extern "C" void _Jv_MonitorExit (jobject
);
482 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
483 __attribute__((__malloc__
));
484 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
485 __attribute__((__malloc__
));
486 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
487 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
488 extern "C" jint
_Jv_hashUtf8String (char*, int);
492 // a VM initialization option
494 // extra information associated with this option
498 struct _Jv_VMInitArgs
500 // for compatibility with JavaVMInitArgs
503 // number of VM initialization options
506 // an array of VM initialization options
507 struct _Jv_VMOption
* options
;
509 // true if the option parser should ignore unrecognized options
510 jboolean ignoreUnrecognized
;
513 extern jint
_Jv_CreateJavaVM (struct _Jv_VMInitArgs
*);
516 _Jv_ThreadRun (java::lang::Thread
* thread
);
518 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
519 extern "C" java::lang::Thread
*
520 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
521 extern "C" java::lang::Thread
*
522 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
523 extern "C" jint
_Jv_DetachCurrentThread (void);
525 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
526 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
527 extern "C" void* _Jv_Realloc (void *, jsize
);
528 extern "C" void _Jv_Free (void*);
529 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
530 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
532 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
533 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
534 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
539 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
540 char data
[1]; /* In Utf8 format, with final '\0'. */
542 /** Return same value of java.lang.String's hashCode. */
543 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
544 /** Return a hash code that has at least 16 bits of information. */
545 _Jv_ushort
hash16 () { return hash
; }
546 /** Return a hash code that has at least 8 bits of information. */
547 _Jv_ushort
hash8 () { return hash
; }
548 /** Length in bytes of the UTF8-encoding. */
549 _Jv_ushort
len () const { return length
; }
550 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
551 char* chars() { return data
; }
552 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
553 char* limit() { return data
+length
; }
554 /** Return the first byte in the UTF8-encoding. */
555 char first() const { return data
[0]; }
556 /** Create a (non-interned) java.lang.String from this UTF8Const. */
557 jstring
toString() { return _Jv_NewStringUTF(data
); }
558 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
559 including struct header, and final NUL. I.e. what to pas to malloc. */
560 static int space_needed (char *, int len
)
561 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
562 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
563 void init (char *s
, int len
);
564 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
565 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
566 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
567 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (char*, int);
568 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
569 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
573 #endif /* __JAVAPRIMS_H__ */