Hardware Objects
From JopWiki
Hardware objects are objects that represent IO devices. The intention of hardware objects is a safe and efficient access to low-level devices from Java.
Representing IO devices as first class objects has following benefits:
- Object-oriented: An object for a device is the most natural integration into an OO language
- Safe: The safety of Java is not compromised. We can access only those device registers that are represented by the class definition
- Efficient Device access is performed by single bytecodes getfield and putfield. We can avoid expensive native calls to C
[edit] Example
Following code defines a HW object for a serial port:
public final class SerialPort extends IODevice {
public volatile int status;
public volatile int data;
}
Writing data to the serial port is as simple as:
serial.data = 'x';
