Here is some more illumination from PathClassLoader.java in android
(inside the loadClass() method):
/* --this doesn't work in current version of Dalvik--
            if (data != null) {
                System.out.println("--- Found class " + name
                    + " in zip[" + i + "] '" + mZips[i].getName() +
"'");
                int dotIndex = name.lastIndexOf('.');
                if (dotIndex != -1) {
                    String packageName = name.substring(0, dotIndex);
                    synchronized (this) {
                        Package packageObj = getPackage(packageName);
                        if (packageObj == null) {
                            definePackage(packageName, null, null,
                                    null, null, null, null, null);
                        }
                    }
                }

                return defineClass(name, data, 0, data.length);
            }
            */

Does anyone know when they are planning on implementing this?

On May 10, 11:13 pm, Tomasz <pulchritud...@gmail.com> wrote:
> It turns out that VMClassloader defineClass() methods do nothing, but
> throw the class format error. So how is one supposed to load class
> bytes directly from a byte array? Hmmm.
>
> On May 10, 10:50 pm, Tomasz <pulchritud...@gmail.com> wrote:
>
> > Hi friends,
>
> > I have an application which dynamically creates classes at runtime (in
> > the dex format). Is it possible to load these dex bytes directly
> > without saving them to a dex file, and then zipping it (many such
> > classes are created). An equivalent of
> > ClassLoader.defineClass(className, classDexBytes, 0,
> > classDexBytes.length) is what I'd like. I.e. a DexClassLoader that
> > doesn't have to reference a physical file, but can be passed byte
> > arrays instead.
>
> > If I try just extending ClassLoader is get a
> > java.lang.UnsupportedOperationException: can't load this type of class
> > file
> > despite the byte[] definitely being in dex format (it starts with 'd'
> > 'e' 'x' bytes). The trace for this is:
> > W/System.err(  362): java.lang.UnsupportedOperationException: can't
> > load this type of class file
> > W/System.err(  362):    at java.lang.VMClassLoader.defineClass(Native
> > Method)
> > W/System.err(  362):    at
> > java.lang.ClassLoader.defineClass(ClassLoader.java:338)
> > W/System.err(  362):    at
> > java.lang.ClassLoader.defineClass(ClassLoader.java:301)
>
> > Thank you very much for your help,
> > Tomasz

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

Reply via email to