s200662038 / as3-commons

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

Bug and fix, null pointers from ProxyFactory.defineProxy #111

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

If you write code like so generates null pointer exception: 

proxyFactory.defineProxy(LoginService, BasicMethodInvocationInterceptor);

[Fault] exception, information=TypeError: Error #1009: Cannot access a property 
or method of a null object reference.
at 
org.as3commons.bytecode.proxy.impl::ProxyFactory/buildProxyClass()[C:\projects\a
s3-commons\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\pr
oxy\impl\ProxyFactory.as:406]
at 
org.as3commons.bytecode.proxy.impl::ProxyFactory/generateProxyClasses()[C:\proje
cts\as3-commons\as3-commons-bytecode\src\main\actionscript\org\as3commons\byteco
de\proxy\impl\ProxyFactory.as:302]
at 
Main$/appcreationCompleteHandler()[/common/mine/as3-commons-sample/src/main/flex
/Main.mxml:50]
at 
Main/___Main_Application1_applicationComplete()[/common/mine/as3-commons-sample/
src/main/flex/Main.mxml:6]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\
src\mx\core\UIComponent.as:13128]
at 
mx.managers::SystemManager/preloader_preloaderDoneHandler()[E:\dev\4.5.1\framewo
rks\projects\framework\src\mx\managers\SystemManager.as:2682]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.preloaders::Preloader/displayClassCompleteHandler()[E:\dev\4.5.1\frameworks\p
rojects\framework\src\mx\preloaders\Preloader.as:582]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.preloaders::SparkDownloadProgressBar/initCompleteHandler()[E:\dev\4.5.1\frame
works\projects\framework\src\mx\preloaders\SparkDownloadProgressBar.as:1087]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.preloaders::Preloader/dispatchAppEndEvent()[E:\dev\4.5.1\frameworks\projects\
framework\src\mx\preloaders\Preloader.as:380]
at 
mx.preloaders::Preloader/appCreationCompleteHandler()[E:\dev\4.5.1\frameworks\pr
ojects\framework\src\mx\preloaders\Preloader.as:590]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\
src\mx\core\UIComponent.as:13128]
at mx.core::UIComponent/set 
initialized()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent
.as:1818]
at 
mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\proje
cts\framework\src\mx\managers\LayoutManager.as:842]
at 
mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\framewor
ks\projects\framework\src\mx\managers\LayoutManager.as:1180]

If you write code like so, no problems:
proxyFactory.defineProxy(LoginService, BasicMethodInvocationInterceptor, 
FlexGlobals.topLevelApplication.loaderInfo.applicationDomain);

Original issue reported on code.google.com by sentimen...@gmail.com on 19 Dec 2011 at 3:47

GoogleCodeExporter commented 9 years ago

If you write code like so, no problems:
proxyFactory.defineProxy(LoginService, BasicMethodInvocationInterceptor, 
FlexGlobals.topLevelApplication.loaderInfo.applicationDomain);

Original comment by sentimen...@gmail.com on 19 Dec 2011 at 3:47

GoogleCodeExporter commented 9 years ago
Indeed correct, bytecode type information is stored per application domain 
(since its possible to load classes with the same name yet different 
implementations into separate application domains.)
It is therefore necessary to provide the defineProxy() method with the correct 
applicationDomain instance.
I'll try and make this clearer in the documentation.

cheers,

Roland

Original comment by ihatelivelyids on 19 Dec 2011 at 7:02

GoogleCodeExporter commented 9 years ago
IMHO. It might be better then to make the second argument obligatory or to 
throw a more descriptive Error in order to point the user in the right 
direction.

Original comment by sentimen...@gmail.com on 21 Dec 2011 at 11:12

GoogleCodeExporter commented 9 years ago
Hey there, sorry for the really late reply here, but I've added a more 
descriptive error. It know suggests to check whether the defineProxy() method 
receives the correct applicationdomain instance.
I hope that'll make things a bit clearer.

Original comment by ihatelivelyids on 23 Mar 2012 at 4:40

GoogleCodeExporter commented 9 years ago
Thanks Bro

Original comment by sentimen...@gmail.com on 26 Mar 2012 at 11:37