
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
- 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.
- When you call a method, you must pass in all of the required parameters.
Examples
Use the following examples as a guideline.
Example #1:
<method name="methodA">
<![CDATA[
// body of methodA
]]>
</method>
In the subclass, you have the following customization:<method name="methodA" args="arg1">
<![CDATA[
// override method A
]]>
</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:
<method name="methodA" args="arg1,arg2">
<![CDATA[
// body of methodA
]]>
</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:
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(...)