Hi Peter,
After tried couple implementations it seems the most reasonable approach
is to
use the coding pattern you suggested to move all pieces into ZSStream
Ref. Given
we are already using the internal API CleanerFactory it is attractive to
go a little
further to subclass PhantomCleanable directly (in which I would assume
we can
save one extra object), but I think I'd better to follow the "suggested"
clean usage
(to register a runnable into the cleaner) for now.
39 class ZStreamRef implements Runnable {
40
41 private LongConsumer end;
42 private volatile long address;
43 private final Cleanable cleanable;
44
45 ZStreamRef (Object owner, LongSupplier addr, LongConsumer end) {
46 this.cleanable = CleanerFactory.cleaner().register(owner,
this);
47 this.end = end;
48 this.address = addr.getAsLong();
49 }
50
Similar change has been made for the ZipFile cleaner to follow the same
coding
pattern. The "cleaner" is now renamed from Releaser to CleanableResource.
http://cr.openjdk.java.net/~sherman/8185582/webrev/
Thanks,
Sherman