Giter VIP home page Giter VIP logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
Clarification...

Actually, Type/ByteCodeType.forClass() does work!  But, 
Type/ByteCodeType.forInstance() fails (which is actually what I was 
encountering in my real code).

Also, I think I see the possible cause...

The information returned by forClass shows that the fullName of Helper is 
"Test.as$0.Helper".  But, the Error thrown by forInstance complains about not 
being able to find a class named "Test.as$0::Helper".

So, the issue might be that the library is using "::" instead of "." somewhere?

Revised example:

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

// Test.as

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

    public class Test extends Sprite
    {
        public function Test()
        {
            var t:ByteCodeType = ByteCodeType.forClass(Helper); // OK
            ByteCodeType.forName(t.fullName); // OK
            trace(t.fullName); // "Test.as$0.Helper"
            ByteCodeType.forInstance(new Helper()); // ERROR!
        }
    }
}

class Helper { }

Original comment by [email protected] on 27 Jan 2011 at 8:58

from as3-commons.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
Btw, for now, to avoid the ByteCodeType.forInstance failures on private/helper 
classes, I am using the following work-around:

    function byteCodeTypeForInstance(inst:*):ByteCodeType
    {
        var name:String = StringUtil.replace(getQualifiedClassName(inst), "::", "."); 
        return ByteCodeType.forName(name);
    }

This seems to work for instances of any class.

Original comment by [email protected] on 27 Jan 2011 at 9:56

from as3-commons.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
Thanks for bringing this up, the ByteCodeType.forName() will now first 
normalize the class name before trying to retrieve it from the cache.

Original comment by ihatelivelyids on 28 Jan 2011 at 12:05

  • Changed state: Fixed

from as3-commons.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
What version will this fix appear in?

I am currently using...

   as3commons-reflect-1.3.4.swc
   as3commons-bytecode-0.9.7.swc

but ByteCodeType.forInstance() is still failing I as described in my previous 
comments.

Original comment by [email protected] on 31 Jan 2011 at 11:07

from as3-commons.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
I made some modifications in the trunk, (which I didn't test thoroughly I 
readily admit), ByteCodeType.forClass() now checks if the clazz property is 
null after retrieving it from the cache, if its null (in the case of private 
classes) it will just assign the Class instance that was passed into the 
forClass() method the the clazz property of the specified ByteCodeType instance.
This fix will appear in the next release.

Original comment by [email protected] on 16 Mar 2011 at 10:01

from as3-commons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.