I may have found an Dalvik compiler bug

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

I may have found an Dalvik compiler bug

Postby padde » Sat Feb 06, 2010 9:47 pm

I stumbled across a strange thing when i was preparing an old project
for a friend. I isolated the code that triggers the bug down to one function.
The function does nothing special.. and i already have another version of it
that i posted some time ago here as a slightly optimized version.
Please take a look.. maybe i am looking to hard.. but i realy have no clue whats going on...


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package de.test;
  3.  
  4.  
  5.  
  6. import java.io.DataInputStream;
  7.  
  8. import java.io.IOException;
  9.  
  10.  
  11.  
  12. import android.app.Activity;
  13.  
  14. import android.os.Bundle;
  15.  
  16.  
  17.  
  18. public class compilertest extends Activity {
  19.  
  20.     private final static int FRAME_MAX_LENGTH = 40000;
  21.  
  22.        
  23.  
  24.     public void onCreate(Bundle savedInstanceState) {
  25.  
  26.         super.onCreate(savedInstanceState);
  27.  
  28.         setContentView(R.layout.main);
  29.  
  30.     }
  31.  
  32.    
  33.  
  34.    
  35.  
  36.     public int test(DataInputStream in, byte[] sequence) throws IOException {
  37.  
  38.         byte c;
  39.  
  40.         int seqIndex = 0, len = sequence.length, i;
  41.  
  42.         for(i=0; i < FRAME_MAX_LENGTH && seqIndex < len; i++) {
  43.  
  44.             c = (byte) in.readUnsignedByte();          
  45.  
  46.                 seqIndex = (c == sequence[seqIndex]) ? seqIndex++ : 0;
  47.  
  48.         }
  49.  
  50.         return (seqIndex == len) ? i+1 : -1;            
  51.  
  52.     }
  53.  
  54.    
  55.  
  56.    
  57.  
  58.     public int test2(DataInputStream in, byte[] sequence) throws IOException {
  59.  
  60.         int seqIndex = 0;
  61.  
  62.         byte c;
  63.  
  64.         for(int i=0; i < FRAME_MAX_LENGTH; i++) {
  65.  
  66.             c = (byte) in.readUnsignedByte();
  67.  
  68.             if(c == sequence[seqIndex]) {
  69.  
  70.                 seqIndex++;
  71.  
  72.                 if(seqIndex == sequence.length) return i + 1;
  73.  
  74.             } else seqIndex = 0;
  75.  
  76.         }
  77.  
  78.         return -1;
  79.  
  80.     }    
  81.  
  82. }
  83.  
  84.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


Add this activity to a project and try to compile.
For me it throws "Conversion to Dalvik format failed with error 2".
If you comment out the function "test" and just leave test2 you can compile.
So the bug lies within function "test".

Note: Both functions do the same.. just slightly different.

If someone has a clue .. please enlighten me :)


Greets
Padde


--- Edit ---
I tested version 1.5 and 1.6 of android so far
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Postby padde » Mon Feb 08, 2010 4:25 pm

Can someone confirm this bug?!
Or is my development environment broken?!
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 6 guests