Merge pull request #436 from TehLeo/patch-2

Update BufferUtils.java
experimental
Kirill Vainer 9 years ago
commit a416eafec5
  1. 14
      jme3-core/src/main/java/com/jme3/util/BufferUtils.java

@ -51,7 +51,6 @@ import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -1268,7 +1267,6 @@ public final class BufferUtils {
System.out.println(store.toString());
}
}
private static final AtomicBoolean loadedMethods = new AtomicBoolean(false);
private static Method cleanerMethod = null;
private static Method cleanMethod = null;
private static Method viewedBufferMethod = null;
@ -1288,14 +1286,7 @@ public final class BufferUtils {
}
}
private static void loadCleanerMethods() {
// If its already true, exit, if not, set it to true.
if (BufferUtils.loadedMethods.getAndSet(true)) {
return;
}
// This could potentially be called many times if used from multiple
// threads
synchronized (BufferUtils.loadedMethods) {
static {
// Oracle JRE / OpenJDK
cleanerMethod = loadMethod("sun.nio.ch.DirectBuffer", "cleaner");
cleanMethod = loadMethod("sun.misc.Cleaner", "clean");
@ -1314,7 +1305,6 @@ public final class BufferUtils {
} catch (SecurityException ex) {
}
}
}
/**
* Direct buffers are garbage collected by using a phantom reference and a
@ -1333,8 +1323,6 @@ public final class BufferUtils {
return;
}
BufferUtils.loadCleanerMethods();
try {
if (freeMethod != null) {
freeMethod.invoke(toBeDestroyed);

Loading…
Cancel
Save