Introduced in Feature Pack 2

Troubleshooting: Avoiding compile errors when using a new OpenLaszlo compiler

When you migrate to a higher feature pack version, you receive one of the following compile errors: Incompatible override, Incorrect number of argument, Cannot redefine a final method, or Call to a possibly undefined method

Problem

Customers using Flash 10 byte code and a new OpenLaszlo compiler, experience compile errors when migrating to a higher feature pack version. The new compiler strictly enforces rules previously ignored by earlier versions of the compiler. It also flags more problems than previous versions.

Solution

There are two scenarios that must be addressed to avoid these errors:
  1. When you override a method by extending a class, the signature of the methods must match exactly. The method must have the same number of parameters.
  2. When you call a method, you must pass in all of the required parameters.

Examples

Use the following examples as a guideline.

Example #1:

You have the following base class:
<method name="methodA">
	<![CDATA[
	// body of methodA
	]]&gt;
</method>
In the subclass, you have the following customization:
<method name="methodA" args="arg1">
	<![CDATA[
	// override method A
	]]&gt;
</method>
You receive an Incompatible override error for the customized code. To resolve the error, you must remove the arguments in the customize method, because the base class has no arguments.

Example #2:

You have the following method:
<method name="methodA" args="arg1,arg2">
	<![CDATA[
	// body of methodA
	]]&gt;
</method>
In the method definition, there are two parameters. However, your customized code that calls this method uses only one parameter. For example, the customized code is:
this.methodA(arg1) 
You receive an Incorrect number of argument compile error for the customized code. To resolve the error, you must use the correct number of parameters to call the method.

Example #3:

You receive a Cannot redefine a final method compile error. In OpenLaszlo, you cannot redefine the final method. To resolve the error, you must either remove the code that redefines the method or change to another method to implement the same function.

Example #4:

There is Call to a possibly undefined method compile error. The reported code might be calling a class constructor. In the new OpenLaszlo compiler, when you call the class constructor, you need to use the namespace lz. For example, if you use the following code:
ClassA(...)
to call the constructor of ClassA. In the new OpenLaszlo compiler you get the compile error Call to a possibly undefined method. To resolve the error, you must change to the following code:
lz.ClassA(...)