4

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.

nikola3103
  • 113
  • 1
  • 9
  • I think you're right, but let's see what others say. – markspace Mar 07 '19 at 18:04
  • 2
    Please quote the context where the word is used. – Andreas Mar 07 '19 at 18:06
  • 1
    `referent - the thing that a word or phrase denotes or stands for.` (pertaining to linguistics) - From Google. – Jonny Henly Mar 07 '19 at 18:07
  • 3
    After a quick google search, I found a documentation page https://docs.oracle.com/javase/7/docs/api/java/lang/ref/SoftReference.html that uses `referent`. After reading this, I would agree with this assessment. The example at the bottom `SoftReference(T referent)` `Creates a new soft reference that refers to the given object.` confirms it, in my eyes. – Nick Vitha Mar 07 '19 at 18:07
  • 1
    _Each reference-object type is implemented by a subclass of the abstract base Reference class. An instance of one of these subclasses encapsulates a single reference to a particular object, called the **referent**_, from https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ref/package-summary.html – Topaco Mar 07 '19 at 18:14
  • Sound to me like a problem of a non-native speaker with an English description. – Robert Mar 07 '19 at 18:15

2 Answers2

6

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.

Community
  • 1
  • 1
Andreas
  • 154,647
  • 11
  • 152
  • 247
  • 2
    I was not referring to javadoc but to the tutorial I read about phantom references, it was not explained there. But thank you for the good explanation and sorry to everyone for forgetting to check the javadocs first before posting this question :) – nikola3103 Mar 07 '19 at 18:28
-1

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

Vishrant
  • 15,456
  • 11
  • 71
  • 120