1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 #ifndef __JAVAPRIMS_H__
13 #define __JAVAPRIMS_H__
15 // Force C++ compiler to use Java-style exceptions.
16 #pragma GCC java_exceptions
18 #include <gcj/libgcj-config.h>
20 // FIXME: this is a hack until we get a proper gcjh.
21 // It is needed to work around system header files that define TRUE
28 // To force selection of correct types that will mangle consistently
32 typedef __java_byte jbyte
;
33 typedef __java_short jshort
;
34 typedef __java_int jint
;
35 typedef __java_long jlong
;
36 typedef __java_float jfloat
;
37 typedef __java_double jdouble
;
38 typedef __java_char jchar
;
39 typedef __java_boolean jboolean
;
42 // The following class declarations are automatically generated by
43 // the `classes.pl' script.
48 class BufferedInputStream
;
49 class BufferedOutputStream
;
52 class ByteArrayInputStream
;
53 class ByteArrayOutputStream
;
54 class CharArrayReader
;
55 class CharArrayWriter
;
56 class CharConversionException
;
58 class DataInputStream
;
60 class DataOutputStream
;
66 class FileInputStream
;
67 class FileNotFoundException
;
68 class FileOutputStream
;
73 class FilterInputStream
;
74 class FilterOutputStream
;
79 class InputStreamReader
;
80 class InterfaceComparator
;
81 class InterruptedIOException
;
82 class InvalidClassException
;
83 class InvalidObjectException
;
84 class LineNumberInputStream
;
85 class LineNumberReader
;
86 class MemberComparator
;
87 class NotActiveException
;
88 class NotSerializableException
;
90 class ObjectInputStream
;
91 class ObjectInputStream$GetField
;
92 class ObjectInputValidation
;
94 class ObjectOutputStream
;
95 class ObjectOutputStream$PutField
;
96 class ObjectStreamClass
;
97 class ObjectStreamConstants
;
98 class ObjectStreamException
;
99 class ObjectStreamField
;
100 class OptionalDataException
;
102 class OutputStreamWriter
;
103 class PipedInputStream
;
104 class PipedOutputStream
;
109 class PushbackInputStream
;
110 class PushbackReader
;
111 class RandomAccessFile
;
113 class SequenceInputStream
;
115 class SerializablePermission
;
116 class StreamCorruptedException
;
117 class StreamTokenizer
;
118 class StringBufferInputStream
;
121 class SyncFailedException
;
122 class UTFDataFormatException
;
123 class UnsupportedEncodingException
;
124 class VMObjectStreamClass
;
125 class ValidatorAndPriority
;
126 class WriteAbortedException
;
132 class AbstractMethodError
;
133 class ArithmeticException
;
134 class ArrayIndexOutOfBoundsException
;
135 class ArrayStoreException
;
136 class AssertionError
;
141 class Character$Subset
;
142 class Character$UnicodeBlock
;
144 class ClassCastException
;
145 class ClassCircularityError
;
146 class ClassFormatError
;
148 class ClassNotFoundException
;
149 class CloneNotSupportedException
;
153 class ConcreteProcess
;
154 class ConcreteProcess$EOFInputStream
;
155 class ConcreteProcess$ProcessManager
;
159 class ExceptionInInitializerError
;
161 class IllegalAccessError
;
162 class IllegalAccessException
;
163 class IllegalArgumentException
;
164 class IllegalMonitorStateException
;
165 class IllegalStateException
;
166 class IllegalThreadStateException
;
167 class IncompatibleClassChangeError
;
168 class IndexOutOfBoundsException
;
169 class InheritableThreadLocal
;
170 class InstantiationError
;
171 class InstantiationException
;
174 class InterruptedException
;
178 class NegativeArraySizeException
;
179 class NoClassDefFoundError
;
180 class NoSuchFieldError
;
181 class NoSuchFieldException
;
182 class NoSuchMethodError
;
183 class NoSuchMethodException
;
184 class NullPointerException
;
186 class NumberFormatException
;
188 class OutOfMemoryError
;
193 class RuntimeException
;
194 class RuntimePermission
;
195 class SecurityContext
;
196 class SecurityException
;
197 class SecurityManager
;
199 class StackOverflowError
;
200 class StackTraceElement
;
203 class String$CaseInsensitiveComparator
;
205 class StringIndexOutOfBoundsException
;
213 class UnsatisfiedLinkError
;
214 class UnsupportedClassVersionError
;
215 class UnsupportedOperationException
;
217 class VMSecurityManager
;
220 class VirtualMachineError
;
224 class PhantomReference
;
226 class ReferenceQueue
;
233 class AccessibleObject
;
237 class InvocationHandler
;
238 class InvocationTargetException
;
243 class Proxy$ClassFactory
;
244 class Proxy$ProxyData
;
245 class Proxy$ProxySignature
;
246 class Proxy$ProxyType
;
247 class ReflectPermission
;
248 class UndeclaredThrowableException
;
254 class AbstractCollection
;
257 class AbstractMap$BasicMapEntry
;
258 class AbstractSequentialList
;
262 class Arrays$ArrayList
;
267 class Collections$CopiesList
;
268 class Collections$EmptyList
;
269 class Collections$EmptyMap
;
270 class Collections$EmptySet
;
271 class Collections$ReverseComparator
;
272 class Collections$SingletonList
;
273 class Collections$SingletonMap
;
274 class Collections$SingletonSet
;
275 class Collections$SynchronizedCollection
;
276 class Collections$SynchronizedIterator
;
277 class Collections$SynchronizedList
;
278 class Collections$SynchronizedListIterator
;
279 class Collections$SynchronizedMap
;
280 class Collections$SynchronizedMapEntry
;
281 class Collections$SynchronizedRandomAccessList
;
282 class Collections$SynchronizedSet
;
283 class Collections$SynchronizedSortedMap
;
284 class Collections$SynchronizedSortedSet
;
285 class Collections$UnmodifiableCollection
;
286 class Collections$UnmodifiableEntrySet
;
287 class Collections$UnmodifiableIterator
;
288 class Collections$UnmodifiableList
;
289 class Collections$UnmodifiableListIterator
;
290 class Collections$UnmodifiableMap
;
291 class Collections$UnmodifiableRandomAccessList
;
292 class Collections$UnmodifiableSet
;
293 class Collections$UnmodifiableSortedMap
;
294 class Collections$UnmodifiableSortedSet
;
296 class ConcurrentModificationException
;
300 class EmptyStackException
;
303 class EventListenerProxy
;
305 class GregorianCalendar
;
307 class HashMap$HashEntry
;
308 class HashMap$HashIterator
;
311 class Hashtable$Enumerator
;
312 class Hashtable$HashEntry
;
313 class Hashtable$HashIterator
;
314 class IdentityHashMap
;
315 class IdentityHashMap$IdentityEntry
;
316 class IdentityHashMap$IdentityIterator
;
319 class LinkedHashMap$LinkedHashEntry
;
322 class LinkedList$Entry
;
323 class LinkedList$LinkedListItr
;
326 class ListResourceBundle
;
331 class MissingResourceException
;
333 class NoSuchElementException
;
337 class PropertyPermission
;
338 class PropertyPermissionCollection
;
339 class PropertyResourceBundle
;
342 class RandomAccessSubList
;
343 class ResourceBundle
;
344 class ResourceBundle$BundleKey
;
346 class SimpleTimeZone
;
350 class StringTokenizer
;
354 class Timer$Scheduler
;
355 class Timer$TaskQueue
;
357 class TooManyListenersException
;
360 class TreeMap$SubMap
;
361 class TreeMap$TreeIterator
;
366 class WeakHashMap$WeakBucket
;
367 class WeakHashMap$WeakEntry
;
368 class WeakHashMap$WeakEntrySet
;
372 class Attributes$Name
;
376 class JarFile$JarEnumeration
;
377 class JarInputStream
;
378 class JarOutputStream
;
384 class ConsoleHandler
;
394 class LoggingPermission
;
396 class SimpleFormatter
;
404 class AbstractPreferences
;
405 class BackingStoreException
;
406 class InvalidPreferencesFormatException
;
407 class NodeChangeEvent
;
408 class NodeChangeListener
;
409 class PreferenceChangeEvent
;
410 class PreferenceChangeListener
;
412 class PreferencesFactory
;
419 class PatternSyntaxException
;
426 class CheckedInputStream
;
427 class CheckedOutputStream
;
429 class DataFormatException
;
431 class DeflaterOutputStream
;
432 class GZIPInputStream
;
433 class GZIPOutputStream
;
435 class InflaterInputStream
;
440 class ZipFile$PartialInputStream
;
441 class ZipFile$ZipEntryEnumeration
;
442 class ZipInputStream
;
443 class ZipOutputStream
;
449 typedef struct java::lang::Object
* jobject
;
450 typedef class java::lang::Class
* jclass
;
451 typedef class java::lang::Throwable
* jthrowable
;
452 typedef class java::lang::String
* jstring
;
455 typedef struct _Jv_Field
*jfieldID
;
456 typedef struct _Jv_Method
*jmethodID
;
458 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
459 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
460 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
461 #ifdef JV_HASH_SYNCHRONIZATION
462 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
463 __attribute__((__malloc__
));
465 // Collector still needs to scan sync_info
466 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
468 return _Jv_AllocObject(klass
);
471 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
472 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
473 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
474 __attribute__((__malloc__
));
475 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
476 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
477 extern "C" void _Jv_MonitorEnter (jobject
);
478 extern "C" void _Jv_MonitorExit (jobject
);
479 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
480 __attribute__((__malloc__
));
481 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
482 __attribute__((__malloc__
));
483 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
484 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
485 extern "C" jint
_Jv_hashUtf8String (char*, int);
487 extern jint
_Jv_CreateJavaVM (void* /*vm_args*/);
490 _Jv_ThreadRun (java::lang::Thread
* thread
);
492 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
493 extern "C" java::lang::Thread
*
494 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
495 extern "C" java::lang::Thread
*
496 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
497 extern "C" jint
_Jv_DetachCurrentThread (void);
499 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
500 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
501 extern "C" void* _Jv_Realloc (void *, jsize
);
502 extern "C" void _Jv_Free (void*);
503 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
504 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
506 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
507 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
508 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
513 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
514 char data
[1]; /* In Utf8 format, with final '\0'. */
516 /** Return same value of java.lang.String's hashCode. */
517 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
518 /** Return a hash code that has at least 16 bits of information. */
519 _Jv_ushort
hash16 () { return hash
; }
520 /** Return a hash code that has at least 8 bits of information. */
521 _Jv_ushort
hash8 () { return hash
; }
522 /** Length in bytes of the UTF8-encoding. */
523 _Jv_ushort
len () const { return length
; }
524 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
525 char* chars() { return data
; }
526 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
527 char* limit() { return data
+length
; }
528 /** Return the first byte in the UTF8-encoding. */
529 char first() const { return data
[0]; }
530 /** Create a (non-interned) java.lang.String from this UTF8Const. */
531 jstring
toString() { return _Jv_NewStringUTF(data
); }
532 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
533 including struct header, and final NUL. I.e. what to pas to malloc. */
534 static int space_needed (char *, int len
)
535 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
536 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
537 void init (char *s
, int len
);
538 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
539 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
540 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
541 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (char*, int);
542 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
543 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
547 #endif /* __JAVAPRIMS_H__ */