re PR libgcj/11801 (Problems with Process.waitFor() and exitValue())
[gcc.git] / libjava / gcj / javaprims.h
1 // javaprims.h - Main external header file for libgcj. -*- c++ -*-
2
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 Free Software Foundation
5
6 This file is part of libgcj.
7
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10 details. */
11
12 #ifndef __JAVAPRIMS_H__
13 #define __JAVAPRIMS_H__
14
15 // Force C++ compiler to use Java-style exceptions.
16 #pragma GCC java_exceptions
17
18 #include <gcj/libgcj-config.h>
19
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
27
28 // To force selection of correct types that will mangle consistently
29 // across platforms.
30 extern "Java"
31 {
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;
41
42 // The following class declarations are automatically generated by
43 // the `classes.pl' script.
44 namespace java
45 {
46 namespace io
47 {
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;
128 }
129
130 namespace lang
131 {
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$ProcessManager;
155 class Double;
156 class Error;
157 class Exception;
158 class ExceptionInInitializerError;
159 class Float;
160 class IllegalAccessError;
161 class IllegalAccessException;
162 class IllegalArgumentException;
163 class IllegalMonitorStateException;
164 class IllegalStateException;
165 class IllegalThreadStateException;
166 class IncompatibleClassChangeError;
167 class IndexOutOfBoundsException;
168 class InheritableThreadLocal;
169 class InstantiationError;
170 class InstantiationException;
171 class Integer;
172 class InternalError;
173 class InterruptedException;
174 class LinkageError;
175 class Long;
176 class Math;
177 class NegativeArraySizeException;
178 class NoClassDefFoundError;
179 class NoSuchFieldError;
180 class NoSuchFieldException;
181 class NoSuchMethodError;
182 class NoSuchMethodException;
183 class NullPointerException;
184 class Number;
185 class NumberFormatException;
186 class Object;
187 class OutOfMemoryError;
188 class Package;
189 class Process;
190 class Runnable;
191 class Runtime;
192 class RuntimeException;
193 class RuntimePermission;
194 class SecurityContext;
195 class SecurityException;
196 class SecurityManager;
197 class Short;
198 class StackOverflowError;
199 class StackTraceElement;
200 class StrictMath;
201 class String;
202 class String$CaseInsensitiveComparator;
203 class StringBuffer;
204 class StringIndexOutOfBoundsException;
205 class System;
206 class Thread;
207 class ThreadDeath;
208 class ThreadGroup;
209 class ThreadLocal;
210 class Throwable;
211 class UnknownError;
212 class UnsatisfiedLinkError;
213 class UnsupportedClassVersionError;
214 class UnsupportedOperationException;
215 class VMClassLoader;
216 class VMSecurityManager;
217 class VMThrowable;
218 class VerifyError;
219 class VirtualMachineError;
220 class Void;
221 namespace ref
222 {
223 class PhantomReference;
224 class Reference;
225 class ReferenceQueue;
226 class SoftReference;
227 class WeakReference;
228 }
229
230 namespace reflect
231 {
232 class AccessibleObject;
233 class Array;
234 class Constructor;
235 class Field;
236 class InvocationHandler;
237 class InvocationTargetException;
238 class Member;
239 class Method;
240 class Modifier;
241 class Proxy;
242 class Proxy$ClassFactory;
243 class Proxy$ProxyData;
244 class Proxy$ProxySignature;
245 class Proxy$ProxyType;
246 class ReflectPermission;
247 class UndeclaredThrowableException;
248 }
249 }
250
251 namespace util
252 {
253 class AbstractCollection;
254 class AbstractList;
255 class AbstractMap;
256 class AbstractMap$BasicMapEntry;
257 class AbstractSequentialList;
258 class AbstractSet;
259 class ArrayList;
260 class Arrays;
261 class Arrays$ArrayList;
262 class BitSet;
263 class Calendar;
264 class Collection;
265 class Collections;
266 class Collections$CopiesList;
267 class Collections$EmptyList;
268 class Collections$EmptyMap;
269 class Collections$EmptySet;
270 class Collections$ReverseComparator;
271 class Collections$SingletonList;
272 class Collections$SingletonMap;
273 class Collections$SingletonSet;
274 class Collections$SynchronizedCollection;
275 class Collections$SynchronizedIterator;
276 class Collections$SynchronizedList;
277 class Collections$SynchronizedListIterator;
278 class Collections$SynchronizedMap;
279 class Collections$SynchronizedMapEntry;
280 class Collections$SynchronizedRandomAccessList;
281 class Collections$SynchronizedSet;
282 class Collections$SynchronizedSortedMap;
283 class Collections$SynchronizedSortedSet;
284 class Collections$UnmodifiableCollection;
285 class Collections$UnmodifiableEntrySet;
286 class Collections$UnmodifiableIterator;
287 class Collections$UnmodifiableList;
288 class Collections$UnmodifiableListIterator;
289 class Collections$UnmodifiableMap;
290 class Collections$UnmodifiableRandomAccessList;
291 class Collections$UnmodifiableSet;
292 class Collections$UnmodifiableSortedMap;
293 class Collections$UnmodifiableSortedSet;
294 class Comparator;
295 class ConcurrentModificationException;
296 class Currency;
297 class Date;
298 class Dictionary;
299 class EmptyStackException;
300 class Enumeration;
301 class EventListener;
302 class EventListenerProxy;
303 class EventObject;
304 class GregorianCalendar;
305 class HashMap;
306 class HashMap$HashEntry;
307 class HashMap$HashIterator;
308 class HashSet;
309 class Hashtable;
310 class Hashtable$Enumerator;
311 class Hashtable$HashEntry;
312 class Hashtable$HashIterator;
313 class IdentityHashMap;
314 class IdentityHashMap$IdentityEntry;
315 class IdentityHashMap$IdentityIterator;
316 class Iterator;
317 class LinkedHashMap;
318 class LinkedHashMap$LinkedHashEntry;
319 class LinkedHashSet;
320 class LinkedList;
321 class LinkedList$Entry;
322 class LinkedList$LinkedListItr;
323 class List;
324 class ListIterator;
325 class ListResourceBundle;
326 class Locale;
327 class Map;
328 class Map$Entry;
329 class Map$Map;
330 class MissingResourceException;
331 class MyResources;
332 class NoSuchElementException;
333 class Observable;
334 class Observer;
335 class Properties;
336 class PropertyPermission;
337 class PropertyPermissionCollection;
338 class PropertyResourceBundle;
339 class Random;
340 class RandomAccess;
341 class RandomAccessSubList;
342 class ResourceBundle;
343 class ResourceBundle$BundleKey;
344 class Set;
345 class SimpleTimeZone;
346 class SortedMap;
347 class SortedSet;
348 class Stack;
349 class StringTokenizer;
350 class SubList;
351 class TimeZone;
352 class Timer;
353 class Timer$Scheduler;
354 class Timer$TaskQueue;
355 class TimerTask;
356 class TooManyListenersException;
357 class TreeMap;
358 class TreeMap$Node;
359 class TreeMap$SubMap;
360 class TreeMap$TreeIterator;
361 class TreeSet;
362 class Vector;
363 class WeakHashMap;
364 class WeakHashMap$WeakBucket;
365 class WeakHashMap$WeakEntry;
366 class WeakHashMap$WeakEntrySet;
367 namespace jar
368 {
369 class Attributes;
370 class Attributes$Name;
371 class JarEntry;
372 class JarException;
373 class JarFile;
374 class JarFile$JarEnumeration;
375 class JarInputStream;
376 class JarOutputStream;
377 class Manifest;
378 }
379
380 namespace logging
381 {
382 class ConsoleHandler;
383 class ErrorManager;
384 class FileHandler;
385 class Filter;
386 class Formatter;
387 class Handler;
388 class Level;
389 class LogManager;
390 class LogRecord;
391 class Logger;
392 class LoggingPermission;
393 class MemoryHandler;
394 class SimpleFormatter;
395 class SocketHandler;
396 class StreamHandler;
397 class XMLFormatter;
398 }
399
400 namespace prefs
401 {
402 class AbstractPreferences;
403 class BackingStoreException;
404 class InvalidPreferencesFormatException;
405 class NodeChangeEvent;
406 class NodeChangeListener;
407 class PreferenceChangeEvent;
408 class PreferenceChangeListener;
409 class Preferences;
410 class PreferencesFactory;
411 }
412
413 namespace regex
414 {
415 class Matcher;
416 class Pattern;
417 class PatternSyntaxException;
418 }
419
420 namespace zip
421 {
422 class Adler32;
423 class CRC32;
424 class CheckedInputStream;
425 class CheckedOutputStream;
426 class Checksum;
427 class DataFormatException;
428 class Deflater;
429 class DeflaterOutputStream;
430 class GZIPInputStream;
431 class GZIPOutputStream;
432 class Inflater;
433 class InflaterInputStream;
434 class ZipConstants;
435 class ZipEntry;
436 class ZipException;
437 class ZipFile;
438 class ZipFile$PartialInputStream;
439 class ZipFile$ZipEntryEnumeration;
440 class ZipInputStream;
441 class ZipOutputStream;
442 }
443 }
444 }
445 }
446
447 typedef struct java::lang::Object* jobject;
448 typedef class java::lang::Class* jclass;
449 typedef class java::lang::Throwable* jthrowable;
450 typedef class java::lang::String* jstring;
451 struct _Jv_JNIEnv;
452
453 typedef struct _Jv_Field *jfieldID;
454 typedef struct _Jv_Method *jmethodID;
455
456 extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));
457 extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass) __attribute__((__malloc__));
458 extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass) __attribute__((__malloc__));
459 #ifdef JV_HASH_SYNCHRONIZATION
460 extern "C" jobject _Jv_AllocPtrFreeObject (jclass)
461 __attribute__((__malloc__));
462 #else
463 // Collector still needs to scan sync_info
464 static inline jobject _Jv_AllocPtrFreeObject (jclass klass)
465 {
466 return _Jv_AllocObject(klass);
467 }
468 #endif
469 extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
470 extern "C" jstring _Jv_AllocString(jsize) __attribute__((__malloc__));
471 extern "C" jstring _Jv_NewString (const jchar*, jsize)
472 __attribute__((__malloc__));
473 extern jint _Jv_FormatInt (jchar* bufend, jint num);
474 extern "C" jchar* _Jv_GetStringChars (jstring str);
475 extern "C" void _Jv_MonitorEnter (jobject);
476 extern "C" void _Jv_MonitorExit (jobject);
477 extern "C" jstring _Jv_NewStringUTF (const char *bytes)
478 __attribute__((__malloc__));
479 extern "C" jstring _Jv_NewStringLatin1(const char*, jsize)
480 __attribute__((__malloc__));
481 extern "C" jsize _Jv_GetStringUTFLength (jstring);
482 extern "C" jsize _Jv_GetStringUTFRegion (jstring, jsize, jsize, char *);
483 extern "C" jint _Jv_hashUtf8String (char*, int);
484
485 extern jint _Jv_CreateJavaVM (void* /*vm_args*/);
486
487 void
488 _Jv_ThreadRun (java::lang::Thread* thread);
489 jint
490 _Jv_AttachCurrentThread(java::lang::Thread* thread);
491 extern "C" java::lang::Thread*
492 _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);
493 extern "C" java::lang::Thread*
494 _Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);
495 extern "C" jint _Jv_DetachCurrentThread (void);
496
497 extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));
498 extern "C" void* _Jv_Malloc (jsize) __attribute__((__malloc__));
499 extern "C" void* _Jv_Realloc (void *, jsize);
500 extern "C" void _Jv_Free (void*);
501 extern void (*_Jv_RegisterClassHook) (jclass cl);
502 extern "C" void _Jv_RegisterClassHookDefault (jclass);
503
504 typedef unsigned short _Jv_ushort __attribute__((__mode__(__HI__)));
505 typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__)));
506 typedef unsigned int _Jv_ulong __attribute__((__mode__(__DI__)));
507
508 class _Jv_Utf8Const
509 {
510 _Jv_ushort hash;
511 _Jv_ushort length; /* In bytes, of data portion, without final '\0'. */
512 char data[1]; /* In Utf8 format, with final '\0'. */
513 public:
514 /** Return same value of java.lang.String's hashCode. */
515 jint hash32() { return _Jv_hashUtf8String(data, length); }
516 /** Return a hash code that has at least 16 bits of information. */
517 _Jv_ushort hash16 () { return hash; }
518 /** Return a hash code that has at least 8 bits of information. */
519 _Jv_ushort hash8 () { return hash; }
520 /** Length in bytes of the UTF8-encoding. */
521 _Jv_ushort len () const { return length; }
522 /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
523 char* chars() { return data; }
524 /** Pointer to the NUL byte that terminated the UTF8-encoding. */
525 char* limit() { return data+length; }
526 /** Return the first byte in the UTF8-encoding. */
527 char first() const { return data[0]; }
528 /** Create a (non-interned) java.lang.String from this UTF8Const. */
529 jstring toString() { return _Jv_NewStringUTF(data); }
530 /** Given an UTF8 string, how many bytes needed for a UTF8Const,
531 including struct header, and final NUL. I.e. what to pas to malloc. */
532 static int space_needed (char *, int len)
533 { return sizeof (_Jv_Utf8Const) + len + 1; }
534 /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
535 void init (char *s, int len);
536 friend jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const*, const _Jv_Utf8Const *);
537 friend jboolean _Jv_equal (_Jv_Utf8Const*, jstring, jint);
538 friend jboolean _Jv_equaln (_Jv_Utf8Const*, jstring, jint);
539 friend _Jv_Utf8Const *_Jv_makeUtf8Const (char*, int);
540 friend _Jv_Utf8Const *_Jv_makeUtf8Const (jstring);
541 friend jstring _Jv_NewStringUtf8Const (_Jv_Utf8Const*);
542 };
543
544
545 #endif /* __JAVAPRIMS_H__ */