60 //------------------------------------------------------------------------------------------------------------------------
61 // Base class for all handles. Provides overloading of frequently
62 // used operators for ease of use.
63
64 class Handle {
65 private:
66 oop* _handle;
67
68 protected:
69 oop obj() const { return _handle == NULL ? (oop)NULL : *_handle; }
70 oop non_null_obj() const { assert(_handle != NULL, "resolving NULL handle"); return *_handle; }
71
72 public:
73 // Constructors
74 Handle() { _handle = NULL; }
75 inline Handle(Thread* thread, oop obj);
76
77 // General access
78 oop operator () () const { return obj(); }
79 oop operator -> () const { return non_null_obj(); }
80 bool operator == (oop o) const { return obj() == o; }
81 bool operator == (const Handle& h) const { return obj() == h.obj(); }
82
83 // Null checks
84 bool is_null() const { return _handle == NULL; }
85 bool not_null() const { return _handle != NULL; }
86
87 // Debugging
88 void print() { obj()->print(); }
89
90 // Direct interface, use very sparingly.
91 // Used by JavaCalls to quickly convert handles and to create handles static data structures.
92 // Constructor takes a dummy argument to prevent unintentional type conversion in C++.
93 Handle(oop *handle, bool dummy) { _handle = handle; }
94
95 // Raw handle access. Allows easy duplication of Handles. This can be very unsafe
96 // since duplicates is only valid as long as original handle is alive.
97 oop* raw_value() { return _handle; }
98 static oop raw_resolve(oop *handle) { return handle == NULL ? (oop)NULL : *handle; }
99 };
100
101 // Specific Handles for different oop types
|
60 //------------------------------------------------------------------------------------------------------------------------
61 // Base class for all handles. Provides overloading of frequently
62 // used operators for ease of use.
63
64 class Handle {
65 private:
66 oop* _handle;
67
68 protected:
69 oop obj() const { return _handle == NULL ? (oop)NULL : *_handle; }
70 oop non_null_obj() const { assert(_handle != NULL, "resolving NULL handle"); return *_handle; }
71
72 public:
73 // Constructors
74 Handle() { _handle = NULL; }
75 inline Handle(Thread* thread, oop obj);
76
77 // General access
78 oop operator () () const { return obj(); }
79 oop operator -> () const { return non_null_obj(); }
80 bool operator == (oop o) const { return oopDesc::equals(obj(), o); }
81 bool operator == (const Handle& h) const{ return oopDesc::equals(obj(), h.obj()); }
82
83 // Null checks
84 bool is_null() const { return _handle == NULL; }
85 bool not_null() const { return _handle != NULL; }
86
87 // Debugging
88 void print() { obj()->print(); }
89
90 // Direct interface, use very sparingly.
91 // Used by JavaCalls to quickly convert handles and to create handles static data structures.
92 // Constructor takes a dummy argument to prevent unintentional type conversion in C++.
93 Handle(oop *handle, bool dummy) { _handle = handle; }
94
95 // Raw handle access. Allows easy duplication of Handles. This can be very unsafe
96 // since duplicates is only valid as long as original handle is alive.
97 oop* raw_value() { return _handle; }
98 static oop raw_resolve(oop *handle) { return handle == NULL ? (oop)NULL : *handle; }
99 };
100
101 // Specific Handles for different oop types
|