1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 #ifndef __JAVAPRIMS_H__
12 #define __JAVAPRIMS_H__
14 // Force C++ compiler to use Java-style exceptions.
15 #pragma GCC java_exceptions
17 #include <gcj/libgcj-config.h>
19 // FIXME: this is a hack until we get a proper gcjh.
20 // It is needed to work around system header files that define TRUE
27 // To force selection of correct types that will mangle consistently
31 typedef __java_byte jbyte
;
32 typedef __java_short jshort
;
33 typedef __java_int jint
;
34 typedef __java_long jlong
;
35 typedef __java_float jfloat
;
36 typedef __java_double jdouble
;
37 typedef __java_char jchar
;
38 typedef __java_boolean jboolean
;
41 // The following class declarations are automatically generated by
42 // the `classes.pl' script.
47 class BufferedInputStream
;
48 class BufferedOutputStream
;
51 class ByteArrayInputStream
;
52 class ByteArrayOutputStream
;
53 class CharArrayReader
;
54 class CharArrayWriter
;
55 class CharConversionException
;
57 class DataInputStream
;
59 class DataOutputStream
;
65 class FileInputStream
;
66 class FileNotFoundException
;
67 class FileOutputStream
;
72 class FilterInputStream
;
73 class FilterOutputStream
;
78 class InputStreamReader
;
79 class InterfaceComparator
;
80 class InterruptedIOException
;
81 class InvalidClassException
;
82 class InvalidObjectException
;
83 class LineNumberInputStream
;
84 class LineNumberReader
;
85 class MemberComparator
;
86 class NotActiveException
;
87 class NotSerializableException
;
89 class ObjectInputStream
;
90 class ObjectInputStream$GetField
;
91 class ObjectInputValidation
;
93 class ObjectOutputStream
;
94 class ObjectOutputStream$PutField
;
95 class ObjectStreamClass
;
96 class ObjectStreamConstants
;
97 class ObjectStreamException
;
98 class ObjectStreamField
;
99 class OptionalDataException
;
101 class OutputStreamWriter
;
102 class PipedInputStream
;
103 class PipedOutputStream
;
108 class PushbackInputStream
;
109 class PushbackReader
;
110 class RandomAccessFile
;
112 class SequenceInputStream
;
114 class SerializablePermission
;
115 class StreamCorruptedException
;
116 class StreamTokenizer
;
117 class StringBufferInputStream
;
120 class SyncFailedException
;
121 class UTFDataFormatException
;
122 class UnsupportedEncodingException
;
123 class VMObjectStreamClass
;
124 class ValidatorAndPriority
;
125 class WriteAbortedException
;
131 class AbstractMethodError
;
132 class ArithmeticException
;
133 class ArrayIndexOutOfBoundsException
;
134 class ArrayStoreException
;
135 class AssertionError
;
140 class Character$Subset
;
141 class Character$UnicodeBlock
;
143 class ClassCastException
;
144 class ClassCircularityError
;
145 class ClassFormatError
;
147 class ClassNotFoundException
;
148 class CloneNotSupportedException
;
152 class ConcreteProcess
;
156 class ExceptionInInitializerError
;
158 class IllegalAccessError
;
159 class IllegalAccessException
;
160 class IllegalArgumentException
;
161 class IllegalMonitorStateException
;
162 class IllegalStateException
;
163 class IllegalThreadStateException
;
164 class IncompatibleClassChangeError
;
165 class IndexOutOfBoundsException
;
166 class InheritableThreadLocal
;
167 class InstantiationError
;
168 class InstantiationException
;
171 class InterruptedException
;
175 class NegativeArraySizeException
;
176 class NoClassDefFoundError
;
177 class NoSuchFieldError
;
178 class NoSuchFieldException
;
179 class NoSuchMethodError
;
180 class NoSuchMethodException
;
181 class NullPointerException
;
183 class NumberFormatException
;
185 class OutOfMemoryError
;
190 class RuntimeException
;
191 class RuntimePermission
;
192 class SecurityContext
;
193 class SecurityException
;
194 class SecurityManager
;
196 class StackOverflowError
;
197 class StackTraceElement
;
200 class String$CaseInsensitiveComparator
;
202 class StringIndexOutOfBoundsException
;
210 class UnsatisfiedLinkError
;
211 class UnsupportedClassVersionError
;
212 class UnsupportedOperationException
;
214 class VMSecurityManager
;
217 class VirtualMachineError
;
221 class PhantomReference
;
223 class ReferenceQueue
;
230 class AccessibleObject
;
234 class InvocationHandler
;
235 class InvocationTargetException
;
240 class Proxy$ClassFactory
;
241 class Proxy$ProxyData
;
242 class Proxy$ProxySignature
;
243 class Proxy$ProxyType
;
244 class ReflectPermission
;
245 class UndeclaredThrowableException
;
251 class AbstractCollection
;
254 class AbstractMap$BasicMapEntry
;
255 class AbstractSequentialList
;
259 class Arrays$ArrayList
;
264 class Collections$CopiesList
;
265 class Collections$EmptyList
;
266 class Collections$EmptyMap
;
267 class Collections$EmptySet
;
268 class Collections$ReverseComparator
;
269 class Collections$SingletonList
;
270 class Collections$SingletonMap
;
271 class Collections$SingletonSet
;
272 class Collections$SynchronizedCollection
;
273 class Collections$SynchronizedIterator
;
274 class Collections$SynchronizedList
;
275 class Collections$SynchronizedListIterator
;
276 class Collections$SynchronizedMap
;
277 class Collections$SynchronizedMapEntry
;
278 class Collections$SynchronizedRandomAccessList
;
279 class Collections$SynchronizedSet
;
280 class Collections$SynchronizedSortedMap
;
281 class Collections$SynchronizedSortedSet
;
282 class Collections$UnmodifiableCollection
;
283 class Collections$UnmodifiableEntrySet
;
284 class Collections$UnmodifiableIterator
;
285 class Collections$UnmodifiableList
;
286 class Collections$UnmodifiableListIterator
;
287 class Collections$UnmodifiableMap
;
288 class Collections$UnmodifiableRandomAccessList
;
289 class Collections$UnmodifiableSet
;
290 class Collections$UnmodifiableSortedMap
;
291 class Collections$UnmodifiableSortedSet
;
293 class ConcurrentModificationException
;
297 class EmptyStackException
;
300 class EventListenerProxy
;
302 class GregorianCalendar
;
304 class HashMap$HashEntry
;
305 class HashMap$HashIterator
;
308 class Hashtable$Enumerator
;
309 class Hashtable$HashEntry
;
310 class Hashtable$HashIterator
;
311 class IdentityHashMap
;
312 class IdentityHashMap$IdentityEntry
;
313 class IdentityHashMap$IdentityIterator
;
316 class LinkedHashMap$LinkedHashEntry
;
319 class LinkedList$Entry
;
320 class LinkedList$LinkedListItr
;
323 class ListResourceBundle
;
328 class MissingResourceException
;
330 class NoSuchElementException
;
334 class PropertyPermission
;
335 class PropertyPermissionCollection
;
336 class PropertyResourceBundle
;
339 class RandomAccessSubList
;
340 class ResourceBundle
;
341 class ResourceBundle$BundleKey
;
343 class SimpleTimeZone
;
347 class StringTokenizer
;
351 class Timer$Scheduler
;
352 class Timer$TaskQueue
;
354 class TooManyListenersException
;
357 class TreeMap$SubMap
;
358 class TreeMap$TreeIterator
;
362 class WeakHashMap$WeakBucket
;
363 class WeakHashMap$WeakEntry
;
364 class WeakHashMap$WeakEntrySet
;
368 class Attributes$Name
;
372 class JarFile$JarEnumeration
;
373 class JarInputStream
;
374 class JarOutputStream
;
380 class ConsoleHandler
;
390 class LoggingPermission
;
392 class SimpleFormatter
;
400 class AbstractPreferences
;
401 class BackingStoreException
;
402 class InvalidPreferencesFormatException
;
403 class NodeChangeEvent
;
404 class NodeChangeListener
;
405 class PreferenceChangeEvent
;
406 class PreferenceChangeListener
;
408 class PreferencesFactory
;
415 class PatternSyntaxException
;
422 class CheckedInputStream
;
423 class CheckedOutputStream
;
425 class DataFormatException
;
427 class DeflaterOutputStream
;
428 class GZIPInputStream
;
429 class GZIPOutputStream
;
431 class InflaterInputStream
;
436 class ZipFile$PartialInputStream
;
437 class ZipFile$ZipEntryEnumeration
;
438 class ZipInputStream
;
439 class ZipOutputStream
;
445 typedef struct java::lang::Object
* jobject
;
446 typedef class java::lang::Class
* jclass
;
447 typedef class java::lang::Throwable
* jthrowable
;
448 typedef class java::lang::String
* jstring
;
451 typedef struct _Jv_Field
*jfieldID
;
452 typedef struct _Jv_Method
*jmethodID
;
454 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
455 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
456 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
457 #ifdef JV_HASH_SYNCHRONIZATION
458 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
459 __attribute__((__malloc__
));
461 // Collector still needs to scan sync_info
462 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
464 return _Jv_AllocObject(klass
);
467 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
468 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
469 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
470 __attribute__((__malloc__
));
471 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
472 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
473 extern "C" void _Jv_MonitorEnter (jobject
);
474 extern "C" void _Jv_MonitorExit (jobject
);
475 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
476 __attribute__((__malloc__
));
477 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
478 __attribute__((__malloc__
));
479 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
480 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
481 extern "C" jint
_Jv_hashUtf8String (char*, int);
483 extern jint
_Jv_CreateJavaVM (void* /*vm_args*/);
486 _Jv_ThreadRun (java::lang::Thread
* thread
);
488 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
489 extern "C" java::lang::Thread
*
490 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
491 extern "C" java::lang::Thread
*
492 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
493 extern "C" jint
_Jv_DetachCurrentThread (void);
495 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
496 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
497 extern "C" void* _Jv_Realloc (void *, jsize
);
498 extern "C" void _Jv_Free (void*);
499 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
500 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
502 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
503 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
504 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
509 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
510 char data
[1]; /* In Utf8 format, with final '\0'. */
512 /** Return same value of java.lang.String's hashCode. */
513 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
514 /** Return a hash code that has at least 16 bits of information. */
515 _Jv_ushort
hash16 () { return hash
; }
516 /** Return a hash code that has at least 8 bits of information. */
517 _Jv_ushort
hash8 () { return hash
; }
518 /** Length in bytes of the UTF8-encoding. */
519 _Jv_ushort
len () const { return length
; }
520 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
521 char* chars() { return data
; }
522 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
523 char* limit() { return data
+length
; }
524 /** Return the first byte in the UTF8-encoding. */
525 char first() const { return data
[0]; }
526 /** Create a (non-interned) java.lang.String from this UTF8Const. */
527 jstring
toString() { return _Jv_NewStringUTF(data
); }
528 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
529 including struct header, and final NUL. I.e. what to pas to malloc. */
530 static int space_needed (char *, int len
)
531 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
532 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
533 void init (char *s
, int len
);
534 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
535 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
536 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
537 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (char*, int);
538 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
539 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
543 #endif /* __JAVAPRIMS_H__ */