1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
4 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
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 InterruptedIOException
;
82 class InvalidClassException
;
83 class InvalidObjectException
;
84 class LineNumberInputStream
;
85 class LineNumberReader
;
86 class NotActiveException
;
87 class NotSerializableException
;
89 class ObjectInputStream
;
90 class ObjectInputStream$GetField
;
91 class ObjectInputStream$ValidatorAndPriority
;
92 class ObjectInputValidation
;
94 class ObjectOutputStream
;
95 class ObjectOutputStream$PutField
;
96 class ObjectStreamClass
;
97 class ObjectStreamClass$InterfaceComparator
;
98 class ObjectStreamClass$MemberComparator
;
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 WriteAbortedException
;
133 class AbstractMethodError
;
134 class ArithmeticException
;
135 class ArrayIndexOutOfBoundsException
;
136 class ArrayStoreException
;
137 class AssertionError
;
142 class Character$Subset
;
143 class Character$UnicodeBlock
;
145 class ClassCastException
;
146 class ClassCircularityError
;
147 class ClassFormatError
;
149 class ClassNotFoundException
;
150 class CloneNotSupportedException
;
154 class ConcreteProcess
;
155 class ConcreteProcess$EOFInputStream
;
156 class ConcreteProcess$ProcessManager
;
160 class ExceptionInInitializerError
;
162 class IllegalAccessError
;
163 class IllegalAccessException
;
164 class IllegalArgumentException
;
165 class IllegalMonitorStateException
;
166 class IllegalStateException
;
167 class IllegalThreadStateException
;
168 class IncompatibleClassChangeError
;
169 class IndexOutOfBoundsException
;
170 class InheritableThreadLocal
;
171 class InstantiationError
;
172 class InstantiationException
;
175 class InterruptedException
;
179 class NegativeArraySizeException
;
180 class NoClassDefFoundError
;
181 class NoSuchFieldError
;
182 class NoSuchFieldException
;
183 class NoSuchMethodError
;
184 class NoSuchMethodException
;
185 class NullPointerException
;
187 class NumberFormatException
;
189 class OutOfMemoryError
;
194 class RuntimeException
;
195 class RuntimePermission
;
196 class SecurityContext
;
197 class SecurityException
;
198 class SecurityManager
;
200 class StackOverflowError
;
201 class StackTraceElement
;
204 class String$CaseInsensitiveComparator
;
207 class StringIndexOutOfBoundsException
;
214 class Throwable$StaticData
;
216 class UnsatisfiedLinkError
;
217 class UnsupportedClassVersionError
;
218 class UnsupportedOperationException
;
223 class VMSecurityManager
;
226 class VirtualMachineError
;
230 class PhantomReference
;
232 class ReferenceQueue
;
239 class AccessibleObject
;
243 class InvocationHandler
;
244 class InvocationTargetException
;
249 class Proxy$ClassFactory
;
250 class Proxy$ProxyData
;
251 class Proxy$ProxySignature
;
252 class Proxy$ProxyType
;
253 class ReflectPermission
;
254 class UndeclaredThrowableException
;
260 class AbstractCollection
;
262 class AbstractList$RandomAccessSubList
;
263 class AbstractList$SubList
;
265 class AbstractMap$BasicMapEntry
;
266 class AbstractSequentialList
;
270 class Arrays$ArrayList
;
275 class Collections$CopiesList
;
276 class Collections$EmptyList
;
277 class Collections$EmptyMap
;
278 class Collections$EmptySet
;
279 class Collections$ReverseComparator
;
280 class Collections$SingletonList
;
281 class Collections$SingletonMap
;
282 class Collections$SingletonSet
;
283 class Collections$SynchronizedCollection
;
284 class Collections$SynchronizedIterator
;
285 class Collections$SynchronizedList
;
286 class Collections$SynchronizedListIterator
;
287 class Collections$SynchronizedMap
;
288 class Collections$SynchronizedMapEntry
;
289 class Collections$SynchronizedRandomAccessList
;
290 class Collections$SynchronizedSet
;
291 class Collections$SynchronizedSortedMap
;
292 class Collections$SynchronizedSortedSet
;
293 class Collections$UnmodifiableCollection
;
294 class Collections$UnmodifiableEntrySet
;
295 class Collections$UnmodifiableIterator
;
296 class Collections$UnmodifiableList
;
297 class Collections$UnmodifiableListIterator
;
298 class Collections$UnmodifiableMap
;
299 class Collections$UnmodifiableRandomAccessList
;
300 class Collections$UnmodifiableSet
;
301 class Collections$UnmodifiableSortedMap
;
302 class Collections$UnmodifiableSortedSet
;
304 class ConcurrentModificationException
;
308 class EmptyStackException
;
311 class EventListenerProxy
;
313 class GregorianCalendar
;
315 class HashMap$HashEntry
;
316 class HashMap$HashIterator
;
319 class Hashtable$Enumerator
;
320 class Hashtable$HashEntry
;
321 class Hashtable$HashIterator
;
322 class IdentityHashMap
;
323 class IdentityHashMap$IdentityEntry
;
324 class IdentityHashMap$IdentityIterator
;
327 class LinkedHashMap$LinkedHashEntry
;
330 class LinkedList$Entry
;
331 class LinkedList$LinkedListItr
;
334 class ListResourceBundle
;
339 class MissingResourceException
;
341 class NoSuchElementException
;
345 class PropertyPermission
;
346 class PropertyPermissionCollection
;
347 class PropertyResourceBundle
;
350 class ResourceBundle
;
351 class ResourceBundle$BundleKey
;
353 class SimpleTimeZone
;
357 class StringTokenizer
;
360 class Timer$Scheduler
;
361 class Timer$TaskQueue
;
363 class TooManyListenersException
;
366 class TreeMap$SubMap
;
367 class TreeMap$TreeIterator
;
372 class WeakHashMap$WeakBucket
;
373 class WeakHashMap$WeakEntry
;
374 class WeakHashMap$WeakEntrySet
;
378 class Attributes$Name
;
382 class JarFile$EntryInputStream
;
383 class JarFile$JarEnumeration
;
384 class JarInputStream
;
385 class JarOutputStream
;
391 class ConsoleHandler
;
401 class LoggingPermission
;
403 class SimpleFormatter
;
411 class AbstractPreferences
;
412 class BackingStoreException
;
413 class InvalidPreferencesFormatException
;
414 class NodeChangeEvent
;
415 class NodeChangeListener
;
416 class PreferenceChangeEvent
;
417 class PreferenceChangeListener
;
419 class PreferencesFactory
;
426 class PatternSyntaxException
;
433 class CheckedInputStream
;
434 class CheckedOutputStream
;
436 class DataFormatException
;
438 class DeflaterOutputStream
;
439 class GZIPInputStream
;
440 class GZIPOutputStream
;
442 class InflaterInputStream
;
447 class ZipFile$PartialInputStream
;
448 class ZipFile$ZipEntryEnumeration
;
449 class ZipInputStream
;
450 class ZipOutputStream
;
456 typedef struct java::lang::Object
* jobject
;
457 typedef class java::lang::Class
* jclass
;
458 typedef class java::lang::Throwable
* jthrowable
;
459 typedef class java::lang::String
* jstring
;
462 typedef struct _Jv_Field
*jfieldID
;
463 typedef struct _Jv_Method
*jmethodID
;
465 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
466 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
467 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
468 #ifdef JV_HASH_SYNCHRONIZATION
469 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
470 __attribute__((__malloc__
));
472 // Collector still needs to scan sync_info
473 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
475 return _Jv_AllocObject(klass
);
478 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
479 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
480 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
481 __attribute__((__malloc__
));
482 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
483 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
484 extern "C" void _Jv_MonitorEnter (jobject
);
485 extern "C" void _Jv_MonitorExit (jobject
);
486 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
487 __attribute__((__malloc__
));
488 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
489 __attribute__((__malloc__
));
490 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
491 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
492 extern "C" jint
_Jv_hashUtf8String (const char*, int);
496 // a VM initialization option
498 // extra information associated with this option
502 struct _Jv_VMInitArgs
504 // for compatibility with JavaVMInitArgs
507 // number of VM initialization options
510 // an array of VM initialization options
511 struct _Jv_VMOption
* options
;
513 // true if the option parser should ignore unrecognized options
514 jboolean ignoreUnrecognized
;
517 extern jint
_Jv_CreateJavaVM (struct _Jv_VMInitArgs
*);
520 _Jv_ThreadRun (java::lang::Thread
* thread
);
522 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
523 extern "C" java::lang::Thread
*
524 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
525 extern "C" java::lang::Thread
*
526 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
527 extern "C" jint
_Jv_DetachCurrentThread (void);
529 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
530 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
531 extern "C" void* _Jv_Realloc (void *, jsize
);
532 extern "C" void _Jv_Free (void*);
533 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
534 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
536 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
537 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
538 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
543 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
544 char data
[1]; /* In Utf8 format, with final '\0'. */
546 /** Return same value of java.lang.String's hashCode. */
547 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
548 /** Return a hash code that has at least 16 bits of information. */
549 _Jv_ushort
hash16 () { return hash
; }
550 /** Return a hash code that has at least 8 bits of information. */
551 _Jv_ushort
hash8 () { return hash
; }
552 /** Length in bytes of the UTF8-encoding. */
553 _Jv_ushort
len () const { return length
; }
554 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
555 char* chars() { return data
; }
556 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
557 char* limit() { return data
+length
; }
558 /** Return the first byte in the UTF8-encoding. */
559 char first() const { return data
[0]; }
560 /** Create a (non-interned) java.lang.String from this UTF8Const. */
561 jstring
toString() { return _Jv_NewStringUTF(data
); }
562 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
563 including struct header, and final NUL. I.e. what to pas to malloc. */
564 static int space_needed (const char *, int len
)
565 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
566 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
567 void init (const char *s
, int len
);
568 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
569 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
570 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
571 friend jboolean
_Jv_equalUtf8Classnames (const _Jv_Utf8Const
*,
572 const _Jv_Utf8Const
*);
573 friend jboolean
_Jv_isPrimitiveOrDerived (const _Jv_Utf8Const
*);
574 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (const char*, int);
575 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
576 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
580 #endif /* __JAVAPRIMS_H__ */