File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
src/java.base/share/classes/java/lang/ref Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ private void runFinalizer(JavaLangAccess jla) {
82
82
}
83
83
84
84
try {
85
- Object finalizee = this .get ();
85
+ Object finalizee = this .getInactive ();
86
86
if (finalizee != null && !(finalizee instanceof java .lang .Enum )) {
87
87
jla .invokeFinalize (finalizee );
88
88
Original file line number Diff line number Diff line change @@ -342,6 +342,20 @@ public T get() {
342
342
return this .referent ;
343
343
}
344
344
345
+ /**
346
+ * Load referent with strong semantics. Treating the referent
347
+ * as strong referent is ok when the Reference is inactive,
348
+ * because then the referent is switched to strong semantics
349
+ * anyway.
350
+ *
351
+ * This is only used from Finalizer to bypass the intrinsic,
352
+ * which might return a null referent, even though it is not
353
+ * null, and would subsequently not finalize the referent/finalizee.
354
+ */
355
+ T getInactive () {
356
+ return this .referent ;
357
+ }
358
+
345
359
/**
346
360
* Tests if the referent of this reference object is {@code obj}.
347
361
* Using a {@code null} {@code obj} returns {@code true} if the
You can’t perform that action at this time.
0 commit comments