Browse Source

* BufferUtils.destroyDirectBuffer() now works on Android

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9408 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Sha..rd 13 years ago
parent
commit
8b5f4cba36
1 changed files with 7 additions and 4 deletions
  1. 7 4
      engine/src/core/com/jme3/util/BufferUtils.java

+ 7 - 4
engine/src/core/com/jme3/util/BufferUtils.java

@@ -1183,10 +1183,13 @@ public final class BufferUtils {
             }
             
             // Apache Harmony
-            freeMethod = loadMethod("org.apache.harmony.nio.internal.DirectBuffer", "free");
-            
-            // GUN Classpath (not likely)
-            //finalizeMethod = loadMethod("java.nio.DirectByteBufferImpl", "finalize");
+            ByteBuffer bb = BufferUtils.createByteBuffer(1);
+            Class<?> clazz = bb.getClass();
+            try {
+                freeMethod = clazz.getMethod("free");
+            } catch (NoSuchMethodException ex) {
+            } catch (SecurityException ex) {
+            }
         }
     }