Skip to content

Commit

Permalink
Inlined the WeakReference to ease following the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jccarrillo committed Jan 17, 2016
1 parent d973fba commit 325061d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions core/test/com/googlecode/guice/BytecodeGenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void configure(Binder binder) {
}
}

private WeakReference<Class<?>> getWeakReference() {
public void testProxyClassUnloading() {
Object testObject = Guice.createInjector(interceptorModule, testModule)
.getInstance(proxyTestClass);
assertNotNull(testObject.getClass().getClassLoader());
Expand All @@ -232,11 +232,16 @@ private WeakReference<Class<?>> getWeakReference() {

// null the proxy
testObject = null;
return clazzRef;
}

public void testProxyClassUnloading() {
GcFinalization.awaitClear(getWeakReference());
/*
* this should be enough to queue the weak reference
* unless something is holding onto it accidentally.
*/
GcFinalization.awaitClear(clazzRef);

// This test could be somewhat flaky when the GC isn't working.
// If it fails, run the test again to make sure it's failing reliably.
assertNull("Proxy class was not unloaded.", clazzRef.get());
}

public void testProxyingPackagePrivateMethods() {
Expand Down

0 comments on commit 325061d

Please sign in to comment.