I have to implement an object pool that uses phantom references to collect objects abandoned by client threads.
What PROBLEM are you trying to solve?
Why have you chosen that as the solution?
Why are you using reflection to try to modify the access parameters of a field? I say 'try' because your code can't possibly work.
Tell us what YOU think this line of code is doing (hint: it is NOT doing what you may think):
f = Reference.class.getDeclaredField("referent");
That code is reflecting the Reference class itself instead of an 'instance' of the Reference class.
See 'Getting and Setting Field Values' in The Java Tutorials for an example of using reflection.
Book book = new Book();
. . .
Class<?> c = book.getClass();
Field chap = c.getDeclaredField("chapters");chap.setLong(book, 12);
See how that code does NOT use the 'Book' class but uses 'book' which is an instance of the class. That provides access to the instance of the 'Book' class. Then the 'setLong' method is used to set a value in the 'instance'.
The class has NO actual values except those declared as 'static'. To work with 'instance' variables you need to work with the instance.