aaron-nance / as3-commons

Automatically exported from code.google.com/p/as3-commons
0 stars 0 forks source link

ByteCodeType.forInstance() fails for instances of private/helper classes #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Using: as3commons-bytecode-0.9.8-SNAPSHOT.swc
       as3commons-reflect-1.3.5-SNAPSHOT.swc
       as3commons-lang-0.3.3-SNAPSHOT.swc

The following example code fails with a stack like this:

Error: A class with the name 'Test.as$0::Helper' could not be found.
    at org.as3commons.lang::ClassUtils$/forName()[C:\projects\as3-commons\as3-commons-lang\src\main\actionscript\org\as3commons\lang\ClassUtils.as:84]
    at org.as3commons.lang::ClassUtils$/forInstance()[C:\projects\as3-commons\as3-commons-lang\src\main\actionscript\org\as3commons\lang\ClassUtils.as:50]
    at org.as3commons.bytecode.reflect::ByteCodeType$/forInstance()[C:\projects\as3-commons\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\reflect\ByteCodeType.as:137]

You may want to refer to issue #36, which has been "fixed" and closed, for 
additional details.  However, the fix was directed at ByteCodeType.forName(), 
which doens't actually seem to be involved here.  Indeed, with the latest 
build, ByteCodeType.forInstance() is still failing.

---------------

// Test.as

package
{
    import org.as3commons.bytecode.reflect.ByteCodeType;

    public class Test extends Sprite
    {
        public function Test()
        {
            ByteCodeType.forInstance(new Helper()); // ERROR!
        }
    }
}

class Helper { }

Original issue reported on code.google.com by idontneedthisacct@gmail.com on 1 Feb 2011 at 1:36

GoogleCodeExporter commented 8 years ago
Hmm, this is probably related to issue #38.

Original comment by idontneedthisacct@gmail.com on 3 Feb 2011 at 7:15

GoogleCodeExporter commented 8 years ago
Yea, the forInstance will indeed fail because its not possible to retrieve the 
Class for it (getQualifiedName()) will fail), I think the only workaround will 
probably be to use ByteCodeType.forClass(Helper).
Hope this helps.

Original comment by ihatelivelyids on 26 Mar 2011 at 10:53