Stack overflow - 32 deep class hierarchy

by thesquib » Sat, 27 Dec 2008 07:03:29 GMT

Sponsored Links
 I have come across an interesting problem. If I have a class hierarchy
that is 32 deep and attempt to instantiate the 32nd one, the VM breaks
with a stack overflow. I take it this is expected - 32 seems like a
'magic' number. Debugging shows that the VM fails to load the class,
tries to throw and exception and goes into infinite recursion. Can
anyone shed a bit of light on the situation?

Example class hierarchy:
class T1 {}
class T2 extends T1 {}
class T3 extends T2 {}
class T4 extends T3 {}
class T5 extends T4 {}
class T6 extends T5 {}
class T7 extends T6 {}
class T8 extends T7 {}
class T9 extends T8 {}
class T10 extends T9 {}
class T11 extends T10 {}
class T12 extends T11 {}
class T13 extends T12 {}
class T14 extends T13 {}
class T15 extends T14 {}
class T16 extends T15 {}
class T17 extends T16 {}
class T18 extends T17 {}
class T19 extends T17 {}
class T20 extends T19 {}
class T21 extends T20 {}
class T22 extends T21 {}
class T23 extends T22 {}
class T24 extends T23 {}
class T25 extends T24 {}
class T26 extends T25 {}
class T27 extends T26 {}
class T28 extends T27 {}
class T29 extends T28 {}
class T30 extends T29 {}
class T31 extends T30 {}
class T32 extends T31 {}
class T33 extends T32 {}



Stack overflow - 32 deep class hierarchy

by thesquib » Tue, 30 Dec 2008 03:55:59 GMT

 I posted this at the worst time of the year :)
I just wanted to add that I am interested in finding a way around
this, or just to find out if it is a limitation which will not go


Sponsored Links

Stack overflow - 32 deep class hierarchy

by Mark Murphy » Tue, 30 Dec 2008 04:04:07 GMT


I'd focus instead on getting rid of 20+ classes in the hierarchy.

Mark Murphy (a Commons Guy) 

Android Training on the Ranch! -- Mar 16-20, 2009 


Stack overflow - 32 deep class hierarchy

by thesquib » Tue, 30 Dec 2008 05:49:13 GMT

 Thanks for your reply Mark. I realise that the best solution is to
collapse the hierarchy, however I am still interested to know the


Other Threads

1. adc2: can use third party lib from the market?

My app uses the text-to-speech lib from the market, which is developed
by Google Charles Chan.

So is it eligible to have the app download the lib from the market?

And any technique difficulty here? for example, will the app be able
to use the lib from the different source? any security limitation?



2. post

thank you


3. How to draw text in rectangle

4. How to push streaming from android

5. Join android Group

6. Bluetooth Classes documentation???

7. Textview Rounding Issues