changeset 88:73f2f6cbd446

Restore the original code and and add a if then else for Windows.
author volker
date Sun, 27 Mar 2011 21:08:24 +0200
parents 31ee0b85dbfc
children 463222781d67
files src/test/java/org/icedrobot/daneel/DexifyingRunner.java
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/test/java/org/icedrobot/daneel/DexifyingRunner.java	Sun Mar 27 19:28:40 2011 +0200
+++ b/src/test/java/org/icedrobot/daneel/DexifyingRunner.java	Sun Mar 27 21:08:24 2011 +0200
@@ -114,11 +114,17 @@
             throw new DaneelException("Unable to execute 'dx' tool.");
 
         // Rewrite test code from DEX back to Java using our rewriter.
-        byte[] data = new byte[(int)tmp.length()];
-        DataInputStream dai = new DataInputStream(new FileInputStream(tmp));
-        dai.readFully(data);
-        dai.close();
-        DexFile dex = DexFile.parse(data);
+        DexFile dex;
+        if( !System.getProperty("os.name").contains("Windows") ) {
+            dex = DexFile.parse(tmp);
+        } else {
+            //hack for Windows Java bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154
+            byte[] data = new byte[(int)tmp.length()];
+            DataInputStream dai = new DataInputStream(new FileInputStream(tmp));
+            dai.readFully(data);
+            dai.close();
+            dex = DexFile.parse(data);
+        }
         byte[] testCode = DexRewriter.rewrite(testClass, dex);
 
         // From this point on we no longer need the DEX file