MCPcopy Create free account
hub / github.com/antlr/codebuff / cleanUp

Method cleanUp

output/java_guava/1.4.16/Finalizer.java:136–165  ·  view source on GitHub ↗

Cleans up a single reference. Catches and logs all throwables. @return true if the caller should continue, false if the associated FinalizableReferenceQueue is no longer referenced.

(Reference<?> reference)

Source from the content-addressed store, hash-verified

134 */
135
136 private boolean cleanUp(Reference<?> reference) {
137 Method finalizeReferentMethod = getFinalizeReferentMethod();
138 if (finalizeReferentMethod == null) {
139 return false;
140 }
141 do {
142 /*
143 * This is for the benefit of phantom references. Weak and soft references will have already
144 * been cleared by this point.
145 */
146 reference.clear();
147 if (reference == frqReference) {
148 /*
149 * The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
150 */
151 return false;
152 }
153 try {
154 finalizeReferentMethod.invoke(reference);
155 } catch (Throwable t) {
156 logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
157 }
158
159 /*
160 * Loop as long as we have references available so as not to waste CPU looking up the Method
161 * over and over again.
162 */
163 } while ((reference = queue.poll()) != null);
164 return true;
165 }
166
167 /**
168 * Looks up FinalizableReference.finalizeReferent() method.

Callers 1

runMethod · 0.95

Calls 5

logMethod · 0.80
clearMethod · 0.65
invokeMethod · 0.45
pollMethod · 0.45

Tested by

no test coverage detected