2004-09-25 Mark Wielaard <mark@klomp.org>
[official-gcc.git] / libjava / gcj / javaprims.h
blob3120184650fd1033f7c9077b8554191a8142e3fe
1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10 details. */
12 #ifndef __JAVAPRIMS_H__
13 #define __JAVAPRIMS_H__
15 // Force C++ compiler to use Java-style exceptions.
16 #pragma GCC java_exceptions
18 #include <gcj/libgcj-config.h>
20 // FIXME: this is a hack until we get a proper gcjh.
21 // It is needed to work around system header files that define TRUE
22 // and FALSE.
23 #undef TRUE
24 #define TRUE TRUE
25 #undef FALSE
26 #define FALSE FALSE
28 // To force selection of correct types that will mangle consistently
29 // across platforms.
30 extern "Java"
32 typedef __java_byte jbyte;
33 typedef __java_short jshort;
34 typedef __java_int jint;
35 typedef __java_long jlong;
36 typedef __java_float jfloat;
37 typedef __java_double jdouble;
38 typedef __java_char jchar;
39 typedef __java_boolean jboolean;
40 typedef jint jsize;
42 // The following class declarations are automatically generated by
43 // the `classes.pl' script.
44 namespace java
46 namespace io
48 class BufferedInputStream;
49 class BufferedOutputStream;
50 class BufferedReader;
51 class BufferedWriter;
52 class ByteArrayInputStream;
53 class ByteArrayOutputStream;
54 class CharArrayReader;
55 class CharArrayWriter;
56 class CharConversionException;
57 class DataInput;
58 class DataInputStream;
59 class DataOutput;
60 class DataOutputStream;
61 class EOFException;
62 class Externalizable;
63 class File;
64 class FileDescriptor;
65 class FileFilter;
66 class FileInputStream;
67 class FileNotFoundException;
68 class FileOutputStream;
69 class FilePermission;
70 class FileReader;
71 class FileWriter;
72 class FilenameFilter;
73 class FilterInputStream;
74 class FilterOutputStream;
75 class FilterReader;
76 class FilterWriter;
77 class IOException;
78 class InputStream;
79 class InputStreamReader;
80 class InterfaceComparator;
81 class InterruptedIOException;
82 class InvalidClassException;
83 class InvalidObjectException;
84 class LineNumberInputStream;
85 class LineNumberReader;
86 class MemberComparator;
87 class NotActiveException;
88 class NotSerializableException;
89 class ObjectInput;
90 class ObjectInputStream;
91 class ObjectInputStream$GetField;
92 class ObjectInputValidation;
93 class ObjectOutput;
94 class ObjectOutputStream;
95 class ObjectOutputStream$PutField;
96 class ObjectStreamClass;
97 class ObjectStreamConstants;
98 class ObjectStreamException;
99 class ObjectStreamField;
100 class OptionalDataException;
101 class OutputStream;
102 class OutputStreamWriter;
103 class PipedInputStream;
104 class PipedOutputStream;
105 class PipedReader;
106 class PipedWriter;
107 class PrintStream;
108 class PrintWriter;
109 class PushbackInputStream;
110 class PushbackReader;
111 class RandomAccessFile;
112 class Reader;
113 class SequenceInputStream;
114 class Serializable;
115 class SerializablePermission;
116 class StreamCorruptedException;
117 class StreamTokenizer;
118 class StringBufferInputStream;
119 class StringReader;
120 class StringWriter;
121 class SyncFailedException;
122 class UTFDataFormatException;
123 class UnsupportedEncodingException;
124 class VMObjectStreamClass;
125 class ValidatorAndPriority;
126 class WriteAbortedException;
127 class Writer;
130 namespace lang
132 class AbstractMethodError;
133 class ArithmeticException;
134 class ArrayIndexOutOfBoundsException;
135 class ArrayStoreException;
136 class AssertionError;
137 class Boolean;
138 class Byte;
139 class CharSequence;
140 class Character;
141 class Character$Subset;
142 class Character$UnicodeBlock;
143 class Class;
144 class ClassCastException;
145 class ClassCircularityError;
146 class ClassFormatError;
147 class ClassLoader;
148 class ClassNotFoundException;
149 class CloneNotSupportedException;
150 class Cloneable;
151 class Comparable;
152 class Compiler;
153 class ConcreteProcess;
154 class ConcreteProcess$EOFInputStream;
155 class ConcreteProcess$ProcessManager;
156 class Double;
157 class Error;
158 class Exception;
159 class ExceptionInInitializerError;
160 class Float;
161 class IllegalAccessError;
162 class IllegalAccessException;
163 class IllegalArgumentException;
164 class IllegalMonitorStateException;
165 class IllegalStateException;
166 class IllegalThreadStateException;
167 class IncompatibleClassChangeError;
168 class IndexOutOfBoundsException;
169 class InheritableThreadLocal;
170 class InstantiationError;
171 class InstantiationException;
172 class Integer;
173 class InternalError;
174 class InterruptedException;
175 class LinkageError;
176 class Long;
177 class Math;
178 class NegativeArraySizeException;
179 class NoClassDefFoundError;
180 class NoSuchFieldError;
181 class NoSuchFieldException;
182 class NoSuchMethodError;
183 class NoSuchMethodException;
184 class NullPointerException;
185 class Number;
186 class NumberFormatException;
187 class Object;
188 class OutOfMemoryError;
189 class Package;
190 class Process;
191 class Runnable;
192 class Runtime;
193 class RuntimeException;
194 class RuntimePermission;
195 class SecurityContext;
196 class SecurityException;
197 class SecurityManager;
198 class Short;
199 class StackOverflowError;
200 class StackTraceElement;
201 class StrictMath;
202 class String;
203 class String$CaseInsensitiveComparator;
204 class StringBuffer;
205 class StringIndexOutOfBoundsException;
206 class System;
207 class Thread;
208 class ThreadDeath;
209 class ThreadGroup;
210 class ThreadLocal;
211 class Throwable;
212 class UnknownError;
213 class UnsatisfiedLinkError;
214 class UnsupportedClassVersionError;
215 class UnsupportedOperationException;
216 class VMClassLoader;
217 class VMSecurityManager;
218 class VMThrowable;
219 class VerifyError;
220 class VirtualMachineError;
221 class Void;
222 namespace ref
224 class PhantomReference;
225 class Reference;
226 class ReferenceQueue;
227 class SoftReference;
228 class WeakReference;
231 namespace reflect
233 class AccessibleObject;
234 class Array;
235 class Constructor;
236 class Field;
237 class InvocationHandler;
238 class InvocationTargetException;
239 class Member;
240 class Method;
241 class Modifier;
242 class Proxy;
243 class Proxy$ClassFactory;
244 class Proxy$ProxyData;
245 class Proxy$ProxySignature;
246 class Proxy$ProxyType;
247 class ReflectPermission;
248 class UndeclaredThrowableException;
252 namespace util
254 class AbstractCollection;
255 class AbstractList;
256 class AbstractMap;
257 class AbstractMap$BasicMapEntry;
258 class AbstractSequentialList;
259 class AbstractSet;
260 class ArrayList;
261 class Arrays;
262 class Arrays$ArrayList;
263 class BitSet;
264 class Calendar;
265 class Collection;
266 class Collections;
267 class Collections$CopiesList;
268 class Collections$EmptyList;
269 class Collections$EmptyMap;
270 class Collections$EmptySet;
271 class Collections$ReverseComparator;
272 class Collections$SingletonList;
273 class Collections$SingletonMap;
274 class Collections$SingletonSet;
275 class Collections$SynchronizedCollection;
276 class Collections$SynchronizedIterator;
277 class Collections$SynchronizedList;
278 class Collections$SynchronizedListIterator;
279 class Collections$SynchronizedMap;
280 class Collections$SynchronizedMapEntry;
281 class Collections$SynchronizedRandomAccessList;
282 class Collections$SynchronizedSet;
283 class Collections$SynchronizedSortedMap;
284 class Collections$SynchronizedSortedSet;
285 class Collections$UnmodifiableCollection;
286 class Collections$UnmodifiableEntrySet;
287 class Collections$UnmodifiableIterator;
288 class Collections$UnmodifiableList;
289 class Collections$UnmodifiableListIterator;
290 class Collections$UnmodifiableMap;
291 class Collections$UnmodifiableRandomAccessList;
292 class Collections$UnmodifiableSet;
293 class Collections$UnmodifiableSortedMap;
294 class Collections$UnmodifiableSortedSet;
295 class Comparator;
296 class ConcurrentModificationException;
297 class Currency;
298 class Date;
299 class Dictionary;
300 class EmptyStackException;
301 class Enumeration;
302 class EventListener;
303 class EventListenerProxy;
304 class EventObject;
305 class GregorianCalendar;
306 class HashMap;
307 class HashMap$HashEntry;
308 class HashMap$HashIterator;
309 class HashSet;
310 class Hashtable;
311 class Hashtable$Enumerator;
312 class Hashtable$HashEntry;
313 class Hashtable$HashIterator;
314 class IdentityHashMap;
315 class IdentityHashMap$IdentityEntry;
316 class IdentityHashMap$IdentityIterator;
317 class Iterator;
318 class LinkedHashMap;
319 class LinkedHashMap$LinkedHashEntry;
320 class LinkedHashSet;
321 class LinkedList;
322 class LinkedList$Entry;
323 class LinkedList$LinkedListItr;
324 class List;
325 class ListIterator;
326 class ListResourceBundle;
327 class Locale;
328 class Map;
329 class Map$Entry;
330 class Map$Map;
331 class MissingResourceException;
332 class MyResources;
333 class NoSuchElementException;
334 class Observable;
335 class Observer;
336 class Properties;
337 class PropertyPermission;
338 class PropertyPermissionCollection;
339 class PropertyResourceBundle;
340 class Random;
341 class RandomAccess;
342 class RandomAccessSubList;
343 class ResourceBundle;
344 class ResourceBundle$BundleKey;
345 class Set;
346 class SimpleTimeZone;
347 class SortedMap;
348 class SortedSet;
349 class Stack;
350 class StringTokenizer;
351 class SubList;
352 class TimeZone;
353 class Timer;
354 class Timer$Scheduler;
355 class Timer$TaskQueue;
356 class TimerTask;
357 class TooManyListenersException;
358 class TreeMap;
359 class TreeMap$Node;
360 class TreeMap$SubMap;
361 class TreeMap$TreeIterator;
362 class TreeSet;
363 class VMTimeZone;
364 class Vector;
365 class WeakHashMap;
366 class WeakHashMap$WeakBucket;
367 class WeakHashMap$WeakEntry;
368 class WeakHashMap$WeakEntrySet;
369 namespace jar
371 class Attributes;
372 class Attributes$Name;
373 class JarEntry;
374 class JarException;
375 class JarFile;
376 class JarFile$JarEnumeration;
377 class JarInputStream;
378 class JarOutputStream;
379 class Manifest;
382 namespace logging
384 class ConsoleHandler;
385 class ErrorManager;
386 class FileHandler;
387 class Filter;
388 class Formatter;
389 class Handler;
390 class Level;
391 class LogManager;
392 class LogRecord;
393 class Logger;
394 class LoggingPermission;
395 class MemoryHandler;
396 class SimpleFormatter;
397 class SocketHandler;
398 class StreamHandler;
399 class XMLFormatter;
402 namespace prefs
404 class AbstractPreferences;
405 class BackingStoreException;
406 class InvalidPreferencesFormatException;
407 class NodeChangeEvent;
408 class NodeChangeListener;
409 class PreferenceChangeEvent;
410 class PreferenceChangeListener;
411 class Preferences;
412 class PreferencesFactory;
415 namespace regex
417 class Matcher;
418 class Pattern;
419 class PatternSyntaxException;
422 namespace zip
424 class Adler32;
425 class CRC32;
426 class CheckedInputStream;
427 class CheckedOutputStream;
428 class Checksum;
429 class DataFormatException;
430 class Deflater;
431 class DeflaterOutputStream;
432 class GZIPInputStream;
433 class GZIPOutputStream;
434 class Inflater;
435 class InflaterInputStream;
436 class ZipConstants;
437 class ZipEntry;
438 class ZipException;
439 class ZipFile;
440 class ZipFile$PartialInputStream;
441 class ZipFile$ZipEntryEnumeration;
442 class ZipInputStream;
443 class ZipOutputStream;
449 typedef struct java::lang::Object* jobject;
450 typedef class java::lang::Class* jclass;
451 typedef class java::lang::Throwable* jthrowable;
452 typedef class java::lang::String* jstring;
453 struct _Jv_JNIEnv;
455 typedef struct _Jv_Field *jfieldID;
456 typedef struct _Jv_Method *jmethodID;
458 extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));
459 extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass) __attribute__((__malloc__));
460 extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass) __attribute__((__malloc__));
461 #ifdef JV_HASH_SYNCHRONIZATION
462 extern "C" jobject _Jv_AllocPtrFreeObject (jclass)
463 __attribute__((__malloc__));
464 #else
465 // Collector still needs to scan sync_info
466 static inline jobject _Jv_AllocPtrFreeObject (jclass klass)
468 return _Jv_AllocObject(klass);
470 #endif
471 extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
472 extern "C" jstring _Jv_AllocString(jsize) __attribute__((__malloc__));
473 extern "C" jstring _Jv_NewString (const jchar*, jsize)
474 __attribute__((__malloc__));
475 extern jint _Jv_FormatInt (jchar* bufend, jint num);
476 extern "C" jchar* _Jv_GetStringChars (jstring str);
477 extern "C" void _Jv_MonitorEnter (jobject);
478 extern "C" void _Jv_MonitorExit (jobject);
479 extern "C" jstring _Jv_NewStringUTF (const char *bytes)
480 __attribute__((__malloc__));
481 extern "C" jstring _Jv_NewStringLatin1(const char*, jsize)
482 __attribute__((__malloc__));
483 extern "C" jsize _Jv_GetStringUTFLength (jstring);
484 extern "C" jsize _Jv_GetStringUTFRegion (jstring, jsize, jsize, char *);
485 extern "C" jint _Jv_hashUtf8String (char*, int);
487 extern jint _Jv_CreateJavaVM (void* /*vm_args*/);
489 void
490 _Jv_ThreadRun (java::lang::Thread* thread);
491 jint
492 _Jv_AttachCurrentThread(java::lang::Thread* thread);
493 extern "C" java::lang::Thread*
494 _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);
495 extern "C" java::lang::Thread*
496 _Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);
497 extern "C" jint _Jv_DetachCurrentThread (void);
499 extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));
500 extern "C" void* _Jv_Malloc (jsize) __attribute__((__malloc__));
501 extern "C" void* _Jv_Realloc (void *, jsize);
502 extern "C" void _Jv_Free (void*);
503 extern void (*_Jv_RegisterClassHook) (jclass cl);
504 extern "C" void _Jv_RegisterClassHookDefault (jclass);
506 typedef unsigned short _Jv_ushort __attribute__((__mode__(__HI__)));
507 typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__)));
508 typedef unsigned int _Jv_ulong __attribute__((__mode__(__DI__)));
510 class _Jv_Utf8Const
512 _Jv_ushort hash;
513 _Jv_ushort length; /* In bytes, of data portion, without final '\0'. */
514 char data[1]; /* In Utf8 format, with final '\0'. */
515 public:
516 /** Return same value of java.lang.String's hashCode. */
517 jint hash32() { return _Jv_hashUtf8String(data, length); }
518 /** Return a hash code that has at least 16 bits of information. */
519 _Jv_ushort hash16 () { return hash; }
520 /** Return a hash code that has at least 8 bits of information. */
521 _Jv_ushort hash8 () { return hash; }
522 /** Length in bytes of the UTF8-encoding. */
523 _Jv_ushort len () const { return length; }
524 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
525 char* chars() { return data; }
526 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
527 char* limit() { return data+length; }
528 /** Return the first byte in the UTF8-encoding. */
529 char first() const { return data[0]; }
530 /** Create a (non-interned) java.lang.String from this UTF8Const. */
531 jstring toString() { return _Jv_NewStringUTF(data); }
532 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
533 including struct header, and final NUL. I.e. what to pas to malloc. */
534 static int space_needed (char *, int len)
535 { return sizeof (_Jv_Utf8Const) + len + 1; }
536 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
537 void init (char *s, int len);
538 friend jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const*, const _Jv_Utf8Const *);
539 friend jboolean _Jv_equal (_Jv_Utf8Const*, jstring, jint);
540 friend jboolean _Jv_equaln (_Jv_Utf8Const*, jstring, jint);
541 friend _Jv_Utf8Const *_Jv_makeUtf8Const (char*, int);
542 friend _Jv_Utf8Const *_Jv_makeUtf8Const (jstring);
543 friend jstring _Jv_NewStringUtf8Const (_Jv_Utf8Const*);
547 #endif /* __JAVAPRIMS_H__ */