Add gc-basics: Java garbage collection explained and measured on JDK 25, 27, 28 EA
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b44MquEzmd9QMkZCd7
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f7b6c1efca
commit
876ae1bb5c
@@ -0,0 +1,24 @@
|
||||
/** What finalize() does today. Compile with -Xlint:deprecation to see the compiler's view of it. */
|
||||
public class Finalize {
|
||||
static class Holder {
|
||||
@SuppressWarnings({"removal", "deprecation"})
|
||||
@Override
|
||||
protected void finalize() {
|
||||
System.out.println("finalize() ran");
|
||||
}
|
||||
}
|
||||
|
||||
static class Holder2 {
|
||||
@Override
|
||||
protected void finalize() { // deliberately not suppressed: javac prints a removal warning
|
||||
System.out.println("finalize() ran");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new Holder();
|
||||
System.gc();
|
||||
Thread.sleep(500);
|
||||
System.out.println("main done");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user