aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/Object.h
blob: c5d55f17833d3b7b55fd25240bfa2b7fd916789c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Object.h - Header file for java.lang.Object.  -*- c++ -*-

/* Copyright (C) 1998, 1999  Cygnus Solutions

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

#ifndef __JAVA_LANG_OBJECT_H__
#define __JAVA_LANG_OBJECT_H__

#pragma interface

#include <javaprims.h>
#include <java-assert.h>
#include <java-threads.h>
#include <java-gc.h>

// This class is mainly here as a kludge to get G++ to allocate
// vtable pointer as the *first* word of each Object, instead of
// the second word (following sync_info).  Note that various pieces of
// code know that finalize() is the first method.  For instance,
// Object.java knows this, as does _Jv_AllocObject.

struct _JvObjectPrefix
{
protected:
  // This is disguised as the C++ vtbl.
  // _Jv_VTable*  vtable;

  virtual void finalize () = 0;
};

class java::lang::Object : public _JvObjectPrefix
{
public:
  // Order must match order in Object.java.
  jclass getClass (void);
  virtual jint hashCode (void);
  void notify (void);
  void notifyAll (void);
  void wait (jlong timeout, jint nanos);
  virtual jboolean equals (jobject obj);
  Object (void);
  virtual jstring toString (void);
  void wait (void);
  void wait (jlong timeout);

  friend jint _Jv_MonitorEnter (jobject obj);
  friend jint _Jv_MonitorExit (jobject obj);
  friend void _Jv_InitializeSyncMutex (void);
  friend void _Jv_FinalizeObject (jobject obj);

#ifdef JV_MARKOBJ_DECL
  friend JV_MARKOBJ_DECL;
#endif
#ifdef JV_MARKARRAY_DECL
  friend JV_MARKARRAY_DECL;
#endif

protected:
  virtual jobject clone (void);
  virtual void finalize (void);

private:
  // This does not actually refer to a Java object.  Instead it is a
  // placeholder for a piece of internal data (the synchronization
  // information).
  jobject sync_info;

  // Initialize the sync_info field.
  void sync_init (void);

  static void hack12_6 (jobject f);
};

#endif /* __JAVA_LANG_OBJECT_H__ */