Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.as3commons.lang.ClassUtils.forName() fails when getting declaring type of method in RSL #46

Closed
GoogleCodeExporter opened this issue Mar 13, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Load an RSL swf via URLLoader, and call 
ByteCodeType.fromByteArray(loader.data, tempDomain) where loader refers to the 
URLLoader instance and temp domain is a domain you created.
2. Get the ByteCodeType for some class in that RSL and iterate through its 
methods, tracing their declaringType:
      var type:ByteCodeType = ByteCodeType.forName(className,tempDomain);
      for each(var j:ByteCodeMethod in type.methods){
           trace(j.declaringType);
      }
3. Enjoy the resulting stacktrace:

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
    at org.as3commons.reflect::JSONTypeProvider/getType()[C:\projects\as3-commons\as3-commons-reflect\src\main\actionscript\org\as3commons\reflect\JSONTypeProvider.as:44]
    at org.as3commons.reflect::Type$/forClass()[C:\projects\as3-commons\as3-commons-reflect\src\main\actionscript\org\as3commons\reflect\Type.as:171]
    at org.as3commons.reflect::Type$/forName()[C:\projects\as3-commons\as3-commons-reflect\src\main\actionscript\org\as3commons\reflect\Type.as:147]
    at org.as3commons.reflect::Method/get declaringType()[C:\projects\as3-commons\as3-commons-reflect\src\main\actionscript\org\as3commons\reflect\Method.as:84]


If you dig deeply enough, the root issue is that 
tempDomain.getDefinition(className) is returning null in 
org.as3commons.lang.ClassUtils.forName().


I can work around this issue by loading RSLs via Loader and calling 
ByteCodeType.fromLoader instead.

Original issue reported on code.google.com by t...@nthsense.net on 24 Mar 2011 at 7:16

@GoogleCodeExporter
Copy link
Author

I have overriden the declaringType getters in the appropriate -bytecode classes 
to return a ByteCodeType instead of Type instance, this should avoid the 
ClassUtils.forName() call. applicationDomain.getDefinition seems a bit flaky 
when it comes to types loaded into separate applicationdomains (so other than 
the ApplicationDomain.currentDomain), so this may even be a flashplayer bug.

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

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant