What is referent in java?

700 Views Asked by At

What does referent mean in java language?

I came across this word while reading about phantom references in java but it was not explained there, just used (the word). And I could not find the answer by searching on Google either.

What I could conclude from context is that it is the object that a reference is pointing to, but not sure so I want to make sure what it is.

Edit: as suggested in comments I am adding a context where the word is being used:

The Garbage Collector adds a phantom reference to a reference queue after the finalize method of its referent is executed. It implies that the instance is still in the memory.

2

There are 2 best solutions below

1
Andreas On BEST ANSWER

I came across this word while reading about phantom references in java but it was not explained, just used

Assuming you're referring to the javadoc of PhantomReference, the word is explained in the documented methods:

public PhantomReference(T referent, ReferenceQueue<? super T> q)

Parameters:
referent - the object the new phantom reference will refer to

public T get()

Returns this reference object's referent.

3
Vishrant On

There are four types of references in Java:

Phantom references are not automatically cleared by the garbage collector as they are enqueued. An object that is reachable via phantom references will remain so until all such references are cleared or themselves become unreachable. more... and example