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 {}


-Sam

--~--~---------~--~----~------------~-------~--~----~



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
away.




--~--~---------~--~----~------------~-------~--~----~


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)
 http://commonsware.com 

Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml 

--~--~---------~--~----~------------~-------~--~----~



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
cause.





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. (simple?) problem with table layout

I want to create a table layout so I don't have to use absolute
values.

I have 2 <TableRow>'s in my <TableLayout>, and each row has 4 buttons,
all the same width.

The problem I'm having is with the last button on the first row.  the
button is as tall as two buttons combined.  I can make a button span 2
columns (width), but how do I make it span two rows and not move the
second row down?

e.g., What I would like (please excuse my poor ASCII art)

+++  +++  +++  +++
+=+  +=+  +=+  +=+
+++  +++  +++  +=+
                        +=+
+++  +++  +++  +=+
+=+  +=+  +=+  +=+
+++  +++  +++  +=+

What I'm getting:

+++  +++  +++  +++
+=+  +=+  +=+  +=+
+++  +++  +++  +=+
                        +=+
                        +=+
                        +=+
                        +++
+++  +++  +++
+=+  +=+  +=+
+++  +++  +++


Any advice on how to do this properly?!

Thanks

--~--~---------~--~----~------------~-------~--~----~

2. the imageview object supports which formats images other than png and jpg

Hello everybody
    The imageview  object supports, which formats of images other than
png and jpg?
 Is it supporting *.jif, *.bmp. *.tiff, etc. to display them on sceen
of activity?

   The picture application(on emulator) shows only *.jpg and *.png
format it does not shows other format images(*.jif, *.bmp, etc).

Will anybody clear me regarding this issue?

thank you
--~--~---------~--~----~------------~-------~--~----~

3. Location is null

4. Create inode at startup

5. AV Sync

6. DatePicker -- 2/30; 4/31 is quitely treated as a valid input

7. what is example of internal_content_uri