bo0liu / as3-commons

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

problem with read metadata after class generation #126

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new Class with ByteCode library
2. Load this library into currentApplicationDomain
3. Try to get this clas with ByteCodeType.getClassesWithMetadata("aspect");

Code:
var abcBuilder:IAbcBuilder = new AbcBuilder();
abcBuilder.addEventListener(Event.COMPLETE, loadedHandler);
var packageBuilder:IPackageBuilder = 
abcBuilder.definePackage("com.app.aspects");
var classBuilder:IClassBuilder = packageBuilder.defineClass("AspectTest");
var metadataBuilder:IMetadataBuilder = classBuilder.defineMetadata("Aspect");
var abc:AbcFile = abcBuilder.buildAndLoad(
    FlexGlobals.topLevelApplication.loaderInfo.applicationDomain,
    FlexGlobals.topLevelApplication.loaderInfo.applicationDomain);

function loadedHandler(event:Event):void {
    ByteCodeType.fromLoader(FlexGlobals.topLevelApplication.loaderInfo);
    var arr:Array = ByteCodeType.getClassesWithMetadata("aspect");
}

What is the expected output? What do you see instead?
Expected: the variable arr  filed with: ["com.app.aspects.AspectTest"]
But now, it's empty

What version of the product are you using? On what operating system?
bytecode-1.1.1
lang-0.3.6
logging-2.7
reflect-1.6.0

Please provide any additional information below.

Original issue reported on code.google.com by andres.l...@gmail.com on 28 Aug 2012 at 9:53

GoogleCodeExporter commented 9 years ago
The ByteCodeType cache only gets filled with class information extracted from 
the loaderInfo.bytes ByteArray.
If you want to reflect the generated class, use 
Type.forName("com.app.aspects.AspectTest", 
FlexGlobals.topLevelApplication.loaderInfo.applicationDomain) to retrieve the 
regular reflection data.

cheers,

Roland

Original comment by ihatelivelyids on 29 Aug 2012 at 5:16

GoogleCodeExporter commented 9 years ago

Original comment by ihatelivelyids on 29 Aug 2012 at 5:16

GoogleCodeExporter commented 9 years ago

Original comment by ihatelivelyids on 29 Aug 2012 at 5:16