java/GlobalRef: remove method Set(), always require initialization
This commit is contained in:

committed by
Max Kellermann

parent
917fe549b0
commit
31f7fede30
src
@ -110,12 +110,6 @@ class GlobalRef {
|
||||
T value;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs an uninitialized object. The method
|
||||
* set() must be called before it is destructed.
|
||||
*/
|
||||
GlobalRef() = default;
|
||||
|
||||
GlobalRef(JNIEnv *env, T _value) noexcept
|
||||
:value(_value)
|
||||
{
|
||||
@ -135,17 +129,6 @@ public:
|
||||
GlobalRef(const GlobalRef &other) = delete;
|
||||
GlobalRef &operator=(const GlobalRef &other) = delete;
|
||||
|
||||
/**
|
||||
* Sets the object, ignoring the previous value. This
|
||||
* is only allowed once after the default constructor
|
||||
* was used.
|
||||
*/
|
||||
void Set(JNIEnv *env, T _value) noexcept {
|
||||
assert(_value != nullptr);
|
||||
|
||||
value = (T)env->NewGlobalRef(_value);
|
||||
}
|
||||
|
||||
T Get() const noexcept {
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user