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$ProcessManager
;
158 class ExceptionInInitializerError
;
160 class IllegalAccessError
;
161 class IllegalAccessException
;
162 class IllegalArgumentException
;
163 class IllegalMonitorStateException
;
164 class IllegalStateException
;
165 class IllegalThreadStateException
;
166 class IncompatibleClassChangeError
;
167 class IndexOutOfBoundsException
;
168 class InheritableThreadLocal
;
169 class InstantiationError
;
170 class InstantiationException
;
173 class InterruptedException
;
177 class NegativeArraySizeException
;
178 class NoClassDefFoundError
;
179 class NoSuchFieldError
;
180 class NoSuchFieldException
;
181 class NoSuchMethodError
;
182 class NoSuchMethodException
;
183 class NullPointerException
;
185 class NumberFormatException
;
187 class OutOfMemoryError
;
192 class RuntimeException
;
193 class RuntimePermission
;
194 class SecurityContext
;
195 class SecurityException
;
196 class SecurityManager
;
198 class StackOverflowError
;
199 class StackTraceElement
;
202 class String$CaseInsensitiveComparator
;
204 class StringIndexOutOfBoundsException
;
212 class UnsatisfiedLinkError
;
213 class UnsupportedClassVersionError
;
214 class UnsupportedOperationException
;
216 class VMSecurityManager
;
219 class VirtualMachineError
;
223 class PhantomReference
;
225 class ReferenceQueue
;
232 class AccessibleObject
;
236 class InvocationHandler
;
237 class InvocationTargetException
;
242 class Proxy$ClassFactory
;
243 class Proxy$ProxyData
;
244 class Proxy$ProxySignature
;
245 class Proxy$ProxyType
;
246 class ReflectPermission
;
247 class UndeclaredThrowableException
;
253 class AbstractCollection
;
256 class AbstractMap$BasicMapEntry
;
257 class AbstractSequentialList
;
261 class Arrays$ArrayList
;
266 class Collections$CopiesList
;
267 class Collections$EmptyList
;
268 class Collections$EmptyMap
;
269 class Collections$EmptySet
;
270 class Collections$ReverseComparator
;
271 class Collections$SingletonList
;
272 class Collections$SingletonMap
;
273 class Collections$SingletonSet
;
274 class Collections$SynchronizedCollection
;
275 class Collections$SynchronizedIterator
;
276 class Collections$SynchronizedList
;
277 class Collections$SynchronizedListIterator
;
278 class Collections$SynchronizedMap
;
279 class Collections$SynchronizedMapEntry
;
280 class Collections$SynchronizedRandomAccessList
;
281 class Collections$SynchronizedSet
;
282 class Collections$SynchronizedSortedMap
;
283 class Collections$SynchronizedSortedSet
;
284 class Collections$UnmodifiableCollection
;
285 class Collections$UnmodifiableEntrySet
;
286 class Collections$UnmodifiableIterator
;
287 class Collections$UnmodifiableList
;
288 class Collections$UnmodifiableListIterator
;
289 class Collections$UnmodifiableMap
;
290 class Collections$UnmodifiableRandomAccessList
;
291 class Collections$UnmodifiableSet
;
292 class Collections$UnmodifiableSortedMap
;
293 class Collections$UnmodifiableSortedSet
;
295 class ConcurrentModificationException
;
299 class EmptyStackException
;
302 class EventListenerProxy
;
304 class GregorianCalendar
;
306 class HashMap$HashEntry
;
307 class HashMap$HashIterator
;
310 class Hashtable$Enumerator
;
311 class Hashtable$HashEntry
;
312 class Hashtable$HashIterator
;
313 class IdentityHashMap
;
314 class IdentityHashMap$IdentityEntry
;
315 class IdentityHashMap$IdentityIterator
;
318 class LinkedHashMap$LinkedHashEntry
;
321 class LinkedList$Entry
;
322 class LinkedList$LinkedListItr
;
325 class ListResourceBundle
;
330 class MissingResourceException
;
332 class NoSuchElementException
;
336 class PropertyPermission
;
337 class PropertyPermissionCollection
;
338 class PropertyResourceBundle
;
341 class RandomAccessSubList
;
342 class ResourceBundle
;
343 class ResourceBundle$BundleKey
;
345 class SimpleTimeZone
;
349 class StringTokenizer
;
353 class Timer$Scheduler
;
354 class Timer$TaskQueue
;
356 class TooManyListenersException
;
359 class TreeMap$SubMap
;
360 class TreeMap$TreeIterator
;
364 class WeakHashMap$WeakBucket
;
365 class WeakHashMap$WeakEntry
;
366 class WeakHashMap$WeakEntrySet
;
370 class Attributes$Name
;
374 class JarFile$JarEnumeration
;
375 class JarInputStream
;
376 class JarOutputStream
;
382 class ConsoleHandler
;
392 class LoggingPermission
;
394 class SimpleFormatter
;
402 class AbstractPreferences
;
403 class BackingStoreException
;
404 class InvalidPreferencesFormatException
;
405 class NodeChangeEvent
;
406 class NodeChangeListener
;
407 class PreferenceChangeEvent
;
408 class PreferenceChangeListener
;
410 class PreferencesFactory
;
417 class PatternSyntaxException
;
424 class CheckedInputStream
;
425 class CheckedOutputStream
;
427 class DataFormatException
;
429 class DeflaterOutputStream
;
430 class GZIPInputStream
;
431 class GZIPOutputStream
;
433 class InflaterInputStream
;
438 class ZipFile$PartialInputStream
;
439 class ZipFile$ZipEntryEnumeration
;
440 class ZipInputStream
;
441 class ZipOutputStream
;
447 typedef struct java::lang::Object
* jobject
;
448 typedef class java::lang::Class
* jclass
;
449 typedef class java::lang::Throwable
* jthrowable
;
450 typedef class java::lang::String
* jstring
;
453 typedef struct _Jv_Field
*jfieldID
;
454 typedef struct _Jv_Method
*jmethodID
;
456 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
457 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
458 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
459 #ifdef JV_HASH_SYNCHRONIZATION
460 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
461 __attribute__((__malloc__
));
463 // Collector still needs to scan sync_info
464 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
466 return _Jv_AllocObject(klass
);
469 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
470 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
471 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
472 __attribute__((__malloc__
));
473 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
474 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
475 extern "C" void _Jv_MonitorEnter (jobject
);
476 extern "C" void _Jv_MonitorExit (jobject
);
477 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
478 __attribute__((__malloc__
));
479 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
480 __attribute__((__malloc__
));
481 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
482 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
483 extern "C" jint
_Jv_hashUtf8String (char*, int);
485 extern jint
_Jv_CreateJavaVM (void* /*vm_args*/);
488 _Jv_ThreadRun (java::lang::Thread
* thread
);
490 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
491 extern "C" java::lang::Thread
*
492 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
493 extern "C" java::lang::Thread
*
494 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
495 extern "C" jint
_Jv_DetachCurrentThread (void);
497 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
498 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
499 extern "C" void* _Jv_Realloc (void *, jsize
);
500 extern "C" void _Jv_Free (void*);
501 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
502 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
504 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
505 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
506 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
511 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
512 char data
[1]; /* In Utf8 format, with final '\0'. */
514 /** Return same value of java.lang.String's hashCode. */
515 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
516 /** Return a hash code that has at least 16 bits of information. */
517 _Jv_ushort
hash16 () { return hash
; }
518 /** Return a hash code that has at least 8 bits of information. */
519 _Jv_ushort
hash8 () { return hash
; }
520 /** Length in bytes of the UTF8-encoding. */
521 _Jv_ushort
len () const { return length
; }
522 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
523 char* chars() { return data
; }
524 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
525 char* limit() { return data
+length
; }
526 /** Return the first byte in the UTF8-encoding. */
527 char first() const { return data
[0]; }
528 /** Create a (non-interned) java.lang.String from this UTF8Const. */
529 jstring
toString() { return _Jv_NewStringUTF(data
); }
530 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
531 including struct header, and final NUL. I.e. what to pas to malloc. */
532 static int space_needed (char *, int len
)
533 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
534 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
535 void init (char *s
, int len
);
536 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
537 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
538 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
539 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (char*, int);
540 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
541 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
545 #endif /* __JAVAPRIMS_H__ */