Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
5.0M8
-
None
-
None
-
All
Description
In org.eclipse.ui.tests of EUT, some classunloading errors like "testClass() for ..." are found.
I see EUT just invokes GC 100 times after a class has been useless to guarantee the class is unloaded.
On the other hand, Drlvm just does class unloading in its "major GC". So a class can be just not unloaded when running EUT. But forcing every GC as major GC will pass the related EUT tests.
The error is not difficult to be fixed by one of below approaches:
(1) Change the classunloading mechanism of drlvm to let it happens in every GC.
(2) Change the gc_force_gc implementation to give a certain priority to "major GC".
(3) Claim the test case as invalid because the SPEC does not guarantee a class is unloaded.
I prefered (2), suggestions?
Some EUT sources are also listed for reference:
public void testClass() throws Exception {
setName("testClass() for " + getClass().getName());
Bundle bundle = getBundle();
Class clazz = bundle.loadClass(className);
assertNotNull(clazz);
ReferenceQueue myQueue = new ReferenceQueue();
WeakReference ref = new WeakReference(clazz.getClassLoader(), myQueue);
clazz = null; //null our refs
bundle = null;
removeBundle();
checkRef(myQueue, ref);
}
public static void checkRef(ReferenceQueue queue, Reference ref)
throws IllegalArgumentException, InterruptedException {
boolean flag = false;
for (int i = 0; i < 100; i++) {
System.runFinalization();
System.gc();
Thread.yield();
processEvents();
Reference checkRef = queue.remove(100);
if (checkRef != null && checkRef.equals(ref))
}
assertTrue("Reference not enqueued", flag);
}