Created
October 5, 2019 18:11
-
-
Save aoiroaoino/0217f34e8dff1cc109d436dcfde3b820 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scala.language.existentials | |
| import java.net._ | |
| var loader = new URLClassLoader(Array(new URL("file:///tmp/example/"))) | |
| val wrCat = new java.lang.ref.WeakReference(loader.loadClass("example.Cat")) | |
| println("=== class cat: " + wrCat.get) | |
| println("~~~ remove loader ~~~") | |
| loader = null | |
| System.gc() | |
| println("=== class cat: " + wrCat.get) | |
| println("") | |
| /* | |
| === class cat: class example.Cat | |
| ~~~ remove loader ~~~ | |
| === class cat: null | |
| */ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/todesking/status/1180540229473595392