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
;
60 class DataInputStream
;
62 class DataOutputStream
;
63 class DeleteFileHelper
;
64 class DeleteFileHelper$
1;
70 class FileInputStream
;
71 class FileNotFoundException
;
72 class FileOutputStream
;
77 class FilterInputStream
;
78 class FilterOutputStream
;
84 class InputStreamReader
;
85 class InterruptedIOException
;
86 class InvalidClassException
;
87 class InvalidObjectException
;
88 class LineNumberInputStream
;
89 class LineNumberReader
;
90 class NotActiveException
;
91 class NotSerializableException
;
93 class ObjectInputStream
;
94 class ObjectInputStream$
1;
95 class ObjectInputStream$
2;
96 class ObjectInputStream$GetField
;
97 class ObjectInputStream$ValidatorAndPriority
;
98 class ObjectInputValidation
;
100 class ObjectOutputStream
;
101 class ObjectOutputStream$
1;
102 class ObjectOutputStream$PutField
;
103 class ObjectStreamClass
;
104 class ObjectStreamClass$
1;
105 class ObjectStreamClass$
2;
106 class ObjectStreamClass$InterfaceComparator
;
107 class ObjectStreamClass$MemberComparator
;
108 class ObjectStreamConstants
;
109 class ObjectStreamException
;
110 class ObjectStreamField
;
111 class ObjectStreamField$
1;
112 class OptionalDataException
;
114 class OutputStreamWriter
;
115 class PipedInputStream
;
116 class PipedOutputStream
;
121 class PushbackInputStream
;
122 class PushbackReader
;
123 class RandomAccessFile
;
125 class SequenceInputStream
;
127 class SerializablePermission
;
128 class StreamCorruptedException
;
129 class StreamTokenizer
;
130 class StringBufferInputStream
;
133 class SyncFailedException
;
134 class UTFDataFormatException
;
135 class UnsupportedEncodingException
;
136 class VMObjectStreamClass
;
137 class WriteAbortedException
;
143 class AbstractMethodError
;
145 class ArithmeticException
;
146 class ArrayIndexOutOfBoundsException
;
147 class ArrayStoreException
;
148 class AssertionError
;
153 class Character$Subset
;
154 class Character$UnicodeBlock
;
156 class ClassCastException
;
157 class ClassCircularityError
;
158 class ClassFormatError
;
160 class ClassNotFoundException
;
161 class CloneNotSupportedException
;
165 class ConcreteProcess
;
166 class ConcreteProcess$EOFInputStream
;
167 class ConcreteProcess$ProcessManager
;
170 class EnumConstantNotPresentException
;
173 class ExceptionInInitializerError
;
175 class IllegalAccessError
;
176 class IllegalAccessException
;
177 class IllegalArgumentException
;
178 class IllegalMonitorStateException
;
179 class IllegalStateException
;
180 class IllegalThreadStateException
;
181 class IncompatibleClassChangeError
;
182 class IndexOutOfBoundsException
;
183 class InheritableThreadLocal
;
184 class InstantiationError
;
185 class InstantiationException
;
188 class InterruptedException
;
193 class NegativeArraySizeException
;
194 class NoClassDefFoundError
;
195 class NoSuchFieldError
;
196 class NoSuchFieldException
;
197 class NoSuchMethodError
;
198 class NoSuchMethodException
;
199 class NullPointerException
;
201 class NumberFormatException
;
203 class OutOfMemoryError
;
209 class RuntimeException
;
210 class RuntimePermission
;
211 class SecurityContext
;
212 class SecurityException
;
213 class SecurityManager
;
215 class StackOverflowError
;
216 class StackTraceElement
;
219 class String$CaseInsensitiveComparator
;
222 class StringIndexOutOfBoundsException
;
225 class Thread$UncaughtExceptionHandler
;
230 class Throwable$StaticData
;
231 class TypeNotPresentException
;
233 class UnsatisfiedLinkError
;
234 class UnsupportedClassVersionError
;
235 class UnsupportedOperationException
;
240 class VMSecurityManager
;
243 class VirtualMachineError
;
248 class AnnotationFormatError
;
249 class AnnotationTypeMismatchException
;
254 class ClassDefinition
;
255 class ClassFileTransformer
;
256 class IllegalClassFormatException
;
257 class Instrumentation
;
258 class UnmodifiableClassException
;
263 class PhantomReference
;
265 class ReferenceQueue
;
272 class AccessibleObject
;
273 class AnnotatedElement
;
277 class GenericArrayType
;
278 class GenericDeclaration
;
279 class GenericSignatureFormatError
;
280 class InvocationHandler
;
281 class InvocationTargetException
;
282 class MalformedParameterizedTypeException
;
286 class ParameterizedType
;
288 class Proxy$ClassFactory
;
289 class Proxy$ProxyData
;
290 class Proxy$ProxySignature
;
291 class Proxy$ProxyType
;
292 class ReflectPermission
;
295 class UndeclaredThrowableException
;
303 class AbstractCollection
;
305 class AbstractList$
1;
306 class AbstractList$
2;
307 class AbstractList$RandomAccessSubList
;
308 class AbstractList$SubList
;
309 class AbstractList$SubList$
3;
312 class AbstractMap$
1$
2;
314 class AbstractMap$
3$
4;
315 class AbstractMap$BasicMapEntry
;
316 class AbstractSequentialList
;
320 class Arrays$ArrayList
;
326 class Collections$CopiesList
;
327 class Collections$EmptyList
;
328 class Collections$EmptyMap
;
329 class Collections$EmptySet
;
330 class Collections$ReverseComparator
;
331 class Collections$SingletonList
;
332 class Collections$SingletonMap
;
333 class Collections$SingletonMap$
3;
334 class Collections$SingletonSet
;
335 class Collections$SingletonSet$
2;
336 class Collections$SynchronizedCollection
;
337 class Collections$SynchronizedIterator
;
338 class Collections$SynchronizedList
;
339 class Collections$SynchronizedListIterator
;
340 class Collections$SynchronizedMap
;
341 class Collections$SynchronizedMap$
4$SynchronizedMapEntry
;
342 class Collections$SynchronizedMap$
5;
343 class Collections$SynchronizedMap$
5$
6;
344 class Collections$SynchronizedRandomAccessList
;
345 class Collections$SynchronizedSet
;
346 class Collections$SynchronizedSortedMap
;
347 class Collections$SynchronizedSortedSet
;
348 class Collections$UnmodifiableCollection
;
349 class Collections$UnmodifiableIterator
;
350 class Collections$UnmodifiableList
;
351 class Collections$UnmodifiableListIterator
;
352 class Collections$UnmodifiableMap
;
353 class Collections$UnmodifiableMap$UnmodifiableEntrySet
;
354 class Collections$UnmodifiableMap$UnmodifiableEntrySet$
7;
355 class Collections$UnmodifiableMap$UnmodifiableEntrySet$
7$
8;
356 class Collections$UnmodifiableRandomAccessList
;
357 class Collections$UnmodifiableSet
;
358 class Collections$UnmodifiableSortedMap
;
359 class Collections$UnmodifiableSortedSet
;
361 class ConcurrentModificationException
;
365 class EmptyStackException
;
368 class EventListenerProxy
;
370 class GregorianCalendar
;
375 class HashMap$HashEntry
;
376 class HashMap$HashIterator
;
382 class Hashtable$EntryEnumerator
;
383 class Hashtable$EntryIterator
;
384 class Hashtable$HashEntry
;
385 class Hashtable$KeyEnumerator
;
386 class Hashtable$KeyIterator
;
387 class Hashtable$ValueEnumerator
;
388 class Hashtable$ValueIterator
;
389 class IdentityHashMap
;
390 class IdentityHashMap$
1;
391 class IdentityHashMap$
2;
392 class IdentityHashMap$
3;
393 class IdentityHashMap$IdentityEntry
;
394 class IdentityHashMap$IdentityIterator
;
395 class InvalidPropertiesFormatException
;
398 class LinkedHashMap$
1;
399 class LinkedHashMap$LinkedHashEntry
;
402 class LinkedList$Entry
;
403 class LinkedList$LinkedListItr
;
406 class ListResourceBundle
;
410 class MissingResourceException
;
411 class NoSuchElementException
;
415 class PropertyPermission
;
416 class PropertyPermissionCollection
;
417 class PropertyResourceBundle
;
420 class ResourceBundle
;
421 class ResourceBundle$BundleKey
;
423 class SimpleTimeZone
;
427 class StringTokenizer
;
431 class Timer$Scheduler
;
432 class Timer$TaskQueue
;
434 class TooManyListenersException
;
440 class TreeMap$SubMap
;
441 class TreeMap$SubMap$
4;
442 class TreeMap$SubMap$
5;
443 class TreeMap$SubMap$
6;
444 class TreeMap$TreeIterator
;
451 class WeakHashMap$WeakBucket
;
452 class WeakHashMap$WeakBucket$WeakEntry
;
453 class WeakHashMap$WeakEntrySet
;
454 class WeakHashMap$WeakEntrySet$
2;
458 class Attributes$Name
;
462 class JarFile$EntryInputStream
;
463 class JarFile$JarEnumeration
;
464 class JarInputStream
;
465 class JarOutputStream
;
471 class ConsoleHandler
;
474 class FileHandler$ostr
;
483 class LoggingPermission
;
485 class SimpleFormatter
;
493 class AbstractPreferences
;
494 class AbstractPreferences$
1;
495 class AbstractPreferences$
2;
496 class BackingStoreException
;
497 class InvalidPreferencesFormatException
;
498 class NodeChangeEvent
;
499 class NodeChangeListener
;
500 class PreferenceChangeEvent
;
501 class PreferenceChangeListener
;
504 class PreferencesFactory
;
512 class PatternSyntaxException
;
519 class CheckedInputStream
;
520 class CheckedOutputStream
;
522 class DataFormatException
;
524 class DeflaterOutputStream
;
525 class GZIPInputStream
;
526 class GZIPOutputStream
;
528 class InflaterInputStream
;
534 class ZipFile$PartialInputStream
;
535 class ZipFile$ZipEntryEnumeration
;
536 class ZipInputStream
;
537 class ZipOutputStream
;
543 typedef struct java::lang::Object
* jobject
;
544 typedef class java::lang::Class
* jclass
;
545 typedef class java::lang::Throwable
* jthrowable
;
546 typedef class java::lang::String
* jstring
;
549 typedef struct _Jv_Field
*jfieldID
;
550 typedef struct _Jv_Method
*jmethodID
;
552 extern "C" jobject
_Jv_AllocObject (jclass
) __attribute__((__malloc__
));
553 extern "C" jobject
_Jv_AllocObjectNoFinalizer (jclass
) __attribute__((__malloc__
));
554 extern "C" jobject
_Jv_AllocObjectNoInitNoFinalizer (jclass
) __attribute__((__malloc__
));
555 #ifdef JV_HASH_SYNCHRONIZATION
556 extern "C" jobject
_Jv_AllocPtrFreeObject (jclass
)
557 __attribute__((__malloc__
));
559 // Collector still needs to scan sync_info
560 static inline jobject
_Jv_AllocPtrFreeObject (jclass klass
)
562 return _Jv_AllocObject(klass
);
565 extern "C" jboolean
_Jv_IsInstanceOf(jobject
, jclass
);
566 extern "C" jstring
_Jv_AllocString(jsize
) __attribute__((__malloc__
));
567 extern "C" jstring
_Jv_NewString (const jchar
*, jsize
)
568 __attribute__((__malloc__
));
569 extern jint
_Jv_FormatInt (jchar
* bufend
, jint num
);
570 extern "C" jchar
* _Jv_GetStringChars (jstring str
);
571 extern "C" void _Jv_MonitorEnter (jobject
);
572 extern "C" void _Jv_MonitorExit (jobject
);
573 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
)
574 __attribute__((__malloc__
));
575 extern "C" jstring
_Jv_NewStringLatin1(const char*, jsize
)
576 __attribute__((__malloc__
));
577 extern "C" jsize
_Jv_GetStringUTFLength (jstring
);
578 extern "C" jsize
_Jv_GetStringUTFRegion (jstring
, jsize
, jsize
, char *);
579 extern "C" jint
_Jv_hashUtf8String (const char*, int);
583 // a VM initialization option
585 // extra information associated with this option
589 struct _Jv_VMInitArgs
591 // for compatibility with JavaVMInitArgs
594 // number of VM initialization options
597 // an array of VM initialization options
598 struct _Jv_VMOption
* options
;
600 // true if the option parser should ignore unrecognized options
601 jboolean ignoreUnrecognized
;
604 extern jint
_Jv_CreateJavaVM (struct _Jv_VMInitArgs
*);
607 _Jv_ThreadRun (java::lang::Thread
* thread
);
609 _Jv_AttachCurrentThread(java::lang::Thread
* thread
);
610 extern "C" java::lang::Thread
*
611 _Jv_AttachCurrentThread(jstring name
, java::lang::ThreadGroup
* group
);
612 extern "C" java::lang::Thread
*
613 _Jv_AttachCurrentThreadAsDaemon(jstring name
, java::lang::ThreadGroup
* group
);
614 extern "C" jint
_Jv_DetachCurrentThread (void);
616 extern "C" void _Jv_Throw (jthrowable
) __attribute__ ((__noreturn__
));
617 extern "C" void* _Jv_Malloc (jsize
) __attribute__((__malloc__
));
618 extern "C" void* _Jv_Realloc (void *, jsize
);
619 extern "C" void _Jv_Free (void*);
620 extern void (*_Jv_RegisterClassHook
) (jclass cl
);
621 extern "C" void _Jv_RegisterClassHookDefault (jclass
);
623 typedef unsigned short _Jv_ushort
__attribute__((__mode__(__HI__
)));
624 typedef unsigned int _Jv_uint
__attribute__((__mode__(__SI__
)));
625 typedef unsigned int _Jv_ulong
__attribute__((__mode__(__DI__
)));
627 // The type to use when treating a pointer as an integer. Similar to
629 typedef unsigned int _Jv_uintptr_t
__attribute__((__mode__(__pointer__
)));
634 _Jv_ushort length
; /* In bytes, of data portion, without final '\0'. */
635 char data
[1]; /* In Utf8 format, with final '\0'. */
637 /** Return same value of java.lang.String's hashCode. */
638 jint
hash32() { return _Jv_hashUtf8String(data
, length
); }
639 /** Return a hash code that has at least 16 bits of information. */
640 _Jv_ushort
hash16 () { return hash
; }
641 /** Return a hash code that has at least 8 bits of information. */
642 _Jv_ushort
hash8 () { return hash
; }
643 /** Length in bytes of the UTF8-encoding. */
644 _Jv_ushort
len () const { return length
; }
645 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
646 char* chars() { return data
; }
647 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
648 char* limit() { return data
+length
; }
649 /** Return the first byte in the UTF8-encoding. */
650 char first() const { return data
[0]; }
651 /** Create a (non-interned) java.lang.String from this UTF8Const. */
652 jstring
toString() { return _Jv_NewStringUTF(data
); }
653 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
654 including struct header, and final NUL. I.e. what to pas to malloc. */
655 static int space_needed (const char *, int len
)
656 { return sizeof (_Jv_Utf8Const
) + len
+ 1; }
657 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
658 void init (const char *s
, int len
);
659 friend jboolean
_Jv_equalUtf8Consts (const _Jv_Utf8Const
*, const _Jv_Utf8Const
*);
660 friend jboolean
_Jv_equal (_Jv_Utf8Const
*, jstring
, jint
);
661 friend jboolean
_Jv_equaln (_Jv_Utf8Const
*, jstring
, jint
);
662 friend jboolean
_Jv_equalUtf8Classnames (const _Jv_Utf8Const
*,
663 const _Jv_Utf8Const
*);
664 friend jboolean
_Jv_isPrimitiveOrDerived (const _Jv_Utf8Const
*);
665 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (const char*, int);
666 friend _Jv_Utf8Const
*_Jv_makeUtf8Const (jstring
);
667 friend jstring
_Jv_NewStringUtf8Const (_Jv_Utf8Const
*);
671 #endif /* __JAVAPRIMS_H__ */