Java 6 Update 10 breaks Flex compiler!

I just want to share this problem I found so maybe someone can save some time..

Today while surfing the net I received a notification of an update of my Java installation to the Update 10 in order to see correctly the contents of that site.. bla bla bla..

Sometime later I switched to Flex and at the first execution of my ant script for compiling a flex project I suddenly received this beautiful error:
[exec] Error: java/security/MessageDigest
[exec] java.lang.NoClassDefFoundError: java/security/MessageDigest
[exec] at java.io.ObjectStreamClass.computeDefaultSUID(Unknown Source)
[exec] at java.io.ObjectStreamClass.access$100(Unknown Source)
[exec] at java.io.ObjectStreamClass$1.run(Unknown Source)
[exec] at java.security.AccessController.doPrivileged(Native Method)
[exec] at java.io.ObjectStreamClass.getSerialVersionUID(Unknown Source)
[exec] at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
[exec] at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
[exec] at java.io.ObjectInputStream.readClassDesc(Unknown Source)
[exec] at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
[exec] at java.io.ObjectInputStream.readClassDesc(Unknown Source)
[exec] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
[exec] at java.io.ObjectInputStream.readObject0(Unknown Source)
[exec] at java.io.ObjectInputStream.readObject(Unknown Source)
[exec] at flex.util.SerializedTemplateFactory.load(SerializedTemplateFactory.java:30)
[exec] at flex2.compiler.util.VelocityManager.getTemplate(VelocityManager.java:162)
[exec] at flex2.compiler.util.VelocityManager.getTemplate(VelocityManager.java:151)
[exec] at flex2.compiler.util.VelocityManager.getTemplate(VelocityManager.java:137)
[exec] at flex2.compiler.as3.genext.GenerativeSecondPassEvaluator.generateSupportCode(GenerativeSecondPassEvaluator.java:256)
[exec] at flex2.compiler.as3.genext.GenerativeSecondPassEvaluator.modifySyntaxTree(GenerativeSecondPassEvaluator.java:355)
[exec] at flex2.compiler.as3.binding.BindableSecondPassEvaluator.evaluate(BindableSecondPassEvaluator.java:102)
[exec] at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefinitionNode.java:106)
[exec] at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
[exec] at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
[exec] at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:923)
[exec] at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
[exec] at flex2.compiler.as3.genext.GenerativeExtension.parse2(GenerativeExtension.java:114)
[exec] at flex2.compiler.as3.Compiler.parse2(Compiler.java:386)
[exec] at flex2.compiler.API.parse2(API.java:2390)
[exec] at flex2.compiler.API.parse2(API.java:2348)
[exec] at flex2.compiler.API.batch2(API.java:375)
[exec] at flex2.compiler.API.batch(API.java:1117)
[exec] at flex2.compiler.API.compile(API.java:1290)
[exec] at flex2.compiler.API.compile(API.java:1210)
[exec] at flex2.tools.Compc.compc(Compc.java:158)
[exec] at flex2.tools.Compc.main(Compc.java:41)

so I tried also to compile another project before go crazy, but I got this another java funny error, which was more or less unreadable as the previous one!

Fortunately I remembered the update I did of Java! And in fact after remove that update everything worked again!

iPhone on holidays

Welcome back everybody!
I just want to share with you my little experience I had with the iPhone sdk during my summer holidays.

This year I haven’t spent my holidays on the beach, like usual, because I just bought home and so I had to put up everything… that’s why I decided to devote some of the free time to try out objective-c. I wanted to make something for the iphone since I bought it in March in NYC but I never had the free time to do that..

First of all I had to buy a new Mac-mini because the iphone sdk is not supported on my old mac-mini ppc. Then I had to subscribe to the developer program for $99 because otherwise I was unable to test applications on my iphone, but only on the simulator (cool, I have to pay to install my own applications on my iphone!).

Well, after reading a bit the documentation, watching some video tutorials and looking at example code I started with my first application. What I wanted to do was a simple SMS application to show sms received, sent and a simple search. A very simple app but for me better than the limited built-in iphone sms application.

After a couple of days I reached my goal, but not without troubles. There’s nothing inside the iphone documentation about the SMS system.

Afterward using an “UPDATE” sqlite query I was getting an error: “SQL error: no such function: read”, and obviously there was nothing in the doc explaining this. Only after half a day I discovered that I had to create a C method and use sqlite_create_function in order to bypass that error:
const char *fn_name = "read"; sqlite3_create_function(database, fn_name, 1, SQLITE_INTEGER, nil, sqlite_fn_read, nil, nil);
Now that everything with the db was fine I had to google a bit in order to find a way to implements features like “reply”, “forward” or “call” (basic features in a telephone, but not covered in the iphone sdk documentation).

Finally, after a long debug and Instruments session to find leaks ( I must admit xcode has some powerful tools for debugging and inpect apps) I installed my first application on my own iphone.

And big big surprise!! On the iphone my application is unable to mark messages as read and delete messages too!
In other words it is unable to write into the sms.db!

And Why?
That’s because a beautiful sandbox which does not allow applications to write outside their scope! Oh, cool! That’s correct, but in this case you, Apple, must give me an API which wraps those features!
They gave an SDK for developing on a mobile phone but they don’t grant access to any of the telephone features?!?

Awesome stuff from Aviary

It has been a lot of time since we started working on Aviary.

During the last months, a lot of guys have helped us with beta testing some of the tools we are working on, and they have been able to produce really awesome stuff!

I collected a bunch of images from the Aviary website to show you the power of the tools. Those images does not rappresent the best, but they are just a collection of good compositions made with Peacock, Phoenix and Raven (respectively a Computer algorithm-based pattern generator, an Image editor and a Vector editor ).

Here is the list of images I collected, grouped by tool. You can click on each image to go the to Aviary page and (if you have an account) start playing with it.

Phoenix

Phoenix is the Image Editor. It is quite similar to Photoshop, and has some advanced features for image editing.

Peacock

Peacock is a Computer algorithm-based pattern generator. Basically you generate an image assembling nodes that accept an input and produce an output. Combining this nodes may produce awesome stuff, and Peacock can be used for many purposes like advanced retouching effects or the creation of complex reusable filters (like the one used to transform a fish into bricks).

Raven

Raven is the Vector Editor. Actually it is in alpha stage but we are going to release a major update that adds really powerful tools.

From each image you can gather many useful information: the list of revision, the list of derivates, the list of sources, and other useful stuff. Each composition made with Aviary can be edited by any user to create a new revision, or can be used as a source for a brand new image. That makes some tools really useful an powerful: for instance you can build reusable filters in Peacock and use them on your Phoenix images.

There is much more on the Aviary website, and more images are added day by day.

I really suggest you to give Aviary a try; we are working hard to be able to go public soon, and outstanding new features will come in the near future. Post here if u want an invitation!

Have a good day 😉

AMFPHP issue referencing ByteArray

Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field.

But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error:

The php file which was generating this error was:

class Service
{
public function getArray( )
{
$GLOBALS['amfphp']['encoding'] = 'amf3';
$a = new ByteArray("\x00\x10this is a string");
$b = new ByteArray("\x00\x16this is another string");
$c = $a;
return array( $a, $b, $c );
}
}

While the Actionscript test class was:

package
{
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
import flash.utils.ByteArray;

public class test extends Sprite
{
private var nc: NetConnection;
private var rsp: Responder;

public function test()
{
rsp = new Responder( onResult, null );
nc = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF3;
nc.connect( "http://localhost/amfphp/trunk/gateway.php" );
nc.call( "test.bytearray.Service.getArray", rsp );
}

private function onResult( e: * ): void
{
if ( e is Array )
{
for each ( var b: ByteArray in( e as Array ) )
{
trace( 'reading bytearray...' );
b.position = 0;
trace( b.readUTF() );
}
}
}
}
}


After some investigation I found that the error was into the AMFSerializer.php file in the writeAmf3ByteArray method which doesn’t reference correctly the bytearray objects.

Thus I made a little modification and after that I succeeded to retrieve correctly the bytearray list ( with the 3rd element as reference of the first one ).

Here you can download the patch file, if you want to test the modification ( at your own risk 🙂 ). The patch has been created using the last svn version of amfphp and you can apply the patch with the following command:
patch -p0 -i bytearray.patch

Expressions evaluation at (almost) native speed

Finally I found a bit of time this weekend to do some other tests with expressions evaluation.

The results are pretty interesting, even if obvious from some point of view. I took the ExpressionEvaluator I wrote as example for the first post about this topic, and then I edited a bit the code adding just in time AS Bytecode compilation.
Thanks to that, expressions evaluation is much more fast and always safe because it runs in its own ApplicationDomain.

You can download the sources here, that includes the edited code and a test file. The test file runs 1 milion of iterations and may hang your browser or at worst case your system. Reduce the value of the ITERATIONS constant if you are not sure about the power of you machine.

If you want to read a bit more details about that, click on the link below to continue reading.

Continue reading