1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
4 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
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
;
221 class VMSecurityManager
;
224 class VirtualMachineError
;
228 class PhantomReference
;
230 class ReferenceQueue
;
237 class AccessibleObject
;
241 class InvocationHandler
;
242 class InvocationTargetException
;
247 class Proxy$ClassFactory
;
248 class Proxy$ProxyData
;
249 class Proxy$ProxySignature
;
250 class Proxy$ProxyType
;
251 class ReflectPermission
;
252 class UndeclaredThrowableException
;
258 class AbstractCollection
;
260 class AbstractList$RandomAccessSubList
;
261 class AbstractList$SubList
;
263 class AbstractMap$BasicMapEntry
;
264 class AbstractSequentialList
;
268 class Arrays$ArrayList
;
273 class Collections$CopiesList
;
274 class Collections$EmptyList
;
275 class Collections$EmptyMap
;
276 class Collections$EmptySet
;
277 class Collections$ReverseComparator
;
278 class Collections$SingletonList
;
279 class Collections$SingletonMap
;
280 class Collections$SingletonSet
;
281 class Collections$SynchronizedCollection
;
282 class Collections$SynchronizedIterator
;
283 class Collections$SynchronizedList
;
284 class Collections$SynchronizedListIterator
;
285 class Collections$SynchronizedMap
;
286 class Collections$SynchronizedMapEntry
;
287 class Collections$SynchronizedRandomAccessList
;
288 class Collections$SynchronizedSet
;
289 class Collections$SynchronizedSortedMap
;
290 class Collections$SynchronizedSortedSet
;
291 class Collections$UnmodifiableCollection
;
292 class Collections$UnmodifiableEntrySet
;
293 class Collections$UnmodifiableIterator
;
294 class Collections$UnmodifiableList
;
295 class Collections$UnmodifiableListIterator
;
296 class Collections$UnmodifiableMap
;
297 class Collections$UnmodifiableRandomAccessList
;
298 class Collections$UnmodifiableSet
;
299 class Collections$UnmodifiableSortedMap
;
300 class Collections$UnmodifiableSortedSet
;
302 class ConcurrentModificationException
;
306 class EmptyStackException
;
309 class EventListenerProxy
;
311 class GregorianCalendar
;
313 class HashMap$HashEntry
;
314 class HashMap$HashIterator
;
317 class Hashtable$Enumerator
;
318 class Hashtable$HashEntry
;
319 class Hashtable$HashIterator
;
320 class IdentityHashMap
;
321 class IdentityHashMap$IdentityEntry
;
322 class IdentityHashMap$IdentityIterator
;
325 class LinkedHashMap$LinkedHashEntry
;
328 class LinkedList$Entry
;
329 class LinkedList$LinkedListItr
;
332 class ListResourceBundle
;
337 class MissingResourceException
;
339 class NoSuchElementException
;
343 class PropertyPermission
;
344 class PropertyPermissionCollection
;
345 class PropertyResourceBundle
;
348 class ResourceBundle
;
349 class ResourceBundle$BundleKey
;
351 class SimpleTimeZone
;
355 class StringTokenizer
;
358 class Timer$Scheduler
;
359 class Timer$TaskQueue
;
361 class TooManyListenersException
;
364 class TreeMap$SubMap
;
365 class TreeMap$TreeIterator
;
370 class WeakHashMap$WeakBucket
;
371 class WeakHashMap$WeakEntry
;
372 class WeakHashMap$WeakEntrySet
;
376 class Attributes$Name
;
380 class JarFile$EntryInputStream
;
381 class JarFile$JarEnumeration
;
382 class JarInputStream
;
383 class JarOutputStream
;
389 class ConsoleHandler
;
399 class LoggingPermission
;
401 class SimpleFormatter
;
409 class AbstractPreferences
;
410 class BackingStoreException
;
411 class InvalidPreferencesFormatException
;
412 class NodeChangeEvent
;
413 class NodeChangeListener
;
414 class PreferenceChangeEvent
;
415 class PreferenceChangeListener
;
417 class PreferencesFactory
;
424 class PatternSyntaxException
;
431 class CheckedInputStream
;
432 class CheckedOutputStream
;
434 class DataFormatException
;
436 class DeflaterOutputStream
;
437 class GZIPInputStream
;
438 class GZIPOutputStream
;
440 class InflaterInputStream
;
445 class ZipFile$PartialInputStream
;
446 class ZipFile$ZipEntryEnumeration
;
447 class ZipInputStream
;
448 class ZipOutputStream
;
454 typedef struct java::lang::Object
* jobject
;
455 typedef class java::lang::Class
* jclass
;
456 typedef class java::lang::Throwable
* jthrowable
;
457 typedef class java::lang::String
* jstring
;
460 typedef struct _Jv_Field
*jfieldID
;
461 typedef struct _Jv_Method
*jmethodID
;
463 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
464 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
465 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
466 #ifdef JV_HASH_SYNCHRONIZATION
467 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
468 __attribute__((__malloc__
));
470 // Collector still needs to scan sync_info
471 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
473 return _Jv_AllocObject(klass
);
476 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
477 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
478 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
479 __attribute__((__malloc__
));
480 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
481 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
482 extern "C" void _Jv_MonitorEnter (jobject
);
483 extern "C" void _Jv_MonitorExit (jobject
);
484 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
485 __attribute__((__malloc__
));
486 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
487 __attribute__((__malloc__
));
488 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
489 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
490 extern "C" jint
_Jv_hashUtf8String (char*, int);
494 // a VM initialization option
496 // extra information associated with this option
500 struct _Jv_VMInitArgs
502 // for compatibility with JavaVMInitArgs
505 // number of VM initialization options
508 // an array of VM initialization options
509 struct _Jv_VMOption
* options
;
511 // true if the option parser should ignore unrecognized options
512 jboolean ignoreUnrecognized
;
515 extern jint
_Jv_CreateJavaVM (struct _Jv_VMInitArgs
*);
518 _Jv_ThreadRun (java::lang::Thread
* thread
);
520 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
521 extern "C" java::lang::Thread
*
522 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
523 extern "C" java::lang::Thread
*
524 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
525 extern "C" jint
_Jv_DetachCurrentThread (void);
527 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
528 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
529 extern "C" void* _Jv_Realloc (void *, jsize
);
530 extern "C" void _Jv_Free (void*);
531 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
532 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
534 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
535 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
536 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
541 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
542 char data
[1]; /* In Utf8 format, with final '\0'. */
544 /** Return same value of java.lang.String's hashCode. */
545 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
546 /** Return a hash code that has at least 16 bits of information. */
547 _Jv_ushort
hash16 () { return hash
; }
548 /** Return a hash code that has at least 8 bits of information. */
549 _Jv_ushort
hash8 () { return hash
; }
550 /** Length in bytes of the UTF8-encoding. */
551 _Jv_ushort
len () const { return length
; }
552 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
553 char* chars() { return data
; }
554 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
555 char* limit() { return data
+length
; }
556 /** Return the first byte in the UTF8-encoding. */
557 char first() const { return data
[0]; }
558 /** Create a (non-interned) java.lang.String from this UTF8Const. */
559 jstring
toString() { return _Jv_NewStringUTF(data
); }
560 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
561 including struct header, and final NUL. I.e. what to pas to malloc. */
562 static int space_needed (char *, int len
)
563 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
564 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
565 void init (char *s
, int len
);
566 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
567 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
568 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
569 friend jboolean
_Jv_equalUtf8Classnames (const _Jv_Utf8Const
*,
570 const _Jv_Utf8Const
*);
571 friend jboolean
_Jv_isPrimitiveOrDerived (const _Jv_Utf8Const
*);
572 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (char*, int);
573 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
574 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
578 #endif /* __JAVAPRIMS_H__ */