You absolutely can extend classes.  People do that all of the time.

What you can't do is violate the scoping rules by trying to fake out the
system by putting your class in the same namespace as the system's class.

And there are NO protected fields in any view or widget class that are part
of the SDK, so what you are doing is well outside the bounds of the SDK.

On Mon, Oct 26, 2009 at 9:10 PM, Raman <[email protected]> wrote:

>
> Thanks a lot for that input. But, there has to be a solution for it.
> Otherwise, its not correct to call Android open source if they do not
> allow me to add my own classes by extending the existing ones.
>
> As far as I know, there is no such behaviour in normal Java
> Applications when run on a Sun JVM.
> Is this a special behaviour exhibited by Dalvik VM.
> What is the possible workaround for this problem.
>
> On Oct 27, 1:48 am, fadden <[email protected]> wrote:
> > On Oct 25, 11:16 pm, Raman <[email protected]> wrote:
> >
> > > I am trying to extend a class in android.widget, specifically
> > > AbsSpinner class for some change in behaviour. For that I need to
> > > access some protected members of the Classes up in the hierarchy, so I
> > > decided to put my new class in the same package android.widget
> > > It compiles fine in Eclipse but when I run it, it gives me
> > > java.lang.VerifyError.
> >
> > You can view the failure details with "adb logcat".
> >
> > You cannot access protected members in this way, because your class is
> > being loaded by a different class loader.  The package has the same
> > name, so the compiler is happy, but at runtime it's not considered to
> > be part of the same package.
> >
> > In a future release of the VM this will cause an IllegalAccessError at
> > runtime rather than a VerifyError at startup.
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to