deep

a Cross Development Platform for Java

User Tools

Site Tools


crosscompiler:donts

Do's and Don'ts

Java is a very powerful programming language and offers a large and complex library. Only a subset of the standard library is supported on the target to keep a small memory footprint and maintain a high performance.

Don't use longs if not absolutely necessary

The type long consists of 8 bytes and cannot be handled by a 32-bit architecture directly. Though all manipulations of this type are handled correctly by our compiler it is less efficient than working with 32 bit types where most basic calculations can be done in one or few clock cycles.

Do reuse objects

Make sure that you reuse ojects! That is particularly necessary for fast control application. In such cases it's advisable to instantiate all objects needed in an initalization section. These objects will then be reused. This practice ensures that the runtime behaviour of a control task is minimal and predictable. It also makes garbage collection obsolete.

Do not create strings if not absolutely necessary

Many methods in the standard library create strings. As a example: java/lang/Integer.toString or java/lang/Integer.toHexString create a new string object every time the are called. This first takes a considerable time and creates garbage. Do not use such methods if not absolutely necessary. For printing to serial output devices, it's much more efficient to use the methods in java/io/PrintStream. They reuse existing strings.

Use interrupts carefully

Generally speaking, interrupts should not be used by an application. Use tasks to meet certain timing requirements. Interrupts can be and are in fact used by low-level drivers e.g. for serial communication.

crosscompiler/donts.txt · Last modified: 2016/02/25 13:33 by 127.0.0.1