Notes on Code Translation to Java - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Code Generation Package : Java : CodeGeneration/General/JavaDetails

Notes on Code Translation to Java

  

This help page describes details particular to code translation using the CodeGeneration[Java] function. For general information applicable to all the functions in the CodeGeneration package, see CodeGeneration/Details.

Description

• 

The Java code generated by CodeGeneration[Java] is valid for Java 2 as defined by the Java Language Specification.

• 

In addition to the functions listed on the CodeGeneration/Details help page, the following Maple functions are recognized by CodeGeneration[Java]: cat, ceil, floor, and if (operator form).

• 

Generally, math functions recognized by CodeGeneration[Java] are translated to functions in the java.lang.Math library. Additionally, the Maple symbol Pi is translated to the java.lang.Math constant Math.PI.

• 

If the parameter to CodeGeneration[Java] is a procedure, the output is embedded in a class CodeGenerationClass so that it can be included easily in another Java program.

• 

Note that java.lang.Math does not have equivalents for the hyperbolic trigonometric functions, so CodeGeneration[Java] expresses them in terms of exponential functions.

• 

Since there are no equivalents for sign, and signum in Java, CodeGeneration[Java] translates them to expressions involving the conditional operator.

• 

The functions mod, modp, and mods are all translated to Java expressions using the modulus operator %.

  

Note: The behavior of these functions is inconsistent with the behavior of % for some values of the arguments.

• 

Because Maple expressions involving powers greater than 2 are translated into Math.pow function calls, the automatic type deduction system may not be able to deduce the most appropriate type in all cases.

• 

CodeGeneration[Java] translates printf statements to System.out calls, but performs only limited analysis of the printf format string. Thus some formatting instructions (for example, precision for floats) are ignored in translation.

• 

Conversions between single-precision and double-precision floats are not performed.  If the precision=single option is specified, explicit type casts must be added to the results of any java.lang.Math calls generated by CodeGeneration[Java].

• 

Ranges of Maple Arrays and rtables are adjusted so that the resulting Java arrays start with index 0.

• 

A Maple module is translated to a Java class, with module members mapped to static class members.  Exports of the module are translated as public methods or fields in the Java class, while variables local to the module are translated as private methods or fields.  All class members are made static.

See Also

CodeGeneration, CodeGeneration/Details, CodeGeneration[Java]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam