Skip to content
Snippets Groups Projects
Commit af4e9020 authored by Sebastien Jourdain's avatar Sebastien Jourdain
Browse files

Remove usage of generics and annotations

Change-Id: I168cce8362bd849015df93de2afad32854373dab
parent 8433dba1
Branches
No related tags found
No related merge requests found
......@@ -18,14 +18,12 @@ public interface vtkJavaMemoryManager {
* Create or return an existing instance of the vtkObject that corresponds
* to the pointer id vtkId.
*
* @param <T>
* Type of the object that we want to return.
* @param vtkId
* is used to uniquely identify a vtkObject inside the C++ layer.
*
* @return a java object that map its underlying C++ instance.
*/
<T extends vtkObjectBase> T getJavaObject(Long vtkId);
vtkObjectBase getJavaObject(Long vtkId);
/**
* Store the Java instance of a vtkObject inside a weak pointer map.
......
......@@ -28,10 +28,8 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
this.garbageCollector = new vtkJavaGarbageCollector();
}
@SuppressWarnings("unchecked")
@Override
// Thread safe
public <T extends vtkObjectBase> T getJavaObject(Long vtkId) {
public vtkObjectBase getJavaObject(Long vtkId) {
// Check pre-condition
if (vtkId == null || vtkId.longValue() == 0) {
throw new RuntimeException("Invalid ID, can not be null or equal to 0.");
......@@ -53,7 +51,7 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
value = objectMap.get(vtkId);
resultObject = (value == null) ? null : value.get();
if (resultObject != null) {
return (T) resultObject;
return resultObject;
}
// We need to do the work of the gc
......@@ -65,9 +63,9 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
if (resultObject == null) {
try {
String className = vtkObjectBase.VTKGetClassNameFromReference(vtkId.longValue());
Class<T> c = (Class<T>) Class.forName("vtk." + className);
Constructor<T> cons = c.getConstructor(new Class[] { long.class });
resultObject = cons.newInstance(new Object[] { vtkId });
Class c = Class.forName("vtk." + className);
Constructor cons = c.getConstructor(new Class[] { long.class });
resultObject = (vtkObjectBase) cons.newInstance(new Object[] { vtkId });
} catch (Exception e) {
e.printStackTrace();
}
......@@ -76,10 +74,9 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
this.lock.unlock();
}
}
return (T) resultObject;
return resultObject;
}
@Override
// Thread safe
public void registerJavaObject(Long id, vtkObjectBase obj) {
try {
......@@ -91,7 +88,6 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
}
}
@Override
// Thread safe
public void unRegisterJavaObject(Long id) {
try {
......@@ -110,7 +106,6 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
}
}
@Override
// Thread safe
public vtkReferenceInformation gc(boolean debug) {
System.gc();
......@@ -134,12 +129,10 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
}
}
@Override
public vtkJavaGarbageCollector getAutoGarbageCollector() {
return this.garbageCollector;
}
@Override
// Thread safe
public int deleteAll() {
int size = this.objectMap.size();
......@@ -154,12 +147,10 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
return size;
}
@Override
public int getSize() {
return objectMap.size();
}
@Override
public vtkReferenceInformation getLastReferenceInformation() {
return this.lastGcResult;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment