vtkObjectBase.Delete() corrupts vtkGlobalJavaHash

The Java garbage collector (called GC in this bugreport) removes weak references from vtkGlobalJavaHash.PointerToReference when it deletes unused objects.
This is all good.  Buf if vtkObjectBase.Delete() is called explicitly (which is recommended in Java to avoid threading issues), vtkGlobalJavaHash.PointerToReference is not updated and contains an invalid entry, old vtkId points to an object which has been deleted from native code but not yet GC'ed.
If native code reuses the same address before object is GC'ed, vtkGlobalJavaHash.PointerToReference.get(vtkId) will return this object instead of null.
Here is a test case to reproduce this bug, output is:
Exception in thread "main" java.lang.ClassCastException: vtk.vtkQuadric cannot be cast to vtk.vtkDataArray
        at vtk.vtkDataArray.CreateDataArray(vtkDataArray.java:267)
        at BugWeakRef.main(BugWeakRef.java:21)

Patch applies against VTK 5.4 and current CVS HEAD.
See http://www.vtk.org/Bug/view.php?id=8942

diff --git a/Wrapping/vtkParseJava.c b/Wrapping/vtkParseJava.c
index f9b0235..19d46a0 100644
--- a/Wrapping/vtkParseJava.c
+++ b/Wrapping/vtkParseJava.c
@@ -669,6 +669,7 @@ void vtkParseOutput(FILE *fp, FileInfo *data)
       fprintf(fp,"\n  protected native void VTKRegister();");
       fprintf(fp,"\n  public void Delete() {");
       fprintf(fp,"\n    int refCount = this.GetReferenceCount();");
+      fprintf(fp,"\n    vtkGlobalJavaHash.PointerToReference.remove(new Long(this.vtkId));");
       fprintf(fp,"\n    this.VTKDelete();");
       fprintf(fp,"\n    this.vtkDeleted = true;");
       fprintf(fp,"\n    if (refCount == 1) {");
