changeset 18:3a79fec307ae

Fixed parsing of class definition items. * dex/ClassDef.java: Use limited data buffer instead of full duplicate.
author Michael Starzinger <michi@complang.tuwien.ac.at>
date Wed, 16 Mar 2011 00:38:21 +0100
parents fe828e968662
children d6245f2a61a6
files src/main/java/org/icedrobot/daneel/dex/ClassDef.java
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/icedrobot/daneel/dex/ClassDef.java	Tue Mar 15 23:25:43 2011 +0100
+++ b/src/main/java/org/icedrobot/daneel/dex/ClassDef.java	Wed Mar 16 00:38:21 2011 +0100
@@ -64,17 +64,18 @@
             sourceFile = dex.getString(sourceFileIdx);
 
         // Parse associated type_list structure and resolve type indices.
-        ByteBuffer buf = buffer.duplicate();
         if (interfacesOff != 0) {
-            buf.position(interfacesOff);
+            ByteBuffer buf = dex.getDataBuffer(interfacesOff);
             interfaces = new String[buf.getInt()];
             for (int i = 0; i < interfaces.length; i++)
                 interfaces[i] = dex.getTypeDescriptor(buf.getShort());
         }
 
         // Parse the associated class_data_item structure.
-        buf.position(classDataOff);
-        classData = ClassData.parse(buf, dex, staticValuesOff);
+        if (classDataOff != 0) {
+            ByteBuffer buf = dex.getDataBuffer(classDataOff);
+            classData = ClassData.parse(buf, dex, staticValuesOff);
+        }
     }
 
     public String getClassName() {