kross77 / as3-commons

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

null pointer exception from the ProxyFactory #109

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Following the introduction from: 
http://www.as3commons.org/as3-commons-bytecode/proxy.html I've basically copied 
it line for line but keep getting null pointer exceptions from the 
ProxyFactory. I've tried building from source but that'd dies with Flex-Mojo 
errors (that's another story).

What is the expected output? What do you see instead?

I'd just expect to create my LoginService and get a bit of tracing info when I 
call it's methods courtesy of TracingInterceptor - instead I get a big, dirty, 
exception:

"""
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin/java 
-Dapplication.home=/common/flex_sdk_4.5.1.21328 -Xmx384m 
-Dsun.io.useCanonCaches=false -Djava.awt.headless=true -Duser.language=en 
-Duser.region=en -Xmx1024m -classpath 
/big/idea-IU-111.69/plugins/flex/lib/idea-fdb-4.5.0.20967-fix.jar:/common/flex_s
dk_4.5.1.21328/lib/fdb.jar flex.tools.debugger.cli.DebugCLI
Adobe fdb (Flash Player Debugger) [build 21328]
Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.
Waiting for Player to connect
Player connected; session starting.
[trace] Warning: Ignoring 'secure' attribute in policy file from 
http://fpdownload.adobe.com/pub/swz/crossdomain.xml.  The 'secure' attribute is 
only permitted in HTTPS and socket policy files.  See 
http://www.adobe.com/go/strict_policy_files for details.
[trace] Error: Ignoring policy file at 
http://fpdownload.adobe.com/crossdomain.xml due to meta-policy 
'by-content-type'.
[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:363]
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:272]
at Run$/applicationCompleteHandler()[/common/dashboard/run/src/Run.mxml:32]
at 
Run/___Run_Application1_applicationComplete()[/common/dashboard/run/src/Run.mxml
:2]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
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()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()

"""

What version of the product are you using? On what operating system?

I'm running Linux, here's the files I'm including.

/common/as3commons-repo/releases/org/as3commons/as3commons-bytecode/1.0/as3commo
ns-bytecode-1.0.swc
/common/as3commons-repo/releases/org/as3commons/as3commons-lang/0.3.5/as3commons
-lang-0.3.5.swc
/common/as3commons-repo/releases/org/as3commons/as3commons-logging/2.7/as3common
s-logging-2.7.swc
/common/as3commons-repo/releases/org/as3commons/as3commons-reflect/1.4.2/as3comm
ons-reflect-1.4.2.swc

Original issue reported on code.google.com by sentimen...@gmail.com on 14 Dec 2011 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ihatelivelyids on 14 Dec 2011 at 4:20

GoogleCodeExporter commented 9 years ago

Have modified the Run.mxml to get it past the exception, it does then throw a 
VerifyError.

try{
  proxyFactory.generateProxyClasses();
}
catch(e:*){
 trace(e);
}
finally{
trace("got past the error");
}

/usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin/java 
-Dapplication.home=/common/flex_sdk_4.5.1.21328 -Xmx384m 
-Dsun.io.useCanonCaches=false -Djava.awt.headless=true -Duser.language=en 
-Duser.region=en -Xmx1024m -classpath 
/big/idea-IU-111.69/plugins/flex/lib/idea-fdb-4.5.0.20967-fix.jar:/common/flex_s
dk_4.5.1.21328/lib/fdb.jar flex.tools.debugger.cli.DebugCLI
Adobe fdb (Flash Player Debugger) [build 21328]
Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.
Waiting for Player to connect
Player connected; session starting.
[trace] Warning: Ignoring 'secure' attribute in policy file from 
http://fpdownload.adobe.com/pub/swz/crossdomain.xml.  The 'secure' attribute is 
only permitted in HTTPS and socket policy files.  See 
http://www.adobe.com/go/strict_policy_files for details.
[trace] Error: Ignoring policy file at 
http://fpdownload.adobe.com/crossdomain.xml due to meta-policy 
'by-content-type'.
[trace] TypeError: Error #1009: Cannot access a property or method of a null 
object reference.
[trace] got past the error
[Fault] exception, information=VerifyError: Error #1047: No entry point was 
found.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at flash.tools.debugger.concrete.DManager.getFrame(DManager.java:669)
    at flash.tools.debugger.concrete.PlayerSession.pullUpActivationObjectVariables(PlayerSession.java:1106)
    at flash.tools.debugger.concrete.PlayerSession.requestFrame(PlayerSession.java:1084)
    at flash.tools.debugger.concrete.PlayerSession.getValue(PlayerSession.java:1199)
    at flex.tools.debugger.cli.ExpressionContext.memberNamed(ExpressionContext.java:430)
    at flex.tools.debugger.cli.ExpressionContext.locateParentForNamed(ExpressionContext.java:532)
    at flex.tools.debugger.cli.ExpressionContext.determineContext(ExpressionContext.java:482)
    at flex.tools.debugger.cli.ExpressionContext.resolveToVariable(ExpressionContext.java:342)
    at flex.tools.debugger.cli.ExpressionContext.lookup(ExpressionContext.java:161)
    at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:160)
    at macromedia.asc.parser.ThisExpressionNode.evaluate(ThisExpressionNode.java:34)
    at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1029)
    at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)
    at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1029)
    at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)
    at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1063)
    at macromedia.asc.parser.ExpressionStatementNode.evaluate(ExpressionStatementNode.java:50)
    at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1304)
    at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
    at flash.tools.debugger.expression.DebuggerExpression.evaluate(DebuggerExpression.java:105)
    at flex.tools.debugger.cli.ExpressionCache.evaluate(ExpressionCache.java:104)
    at flex.tools.debugger.cli.DebugCLI.evalExpression(DebugCLI.java:3677)
    at flex.tools.debugger.cli.DebugCLI.evalExpression(DebugCLI.java:3669)
    at flex.tools.debugger.cli.DebugCLI.doPrint(DebugCLI.java:3595)
    at flex.tools.debugger.cli.DebugCLI.processLine(DebugCLI.java:6580)
    at flex.tools.debugger.cli.DebugCLI.process(DebugCLI.java:737)
    at flex.tools.debugger.cli.DebugCLI.execute(DebugCLI.java:579)
    at flex.tools.debugger.cli.DebugCLI.main(DebugCLI.java:376)

Original comment by sentimen...@gmail.com on 14 Dec 2011 at 6:32

GoogleCodeExporter commented 9 years ago
Also (using svn->hg) I'm using the head/tip from the source repository. 

changeset:   1370:bff7b615921a
tag:         tip
user:        scab@dds.nl@9e4d646c-04d2-11de-9a48-596ebbf2fbe4
date:        Wed Dec 14 16:15:36 2011 +0000
files:       
as3-commons-bytecode/src/main/actionscript/org/as3commons/bytecode/reflect/ByteC
odeTypeCache.as 
as3-commons-bytecode/src/main/actionscript/org/as3commons/bytecode/reflect/ByteC
odeTypeProvider.as
description:
made ByteCodeTypeCache and ByteCodeTypeProvider final

Original comment by sentimen...@gmail.com on 14 Dec 2011 at 6:35

GoogleCodeExporter commented 9 years ago
/home/bryan/.m2/repository/org/as3commons/as3commons-bytecode/1.1-SNAPSHOT/as3co
mmons-bytecode-1.1-SNAPSHOT.swc

Original comment by sentimen...@gmail.com on 14 Dec 2011 at 6:36

GoogleCodeExporter commented 9 years ago
Ok, there's a number of things that are wrong, some of mine are bugs, so they 
need to be looked into.
First of all, it is necessary to populate the BytecodeType cache by parsing the 
loaderInfo, so this line was missing at the start:

ByteCodeType.fromLoader(FlexGlobals.topLevelApplication.loaderInfo);

Without this the bytecode library can't generate any proxy classes because it 
doesn't have the type information.

Secondly, your proxyFactory.defineProxy() invocation looks like this:
proxyFactory.defineProxy(TracingInterceptor, 
BasicMethodInvocationInterceptor,ApplicationDomain.currentDomain);

You want to proxy the LoginService class, not the interceptor.

Thirdly, I found out that the library has problems parsing and proxying classes 
in the default package, so I moved TracingInterceptor and LoginService to a 
package called 'classes'.

And lastly, once that is changed the proxying works, but crashes in your 
interceptor because of this line:

trace("{0} was invoked with parameter {0}", invocation.targetMember, 
invocation.arguments[0]);

The method you are calling on the LoginService has no arguments, so this line 
leads to an RTE.

There was a small bug in the bytecodetypecache as well which I could fix 
quickly, I have deployed a new 1.1-SNAPSHOT so if you update your repository 
you'll get the latest drop.

I have attached your run.mxml file that shows the changes I made.

Hope that helps, I'll try and look into the 'classes in the default package' 
issue as soon as possible.

cheers,

Roland

Original comment by ihatelivelyids on 14 Dec 2011 at 6:59

Attachments:

GoogleCodeExporter commented 9 years ago
Roland, thanks for your awesome help. I'm going to put the sample project up 
online so others can get a quick start. Will update this bug when it's so.

Original comment by sentimen...@gmail.com on 14 Dec 2011 at 7:25

GoogleCodeExporter commented 9 years ago
Hey there,
no problem, glad to help, thanks for sharing your sample with others!

cheers,

Roland

Original comment by ihatelivelyids on 14 Dec 2011 at 7:46

GoogleCodeExporter commented 9 years ago
Yeah bro, I've put my project up on:

https://bitbucket.org/sentimental/as3-commons-sample

If anyone else is starting out and encounters similar problems they can 
download from there for a reality check.

Original comment by sentimen...@gmail.com on 14 Dec 2011 at 7:54

GoogleCodeExporter commented 9 years ago
thanks mate!

All help is appreciated, I'll add your sample to the site next time I update it.

cheers!

Roland

Original comment by ihatelivelyids on 14 Dec 2011 at 8:16