Merge from mainline
[official-gcc.git] / libjava / gcj / javaprims.h
bloba9dd8459d0249986f984111c65c47804b5395cca
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
11 details. */
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
23 // and FALSE.
24 #undef TRUE
25 #define TRUE TRUE
26 #undef FALSE
27 #define FALSE FALSE
29 // To force selection of correct types that will mangle consistently
30 // across platforms.
31 extern "Java"
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;
41 typedef jint jsize;
43 // The following class declarations are automatically generated by
44 // the `classes.pl' script.
45 namespace java
47 namespace io
49 class BufferedInputStream;
50 class BufferedOutputStream;
51 class BufferedReader;
52 class BufferedWriter;
53 class ByteArrayInputStream;
54 class ByteArrayOutputStream;
55 class CharArrayReader;
56 class CharArrayWriter;
57 class CharConversionException;
58 class DataInput;
59 class DataInputStream;
60 class DataOutput;
61 class DataOutputStream;
62 class EOFException;
63 class Externalizable;
64 class File;
65 class FileDescriptor;
66 class FileFilter;
67 class FileInputStream;
68 class FileNotFoundException;
69 class FileOutputStream;
70 class FilePermission;
71 class FileReader;
72 class FileWriter;
73 class FilenameFilter;
74 class FilterInputStream;
75 class FilterOutputStream;
76 class FilterReader;
77 class FilterWriter;
78 class IOException;
79 class InputStream;
80 class InputStreamReader;
81 class InterruptedIOException;
82 class InvalidClassException;
83 class InvalidObjectException;
84 class LineNumberInputStream;
85 class LineNumberReader;
86 class NotActiveException;
87 class NotSerializableException;
88 class ObjectInput;
89 class ObjectInputStream;
90 class ObjectInputStream$GetField;
91 class ObjectInputStream$ValidatorAndPriority;
92 class ObjectInputValidation;
93 class ObjectOutput;
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;
103 class OutputStream;
104 class OutputStreamWriter;
105 class PipedInputStream;
106 class PipedOutputStream;
107 class PipedReader;
108 class PipedWriter;
109 class PrintStream;
110 class PrintWriter;
111 class PushbackInputStream;
112 class PushbackReader;
113 class RandomAccessFile;
114 class Reader;
115 class SequenceInputStream;
116 class Serializable;
117 class SerializablePermission;
118 class StreamCorruptedException;
119 class StreamTokenizer;
120 class StringBufferInputStream;
121 class StringReader;
122 class StringWriter;
123 class SyncFailedException;
124 class UTFDataFormatException;
125 class UnsupportedEncodingException;
126 class VMObjectStreamClass;
127 class WriteAbortedException;
128 class Writer;
131 namespace lang
133 class AbstractMethodError;
134 class ArithmeticException;
135 class ArrayIndexOutOfBoundsException;
136 class ArrayStoreException;
137 class AssertionError;
138 class Boolean;
139 class Byte;
140 class CharSequence;
141 class Character;
142 class Character$Subset;
143 class Character$UnicodeBlock;
144 class Class;
145 class ClassCastException;
146 class ClassCircularityError;
147 class ClassFormatError;
148 class ClassLoader;
149 class ClassNotFoundException;
150 class CloneNotSupportedException;
151 class Cloneable;
152 class Comparable;
153 class Compiler;
154 class ConcreteProcess;
155 class ConcreteProcess$EOFInputStream;
156 class ConcreteProcess$ProcessManager;
157 class Double;
158 class Error;
159 class Exception;
160 class ExceptionInInitializerError;
161 class Float;
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;
173 class Integer;
174 class InternalError;
175 class InterruptedException;
176 class LinkageError;
177 class Long;
178 class Math;
179 class NegativeArraySizeException;
180 class NoClassDefFoundError;
181 class NoSuchFieldError;
182 class NoSuchFieldException;
183 class NoSuchMethodError;
184 class NoSuchMethodException;
185 class NullPointerException;
186 class Number;
187 class NumberFormatException;
188 class Object;
189 class OutOfMemoryError;
190 class Package;
191 class Process;
192 class Runnable;
193 class Runtime;
194 class RuntimeException;
195 class RuntimePermission;
196 class SecurityContext;
197 class SecurityException;
198 class SecurityManager;
199 class Short;
200 class StackOverflowError;
201 class StackTraceElement;
202 class StrictMath;
203 class String;
204 class String$CaseInsensitiveComparator;
205 class StringBuffer;
206 class StringBuilder;
207 class StringIndexOutOfBoundsException;
208 class System;
209 class Thread;
210 class ThreadDeath;
211 class ThreadGroup;
212 class ThreadLocal;
213 class Throwable;
214 class Throwable$StaticData;
215 class UnknownError;
216 class UnsatisfiedLinkError;
217 class UnsupportedClassVersionError;
218 class UnsupportedOperationException;
219 class VMClassLoader;
220 class VMCompiler;
221 class VMDouble;
222 class VMFloat;
223 class VMSecurityManager;
224 class VMThrowable;
225 class VerifyError;
226 class VirtualMachineError;
227 class Void;
228 namespace ref
230 class PhantomReference;
231 class Reference;
232 class ReferenceQueue;
233 class SoftReference;
234 class WeakReference;
237 namespace reflect
239 class AccessibleObject;
240 class Array;
241 class Constructor;
242 class Field;
243 class InvocationHandler;
244 class InvocationTargetException;
245 class Member;
246 class Method;
247 class Modifier;
248 class Proxy;
249 class Proxy$ClassFactory;
250 class Proxy$ProxyData;
251 class Proxy$ProxySignature;
252 class Proxy$ProxyType;
253 class ReflectPermission;
254 class UndeclaredThrowableException;
258 namespace util
260 class AbstractCollection;
261 class AbstractList;
262 class AbstractList$RandomAccessSubList;
263 class AbstractList$SubList;
264 class AbstractMap;
265 class AbstractMap$BasicMapEntry;
266 class AbstractSequentialList;
267 class AbstractSet;
268 class ArrayList;
269 class Arrays;
270 class Arrays$ArrayList;
271 class BitSet;
272 class Calendar;
273 class Collection;
274 class Collections;
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;
303 class Comparator;
304 class ConcurrentModificationException;
305 class Currency;
306 class Date;
307 class Dictionary;
308 class EmptyStackException;
309 class Enumeration;
310 class EventListener;
311 class EventListenerProxy;
312 class EventObject;
313 class GregorianCalendar;
314 class HashMap;
315 class HashMap$HashEntry;
316 class HashMap$HashIterator;
317 class HashSet;
318 class Hashtable;
319 class Hashtable$Enumerator;
320 class Hashtable$HashEntry;
321 class Hashtable$HashIterator;
322 class IdentityHashMap;
323 class IdentityHashMap$IdentityEntry;
324 class IdentityHashMap$IdentityIterator;
325 class Iterator;
326 class LinkedHashMap;
327 class LinkedHashMap$LinkedHashEntry;
328 class LinkedHashSet;
329 class LinkedList;
330 class LinkedList$Entry;
331 class LinkedList$LinkedListItr;
332 class List;
333 class ListIterator;
334 class ListResourceBundle;
335 class Locale;
336 class Map;
337 class Map$Entry;
338 class Map$Map;
339 class MissingResourceException;
340 class MyResources;
341 class NoSuchElementException;
342 class Observable;
343 class Observer;
344 class Properties;
345 class PropertyPermission;
346 class PropertyPermissionCollection;
347 class PropertyResourceBundle;
348 class Random;
349 class RandomAccess;
350 class ResourceBundle;
351 class ResourceBundle$BundleKey;
352 class Set;
353 class SimpleTimeZone;
354 class SortedMap;
355 class SortedSet;
356 class Stack;
357 class StringTokenizer;
358 class TimeZone;
359 class Timer;
360 class Timer$Scheduler;
361 class Timer$TaskQueue;
362 class TimerTask;
363 class TooManyListenersException;
364 class TreeMap;
365 class TreeMap$Node;
366 class TreeMap$SubMap;
367 class TreeMap$TreeIterator;
368 class TreeSet;
369 class VMTimeZone;
370 class Vector;
371 class WeakHashMap;
372 class WeakHashMap$WeakBucket;
373 class WeakHashMap$WeakEntry;
374 class WeakHashMap$WeakEntrySet;
375 namespace jar
377 class Attributes;
378 class Attributes$Name;
379 class JarEntry;
380 class JarException;
381 class JarFile;
382 class JarFile$EntryInputStream;
383 class JarFile$JarEnumeration;
384 class JarInputStream;
385 class JarOutputStream;
386 class Manifest;
389 namespace logging
391 class ConsoleHandler;
392 class ErrorManager;
393 class FileHandler;
394 class Filter;
395 class Formatter;
396 class Handler;
397 class Level;
398 class LogManager;
399 class LogRecord;
400 class Logger;
401 class LoggingPermission;
402 class MemoryHandler;
403 class SimpleFormatter;
404 class SocketHandler;
405 class StreamHandler;
406 class XMLFormatter;
409 namespace prefs
411 class AbstractPreferences;
412 class BackingStoreException;
413 class InvalidPreferencesFormatException;
414 class NodeChangeEvent;
415 class NodeChangeListener;
416 class PreferenceChangeEvent;
417 class PreferenceChangeListener;
418 class Preferences;
419 class PreferencesFactory;
422 namespace regex
424 class Matcher;
425 class Pattern;
426 class PatternSyntaxException;
429 namespace zip
431 class Adler32;
432 class CRC32;
433 class CheckedInputStream;
434 class CheckedOutputStream;
435 class Checksum;
436 class DataFormatException;
437 class Deflater;
438 class DeflaterOutputStream;
439 class GZIPInputStream;
440 class GZIPOutputStream;
441 class Inflater;
442 class InflaterInputStream;
443 class ZipConstants;
444 class ZipEntry;
445 class ZipException;
446 class ZipFile;
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;
460 struct _Jv_JNIEnv;
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__));
471 #else
472 // Collector still needs to scan sync_info
473 static inline jobject _Jv_AllocPtrFreeObject (jclass klass)
475 return _Jv_AllocObject(klass);
477 #endif
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);
494 struct _Jv_VMOption
496 // a VM initialization option
497 char* optionString;
498 // extra information associated with this option
499 void* extraInfo;
502 struct _Jv_VMInitArgs
504 // for compatibility with JavaVMInitArgs
505 jint version;
507 // number of VM initialization options
508 jint nOptions;
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*);
519 void
520 _Jv_ThreadRun (java::lang::Thread* thread);
521 jint
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__)));
540 class _Jv_Utf8Const
542 _Jv_ushort hash;
543 _Jv_ushort length; /* In bytes, of data portion, without final '\0'. */
544 char data[1]; /* In Utf8 format, with final '\0'. */
545 public:
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__ */