Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / gcj / javaprims.h
blobe972f7ba518f4604209ffb33e752b1ad54707474
1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
4 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
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 InterfaceComparator;
82 class InterruptedIOException;
83 class InvalidClassException;
84 class InvalidObjectException;
85 class LineNumberInputStream;
86 class LineNumberReader;
87 class MemberComparator;
88 class MyIOException;
89 class NotActiveException;
90 class NotSerializableException;
91 class ObjectInput;
92 class ObjectInputStream;
93 class ObjectInputStream$GetField;
94 class ObjectInputValidation;
95 class ObjectOutput;
96 class ObjectOutputStream;
97 class ObjectOutputStream$PutField;
98 class ObjectStreamClass;
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 ValidatorAndPriority;
128 class WriteAbortedException;
129 class Writer;
132 namespace lang
134 class AbstractMethodError;
135 class ArithmeticException;
136 class ArrayIndexOutOfBoundsException;
137 class ArrayStoreException;
138 class AssertionError;
139 class Boolean;
140 class Byte;
141 class CharSequence;
142 class Character;
143 class Character$Subset;
144 class Character$UnicodeBlock;
145 class Class;
146 class ClassCastException;
147 class ClassCircularityError;
148 class ClassFormatError;
149 class ClassLoader;
150 class ClassNotFoundException;
151 class CloneNotSupportedException;
152 class Cloneable;
153 class Comparable;
154 class Compiler;
155 class ConcreteProcess;
156 class ConcreteProcess$EOFInputStream;
157 class ConcreteProcess$ProcessManager;
158 class Double;
159 class Error;
160 class Exception;
161 class ExceptionInInitializerError;
162 class Float;
163 class IllegalAccessError;
164 class IllegalAccessException;
165 class IllegalArgumentException;
166 class IllegalMonitorStateException;
167 class IllegalStateException;
168 class IllegalThreadStateException;
169 class IncompatibleClassChangeError;
170 class IndexOutOfBoundsException;
171 class InheritableThreadLocal;
172 class InstantiationError;
173 class InstantiationException;
174 class Integer;
175 class InternalError;
176 class InterruptedException;
177 class LinkageError;
178 class Long;
179 class Math;
180 class NegativeArraySizeException;
181 class NoClassDefFoundError;
182 class NoSuchFieldError;
183 class NoSuchFieldException;
184 class NoSuchMethodError;
185 class NoSuchMethodException;
186 class NullPointerException;
187 class Number;
188 class NumberFormatException;
189 class Object;
190 class OutOfMemoryError;
191 class Package;
192 class Process;
193 class Runnable;
194 class Runtime;
195 class RuntimeException;
196 class RuntimePermission;
197 class SecurityContext;
198 class SecurityException;
199 class SecurityManager;
200 class Short;
201 class StackOverflowError;
202 class StackTraceElement;
203 class StrictMath;
204 class String;
205 class String$CaseInsensitiveComparator;
206 class StringBuffer;
207 class StringIndexOutOfBoundsException;
208 class System;
209 class Thread;
210 class ThreadDeath;
211 class ThreadGroup;
212 class ThreadLocal;
213 class Throwable;
214 class UnknownError;
215 class UnsatisfiedLinkError;
216 class UnsupportedClassVersionError;
217 class UnsupportedOperationException;
218 class VMClassLoader;
219 class VMCompiler;
220 class VMSecurityManager;
221 class VMThrowable;
222 class VerifyError;
223 class VirtualMachineError;
224 class Void;
225 namespace ref
227 class PhantomReference;
228 class Reference;
229 class ReferenceQueue;
230 class SoftReference;
231 class WeakReference;
234 namespace reflect
236 class AccessibleObject;
237 class Array;
238 class Constructor;
239 class Field;
240 class InvocationHandler;
241 class InvocationTargetException;
242 class Member;
243 class Method;
244 class Modifier;
245 class Proxy;
246 class Proxy$ClassFactory;
247 class Proxy$ProxyData;
248 class Proxy$ProxySignature;
249 class Proxy$ProxyType;
250 class ReflectPermission;
251 class UndeclaredThrowableException;
255 namespace util
257 class AbstractCollection;
258 class AbstractList;
259 class AbstractMap;
260 class AbstractMap$BasicMapEntry;
261 class AbstractSequentialList;
262 class AbstractSet;
263 class ArrayList;
264 class Arrays;
265 class Arrays$ArrayList;
266 class BitSet;
267 class Calendar;
268 class Collection;
269 class Collections;
270 class Collections$CopiesList;
271 class Collections$EmptyList;
272 class Collections$EmptyMap;
273 class Collections$EmptySet;
274 class Collections$ReverseComparator;
275 class Collections$SingletonList;
276 class Collections$SingletonMap;
277 class Collections$SingletonSet;
278 class Collections$SynchronizedCollection;
279 class Collections$SynchronizedIterator;
280 class Collections$SynchronizedList;
281 class Collections$SynchronizedListIterator;
282 class Collections$SynchronizedMap;
283 class Collections$SynchronizedMapEntry;
284 class Collections$SynchronizedRandomAccessList;
285 class Collections$SynchronizedSet;
286 class Collections$SynchronizedSortedMap;
287 class Collections$SynchronizedSortedSet;
288 class Collections$UnmodifiableCollection;
289 class Collections$UnmodifiableEntrySet;
290 class Collections$UnmodifiableIterator;
291 class Collections$UnmodifiableList;
292 class Collections$UnmodifiableListIterator;
293 class Collections$UnmodifiableMap;
294 class Collections$UnmodifiableRandomAccessList;
295 class Collections$UnmodifiableSet;
296 class Collections$UnmodifiableSortedMap;
297 class Collections$UnmodifiableSortedSet;
298 class Comparator;
299 class ConcurrentModificationException;
300 class Currency;
301 class Date;
302 class Dictionary;
303 class EmptyStackException;
304 class Enumeration;
305 class EventListener;
306 class EventListenerProxy;
307 class EventObject;
308 class GregorianCalendar;
309 class HashMap;
310 class HashMap$HashEntry;
311 class HashMap$HashIterator;
312 class HashSet;
313 class Hashtable;
314 class Hashtable$Enumerator;
315 class Hashtable$HashEntry;
316 class Hashtable$HashIterator;
317 class IdentityHashMap;
318 class IdentityHashMap$IdentityEntry;
319 class IdentityHashMap$IdentityIterator;
320 class Iterator;
321 class LinkedHashMap;
322 class LinkedHashMap$LinkedHashEntry;
323 class LinkedHashSet;
324 class LinkedList;
325 class LinkedList$Entry;
326 class LinkedList$LinkedListItr;
327 class List;
328 class ListIterator;
329 class ListResourceBundle;
330 class Locale;
331 class Map;
332 class Map$Entry;
333 class Map$Map;
334 class MissingResourceException;
335 class MyResources;
336 class NoSuchElementException;
337 class Observable;
338 class Observer;
339 class Properties;
340 class PropertyPermission;
341 class PropertyPermissionCollection;
342 class PropertyResourceBundle;
343 class Random;
344 class RandomAccess;
345 class RandomAccessSubList;
346 class ResourceBundle;
347 class ResourceBundle$BundleKey;
348 class Set;
349 class SimpleTimeZone;
350 class SortedMap;
351 class SortedSet;
352 class Stack;
353 class StringTokenizer;
354 class SubList;
355 class TimeZone;
356 class Timer;
357 class Timer$Scheduler;
358 class Timer$TaskQueue;
359 class TimerTask;
360 class TooManyListenersException;
361 class TreeMap;
362 class TreeMap$Node;
363 class TreeMap$SubMap;
364 class TreeMap$TreeIterator;
365 class TreeSet;
366 class VMTimeZone;
367 class Vector;
368 class WeakHashMap;
369 class WeakHashMap$WeakBucket;
370 class WeakHashMap$WeakEntry;
371 class WeakHashMap$WeakEntrySet;
372 namespace jar
374 class Attributes;
375 class Attributes$Name;
376 class JarEntry;
377 class JarException;
378 class JarFile;
379 class JarFile$JarEnumeration;
380 class JarInputStream;
381 class JarOutputStream;
382 class Manifest;
385 namespace logging
387 class ConsoleHandler;
388 class ErrorManager;
389 class FileHandler;
390 class Filter;
391 class Formatter;
392 class Handler;
393 class Level;
394 class LogManager;
395 class LogRecord;
396 class Logger;
397 class LoggingPermission;
398 class MemoryHandler;
399 class SimpleFormatter;
400 class SocketHandler;
401 class StreamHandler;
402 class XMLFormatter;
405 namespace prefs
407 class AbstractPreferences;
408 class BackingStoreException;
409 class InvalidPreferencesFormatException;
410 class NodeChangeEvent;
411 class NodeChangeListener;
412 class PreferenceChangeEvent;
413 class PreferenceChangeListener;
414 class Preferences;
415 class PreferencesFactory;
418 namespace regex
420 class Matcher;
421 class Pattern;
422 class PatternSyntaxException;
425 namespace zip
427 class Adler32;
428 class CRC32;
429 class CheckedInputStream;
430 class CheckedOutputStream;
431 class Checksum;
432 class DataFormatException;
433 class Deflater;
434 class DeflaterOutputStream;
435 class GZIPInputStream;
436 class GZIPOutputStream;
437 class Inflater;
438 class InflaterInputStream;
439 class ZipConstants;
440 class ZipEntry;
441 class ZipException;
442 class ZipFile;
443 class ZipFile$PartialInputStream;
444 class ZipFile$ZipEntryEnumeration;
445 class ZipInputStream;
446 class ZipOutputStream;
452 typedef struct java::lang::Object* jobject;
453 typedef class java::lang::Class* jclass;
454 typedef class java::lang::Throwable* jthrowable;
455 typedef class java::lang::String* jstring;
456 struct _Jv_JNIEnv;
458 typedef struct _Jv_Field *jfieldID;
459 typedef struct _Jv_Method *jmethodID;
461 extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));
462 extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass) __attribute__((__malloc__));
463 extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass) __attribute__((__malloc__));
464 #ifdef JV_HASH_SYNCHRONIZATION
465 extern "C" jobject _Jv_AllocPtrFreeObject (jclass)
466 __attribute__((__malloc__));
467 #else
468 // Collector still needs to scan sync_info
469 static inline jobject _Jv_AllocPtrFreeObject (jclass klass)
471 return _Jv_AllocObject(klass);
473 #endif
474 extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
475 extern "C" jstring _Jv_AllocString(jsize) __attribute__((__malloc__));
476 extern "C" jstring _Jv_NewString (const jchar*, jsize)
477 __attribute__((__malloc__));
478 extern jint _Jv_FormatInt (jchar* bufend, jint num);
479 extern "C" jchar* _Jv_GetStringChars (jstring str);
480 extern "C" void _Jv_MonitorEnter (jobject);
481 extern "C" void _Jv_MonitorExit (jobject);
482 extern "C" jstring _Jv_NewStringUTF (const char *bytes)
483 __attribute__((__malloc__));
484 extern "C" jstring _Jv_NewStringLatin1(const char*, jsize)
485 __attribute__((__malloc__));
486 extern "C" jsize _Jv_GetStringUTFLength (jstring);
487 extern "C" jsize _Jv_GetStringUTFRegion (jstring, jsize, jsize, char *);
488 extern "C" jint _Jv_hashUtf8String (char*, int);
490 struct _Jv_VMOption
492 // a VM initialization option
493 char* optionString;
494 // extra information associated with this option
495 void* extraInfo;
498 struct _Jv_VMInitArgs
500 // for compatibility with JavaVMInitArgs
501 jint version;
503 // number of VM initialization options
504 jint nOptions;
506 // an array of VM initialization options
507 struct _Jv_VMOption* options;
509 // true if the option parser should ignore unrecognized options
510 jboolean ignoreUnrecognized;
513 extern jint _Jv_CreateJavaVM (struct _Jv_VMInitArgs*);
515 void
516 _Jv_ThreadRun (java::lang::Thread* thread);
517 jint
518 _Jv_AttachCurrentThread(java::lang::Thread* thread);
519 extern "C" java::lang::Thread*
520 _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);
521 extern "C" java::lang::Thread*
522 _Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);
523 extern "C" jint _Jv_DetachCurrentThread (void);
525 extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));
526 extern "C" void* _Jv_Malloc (jsize) __attribute__((__malloc__));
527 extern "C" void* _Jv_Realloc (void *, jsize);
528 extern "C" void _Jv_Free (void*);
529 extern void (*_Jv_RegisterClassHook) (jclass cl);
530 extern "C" void _Jv_RegisterClassHookDefault (jclass);
532 typedef unsigned short _Jv_ushort __attribute__((__mode__(__HI__)));
533 typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__)));
534 typedef unsigned int _Jv_ulong __attribute__((__mode__(__DI__)));
536 class _Jv_Utf8Const
538 _Jv_ushort hash;
539 _Jv_ushort length; /* In bytes, of data portion, without final '\0'. */
540 char data[1]; /* In Utf8 format, with final '\0'. */
541 public:
542 /** Return same value of java.lang.String's hashCode. */
543 jint hash32() { return _Jv_hashUtf8String(data, length); }
544 /** Return a hash code that has at least 16 bits of information. */
545 _Jv_ushort hash16 () { return hash; }
546 /** Return a hash code that has at least 8 bits of information. */
547 _Jv_ushort hash8 () { return hash; }
548 /** Length in bytes of the UTF8-encoding. */
549 _Jv_ushort len () const { return length; }
550 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
551 char* chars() { return data; }
552 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
553 char* limit() { return data+length; }
554 /** Return the first byte in the UTF8-encoding. */
555 char first() const { return data[0]; }
556 /** Create a (non-interned) java.lang.String from this UTF8Const. */
557 jstring toString() { return _Jv_NewStringUTF(data); }
558 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
559 including struct header, and final NUL. I.e. what to pas to malloc. */
560 static int space_needed (char *, int len)
561 { return sizeof (_Jv_Utf8Const) + len + 1; }
562 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
563 void init (char *s, int len);
564 friend jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const*, const _Jv_Utf8Const *);
565 friend jboolean _Jv_equal (_Jv_Utf8Const*, jstring, jint);
566 friend jboolean _Jv_equaln (_Jv_Utf8Const*, jstring, jint);
567 friend _Jv_Utf8Const *_Jv_makeUtf8Const (char*, int);
568 friend _Jv_Utf8Const *_Jv_makeUtf8Const (jstring);
569 friend jstring _Jv_NewStringUtf8Const (_Jv_Utf8Const*);
573 #endif /* __JAVAPRIMS_H__ */