开发者

Can we use static initializers in a Flex Library?

We are using as3Crypto library in my project. We have downloaded the code, modified a bit and started using it. Initially we have included the complete code as the part of the project. Now we are trying to compile it as Separate Library file(.swc). When we compile the code, we didn't get any errors, but we got one warning saying

Severity and Description    Path    Resource    Location    Creation Time   Id
flex2.compiler.as3.SignatureExtension.SignatureGenerationFailed[level='warning', column='23', node='ForStatement', line='214', cause='flex2.compiler.as3.SignatureAssertionRuntimeException: U开发者_高级运维nreachable Codepath
    at flex2.compiler.as3.SignatureEvaluator.ASSERT(SignatureEvaluator.java:369)
    at flex2.compiler.as3.SignatureEvaluator.UNREACHABLE_CODEPATH(SignatureEvaluator.java:357)
    at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:1560)
    at macromedia.asc.parser.ForStatementNode.evaluate(ForStatementNode.java:50)
    at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
    at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:1795)
    at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
    at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:530)
    at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefinitionNode.java:106)
    at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
    at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:1795)
    at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
    at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:454)
    at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
    at flex2.compiler.as3.SignatureExtension.generateSignature(SignatureExtension.java:270)
    at flex2.compiler.as3.SignatureExtension.doSignatureGeneration(SignatureExtension.java:174)
    at flex2.compiler.as3.SignatureExtension.parse1(SignatureExtension.java:137)
    at flex2.compiler.as3.Compiler.parse1(Compiler.java:369)

', path='C:\MyData\Flex WorkSpaces\Separate\HurlantCryptoLib\src\com\hurlant\crypto\symmetric\AESKey.as']   HurlantCryptoLib/src/com/hurlant/crypto/symmetric   AESKey.as   line 214    1312947481229   27

When we check the code, we traced it to a code file AESKey.as, especially from a Static initializers code block. I can't simply ignore the warning as it is the critical part of my applications security.

If Anybody come across this problem, please help me to fix this issue.


To answer the question in the title, it looks like, yes, you can use static initializers in a Flex library project. Here is a class in a library project:

package test
{
public class StaticInitializerTest
{
    public static var VALUE:String = "fail";

    {
        VALUE = "pass";
    }
}
}

And here is a Flex application that uses it:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                        creationComplete="onCreationComplete()">
    <mx:Script>
        <![CDATA[
            import test.StaticInitializerTest;

            private function onCreationComplete ():void
            {
                trace("Static initializers in a Flex library project: " + StaticInitializerTest.VALUE);
            }
        ]]>
    </mx:Script>
</mx:WindowedApplication>

This produces the following output:

Static initializers in a Flex library project: pass
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜