template<class NativeType> class JNIField {
typedef JNIField<NativeType> _self;
jobject _obj; // Object that holds the field
JNIFieldId<NativeType> _id; // field ID
public:
JNIField(JNIEnv *env, jobject obj, const char *name,
const char *sig) : _obj(obj), _id(env, obj, name, sig) {}
JNIField(JNIEnv *env, jobject obj, const char *name)
: _obj(obj), _id(env, obj, name) {}
JNIField(JNIFieldId<NativeType> id, jobject obj)
: _obj(obj), _id(id) {}
_self &operator= (const _self &rhs);
_self &operator= (const NativeType &rhs);
// Casting to NativeType
operator NativeType() const { return _id.Get(_obj); }
};
End of Listing