Professional Documents
Culture Documents
Contents
Chapter 1 Introduction
2
Client/Server Architecture
3-tier Architecture
Remote Evaluation & Execution
Code on Demand
Mobile Agent
Chapter 3 Technologies
Mobile Agent
3.9 AGLETS.............................................................................................48
3.10 Telescript ...........................................................................................50
Scripting Languages
3.11 Tcl/Tk ................................................................................................ 52
3.12 Internet Scripting: JavaScript, Jscript, VBScript...........................53
3
3.14 A Technology for the DAB System................................................58
Chapter 4 Java
Chapter 6 Simulation
4
6.1 Overview of the Simulation............................................................
6.2 Integration of the Java Virtual Machine: MS COM.....................
6.3 Software Implementation: the Main Java Component ...............
Conclusion
References
5
6
Chapter 1 Introduction
7
digital channel to receive all kind of data (mpeg audio, videos, images, text data and
code).
Digital data opens to a wide area of broadcast applications because it is the base
language used in the computing environment and it can be used as a link to the world of
the computer and telecom services (Internet, database services, multimedia applications,
telephony, GSM) with the world of broadcast radio and video communication (GPS,
Video On Demand).
Otherwise broadcast radio systems are well suitable and more flexible for large
scale distributed data and for general data services communication systems: weather
forecast, traffic information, news, etc.
Today in the market different broadcast system for digital radio transmission are
also available: DSR (Digital Satellite Radio) and ADR (Astra Digital Radio); they are not
so flexible and smarter as we will see than DAB.
Video
on
Demand
Entertainment
Music
Multimedia
Mpeg 2
Broadcast Encoding
Database
Distributed Systems
Telecommunication Computing
Internet
GPS GSM Mobile Code
Single
Frequency Virtual Machine
Network
8
digital datacommunication applications, now are ready to compete and to integrate with
other distributed multimedia computing technologies.
♣♣♣
* unidirectional
* scalable
* ubiquitous
* low capacity data channel - FM-RDS
Unidirectional and scalability are the main characteristics of broadcast systems: signals
are broadcast by a single source and are received by a large number of users and the
amount of traffic (occupied bandwindth) is independent from the number of possible
users: these aspects make the radio system suitable for low cost large scale data
broadcasting.
Ubiquitous computing is related to the physical medium used to transmit the
radio signals. Whenever a wire is unavailable or unnecessary, wherever mobility is a big
constraint radio systems are the best solutions: boats, cars, small cabins, historical
buildings, mobile stations, PDA, Walkman, etc.
Besides all this positive aspects of traditional broadcast radio systems, AM and
FM radio miss some issues and there are some big disadvantages: noise interference,
multipath propagation on mobile systems, interfrequency interference, low quality audio
(with respect to CD or DAT audio quality), a poor number of extra services (FM-RDS),
etc.
What are the new features of the DAB system and what kind of services can be
developed ?
The DAB transmission signal (see chapter 5 for details) carries a multiplex of
several digital services simultaneously; it uses advanced digital audio compression
algorithm to achieve a spectrum efficiency equivalent to or higher than that of
conventional FM radio. Its overall bandwidth is 1.536 MHz, providing a useful bit-rate
capacity of approximately 1.5 Mbit/s in a complete "ensemble". Each service is
independently error protected with a coding overhead ranging from about 33% to 300%
(200% for sound), the amount of which depends on the requirements of the broadcasters
(coverage, reception quality, number of services).
The ensemble contains audio programmes, data related to audio programmes,
and independent data services. Usually the receiver will decode several of this services in
parallel.
A specific part of the multiplex contains information on how the multiplex is
actually configured, so that the receiver can decode the signal correctly.
DAB system is the best gateway to move digital data towards mobile devices and
it is suitable for providing integration with other communication architectures (Internet,
GSM, satellite networks). Actually there are other digital system to broadcast
information: DSR (Digital Satellite Radio) and ADR (Astra Digital Radio) are two services
provided by the use of satellite channels. They both provide CD-quality radio (with none
or some kind of compression mechanisms) using large bandwidth and they both lack
good performance for mobile devices and they are not suitable for local radio services.
9
DAB, in brief, is characterized by the following attributes:
Some attributes are similar to traditional broadcast system, but new one are
added in DAB. High quality audio and design for mobile reception are one of the
fundamental introduction of DAB system: the use of special coding techniques permits to
optimise the reception from mobile device (car radio, boat radio) and the use of some
special compression tecnique permits the trasmission of CD-quality audio. DAB is also a
cheaper way respect to the FM system to trasmit radio signal: transmitter are less
powered than traditional high frequencies transmitter. For the same reasons we have a
reduction of electromagnetic fields emission (electrosmog).
DAB has been under development since 1981 at the Institut für Rundfunktechnic
(IRT): broadcasters, research institutes, network providers/operators and consumer
electronics firms are contribuiting. The DAB system is a European standard (ETS 300401,
February 1995) adopted by the European Telecommunications Standards Institute (ETSI).
Services or pilot projects are running in many countries, including Australia, Belgium,
Canada, Finland, France, Germany, Italy, Norway, Sweden and Switzerland [8a].
10
DAB active services
DAB sperimental services
interested countries
information not available
The research of new software solutions for the DAB system is the leading topic of
this thesis: virtual machine architecture, dynamic applications, distributed computing,
mobile code, software components, Internet services are new word in the context of the
broadcast services. Internet is a big laboratory for new solutions in the field of network,
software engineering and multimedia: for that reasons we will refer continuously to
Internet technologies applications.
For example virtual machines are important components of a modern portable
computing environment (as the Internet) because they provide an architecture-
independent representation of executable code. Their performance is critical to the
success of such environments and for the development of general purpose services; but
11
they are difficult to design because they are subject to conflicting goals. On one hand,
they offer a way to hide differences between hardware devices and they give a
standardized software layer for programmers; on the other hand, they must be
implemented efficiently on a variety of different machines.
Since radio receivers are becoming increasingly complex and microprocessors
cheaper and cheaper, in the near future we think that receivers will became more like
computers, and computers will incorporate receivers [9]. Some of the leading software
companies have been introducing in these months complete OS for the market of the
embedded devices (car radio, settop box, hand held computers): Windows CE from
Microsoft and Java OS from Sun, but also Linux RTOS, Inferno from Lucent, are only a
few examples of the big interests involved in this direction.
Dynamic Label. DAB provides a flexible way to associate and synchronize a data
information channel with audio programmes. This additional data has a variable
capacity from a minimum of 667 bit/sec up to 65 kbit/sec. This additional information
can be used to implement different new services: dynamic label messages, Karaoke-like
transmission of lyrics, multilanguages information transmission.
12
Travel/Traffic Information. All information for traveling can be retrieved from a DAB
service. Using text, images, maps and applications we can coordinate and inform car
driver about all kind of information (from hotel prices to traffic situations) needed for a
good and secure trip. The DAB system is a perfect medium to communicate this kind of
information.
Broadcast Web Site. Once we have build a new communication medium, we can
develop a Web Browser application to receive HTML pages, Java DABApplet, Images
like a normal network link. DAB is a high bitrate downlink medium for providing a
selected number of Internet services: traffic information, weather forecast, sport news,
emergency messages, entertainment, etc.
Commercial Applications and Data Download. For a large company that has to
exchange common information (price reports, software patches, internal communication)
to a large numbers of branches customers, DAB offers low cost and secure services. For
example a car company has to inform thousands of car shops around a large area like
Europe about new price lists or new offers; then each single shop can use some feedback
channels (Internet, phone, mail) to order specific items. A software company can offer
software uploads for their customers. To realize these kind of closed user group services
means to control access to potentially confidential data are required: conditional access
systems and cryptography.
DAB
Booked !!
Downlink path
Train/Flight Tim etable
Information UPlink path
Internet
13
include comprehensive information about a piece of music being played, such as the
song title, composer, singer, album name, album picture, video frames and so on.
Brokering Information & Stock Quote Systems. Information about sport results or
stock prices can be delivered using DAB and be presented by Java application. A
brokering agency can deliver information to users using a ubiquitous medium like DAB.
Polling & Surveying. Agencies that collect information can create a polling service
upon the DAB channel, asking general information and can receive the feedback from the
users by the means of GSM mail service, Internet mail, etc.
Multimedia Home Network. The DAB receivers will be just a node inside a home
multimedia network together with HIFI systems, digital TVs, digital cameras, Settop
boxes, etc: Java would be the glue for all these different platforms.
DAB
?!!@:-(
GSM
Internet
???!!!!@:-(
Web/DAB Integration. Once we have created a software bridge between Java and
DAB services, the computer can be an hardware bridge to the Internet: we can think
about a global network in which we can move and optimize data exchanges. We can use
the characteristic of the DAB channel to reduce traffic congestion on the Internet
networks for some special kind of information.
Games. Using download application means the possibility to move also games.
User can receive games in their DAB car radio: the runtime environment with graphical
output provides all the facilities to create this services.
14
1.4 A Brief Description of the Contents of this Thesis
The goals of this work is to give a theoretical and practical introduction to the
problems related to distributed programming environment, in general, and to give the
basic requirements for a downloading application service using the DAB system, in
particular. Understanding the Java platform is another central topic of this thesis: Java up
to now is a platform useful for network applications; we analyze in detail the potentiality
of this platform for a DAB system.
At the end we have applied some of the Java mechanisms to investigate in details
some particular mechanisms of Java and to simulated a simple download application
(Applets) service for seeing the behavior of some Internet-like services (CodeOnDemand,
teledatacommunication) using a DAB system simulation.
All the information used in this thesis comes from specification papers, academic
articles1, and free available documentation on the Web [8].
Chapter 1 Introduction
This chapter wants to introduce the reader to the new aspects and future
developments related to the DAB systems. We point out the new kind of services
available and the need of building a complete computing environment for the future
challenges for the DAB service. We also focus our attention on the differences and
the likeness of the DAB system and the Internet world. At the end we give a brief
overview of the possible future applications using DAB.
Chapter 3 Technologies
This chapter is a brief description of the main distributed computing technologies now
available on the market. The chapter is not exhaustive, but we have tried to mention
the majority of the products now available both from the market and from the
academic world. Inferno from Lucent, Java from Sun, ActiveX/DCOM from Microsoft,
Obliq from DEC are only few examples of complete programming environment for
distributed applications. At the end of this chapter we make a comparison between all
this technologies and we try to choose the right platform for application download in
DAB. These first chapters are the base for the developing platform for this project:
the Java technology.
Chapter 4 Java
Java is the winning technology for developing a download application service in the
DAB system. We describe here the Java technology moving from the abstract
machine implementation to the API library. We describe also some of the main
characteristics of this developing platform: abstract machine architecture,
1
See references for a detailed list of documents
15
programming language features, security mechanism, Java API, native interface,
Applet model, etc.
Chapter 6 Simulation
In the project we have integrated inside a C++ application the VM: we have tried to
understand the inner mechanisms to integrate the Java VM. In this chapter we
describe in details the simulation and the used software components: we have
integrated the MS Java VM inside an MFC project that simulates the DAB Navigator.
16
17
Chapter 2 Mobile Code
18
Before starting our investigation on the possibility to implement a download
application on the DAB channel, we need to retrieve some theoretical and technical
concepts about the distributed computing systems. The Internet world has been a
exsperimental platform for lots of new distributed technology: we want to use all these
experience for start the development of new solution for the radio services using the
DAB system.
♣♣♣
The expression "mobile code" is used with various different meanings in the
technical literature; for our purpose we define mobile code
"as software that travels on a heterogeneous network, crossing protection domains and is
automatically executed upon arrival at the destination"[1].
For protection domains we intend both wide area networks and small
embedded systems (DAB radio receiver, Personal Digital Assistant, Smart Card, etc.), the
only requirements is that all nodes are linked via a specific network medium that permits
to move digital information.
♣♣♣
"Code Mobility" is not a recent discovery: we have already some examples. (For
an introduction on the mobile code see reference [1].)
19
* Software Distribution and Installation problem: this specific
application has produced many proprietary solution as Inferno of Lucent Tech., a mobile
code enabled network operating system for media providers and telecommunication
systems; the management of the software installation is a typical application where code
mobility can give a better solution than the old strategies for its particular features:
scalability, customizability, etc.
These are only few example of the possible applications of mobile code, but as
you can see they try to solve some specific constraints to built efficient systems in terms
of scalability, network traffic reduction, security, minimal overhead and performance.
Mobile code technology is not a new approach, but until now it was relegated to very
specific applications: these new model start to be investigate in a deep manner and
different University Centers have started a formalization process of the new paradigms.
Communicaton mechanisms
Point-to-Point
Messages
RPC
Stream
Point-to-Multi-point
Events
Group Communication
Shared Memory
Tuple Spaces
Multicasting/Broadcasting
20
Basically we can distinguish the number of the objects that interact and the mechanism of
the interactions. For the first we have components communicating inside the same
machine (processes, threads inside a process) or remotely (different machine in the
network); the second is a group of mechanisms used to exchange information between
these components: anonymous notifier events, packet exchanged on stream connection
oriented channel (sockets), messages posted on specific site, etc.
Point-to-Point. It refers to the communication between two Execution Unit both locally and
remotely. The more primitive and simple mechanism is message passing used in the
client/server paradigm (HTTP, XWindow); Remote Procedure Call is a more advanced
but always based on client/server mechanisms (UNIX, Win); streams are channel used to
transfer data from two entities in a continuos way (pipes in UNIX, TCP socket
connections).
21
heterogeneous machine are linked together that is not enough to create efficient,
scalable, secure, customizable applications. The numbers of the interactions between
clients and servers, the delays introduced in WAN networks, the lack of flexibility in a
non homogeneous network are few examples of the problems of the client/server
approach.
Computation Interaction
Component
(CPU,memory,VM)
Resources Component
Figure 5: Traditional not distributed system: all components reside in a single machine
By using this abstractions we can introduce the main design paradigm used for
implementing distributed applications (in the pictures used in this chapter we use for
simplicity computer-like entities, but these system can refer to any possible network
architecture).
We distinguish:
22
* 3 tier architecture (N tier architecture)
* Remote Evaluation
* Code on Demand
* Mobile Agents
Client/Server Architecture.
This is the classical implementation of traditional distributed applications. The
mechanisms used to exchange information are very simple and only data information is
exchanged between two machines connected with a network. All management and
security mechanisms are centered in a high performance server machine that provides a
"a priori fixed set of services accessible through a statically defined interface" [2]; the server can
communicate with a number of low-capabilities clients (mainframe architecture) or with
a group of medium powered machines (LAN architecture). This architecture has
encountered many problems of scalability, especially today that network applications
spread from LAN to WAN in an heterogeneous environment and the number of users is
growing up. A few examples of this kind of implementation can be reported: X-Window
systems, POP, FTP and HTTP protocols, Remote Procedural Call, etc. New
implementation for distributed computing as CORBA, DCOM, RMI try to use this
architecture paradigm (RPC) together with an object oriented programming, in which
clients and servers are "object entity" distributed in the network. There is a big difference
between the latter mentioned computing models and mobile code paradigms: in the
mobile code paradigm we explicitly model the concept of a separate execution
environment and how computations are moved between these environments, while in
the object oriented distributed application, the computational environment is an
abstraction layer that hides all the network system.
23
Client/Server (pure)
message data
data
Service
Client Server
Computation
Es: RPC, HTTP, FTP, Xwindow Environment
Code
(CPU,memory,VM)
In C/S systems the generated traffic is large and it can be a problem the latency
of the medium and the number of the interactions: clients and servers exchange a large
number of messages for coordination, control, and executing specific tasks.
That's why this architecture is in general used only for small networks with high
band capabilities (LAN). A lot of Internet application use this paradigm for its simplicity,
but the produced overhead of information and the lower reliability of the large networks
decrease the performance of this system.
Security policy is centralized on the server: the gain on security is paid with a
loss on flexibility (static set of controlled services) and a decrease on performance (high
overhead).
3-tier Architecture.
This architecture design is the natural evolution of the C/S model. For balancing
the load of computing between different computers with the same high-medium
capabilities, especially in commercial web-based application, it has been introduced a
multi-layer chained layout; each stage deals with a particular aspect of the distributed
application. For example we can separate the presentation tasks from the processing
tasks and from data access: in this way we reduce the overload of the exchanged
information in the network and we increase the performance of the entire system. The
layering process can be done both at an hardware level (different machines implement
different tasks) and at a software level (inside the same machine we can have many
processes that communicate with each other).
24
3 tier architecture
presentation processing data access
message
message
Service
Server
Service
Computation
Client Environment
Server/Client (CPU,memory,VM)
code
Es: HTTP/CGI Computation code
Environment
(CPU,memory,VM)
message code
message
Code on Demand.
Many upcoming Internet applications are based on this paradigm. In this case a
client has already all necessary components to execute some service, but it does not have
the know-how; the provider machine gives the necessary know-how "on demand", that is
in replay to a request of the client machine (in general this is automatically controlled by
25
applications); the client machine must have capabilities to download, link, run the code
automatically.
Each client has a complete computing engine; for the portability of the
distributed code, all machines that interact with the server must have the same
computational capabilities: for that reason for implementing this kind of paradigm we
need a complete virtual machine (a machine with the same computational characteristics
in spite of different platforms). Among the many existing proposals, the most well
known is the Java Applets technology of Sun Microsystem; other technologies are
ActiveX from MicroSoft, Obliq from DEC Lab, etc.
We can see that the code is fetched from a source in the network and once it is in
the host is executed.
Code on Demand
Es: ActiveX/IE4.0, Applet, Web services
message
code
Client Server
Service Computation
Environment
(CPU,memory,VM)
Mobile Agents.
This is the most advanced distributed computing paradigm and today many
research centers and academia are trying to design the more efficient implementation for
implementing mobile agent applications.
Mobile Agents are computer programs which may migrate from one computer to
another on the network [10 pag.3]. They are said to be intelligent, because they can
perform autonomous actions in the network depending on the external conditions: in
each host the agent application can exchange some information (through events, local
variables, etc.) and can choose how to continue its travel.
The advantage of this kind approach is clear: hosts interactions are reduced to
the minimum, high flexibility and scalability, new solutions for unsolved problems (for
example in the network management); the disadvantage is the need of a complex
computing environment.
The executed process is moved among the nodes of the network autonomously.
This intelligent agent seems to be the best way for intelligent network and seems to
resolve problems related to efficiency, customization, management: mobile agent has
become a huge industry buzzword, especially in the business applications!
A complete process (an application running) can be moved from one site to the
other with its execution data (variables) or completely with its execution state (stack
image, register values). This approach is more complex than the others and it needs a
complete framework environment that manages the migration.
26
Mobile Agent
Es: Aglet,Obliq
code code
♦♦♦♦
27
Network Apps Components Network Apps Components
Hardware
Hardware
Host Host Host Host Host Host
code
stack/registers
data space
Execution Units
Computational Environment
28
These new concepts give us the possibility to classify two main forms of
mobility: Strong Mobility and Weak Mobility. Strong Mobility is the ability to allow
migration of both the code and the execution state of an EU to a different CE. Weak
Mobility is the ability to allow code move across different CEs; code may be accompanied
by some initialization data or some state-data, but no migration of execution state is
involved. Let me do some examples to explain these concepts: in the case of a strong
mobility the execution of the application is frosen and the host engine takes care to
remove all the information inside the CPU registers and all the bound resources, and
move all in another machine; in the case of weak mobility only the code and the data are
moved: programmers can use special flag and variables to save the state of the execution,
but at the application level.
Strong mobility is supported by two mechanisms: migration and cloning. The
migration mechanism suspends an EU, moves it to the destination CE, and then resumes
it. The remote cloning mechanism creates a copy of an EU at a remote CE. Remote
cloning differs from the migration mechanism because the original EU is not detached
from its current CE.
Mechanism supporting weak mobility provide the capabilities to transfer code
across CEs and either link it dynamically to a running EU or use it as the code segment
for a new EU. Such mechanism can be classified according to the direction of code
transfer, the nature of the code being moved, the synchronization involved, and the time
when code is actually executed at the destination site. An EU can either fetch the code
dynamically linked and/or executed, or ship such code to another CE. The code migrates
either as a stand-alone code or as a code fragment: the first is a self-contained piece of
code and will be used to instantiate a new EU on the destination sites (Java Applet);
conversely a code fragment must be linked in the context of already running code and
eventually executed (Safe-Tcl).
The mechanism supporting weak mobility can be either synchronous or
asynchronous, depending on either the EU requesting the transfer suspends or not until
the code executed.
We can compare the previous section contents about network paradigm and the
last concepts about code mobility n the next figure.
29
data mobility code mobility
code
data code +
+ + data
only data code data state +
exec state
Remote
Execution
Client/Server Code
on
Demand
Weak Migration Strong Migration
30
2.4 Programming Languages Concepts for Mobile Code
From a less abstract point of view, we now try to emphasize what are the
technical concerns on the implementation of code mobility. In the last section we have
seen the basic paradigm for implementing a distributed system; here we want to
introduce some technical concepts related to the development of a distributed system.
Mobile code technologies include specific new programming languages (or
special capabilities added to the old ones) and a corresponding run-time support.
For the sake of clarity, we introduce three conceptual levels to understand the
major constraints of a mobile architecture and the implementation of some specific
technologies [1]. We distinguish:
* Language Level
* Library Level
This distinction is valid in general, but sometimes specific problems of the distributed
system are not limited to a single level: for example security and safety are global
properties, so a security model must take into account all aspects of the system support
and the execution of the code.
a Graphics support
a Network
Library Level a Encryption
a Hierarchical Class Support
a Interpreted or Compiled
Languages Level a Strongly Typed or Typeless
a Programming Paradigm
a Concurrency
a Security Model
a Memory Management
Abstract Machine Level a Memory Architecture
a Platform Architecture
a Mobility Mechanism
a Shipping or Fetching
Language Level.
Interpreted or Compiled.
The language level is the first step and the main resources toward code mobility. The first
characteristic is the nature of the produced code: interpreted or compiled.
Compiled languages (C, C++, Pascal) translate code directly in the hardware language
of the execution machine (Assembler); they have big performance and are more efficient,
31
but they lack portability and we have to compiled the code each time we want to move
the code in other platforms.
Interpreted languages (Visual Basic, JavaScript, Jscript) instead are based on special
execution engines, called interpreters (in general developed for each platform), and they
are interpreted directly from the source code to the code of the particular executing
machine: this middle software level produce worse performance, but it is a complete
portable architecture ("write once, run everywhere").
Some new languages support a third way: they compile the source code in a platform
independent format for an abstract machine architecture and they execute it with some
interpreter engine or sometimes with a so-called Just-In-Time compiler (Java of
MicroSoft Browser, Limbo of Lucent Tech., etc.): this solution is a compromise between
performance and portability.
Programming Paradigm.
The majority of modern languages use the Object Oriented Programming paradigm
(OOP) for its basic characteristic (reusability, inheritance, encapsulation, security
mechanism) (Java, Obliq, Telescript); others use different paradigm and less complex
instruments, but in general they give some form of code modularity and security issues..
Some versions are based on the more traditional imperative (or procedural) and
functional languages, but they have some specific additional security features (Limbo,
Objective Caml).
Mobility.
At Language Level, the mobility mechanism are some time implemented in a transparent
and automatic way directly in the Abstract Machine Level, or sometimes there are
explicit mechanisms for triggering the migration in the network. Some implementation
use only some specific network mechanisms (TCP, UDP, HTTP connections on computer
networks), while others give some loading mechanisms for general purpose code
mobility.
32
components (stack, variables, handles, etc.). The characteristic of this machine depend on
what are the goals of developers: the Java VM looks like the Intel 4004 processor (used
for embedded applications) and need few hardware resources, while the VM of Lucent
tech., Inferno-Dis, is a RISC-like implementation with good configuration from high end
system to embedded phone machine.
From a programming point of view nothing change, but if we are looking for specific
performance or we want to have a flexible architecture we have to consider the nature of
the implementation design.
Also the Memory Architecture follows some hardware specific requirements, but all
implemented via software: stack base design, memory-to-memory design, etc.; in these
case we have to consider the possibility to implement the design "idea" with the
underneath hardware platform (virtual memory mechanism, security features, etc.). We
have to be carefully on the memory protection mechanisms: some memory protection
mechanism are implemented directly in hardware in a platform dependent way, while in
some abstract machine implementation all protection mechanism are implemented via
software.
We can see again that the goal in the platform design, is either having a general purpose
portable design or getting some specific efficient features for embedded systems.
In general, in the memory design, it is implemented an automatic memory control, the so
called Garbage Collector mechanism. This is done for many reasons:
All Virtual Machines for mobile code follow in some way this rules.
Security mechanisms.
General protection of the running process is performed in general by hardware memory
mechanism, confining the code in separate memory spaces; but sometimes this could be a
solution too expensive for small devices; some security features are implemented at the
Abstract Machine Level in order to control the executed code. During the loading and the
linking process we can verify the contents of the code itself and control it before the
execution; a sort of Security Monitor can be implemented to control the access to some
resources or to manage trusted and untrusted references (Security Manager in Java).
(A more complete study on security mechanisms is reported in the next section )
Concurrency.
In this case we point out the capacity of the Virtual Machine to manage two or more
applications (single thread process or threads on a multi-threads process) at the same
time in order to improve the use of the CPUs resources.
33
In general a thread is an independent execution resource managed and scheduled by the
operating system; the OS associates the CPU, a set of instructions and a stack context
(including local variables) to a thread. The first Operating System responsibility is to
manage computing resources. One of the ways the OS manages is by scheduling access to
the CPU to the various programs that are executed contemporarily. Programs then can be
made up of multiple threads. Threads became a fundamental part of the operating
system and nowadays they are spreadly used.
In general we use a collections of threads ruled by a preemptive or an cooperative
scheduling. The first is better for a strong thread control because the CPU gives to each
thread a fixed time slice to execute its code: the second is better for multimedia or real-
time applications, in which it is the programmers that manage the CPU resources
depending on the need of the application. Some Abstract Machine give the possibility to
use embedded concurrency techniques in spite of the underlying platform (Java on Win
3.1), others use the specific instrument of the platform in which they are running).
Linking Mechanism.
One of the main characteristics of the modern operating system is the possibility to call
functions libraries or external code at runtime and linking this code directly on the
calling process: these techniques allow programmers to produce modular, flexible and
smaller applications. Some example are: the DLL mechanism in the Windows
environment, class loading and linking techniques in Java, modules loading in the
Inferno system, etc.
Library Level.
Graphics.
The existence of a complete set or packages to develop a graphical user interface is a
strong advantage on choosing a platform for mobile code: an easy and ready to use
34
library, can allow from one side developers to focus their attention on mobility skills and
from the other have an integrated, secure and stable graphics interface. Java and
Inferno/Limbo, for example, provide these features.
Security instruments.
Some complex mechanisms to built some specific implementation of security are
enclosed in ready to use library: security interfaces for authentication and certification,
security algorithms, etc.
" You can build a 100 billion dollar secure system to prevent access to private
password in your system, but are you sure that your system manager will not give this
information for less ? "
(A.Lioy - Security and Distributed Programming Professor at the Politecnico of Turin)
Another aspects is related to the nature of code mobility. As the mobile code is
crossing protections domains, special care must be taken in order to protect it against
external computing environment and special care must be taken by computing
environment against malicious mobile code. A good introduction on these issues could
be found in [1].
* Communication Level
35
* Operating System Level
* Abstract Machine Level
* Programming Language Level
Communication Level
At this level the network is a collection of computer connected with hardware
networking technology: the requirements at this level in general are concerning the
robustness and efficiency of the protocol. But how the information are protected by
eavesdropping or how the confidential of exchanged information is controlled ? Only in
these years new secure features have been introduced at network layer (IPv6);
HTTPSecure and SSL (Secure Socket Layer) are some implementation that are located
just on the HTTP and Socket mechanisms. This new protocol based on cryptography
techniques controls and manages confidentiality, integrity and authentication, but they
seldom lack availability: lots of examples are related to the problems of deny of services
in Internet.
36
As an optimization, the high level program can be compiled and type checked before
being shipped as mobile code, but can we be sure that the object code is really a non
tampered output of a correct compiler ?
Three techniques have been proposed [2]:
• using cryptographic signatures to reduce the problem to one of trusting the author
(ActiveX)
• using cryptographic signatures to trust compilers, in this case we use only a small
number of trusted sites for compilation and certification (Inferno/Limbo)
• compiling to an intermediate language which can be checked to verify the same
constraints that are imposed on the source language (Java)
These techniques are not exclusive. You can use some combination of these techniques to
improve your security wall. For example you can combine the use of cryptographic
signatures and trust compilers: it seems easily feasible as they require much of the same
technology and infrastructure [1].
37
38
Chapter 3 Technologies
A number of mobile code solutions have been developed in the last years by the
main software Companies (Sun, Microsoft, IBM, Lucent, DEC) and by a number of
academic research centers (Berkeley, Stuttgart, Zurich).
As we have seen, mobile code applications can follow different implementations
approach in spite of the specific goals of the designers and follow different mechanisms
to exchange information. Our purpose, in this chapter, is to provide the readers an
overview on the basic characteristics of the products now available on the market,
following the architectural frameworks (paradigms, techniques and instruments)
explained in the last chapter.
39
Using the theoretical tools of the previous chapter we also want to identify the
differences and the similarities of the distributed computing technologies and find the
best suitable solution for our particular domain (see next chapters).
Talking about technologies means to investigate the basic practical tools used for
implementing a certain kind of engineering solution: that is talk about the architecture,
the software components and tools, the qualitative performances, etc.
A starting point for a complete overview of mobile code technologies can be
found in [1].
In these subsections we will classify the different technologies in 4 main groups:
• Virtual Machine/OS
• Architecture for Object Components
• Mobile Agents
• Scripting Languages
The first group is a complete programming environment to create mobile code
solutions: Java from Sun and Inferno from Lucent Technologies are some good example
to explain the main concepts of Operating System and Virtual Machine for mobile code.
The second group is more general object oriented approach to the mobile
technology; in the last chapter we have discussed about true distributed system and here
we make some example of this solutions. CORBA, DCOM, Obliq, Java Beans are just
some examples of this approach to distributed system: some are only specification, other
are ready-to-use tools to implement object components systems.
Mobile Agent are the more advanced architecture for building a distributed
system: some solutions are nowadays available on the market, but a lot of work has still
to be done in this direction.
Finally. Scripting languages are a collection of very simple and efficient solutions
for implementing distributed system: they lack lots of the flexibility of other more
sophisticated technologies, but they are productive, cross-platform, and specialized tools.
3.1 Java
Java was originally called Oak and was proposed by Sun as a language for
embedded non-computer devices - mostly consumer devices. When the Web became
explosively popular, it was a natural fit to apply this technology to the Web environment,
and now this product is the leading technology for implementing distributed mobile
code applications in Internet.
Today there are two main version available on the market, SDK 1.x and SDK
1.1.x 2; it is going to be shipped between few months JDK 1.2. All the information inside
this section refers to [2], [3], and [5].
2 In this chapter we refer to the JDK 1.1 implementation of Sun Microsystems and the JDK 2.0 of
40
What is Java under the hood ?
Java, first of all, is a class-based, cross-platform, network-based, object oriented
language created by Sun Microsystems, with an emphasis on portability and security.
Java is a complete programming environment: it is not only a programming language,
but a complete virtual machine specification and a set of general purpose libraries that
forms the API of the Java system.
Today Java is the most dynamic technology for Internet applications and for
distributed computing: initially it lacked performance and efficiency, but nowadays all
the advantages of this platform are clear and touchable. Portability is one of the main
advantage, but also flexibility (loading mechanism, security policy, API extensibility,
specification).
It is hard to make a brief overview of the Java family; in this section we will
provide some basic concepts and practical implementation to see both the advantages
and the disadvantages of this architecture following the theoretical framework built in
section 2.5.
The most known applications of the Java technology are the Applets: a secure,
easy to develop, portable, object oriented application for embedding dynamic application
inside HTML pages, the Web basic mean to communicate over Internet. Applets are Java
classes that are loaded automatically from the net and executed inside a secure "sand
box" following the code on demand paradigm. Applets have transformed the way you
can think of Internet and HTML pages: code is moved towards every point of the net
whatever are the OSes or the hardware platforms.
bytecode
Java Application
Java API
Interrupt Device
Management Memory Graphics
Language Level. The Java programming language is based on a simplified variant of C++
(the developing language most used on the market and in the academic world) with all
unsafe and most complicated language features removed: unsafe operations, like pointer
arithmetic, unrestricted casts, unions, and features leading to unmantainability programs
41
like the C preprocessor, unstructured goto, operator overloading, and multiple
inheritance.
In computer science terms, Java is strongly typed and late bound with dynamic
linking programming language. It supports encapsulation, which reduces complexity; it
is strongly object oriented, where inheritance, polymorphism and delegation help to
reuse the code; array and string types are built-in with range checks for all accesses.
Exception handling has also been added, in order to permit the creation of robust
programs.
Concurrency is provided at the language level with thread and serialized
methods, using mutex-locking technique on the corresponding object.
Java includes a novel notion of interface types. Interfaces define a collection of
abstract methods and attribute variables with their associated types. A class can be
declared to implement an interface, in which case it must implement all the methods of
the interface. Whenever a value of an interface type is expected, a value of a class
implementing this interface is used. Interfaces are useful for a number of purposes: they
can be used to hide the implementation of a class and to group classes with a common
functionality without forcing them into a class hierarchy.
Java also uses the notion of package. A package groups a number of class and
interface definitions. A class can be defined final (disallowing subclasses of itself to be
derived), abstract (disallowing instances to be created), and private (limiting the scope of
the class declaration to the containing package). Attributes have four levels of visibility:
private, default, protected, and public. Private attributes are only visible from within the
object itself; default visibility extends visibility to the package in which it is defined;
protected attributes further extend the visibility to subclasses of defining class,
potentially defined in another package; finally, public attributes are visible everywhere.
As we can see Java is more than a traditional programming language: it is a
instrument built to help programmers to develop object oriented applications skills and
to create a secure platform to manage code in a distributed computing environment. All
these aspects make Java a complete operating system language, as C++.
Abstract Machine Level. Basically the virtual machine of Java is a virtual hardware platform.
Today processors have high computing capabilities and they can simulate by software a
complete hardware platform for building a software layer between different specific
platform and user applications.
From an architectural point of view, the Java VM is like the Intel 4004 processor, with a
minimum number of registers (4) and a stack base memory architecture; this
requirements allow to implement the VM on almost all hardware platform, from
embedded systems to high power computers. The VM have its own machine language,
the so called bytecode, that is used unchanged for each VM: it has both efficiency of a
compiled code and portability of a interpreted code.
The VM is not a monolithic piece of code. Since it is designed with portability
and scalability in mind, it heavily uses separate subsystems for threading, memory
management (Garbage Collector), native method interfacing, native system calls, loading,
verifying and linking code, etc.. Each block can be used and configured for specific
purposes and can be added or removed to adapt to specific software and hardware
requirements. For example some embedded implementations of the JVM don't need the
GC module or the verifier module, because memory management is done manually and
Java classes are embedded inside the ROM memory.
42
key-point in distributed systems both to control and manage resources and for security
reasons.
The most interesting part of the VM is the execution engine itself, which comes
in two different flavors: interpreter and "just in time" compiler. The first is just a
translator of the bytecode commands, while the second is a more efficient way to execute
Java code in a platform dependent way using caching technique for the frequently used
blocks of code.
The second solution is surely the more efficient but it lacks portability, because
the VM implementation is strictly dependent on the specific machine.
A JVM is available for a huge number of different hardware platform and OSes:
from RISC based processor to Intel Pentium, from embedded system to PDA, from MS
Windows platform to Sun's Solaris, etc.
Library Level. From the beginning of its life, Java has been shipped with a set of libraries
(JAPI) that have given programmers a complete and secure class based environment.
System classes are a complete set of pieces of reusable (using inheritance technique) code
for permitting to programmers to focus on their specific tasks, without worrying about
all parts of the system. The Java Development Kit (JDK) from Sun range from GUI
interface to HTTP communication libraries, from complex Math calculations to remote
procedure calls.
The importance of the Java class libraries is in its role for built a secure system:
Java class libraries are written in such a way that all sensitive operations call into a
centralized object, the security manager, to check whether the caller is allowed to invoke
this operation. Programmers can built their own security manager to trigger the security
of their environment.
Initially JDK was the only Java Technology available for application
development, because Java was positioned for the Internet market. Sun nowadays is
looking seriously to other specific market segments. You can adapt your Java system for
different platforms: Personal Java for Network computers, smart phones, handheld PDA;
Embedded Java for embedded systems and Java Card for smart card technologies. They
all are designed to be upwardly compatible, so you can run your applications on the
upper API implementations.
43
Figure 16: Applet executed in Internet Explorer and in Netscape Navigator: not all is the same !!
♣♣♣
44
Java is used as a base technology to implement different kind of mobile code
architectures and paradigms. Java and applets have revolutionized the Web, and
executable contents has become a common term in the Web and network glossary. We
have seen that Applets are essentially a set of program codes that can be downloaded
(code on demand paradigm), instantiated, and executed in Web Browser.
Recently, this concepts has been matched by the introduction of servlet: the
servlet is moved from the client in the opposite way to the applet; that is, it allows the
client program to upload additional program code into server; the servlet's code is then
instantiated and executed in the server (remote execution paradigm).
In the next sections we will analyze some additional implementation using the
Java technology: a mobile agent architecture, Aglets, and an object components, Java
Beans. These implementation are Java solution but they have particular aspects that they
have to be considered separately.
3.2 Inferno/Limbo
The same folks that brought us UNIX an C are promising something even better
for network communication: Inferno OS and Limbo language.
Inferno by Lucent Technologies (Bell Labs Innovations) is a network operating
system designed to suit the constraints and needs of this environment; Limbo is the
operating system programming language used to build the majority of the OS and all
applications. All information about Inferno is available on the Lucent Web site and in
some paper available also from Lucent [7].
Inferno is a commercial product intended to be flexible enough to be employed
on devices as diverse as intelligent telephones, hand-held computers, personal digital
assistants, television set-top boxes, home video game consoles, and inexpensive network
computers; it can also be used on servers such as Internet servers, financial servers, and
video-on-demand servers. It is portable across processors (Intel, Sparc, MIPS, ARM, HP-
PA, AMD 29K) and across platforms (WinNT, Win95, UNIX: Irix, Solaris, Linux, AIX,
HP/UX).
The design of Inferno is based largely on Plan9 OS, a network operating system
from Lucent, but emphasizes portability, versatility, and economical implementation.
Economic here refers to the computing resources required; Inferno can run within little
memory and does not require virtual memory hardware. The portability has two
dimension in Inferno. The operating system itself can run on a bare hardware directly on
the CPU (native mode), or on top of an existing operating system like UNIX, WinNT or
Plan9 as a VM (emulation environment). In the latter case, the services provided by
Inferno are mapped to the native services of the underlying operating system. The
second dimension is the portability of Inferno applications. Applications (as we have
already mentioned) are written in Limbo, an integral part of Inferno, and they are
compiled to a binary format that is portable between all Inferno implementations.
The Inferno system is based on the application of three basic principles:
* resources as files: system resources are represented as files in a
hierarchical file system;
* namespaces: the application view of the network is a single, coherent
namespace that appears as a hierarchical file system but may represent physically
separated resources;
45
* standard communication protocol: a standard communication
protocol, called Styx, is used to access all resources, both remote and local.
In the figure 5 we can see an overview of the architecture of the Inferno/Limbo
system.
Java ?
Applications
Application Layer
Dis Virtual Machine
Process Management
Memory Management
Graphics library
Namespaces
Security
Limbo Kernel Layer
Styx communication
Language Level. A Technology for the DAB System Limbo is a safe imperative
language. It's main inspiration is C, but it includes in addition declarations as in Pascal,
abstract data types (ADT), first class modules, first class channels, automatic memory
management, and preemptive scheduled threads. It excludes pointer arithmetic and
casts.
The declaration of a module identifies the types of exported functions and
contains the exported declarations of ADT's, simple type declarations, and constants. In
order to use a module, it must be instantiated by loading an implementation of the
module (at runtime). The loading is done with the built-in function load that takes a
module type and a path to the module implementation and return the instantiated
module (or null if unsuccessful). This allows the programs to choose among several
implementations at run-time.
The channels of Limbo allow the communication of any value of its declared
type. A channel can be connected directly to another process or, through a library call, to
a named destination. Channel are the only built-in primitive for interprocess
communication, but more complicated mechanism can be built upon them.
Memory is managed automatically by a garbage collector mechanism.
Abstract Machine Level. Limbo programs are compiled to a RISC-like abstract machine
called Dis. Dis is designed for just-in-time compilation to efficient native code by Limbo
run-time system. The machine is memory-to-memory architecture, not a stack machine,
that translates easily to native instructions sets.
The Inferno kernel provides preemptive scheduling of processes (with a very low
overload) that are responsible for managing and servicing protocol stack, media copies,
alarms, interrupts, and the like.. The kernel schedules processes with multiple priority
run queues (8 levels) using round-robin mechanism. Scheduling is on a fixed time slice,
or quantum, basis with each quantum being set by the local system clock.
46
Inferno has two-level memory allocation mechanism: the lower level maintains
control of large block of contiguous memory. The higher level divides memory into pools
to allow applications to control the behavior of the system when the resources become
scarce. Memory is stored as block in an unbalanced B-tree with the leaves sorted by size.
The interface to all devices is via the Inferno file system interface (as it is partially
done in UNIX) and each device driver is a kernel resident file system.
Library level. A rich set of standard modules are provided, including modules for network
communication, secure and encrypted communication, and graphics. Two user interface
libraries are available: one based on Tk is intended for traditional window based user
interface; the other is a ready made interface components for typical embedded
applications, such interactive TV. The specialized design allows for a minimal memory
requirements.
Security. Safety is achieved through a safe language with restricted pointers and
automatic memory management: this safety is not enforced by the abstract machine (as in
Java). Inferno relies on applications being signed by trusted authorities who control their
validity and behavior: this is a big constraint for the diffusion of that environment for
Internet applications, where a huge number of programmers live on.
Applications. The applications domain for Inferno is focused toward applications for
service providers.
Inferno has been compared to Java by many in the press. The lack of an object
oriented structure in Limbo is one of the reason for which Inferno developer are thinking
of an integration of Java inside Inferno [4]. The two platform are briefly compared in the
following table.
47
Table 1: Inferno vs. Java - a Comparison -
Inferno/Limbo JavaOS/Java
Security Built in authentication and Machine protection security is
encryption at OS level, not built-in. Encryption has been
automatic machine protection added.
security
Resources access One file system access File system access local data:
everything from data to network network data must be accessed
through the server
Minimum size machine 512 KB of RAM 128 of RAM
to run applications 512 KB of ROM 512 of ROM
Object Oriented No Yes
Virtual Machine DIS Java Virtual Machine
48
Architecture for Object Components
Modern programming languages employ the object paradigm to structure
computation within a single operating system. The next logical step is to distributed a
computation over multiple processes on one single or even on different machines.
Because object orientation has proven to be adequate means for developing and
maintaining large scale applications, it seems reasonable to apply the object paradigm to
distributed computation as well. Object are distributed over the machines within a
networked environment and communicate with each other [9].
As a fact of life the computers within a networked environment differ in
hardware architecture, operating system software, and the programming languages used
to implement the objects. That is what we call a heterogeneous distributed environment.
To allow communication between components in such environment one needs a rather
complex piece of software called a middleware platform.
3.4 CORBA
Currently there are two major approaches to distributed-object technology,
namely Microsoft's OLE/ActiveX technologies and the Object Management Group's
(OMG) CORBA Architecture specification.
CORBA stands for Common Object Request Broker Architecture. Let's imagine
the internal hardware architecture of a PC. Inside we have different blocks that
implement different mechanisms: one o more CPU, hard disks, floppy controller, video
controller, audio card. All we need to coordinate all these separate block is a common
"bus" that coordinate and ruled the exchanging information. CORBA provides the
software solution, a "bus" specification to connect different software components from
different platforms.
CORBA addresses the following issues:
* object orientation
* distribution transparency
* hardware, operating system and language independence
* vendor independence.
CORBA is an open standard in the sense that anybody can obtain the specification and
implement it; besides its technical features this is considered one of the CORBA's main
advantages over other proprietary solutions.
For resume CORBA is a standard specification to built a multiplatform
distributed computing environment using a object oriented paradigm. Other proprietary
solutions are now available on the market (DCOM from MS), but CORBA is becoming
the standard and the reference model for large distributed applications. The biggest
Software Company use CORBA as a reference model for their applications (IBM, HP,
ORACLE) and a lot of other company are building a bridge to this specification
(Java/CORBA, DCOM/CORBA).
49
separated from a particular technology: OSes, programming languages, communication
mechanisms.
In CORBA there is no mobile code: this technology is a coordinating framework
to export object communication from single address space process to a distributed
environment (both locally and remotely).
As other technology CORBA is Internet oriented, that is a complete specification
to build a sophisticated system for large high powered computers networks and for large
scale applications. It can be considered a reference model for building general distributed
computing environments.
50
Language Level. DCOM architecture is not related to a particular language. The only
needed features is the possibility to deference and create virtual function table, to create
the necessary framework for create components and communicating each other.
General purpose object oriented languages like C++, Java, Delphi could use this
technology, but today only a restrict number of languages (all belonging to Microsoft
Company) are the concrete instruments for this technology: Visual C++, Visual J++ and
Visual Basic, the first two more suitable for operating system programming, the third is a
more efficient and faster developing instrument for simple front-end user friendly
applications.
Software components are objects that implement a specific standard interface for
each particular kind of applications (all interface inherits from a single interface called
IUnknown): ActiveX control, ActiveX documents, ActiveX container, etc.
Abstract Machine Level. The complete framework needed to built a DCOM system is given
by the Microsoft OSes: each components when instanced it is registered inside the
registry database (a central, efficient database for collect all software and hardware
configuration information of a machine); this registering mechanism can be
implemented also for remote objects.
Usually in the Internet application ActiveX components are used to create dynamic
behavior inside the HTML pages: each time in a page there is a special tag (<OBJECT
..> see figure) that refers to an ActiveX components (ActiveX documents, ActiveX
Scripting, etc.), the code of this components is fetched, registered on the system and run
to exploit some particular tasks. Differently from Java Applets loading mechanism, this
fetched code don't need a VM, but it can run directly on windows OS because is
compiled only for this platform.
<OBJECT
ID="NewControl"
CLASSID="clsid:12345678-1234-1234-1234-123456789012"
CODEBASE="http://ourserver/somecontrol.ocx">
</OBJECT>
At the moment only the tools of Microsoft allow the development of these
applications; some applications like Web Browsers of other company (Netscape) are
developing some instruments for compatibility or they exists some third part add-ons to
use COM technology.
The solution COM/Java realized by MS is very interesting: MS developer have
design a Java VM component to embed the VM functionality in any applications using
51
COM interface; moreover some special tools permit to interface toward Java class as they
are COM object and allow communication between different technologies (ActiveX
components, Applets, Java Beans, etc.).
Some security mechanisms (authentication, integrity) have been implemented,
but nowadays there are still some dark holes in the implementations. That is also
emphasized by the complete access of the ActiveX code to the system resources.
The disadvantage of being a single platform technology is an enormous
advantage when we have to develop application only in the windows environment: a
complete set of tools is available to develop efficient applications. Today some embedded
system version of Windows OS (Windows CE) is ported to a vast range of hardware
machine (from Palm PC to WinTerminal).
Nowadays the time to market is one of the main constraint for developing
distributed applications: the solution to that problem is the component architecture, that
is a new way to assembly applications using reusable software components. A
component is fundamentally a block of reusable code (a button, a slide bar, but also an
editor, a Web Browser) that can be use to built and assembly very complex network
applications; a software component model is a specification for how to develop reusable
software components and how these components objects can communicate each other.
Today there are different component technologies available on the market: ActiveX and
Visual Basic from MS, Delphi from Borland, and Java Beans from Sun.
JavaBeans is a portable, platform-independent software component model
written entirely in Java [2]; it enables developers to write reusable components once and
run them anywhere - benefiting from the platform-independent power of the Java VM.
Beans are Java classes that can be manipulated in a visual builder tool and composed
together into runtime applications containers (i.e. MS Word, Lotus Notes, Browser, etc.).
Any Java class that adheres to certain property and event interface conventions can be a
Bean.
We introduce some general aspects of component models before going into the
description of Java Beans [1].
In order for a component model to work, each software component must provide
several features:
1. the component model must be able to describe itself: this means that a
component must be able to identify any properties that can be modified during
its configuration and also the events that it generates;
3
Static and dynamic in this context mean that object are located at compile time or at run time; at the moment only
CORBA and DCOM provides the possibility to locate object dynamically.
52
2. the component must allow graphical editing of its properties: the
configuration of a software component is done almost exclusively through
control panels that expose accessible properties;
3. the component must be directly customizable from a programming language
(at least a scripting language);
4. the component must generate events and must provide some other mechanism
that lets programmers semantically link components.
Java Beans supports autodescription through an introspection mechanism, graphical
component editing through a customization mechanism, and linking through an event
model. In details Beans use some characteristics of the Java environment:
Java Beans relies on Java for its security. The Security model includes intrinsic
security mechanism that protects the user from errors that can result from incorrect type
casting or illegal memory access. Also a SecurityManager provides resource level
security that restricts a Java program's access to critical resources (hard disks, network,
video).
And also there are some additional packages provided by Sun or by third
company to create a bridge between Java Beans and other component models, ActiveX
for example.
Java, as we can see from the Aglets and Java Beans applications, is not a
programming language, but a complete platform to implement different distributed
programming technologies.
3.7 Obliq
Obliq of DEC System Research Center, is a lexically scoped, dynamically typed,
prototype based language, designed for distributed object-oriented computations.
Computations in Obliq are network transparent, that is they depend neither on the
allocation site or on the computation site, but the distribution is managed explicitly at
the language level.
Language Level. Obliq has three main characteristics:
* network transparency: any value can be transmitted between hosts,
including closures and object references;
* embedded prototype based: there are no classes and object are created
by copying (cloning) existing objects (the prototypes); in embedded prototyping
all methods valid on an object are contained in the object itself, without using a
list of super class methods;
* dynamically typed: type errors are caught cleanly and propagated to
the original site.
53
• Selection/Invocation
• Updating/overriding
• Cloning: create a shallow copy of an object;
• Aliasing: attributes can be redirected to attributes in other object via the
mechanism of aliases.
Objects can be protected against modification, aliasing, and cloning from outside the
object using the protected keyword.
Concurrency is inherent in Obliq; processes can executed independently on
distinct server and processes can spawn new threads locally. To handle concurrent
accesses, Obliq supports serializing objects; when an object is serialized, at most one
thread can access an object or run one of its methods at any given time.
Object migration can be programmed: we use a combination of closure
transmission, cloning, and surrogates. Transmitted closures can use functions from the
basic library, but do not otherwise gain access to names from the receiving site. Names
are explicitly exported by passing them as parameters to the received closures.
Abstract Machine Level. An Obliq computation may involved multiple threads of
control within an address space, multiple address spaces on a machine, heterogeneous
machine over a local network, and multiple networks over the Internet. This is
implemented using application server engines that create a complete object oriented
distributed system.
All applications made in Obliq are academic projects: user-interface toolkit,
algorithm animation, 3D graphics are some examples.
All type error are caught during compilation and primitives error are handled through
an exception mechanism; functions can be passed to other functions and returned as
results.
54
Concurrency is obtained through the use of threads and mutex, while class-based
orientation through an extension of the typing discipline.
O'Caml supports a small number of visibility modifiers for classes and object attributes: a
class can be declared virtual, disallowing any instances to be created, and closed
disallowing any subclass to be derived. Attributes can be declared private, making them
inaccessible outside the methods of the defining class.
MMM Applets are only allowed to use safe variants of the standard libraries: a safe
library imports everything exported from the unsafe original, but it only re-exports a
selected subset.
The advantage of O'Caml is a rich language with support for several programming
paradigms: functional, imperative, and object oriented.
55
Mobile Agent
We introduce the group of the Mobile Agent using two technologies: Aglets and
Telescript. The first one is a solution using Java, while the second it is a solution provided
by General Magic for UNIX Environment.
3.9 AGLETS
The Aglets are Agent Applets developed at the IBM Research Center in Tokio by
D.B.Lange; you can find a detailed explanation of the Aglet architecture in [6] or directly
refers to the Aglet Web Page (http://www.trl.ibm.jp/Aglets).
The Aglet represents the next leap forward in the evolution of executable
contents on the Internet, introducing program code that can be transported along with
state information (we will see that the Aglet mechanism is considered a weak mobile agent
mechanism, see previous chapter).
Aglets are Java-based objects that can move from one host on the Internet to
another. Aglets can execute some specific methods on one host and can suddenly halt
execution, dispatch to a remote host, and resume execution there. When Aglets move,
they bring with them their program code as well as their state (data) - state in this case
doesn't means the execution state data (program counter, stack, etc.), but a series of data
information variables - weak mobility.
Conceptually, the Aglet is a mobile agent because it supports the ideas of
autonomous execution and dynamic routing on its itinerary.
This mobile agent architecture is completely based on the Java features and uses
all the mechanism embedded inside Java platform to create a complete agents system:
object oriented paradigm for hiding information of the different communicating objects;
Serialisation for moving code objects from one host to the other; security policy using the
embedded Java mechanism; Applet-like architecture for manage the dynamic behavior of
agents; network communication using sockets; threads architecture; etc.
The Aglets object model defines a set of abstractions and the behavior needed to
leverage mobile code technology in Internet-like open wide-area networks. The key
abstractions found in these model are Aglets, context, proxy, message, itinerary and
identifier.
An Aglets is a mobile Java object that visits Aglets-enabled hosts in a computer
network. It is autonomous, since it runs in its own thread of execution after arriving at a
host, and reactive, because of its ability to respond to incoming messages. The behavior
of the Aglets is controlled by a specific set of interface-methods and the Aglets can react
to some exchanged messages: the execution environment leads the Aglets during all its
life calling the specific method implemented by the Aglets. Behavior supported in the
Aglets object model includes creation, dispatching, retraction, deactivation, activation, disposal
and messaging (see figure).
56
identifier core
Methods
itinerary
variables
Message
Aglet
Aglet Proxy Aglet Aglet
Proxy
Comunication
Aglet-AgletContext
57
Context A Context B
Dispatch()
Dispose()
Aglet Aglet
Retract()
Class secondary
storage
All the security policy of the Aglets framework is managed using the
SecurityManager class: for each host, local users can set the security permissions for the
arriving Aglets and limited the access to local resources; even the memory usage of the
Aglets is controlled.
Aglets are suitable for a lot of software applications from business area to
network control: accessing remote database for queries, distributed meeting scheduling,
network monitor, electronic commerce are only few examples of their possible
applications.
As we can see in the Aglets Architecture are mixed old and new concepts:
interprocess communication between objects, network transparency, code mobility,
global object identifiers, security.
Java is a basic platform to glue all these mechanisms for building a flexible
distributed architecture.
3.10 Telescript
Telescript of General Magic is an object oriented class-based interpreted
language for the development of large distributed applications .
Telescript is not intended for general purpose programming, but only as a
specialized language for communication. Security has been one of the driving factors in
the language design, together with a focus on strong mobility.
Telescript interpreters (engines) run on each host in a network and accept
incoming traveling agents, which autonomously execute code on behalf of their owner.
Language level. The Telescript language itself is a class based and includes run-time
typing. Classes can inherit from a single superclass, any number of mix-ins and abstract
classes which cannot be instantiated. Classes have two attributes: sealed and abstract.
The first one indicates that the class cannot be specialized, and the second one that the
class cannot be instantiated.
58
Object attributes can be private or public. Private objects can only be accessed from the
class itself and its subclass, while public attributes are unrestricted. The operator
protected turns object references into protected references. The access to objects is also
done through unmoved, uncopied, copyrighted and protected attributes.
Agents itself are processes with a number of properties (telename, owner, sponsor, client,
permit, age, priority) that are used to implement a strictly access authentication and
control. When an agent wants to move in the Telesphere (a network of Telescript
engines) invokes the go operation. The ticket is sent to the remote hosts. If the destination
accepts the agent's authority and gives access, the agent is moved with all its code and
execution is resumed in the new place.
Abstract Machine Level. The network is composed of hosts on which a Telescript engine
runs; this is a sort of computing environment that listens and controls access to the site
and manage the execution of the agents. Mobile processes are run in a separate domain
and can only interact directly with the engine in which they run. All interprocess access
is mediated by the engine.
Telescript employs an intermediate, portable language called Low Telescript, which is
the representation actually transmitted among engines.
Library Level. Each place (Telescript name for computing engine) has a collection of
built-in classes.
59
Scripting Languages
3.11 Tcl/Tk
Tcl/Tk family is the most representative scripting language present on the
market suitable for some specific code mobility purposes [8]. Tcl (Tool command
Language) and Tk (the graphic extension of Tcl) are a set of C libraries developed for
specific high level management computing skills. They are interpreted languages and
they have been implemented for many platforms (all flavors of UNIX, Windows, McOS,
Inferno).
One of the main characteristic is the possibility to embed the functionality of
these two product both inside Internet application (Browser) and inside other languages
(C, Prolog, Lisp). Tcl/Tk is a string based command language and it designed to be a
glue that assembles software building blocks into applications. The flexibility of this
technology is related to its implementation: a set of command are collected inside
libraries or packages (Safe-Tcl, Socket-Tcl, Agent Tcl, etc.).
The new and more interesting application of these scripting languages are Tclets.
Tclets are piece of code written in Tcl/Tk loaded through Internet browser and run
locally.
Another interesting aspects is that today there are a sort of symbiosis between
Java and Tcl/Tk: both languages claim to be suitable for transmitting executable content
over the Internet, but they respond to different kind of applications.
Sun developers want to create a twin of languages that are complementary for
distributed computing system. Sun developers aim to create a tight synergy between Tcl
and Java. The idea is to create an architecture where the developer can use the right tool
for the right job. The architecture is a dual language environment that is meant to
support two very different communities of developers. Java should be used for creating
components, framework, and other core technology that required writing large detailed
systems. Tcl should be used as a glue code, a control language, or other smaller tasks that
require a good deal of dynamism or high level control.
At the moment (see [5]) current deliverable technologies include four items: Jacl
is a Java implementation of Tcl; Tcl Blend allow the (C based) Tcl interpreter to load and
interact with the Java VM and vice versa; the Java package, which is part of both Jacl and
Tcl Blend, provides the communication between Tcl and Java; finally a Tcl Beans for Java
Studio.
C, C++ and Visual Basic are the most famous example of this kind of integration:
from one side there is a complete operating system language suitable for high back end
application (database engine, Internet server, etc.), and to the other side an easy-to-use,
efficient, specific purpose interpreted scripting language suitable for simple front end
applications.
60
Other interesting implementations based on Tcl are Agent Tcl that provides a Tcl
interpreter extended with support for strong mobility and Safe-Tcl that is an extension of
Tcl conceived to support active e-mail.
Paradigm.
As we have seen, some technologies are suitable for some specific mobile code
applications. In general paradigms and technologies are not related: you can implement
61
different paradigm using the same technology. Once we have chosen a model for our
application, we can use some generic developing platform (like JavaOS, Inferno) or use
some specific software solution (Aglets, Telescript, ActiveX, etc.). In general the choice is
related to the goals of the application: time to market, developing tools, flexibility.
In the following table we try to classify some of the studied technologies [10].
Resources
We have to care about the local and remote resources available for computing:
these are physical requirements depending on the target system. For example in a
desktop system, resources like CPU, memory, or storage devices are not a big constraint,
while in embedded systems these resources can be limited.
Also the nature of the network can provide different kind of services: available
bandwidth, one way (Radio, TV Teletext) or two way (Internet/Telecom networks)
communication, naming services (SNMP for Internet), etc.
For these reasons we have to be careful and avoid complex architecture for
simple systems.
DCOM, ActiveX, CORBA applications are technologies sophisticated, that
require a lot of physical (processing unit, networks) and extra coordination resources;
some flavor of Java (Embedded Java, Personal Java) and some implementation of Inferno
are well suited for embedded systems.
Flexibility
In this context, the flexibility of a system is the capability to adapt to some
requirements and to personalize the behavior of a mobile code solution. For example
some internal mechanisms are sometimes hidden to the programmers: the loading of
execution code, the security policy, the communication channels, the event management,
the memory management, etc.
Some mobile code solutions are too Internet oriented and they provide specific
services using infrastructure available only in the computer network system or in specific
Operating System.
ActiveX relies mainly on Windows systems; Telescript is a network oriented
solution for UNIX platforms; some Java solutions are also network oriented, as Mole;
interpreted languages as Jscript and JavaScript are related to specific application systems
(Browsers).
Security
Security is one of the major constraints for distributed system. From the user's
point of view, we need to control the access to local resources and we want to implement
a personal security policy; while from the provider's point of view we need a flexible
mechanism to offer different services and to access all the capabilities of the local
systems.
62
Today different security mechanisms are available embedded inside the
programming platform: from secure programming languages to digitally signed
techniques. Also in these cases we need a flexible security mechanism, not strictly related
to a network system and open enough to include different scenario.
Some technologies rely on some specific security mechanism and lack flexibility
(ActiveX); other have sophisticated way to control the authenticity of the executed code
(Inferno); other solutions give to the user simple, but flexible ways to implement control
(Java).
Target market
The kind of services we want to develop reaches a vast number of consumers.
Each consumer is supposed to have different platform so we have to develop specific
target solution.
Portability is one of the main constraint for a final solution and it can be a big
problem to implement; some time designers prefer creating a specific product for a
specific developing platform for optimizing the performance.
ActiveX, OLE technologies are specific platform solutions for the Microsoft
Window system; Java is a general purpose, portable platform for different network
system; Inferno is a proprietary product mainly suitable for high performance network
application, but it provides also some portability services (Limbo language, Inferno
abstract machine); etc.
Developing tools
Technical and human resources available on the market are important aspects
related to the development. Technical tools are normal developing instruments, but
human resources are all the possible information channel regarding a particular
technology: from paper documentation to practical solutions, from current ongoing
project to future market trends.
Proprietary solutions sometimes don't give all this huge number of information
(ActiveX, Inferno, Telescript). For some other technologies (Java, ActiveX, etc) a vast
number of "public" documentation and overall a vast number of papers are available.
These are good channels for testing the robustness of the technology and see the impact
on the market.
In table 3 we can see for example different mobile code implementations and the
relative used technology [10].
63
MOA* Java The Open Group, USA no
Mole* Java Univ. of Stuttgart, Germany free
MonJa* Java Mitsubishi, Japan binary only
Obliq Obliq DEC Research Center
Odyssey* Java General Magic, USA binary only
Safe-Tcl Tcl
Sumatra* Java Univ. of Maryland
Tacoma Tcl, C, Python, Cormell (USA), Tromso, Norway free
Perl
Telescript Telescript General Magic, USA binary only
Voyager* Java ObjectSpace, Inc., USA binary only
Practically, the choice of the programming language and the flexibility of this
instruments is very important. Time-to-market is a variable that we have to consider if
we are thinking to a competitive product.
The tables that follow are a series of comparison at the programming language
level between the mentioned technology.
In table 4 we can see a comparison between different platform and their general
characteristic: object-oriented paradigm, concurrency model, kind of mobile code
implemented, the security architecture used and the trusting mechanism of the moving
code.
Table 4: Comparison between mobile code Technologies features (General View [11]).
Table 5: Class and attributes protection and the keyword used (Language features [11])
64
No aliases NA NA protected NA
Mutual exclusion serialize
Attributes protections
No restriction public NA NA NA NA
Visible only in the protected NA NA NA NA
same package or in
subclass
Visible in subclasses default NA private NA
Visible only in private private NA default
defining class
Runtime protected protect
reference
Mutual exclusion synchronized
Efficiency
Here for efficiency of a technology we refer to the measure of how the developed
solution is suitable for our purpose, using the right amount of resources: you can
measure efficiency in term of execution speed, cost of the used resources, quality of the
service you want to deliver, maintenability of your application.
65
3.14 A Technology for the DAB System
The brief overview about the distributed computing technologies is the base for a
more specific discussion about the choice of a suitable technology for the DAB system.
In this section we try to list the requirements that the DAB system imposes for
choosing a developing platform. The main goal is to develop a mechanism to download
application using DAB channel.
Java is the right platform mainly for its portability, flexibility and for the big
consensus in the computer industry: we will analyze in more details the reasons of our
choice.
♦ Standardization
♦ Security
♦ Acceptance
♦ Multimedia & Distributed Computing
♦ Maturity
♦ Implementation Aspects
for each items we will discuss in details the DAB requirements and the characteristics the
developing platform is supposed to have. Follow immediately for each items the
relationship with the Java technology.
Standardization. The DAB system is a new technology for radio communication. Although
this network can be seen as an extension of the Internet network, there are some
fundamental differences between the two systems. The nature of the broadcast channel
and the characteristics of the radio services are not so dynamic as computer network
technologies. The systems and the tools used in the radio system are supposed to be
available for a long period and overall they are supposed to stable.
Standardization for radio systems is a must. The choice of a new platform to
develop digital radio services must be the result of an agreement between different parts:
standardization agencies (ITU, ETSI - EUREKA 1474), producer companies (Sony,
Panasonic, Hitachi, Grundig, Borsh) and service providers (BBC, SWR, SWEDISH Radio).
The broadcasting nature of radio (one signal for all) imposes fundamentally
some requirements about the independence of developing environment. We also can
derive some constraints about the complete availability of the needed documentation,
the stability (in terms of versioning and maturity - see also the subsection about Maturity) of
the developing tools and general acceptance by all the DAB community.
4
ITU stands for International Telecommunication Union; ETSI stands for European Telecommunication Standards
Institute
66
Java, in this scenario, is becoming a standard de facto for distributed application in the
computer industry: the number of users, software companies, research centers that work in this
new platform is enormous.
Sun is willing to follow the ISO/IEC patent policy or extend the terms of its current
patent policy to cover implementors of the International Standard ( see
http://www.javasoft.com/aboutJava/standardization/); they realize the
added value to the marketplace that de jure standardization can represent. For example, some
countries and companies still restrict the public procurement of goods and services in the
information technology sector to products based on de jure standards. These aspects can be a good
issue for the choice of a technology in the DAB community.
Java has a very flexible security mechanism. You can control your application at different
levels (from the verification of the bycode to the security manger runtime control), both statically
before executing Java application and dynamically at run time. The Java API includes different
packages to use different security mechanism (authentication, certification, encryption).Java relies
on a Garbage Collector manager to make safe the memory management, the basic requirements for
every modern distributed technology.
The model is robust and it can be adapted to different medium.
Acceptance. There are many issues related to the general acceptance of a technology for
the DAB system. First of all the chosen technology ought to be accepted by the whole
DAB community as a common platform to develop DAB services. In this context we
have to consider some aspect related to the market pressure. As market pressure we can
consider all the interests involved in the DAB services: producer companies,
standardization agencies, but also user acceptance, service providers, integration with
other media.
It is very important that the choice is accepted as a general solution by all
interested parties.
Java is collecting a large consensus: in the computer industry (Sun, IBM, HP, ORACLE,
MS), inside the academia centers and inside research centers (Sony, Mitsubishi). Programmers
are using Java for develop different kind of distributed applications for network system, but also
for embedded devices. Java is a buzz word in the computer world.
Why Java is so diffuse ? Fundamentally because it is an easy, a flexible and a powerful
language. Its abstract machine is really platform independent and there are implementations for
almost all platforms: HP-UX, UNIX, Solaris, SunOS 4.1.3, WinNT, Win95, Win3.1, AIX,
Digital UNIX, Inferno for OSes; Intel, Sparc, ARM, JavaChip for CPUs.
An increasing number of software vendors are including Java, or Java -based components,
as a strategic part of their systems. For example, the leading browser vendors (Microsoft,
Netscape, and Sun) support Java applets. The leading database vendors (Oracle, IBM, Tandem,
67
Informix, etc.) are collaborating on standards for embedding SQL in Java and Java within the
database engine. A leading smart card vendor (Schlumberger) offers a subset of the Java operating
environment on their smart card so that smart card application developers can develop
applications using standard Java development tools. Numerous other vendors in more non -
traditional computing environments (e.g., embedded devices or real-time operating systems) are in
the process of supporting the Java environment.
These large number of Companies are investing in Java technologies and overall Java
seems to be the flexible network platform want to be !
Multimedia & Distributed Computing. The DAB platform is supposed to give all necessary
tools to create a distributed system, but also to give all possible instruments to integrate
different media.
In the first case, we consider the traditional way to build a distributed system
(client/server), but overall the possibility to create advanced code on demand or agent
solutions; we need a complete framework to bind dynamically resources both locally and
remotely.
The second case is more related to the revolutionary introduction of the DAB
system: the new digital channel opens great possibility for the integration of all the
media: DVD systems, Internet services, home computer network, telecom services. The
developing platform is supposed to have all the means to integrate a wide range of
multimedia applications.
Java is born as a network technology with a strong attitude for multimedia applications.
Inside the Java API there are all the functionality for manipulate multimedia objects: images,
sound, speech, animation, Internet protocols.
Java RMI API provides a rich set of libraries to create sophisticated network applications:
agent systems, software components, client/server. Java gives designer flexible and powerful
mechanisms to implement their own download mechanism (ClassLoader) for retrieving code and
resources from any medium.
At the moment there are a large number of applications developed in the Java platform:
Hot Java, Jeeves, Beans, Aglets, Mole, Voyager, Odissey, Kafka, Concordia.
Sun shipped Java around 1995. Java is one of the first technology to use the Internet
world as a development laboratory. In this short period in all areas of computer industry Java have
found its particular application.
The most interesting thing about Java maturity is the fact that not also Java is a market
product, but academia centers have a huge number of projects about the Java platform: Java is not
the best platform, but its implementation includes all the aspects of a modern programming
environment: object oriented, network based, flexible enough to be applied from embedded system
to high end server, from smart card to network computers.
68
Java provides developing tools, but also a complete specification documentation for the
language and for the abstract machine: this formalisation process has been started from the
beginning and it is one of the basic reason of the success of Java.
Implementation Aspects. Basically the chosen technology have to be flexible: but what does
flexible mean? We have yet outlined that the DAB system is not a traditional network:
researchers and programmers need a developing platform in which they can control
completely the loading mechanism, the security policy both at runtime, the execution
environment, the resources binding, the communication mechanism.
Some platforms hide these aspects, while some other completely miss. In the case
of abstract machine implementation (Java, Inferno) there is a need of a standardized
interface to the native operating system.
The extensibility of the system API is also another requirement: a new system
needs new capabilities. Some technologies offer a standard way to add new functionality
to the core API and to the system itself.
Java is a complete portable platform and flexible for implementing different network
applications. The Java API provides a series of objects to control the behavior of the whole system:
securityManager, classLoader, Thread, etc.
Some critics about the Java platform are on the overall performance; we mention some of
the problems:
• the Java VM is a stack based machine, specifically optimised for small devices;
• the interpreter engine lacks performance; just in time compilers seem to be a
solution, but the memory requirements increase;
• garbage collector management is a big constraints for small embedded devices;
• non real time capabilities are a problem for the usage of Java in critical mission and
advanced multimedia applications;
♣♣♣
69
"… every new beginning
comes from some other new beginning end …"
(Pop Songs)
70
71
Chapter 4 Java
72
We have already discussed some features about the programming language in the last
chapter, but for more details about these issues see [1], [2] e [3].
Our focus will be on the last two components to point out what are the
fundamental basis and the wide capabilities of this new architecture; most of the aspects
are related to our purpose of building a download platform for a specific system (I will
not mention yet the specific requirements for our project, because this chapter should be
available for general dissertation about Java technologies).
The documentation on Java VM is vast and we can not go in deep for all the
aspects: we will focus our attention on some specific tools that can be well suit for our
comprehension and for our goals.
The majority of the material used in this chapter can be found in some books [1],
[2], [3] in many papers and articles [4], [5] ,[6], [7], [10] e [12]. In this chapter we always
refer to the JDK 1.1 specification.
Let's start from the first aspects. The explosion of the Internet world gave Sun
developers the opportunities to move their goals towards the network and browser
applications. Internet is a new "arena" and a new market for the most recent generation of
software applications and sometimes is the testing place where new solution are used
and developed.
The second aspect is related to the commercial purpose of Java: not less
important than the technology aspects, Java is a product developed to fight in the
distributed applications and in the OS software market. Sun Microsystems is an
Hardware and Software company oriented on high end network server systems for
business applications.
The market scenario for Internet applications is very complex: different OSes, a
huge number of development tools for each specific platform, wide range of open
possibilities for Web integration of embedded systems, a growing population of
"different skills" Internet programmers, the explosion of multimedia applications, etc.
Java is a well suitable technology for Internet applications that has all the
characteristics of a modern programming instruments:
• a modern dynamic object oriented language;
• safe and secure system;
• a virtual machine platform;
• multithreading architecture;
73
• a ready to use set of APIs for a wide range of applications (from office
computing, to embedded system requirements, to multimedia applications).
This are only few of the main aspects of the Java technology and every day new
solutions exit from the hat of the Sun developers. In the next sections we will go in details
for each specific element of the Java architecture.
* the registers,
* the stack,
74
register, and vars register - point to various parts of the stack frame of the currently
executing method.
A JVM can support many threads of execution at once, therefore each thread has
its own program counter register. Therefore, at any point, each thread is executing the
code of a single method. If that method is not native (code of the underlying hardware
machine, i.e. C, C++, Assembler), the PC register contains the address of the Java VM
instruction currently being executed; if the method is native, the value of the JVM's PC
register is undefined.
The Java stack is used to store parameters for and results of bytecode
instructions, to pass parameters to and return values from methods, and to keep the state
of each method invocation. The state of a method invocation is called its stack frame.
There are three sections in a Java stack frame: the local variables, the execution
environment, and the operand stack. The local variables sections contains all the local
variables being used by the current method invocation: it is pointed to by the vars
register.
The execution environment section is used to maintain the operations of the stack
itself: it is pointed to by the frame register. The operand stack is used as a work space by
bytecode instructions; it is here that the parameters for bytecode instructions are placed,
and the result of bytecode instructions are found: the top of the operand stack is pointed
to by the optop register.
The execution environment is usually sandwiched between the local variables
and the operand stack. The operand stack of the currently executing method is always
the topmost stack section, and the optop register therefore always points to the top of the
entire Java stack.
The size of an address in the JVM is 32 bits. The JVM can, therefore, address up
to 4 GBits of memory, with each memory location containing one byte. Each register
stores one 32-bit address. The stack, the garbage-collected heap, and the method area
reside somewhere within the 4 GBytes of addressable memory (the exact location of these
memory areas is a decision of the implementers of each particular JVM). The method
area, because it contains bytecode, is aligned on byte boundaries. The stack and the
garbage collected heap are aligned on words (32 bits).
The Heap is where the objects of a Java program live. Any time you allocate
memory with the new operator, the memory comes from the heap. The Heap is shared
among all threads. The Java language doesn't allow you to free allocated memory
directly. Instead, the runtime environment keeps tracks of the references to each object of
the heap, and automatically frees the memory occupied by objects that are no longer
referenced (garbage collection process).
The Method Area is analogous to the storage area for compiled code of a
conventional language, or the text segment in a UNIX process: it is the place where the
bytecode resides.
75
Stack
local variables
execution env.
Heap
◊ Java interpreters
◊ Just-in-time compiler
◊ Java chips
The first one, like a translator at the United Nations, translates Java bytecode into
native instructions the CPU understands. Interpreters converts bytecode on-the-fly and
must process the same code over and over again when you run the Java program. It
usually runs slowly, sometimes at only 3-10 percent of the speed of compiled C-code.
Just-in-time (JIT) compilers translate Java bytecode into native code like
interpreters do, but they don't have to translate the same code over and over again,
because they cache the native code and they optimize it. Some blocks of code are
translated in native code and moved in a cache: each time we execute these particular
blocks, the JVM executes the native code. This can result in significant performance
improvements, but sometimes a JIT compiler takes an unacceptable amount of time and
memory to do this job.
76
Java chips are dedicated Java processors, that is processors that run directly
bytecode.
Byte Code
Constant Pool,
Class Descriptor,
Fields,
Methods
and Attributes Areas.
Each class begins with a magic number and version information, followed by a
constant pool, a class descriptor header, fields, methods, and finally an extension area.
This data informs the JVM about to resolve internal and external class references, and
also allows it to verify the security and integrity of classes.
All multibyte data types are in big-endian byte order (most significant byte first).
Information is generally written to the class file with no space or padding between
consecutive pieces of information; everything is aligned on byte boundaries. This helps
keeps class files small so they will be aerodynamic as they fly across networks.
All classes are loaded and linked dynamically from two sources: the first is the
primordial class loader (the loader embedded inside the Java virtual machine) loads
classes from a specific directory set with the CLASSPATH variable; the second is the
implemented ClassLoader class used by programmers (see next section for details). In
an embedded solution some VMs implement different loading mechanism: for example
in the network computer classes are loaded from the network; in embedded devices
classes could be loaded from ROM memories.
77
The virtual machine loads the code of the first class, verifies the contents before
preceding, resolves all the internal classes used and loads all the necessary classes. This
load-verify-link process mechanism is executed dynamically at loading time and
whenever it is necessary during execution time. For improve performance the
verification mechanism could be suspended for internal system classes (from
CLASSPATH).
In the UNIX and Windows platform the start up process is started loading the
execution environment (a set of dynamic C libraries that contains the Java VM
implementation), setting all the needed information (CLASSPATH, Java version, runtime
parameters as stack depth, etc.) and initializing the runtime resources (descriptor, stack,
etc.): the name of the first class is passed and the loading mechanism is executed.
The Java VM is a multithreaded process. At start up the following threads are
executed:
* the garbage collector,
* the thread to execute finalizers,
* an idle thread to fall back on when no other work need to be done,
* the thread that interprets the bytecode and
* the main method thread of the loaded class
* for each new thread object create in the main class it create a separate
thread.
The JVM distinguishes between deamon and non-deamon threads [4]. At start up all the
thread are deamon threads, except the thread that executes the main method; when the
AWT toolkit is initialized, a non deamon thread is started that dispatches events and calls
into call-back code provided by the application. If all the remaining threads turn out to
be deamon threads the JVM exits.
78
VM Application Deamon Threads Non Deamon Threads
starts
spawns
main method
Garbage Collector
Clock Handler
Idle Thread
Finalizer
In JDK 1.x and 1.1, basically to load an external class file we need at least its
image in a byte buffer; we don't care about the source of this data: from the network,
from a optic disc, from a radio channel. All we need is a Java byte array buffer in
memory.
In Java 1.1.x we consider two groups of class code: trusted and untrusted. The
former is composed of all the classes that you can find in the CLASSPATH, while the
latter are all the rest of the class you can use (loaded from network, from a specific path
inside the classLoader, etc.). Trusted classes are allowed to do all (!!!!) while the other
79
group cannot, for example, use native code; and also all critical accesses (to the network,
to the file system, to the runtime environment) are controlled by the SecurityManager.
In fact with the help of a securityManager you can control a set of actions to access
some particular resources (network, file system, instanziation of particular classes, the
classLoader itself, the SecurityManager).
Normally, the Java VM loads all system classes from the local file system in a
platform dependent manner. For example, on a UNIX system, the VM loads classes from
the directory defined by the CLASSPATH environment variable; but in some embedded
JVM implementation classes can be loaded from ROM memory.
We can think of a class loader as a door-keeper that controls every class we need
to execute a Java application. During the class loading it resolve the needed class name
(control the identity), it loads it (let it enter in the building) and registers it (if someone
else need it again) on an hash table (guests books - so called namespaces). When we use a
class loader to load a class, all the internal needed classes are loaded by the same class
loader.
A Java application can use two types of classLoaders: a primordial class
loader, embedded in the basic Java API that use native method, and a subclass of the
classLoader object.
We analyze in detail what are the main steps to implement a custom class loader
(see fig 3).
A class loader is a subclass of java.lang.ClassLoader. The only abstract
method that must be implemented is loadClass(). The flow of loadClass() is as follows:
These basic steps can be used to perform custom control upon class name, class code,
class sources. Moreover we can see how you can manage and enter in the security
architecture of the Java VM; we will see that this mechanism is basically what we use to
load applet from Web Browser.
80
import java.util.Hashtable; Name
Nameofofclass class
... Hash table to control Namespace
Hash table to control Namespace
private Hashtable classes = new Hashtable();
public Class loadClass(String className) throws ClassNotFoundException {
...
return (loadClass(className, true));
1)
1)Verify
Verifythe
theclass
className
Name
We can control the class name string
} We can control the class name string
public synchronized Class loadClass(String className, boolean resolveIt)
throws ClassNotFoundException {
Class result; 2)
2)already
alreadybeen
beenloaded
loaded??
byte classData[]; If it is inside the Hash table
If it is inside the Hash table
result = (Class)classes.get(className);
if (result != null) {
return result; 3)
3)System
Systemclass
class??
} We use the primordial class loader
We use the primordial class loader
try { that in genral load classes from CLASSPATH
that in genral load classes from CLASSPATH
result = super.findSystemClass(className);
return result;
} catch (ClassNotFoundException e) { 4) Custom way ...
} We load the class in a custom way
classData = CustomFunction(className);
if (classData == null) { public class Example {
throw new ClassNotFoundException(); public class Example {
public static void main(String args[]) {
} public static void main(String args[]) {
CustomClassLoader sc = new CustomClassLoader();
result = defineClass(classData, 0, classData.length); CustomClassLoader sc = new CustomClassLoader();
Object o;
if (result == null) { Object o;
Class c;
throw new ClassFormatError(); Class c;
String tst = "ClassName";
} String tst = "ClassName";
try {
try {
if (resolveIt) { 5)
5)Define
Definetha
tha c = sc.loadClass(tst);
c = sc.loadClass(tst);
resolveClass(result);
}
class
classfor
forthe
theVM
VM
o = (c).newInstance();
o = (c).newInstance();
We transform byte stream ((‘ClassInterface’) o).’ClassMethod’("none");
classes.put(className, result); We transform byte stream ((‘ClassInterface’) o).’ClassMethod’("none");
in a class object } catch (Exception e) {
return result; in a class object } catch (Exception e) {
}
} }
}
}
} 6)
6)Return
Returnaaclass
classobject
objectthe
theCaller
Caller
System.setSecurityManager(YourSecurityManager s);
Using this technique you can trigger the loading process of your Java
application. We can define our own securityManager just once in the main java
application: each successive attempt to set the securityManager will throw an exception.
Basically the Java VM takes as input the name of the main class file and the
directory where it can find the system classes (we will see in more details in the next
sections); then it starts running the code from
If you want to configure the loading process you can load an intermediate class
in which you use the mentioned special classes (class loader, Security Manager, etc.), but
also you can use some special tools classes to load a jar file (zipped Java files), object
images stored on HD, or code from the network.
81
java.class arg1 arg2 .. argn Applet.class par1 par2 .. parn jarfile.jar
Jar
Reader
DAB
Loader
Applet ... & Viewer
Viewer JarReader.class jarfile.jar
In the last release, Java 1.2 beta, something is changed in the delegation model of
the ClassLoader and some methods have been added: these changes are backward
compatible.
The new delegation model provides a consistent and well defined search policy
for loading classes and resources. The basic idea is that every class loader has a parent
class loader: when loading a class, a class loader "first" delegates the search for the class
to its parent class loader before attempting to find the class itself; the default parent class
loader is the system class loader.
The loadClass() method in ClassLoader performs these tasks, "in order",
when called to load a class:
* if a class has already been loaded it returns it (hash table)
* otherwise it delegates the search for the new class to the parent class
loader
* if the parent doesn't find the class, loadClass() calls the method
findClass() to find and load the class.
These mechanism is flexible, but at the same time is more secure of the
implementation of Java 1.1; in addition to the extension class loading it gives additional
flexibility for expanding the Java API in a safe way (see Expanding the Java API section).
82
The Java runtime system relies on garbage collection to automatically identify
and reclaim object no longer in use. Garbage collection doesn't alter the behavior of an
application written in Java, with the exception of classes that declare a finalizer method.
Finalizers are executed right before objects found to be garbage are discarded, giving you
a chance to explicitly release non memory resources the class uses. Tricky finalizers may
resuscitate an object by installing a new reference to it, but finalizers are execute only
once. This garantees that objects may be brought back to life only once. Beginning with
JDK 1.1, data belonging to classes is also garbage collected, allowing unused class es to be
automatically discarded (this happens whenever their class loader gets recycled). System
classes are never garbage collected.
The initial set of roots of a Java run time are
The garbage collection code is executed in a separate thread when the system
runs out of memory or when System.gc() is explicitly invoked. The collector may also
run asynchronously when it detects that the system is idle, but this may require some
support from the native thread package. In any case, the execution of the garbage
collector halts all other application threads and scans the entire heap: this is a big
problem for Java embedded system, because the GC can introduce too long delays.
and we close each occurrence of this method inside a special section (see figure 5); if an
exception is thrown we can handle in a smoothly way inside the catch block; if no catch
close handling an exception can be found, then the current thread is terminated, but only
83
after all finally clauses have been executed and the method uncaughtException has
been invoked for the ThreadGroup that is the parent of the current thread [2].
Critical
Criticalregion
region
try { We use some particular method
try { We use some particular method
... that throws exceptions in case of unexpected
... that throws exceptions in case of unexpected
} conditions
} conditions
catch (Exception e) { try {
catch (Exception e) { try {
... File f = new File(‘someFile’);
... File f = new File(‘someFile’);
} }
} }
catch (Exception e) {
catch (Exception e) { Catch
Catchregionregion
catch (IOException e) {
catch (IOException e) {
... We trigger all the thrown System.err.println(..);
... We trigger all the thrown System.err.println(..);
} error exceptions }
} error exceptions }
... finally{
... finally{
finally{ f.close();
finally{ f.close();
... }
}
... Finally
Finallyregion region
}
} In case the exception is sent to super classes,
In case the exception is sent to super classes,
before leaving the critical region,
before leaving the critical region,
we can do something !
we can do something !
Concurrency
Another requirement for a the modern platform is the possibility to develop
applications using multithreading techniques: that means the possibility to have main
process applications and inside the same memory space execute separate light weight
and independent execution units. In general we distinguish two different kind of
multitasking: preemptive and cooperative. In a cooperative multitasking scheme, the
amount of time a task is allowed to run is determined by the task, whereas in a
preemptive scheme, the time is determined by the operating system.
Threads are integral part of the Java programming language. A thread
implementation includes the creation, execution, switching, killing and synchronization
of threads. The JVM specification also states clearly that each object has a mutex (a data
structure to synchronize access to common resources) associated with it.
Java threads can be implemented using threads provided by the host operating
system, as user-level libraries, or as a combination of the two and there is not a
specification of the kind of multitasking (preemptive or cooperative). For example Sun
and MS implements two different policy of multitasking, because they use different base
implementation for the thread mechanism.
From the point of view of the users this means a more user friendly and
dynamic interface, from the hardware point of views means running independent
execution units on every processor available in a parallel-multiprocessor machine. Java
resolves that problem in a very simple and safe way for programmers.
The Java API offers a inheritable class java.lang.Thread and an interface,
Runnable, to develop easily a multithreaded environment.
Each thread in the Java programs corresponds to an instance of the
java.lang.Thread class: for building a separate thread, Java classes are supposed to inherit
from java.lang.Thread or to implement the Runnable interface; programmers have to
implement the block of code in a run() method, and each time you want to create a
separate thread you have to call the start() method of your class. Additionally the Java
environment provides a set of methods to control the dynamic in a multithreaded
84
program. These are methods to change and to control the thread states and methods to
notify information between different threads.
Serialization
One of the main problems for distributed environments is the possibility to
move data throughout different memory spaces located on the same machine or to
different machines in the network. Serialization is a technique implemented for
representing the state of Java objects in order to reconstruct the object itself once it is
moved to a remote machine. This mechanism is often called marshaling and
unmarshalling technique: in details it means that complex structure as array, C struct,
C++ objects are represented in a single process space using pointers to some memory
location; when you have to move this component towards other process spaces, we have
to think of a way to rebuild all the structure (in this sense we serialize because we create
a stream of information that represent the object itself). Many of the common Java classes
implements already a serialisable interface (java.lang.*, java.util.*).
Most of the distributed programming applications written in Java use these
capabilities: RMI is the most well known mechanism, but also the Agent applications
make wide use of this features.
RMI
Sockets communication is the common way to move data throughout the
network for low level communication. Java has a set of classes to open and manage
stream (TPC) and datagram (UDP) connections. Java has also a complete set of ready-to-
use classes to implements more sophisticated network services. RMI (Remote Method
Invocation) is the object oriented implementation of the well know RPC (Remote
Procedure Call) technique used for client/server applications. Everyday new tools are
added to the Java architecture to implement different distributed computing applications
(Agents, Aglets) and they use basically or low level TCP connections or high level RMI
classes.
Java Family: JRE, SDK, Personal Java, Embedded Java, Java card
Before going into a detailed description of Java libraries, we need a brief
introduction on the Java packages available for developers. We have mentioned that
initially Java was a network technology suitable for Internet applications; successively
Sun developer have understand that not only the Internet is a good platform for Java
applications. For those reasons they reduced the set of components to fit the needs of
other applications targets. They build a series of subset APIs designed to be upwardly
compatible: JDK (the main and complete implementation), Personal Java, EmbeddedJava,
and JavaCard.
85
• Desktop PC
• Enterprise Servers
• Mainframe
• RTOS
• Set-top boxes
• PDAs/ScreenPhones
• Internet TV
• Car Navigation
• Industrial controllers
• Pagers
• Automotive
• Smart Card
• Java Ring
Java designer have not only reduced the number of core classes, but for each
platform they have implemented a specific version of the Java VM. This is possible
because the Java VM is describe as a specification not as an implementation. In fact for
example it is possible to re-implement the data structures and methods that form the
internal implementation of the classes for reducing the memory footprint and maximize
the performance for each specific platform.
The following table gives an idea of the resources needed for each Java platform.
Table 6: Resources requirements for different Java environment (only Java system requirements)
86
• using of explicit calls, inside the packages methods, to a global
SecurityManager to check the validity of certain specific operations.
java.object
applet.* text.*
awt.* sql.*
io.* util.*
math.*
lang.*
net.* security.*
beans.* rmi.*
Figure 27: core API class hierarchical tree: Java is a complete Obiect Oriented platform.
The Java core API is composed schematically by a set of core packages divided
following special rule and depending of the functionalities. Sun (but also MS and
Netscape) provides a complete set of application APIs to build a complete developing
environment with secure and tested classes (see figure 7).
87
Application Programming Interface APIs
by Sun
Additional packages are added when they are considered fundamental, but there
are also some expansion mechanisms to add some specific functionalities, without
touching the core API.
88
1
2
Browser
8 3
9
HTML page 4
AppletViewer
10 7
SecurityManager
HTTP
VM
5
6
“CLASSPATH” ...
sun.applet.AppletViewer.class
1 The Browser sends an HTTP request for loading a HTML page file ….
3 The Browser parses the HTML page and formats the video output; if it found an <APPLET> tag ...
4 … it loads the Java libraries in its memory space and executes ...
7 The AppletViewer as in independent application loads the code of the Applet ...
10 The Applet runs under the control of the SecurityManager instantiated in the AppletViewer
Some information is exchanged between the AppletViewer and the applet to set
the run time environment or to pass some extra data: this is done using an embedded
mechanism inside the applet class (from whom all Applets inherit basic methods) or
using some well know interfaces.
The java.applet.* package is a minimum set of classes and interface to create
the necessary framework.
89
Inside the AppletViewer application we can implement a customized security
policy instantiating our own SecurityManager implementation !!!
The Applet mechanism is a very simple solution to the problem of mobile code
oriented to the Internet environment, but it can be expanded to other environments or
can be used as a good example for other network architectures.
In brief, currently, JNI is designed to interface with native methods written only
in C and C++ and native methods can:
* Create, inspect, and update Java objects (including arrays and strings);
* Call Java methods
* Catch and throw exceptions
* Load classes and obtain class information
* Perform runtime type checking
thus virtually everything you can do with classes and objects in ordinary Java you can
also do in native methods.
For example from Java applications, native methods are loaded with the
System.loadLibrary method. The native method is declared as follow:
90
package pkg;
class AnyClass {
native double f(int I, String s);
static {
System.loadLibrary("Pkg_Cls");
}
}
6
...
err = JNI_CreateJavaVM(&jvm, &env, &vm_args);
mcls = env.FindClass(exec); // class of the main java app 7
handleError(); exec is the name of the main
mmid = env.GetStaticMethodID(cls,”main”,”([Ljava/lang/String;)V”); class file; depending of
handleError(); the implementation of the
native function FindClass
cls = env.FindClass(“java/lang/String”);
8 you can pass a C string or
handleError();
special string (es: Win32
args = env.NewObjectArray(argc,cls,0); string)
handleError();
for(int i = 0;I< argc; I++){ 9 NB: the Invocation API is written
str = env.NewStringUTF(argv[I+1]); in C code, but some compiler
accept the C++ notation; so:
handleError();
(*env)->FindClass(env,exec);
env.SetObjectArrayElement(args,I,str);
can be written as
handleError();
} 10 env.FindClass(exec);
env.CallStaticVoidMethod(mcls,mmid,args);
handleError();
jvm.DestroyJavaVM(); 11
91
JNI Invocation Interface JDK 1.1
Inside the jni.h header we define all the prototype of the Java Invocation interface; these functions are
1 defined inside a library implemented by the developer (Sun, MS, Netscape). Basically the JNI is a standard
interface to call all the facilities we need to control, instanziate and manage the JVM
Basic variables & structures used to call JVM environment and java objects. For java objects we call special
2 ID for the class, the method implemented inside the class using a well define interface.
3 We have to specify the version of the Java implementation we are using (very important).
5 We can modify some external environmental variables, ex. the classpath (to include \dab\java\ ?)
6 This functions load the external library inside the process address space and return all the pointer
necessar y to call the JNI API functions.
The FindClass functions returns an ID to a specific class passed as an arguments; this function verifies,
7 loads, resolves & instanciates a Java class. As we can see we need only the name of the class: the
searching path is defined inside the JDK1_1InitArgs structure.
We look at a specific method inside the specified class; usually we call the “main” method, but we can
8 personalise this mechanism. Note the special tag used to identify the called method.
We build a string array and pass a series of arguments used by the java class main method: in this way we
9 could call a predefined java class and pass the main java class as an arguments: java Applet mechanism !!!
One of the big problems with the JNI interface is that you have to rebuild all your
old libraries for reusing them again in the Java applications: new libraries that wrap the
old named native method. A solution come out from Microsoft world and we will see in
details in the next section.
For a detailed explanation see [1], [3].
92
.activeX IJavaExecute::GetDefaultClassPath(..)
IJavaExecute::Execute(..)
.awt .peer
IJavaExecute2::SetSystemProperties(..)
.com IJavaExecute2::SetClassSource(..)
.fx
com.ms .lang
.service
.ui .resource
JVM as a COM
.util .cab object
.vm
Invocation API
Figure 32: Additional facilities of JVM from MS
RNI stands for Raw Native Interface. This is the MS specification to access native
code (C, C++) from Java code or to call the JVM directly from native code. This
specification is studied just for expert developer and to produce very efficient code.
J/Direct is an extension of the MS compiler and interpreter for calling Win32 API
functions in a direct manner from Java code: developers can access all capabilities of the
dynamic library in the Win platform using the same name of the native code.
Class ShowMsgBox {
public static void main(String args[]){
MessageBox(0,"It worked !","…",0);
}
//* @dll.import("USER32") */
private static native int
MessageBox(int,String,String,int);
}
Some special ready-to-use Java classes are added as a extended packages to wrap
the main API functions: com.ms.win32.Kernel32.class, com.ms.win32.Gdi32.class, etc.
import com.ms.win32.*;
class MsgBox{
public static void main(String args[]){
MessageBox(0,"It worked !","…",0);
}
}
93
4.11 The Java Extension Framework: How to Expand the Java
API
The core packages of the JVM are a set of classes to implement general purpose
and network oriented applications. Sometimes programmers need to create some
additional facilities or just create some specific application: a set of classes that control a
proprietary database, a new editor, a new application environment for developing new
distributed paradigm. Java uses extensions as a standard way to add new facilities to its
own programming environment.
Extension are packages of Java classes (and any associated native library) that
application developers can use to extend the functionality of the core platform.
The Extension mechanism allows the Java VM to use the extension classes in
much the same way as the VM uses the system classes.
Adding new classes to the core API is different depending on the JDK version.
Until the JDK 1.1 adding new classes meant to create a new package and to add the
installation directory to the CLASSPATH. The need of a more dynamic and controlled
way, and overall the need to download and to install automatically new packages has
introduced in the JDK 1.2 new standard mechanisms.
First of all, Extensions are embodied in JAR files (compressed ZIP files). Every Jar
file is a potential extension. A Jar file can be an extension package in two way:
* installed extension: put the JAR file inside the a special location ;
* downloaded extension: referenced inside a download JAR file;
When the VM is searching for a class of a particular name, it will first look among the
system classes; if it fails to find the desired class there, it will next look for the class
among any installed extensions (in general in JAVA\bin\ext for Java packages and
JAVA\lib\ext for native libraries, where JAVA is the installed directory of the JVM); if it
doesn't find the class among either the system classes or the installed extension, the VM
will search among any download extension referenced by the application or applet.
Also the name of the packages have to follow some special rules, but not always there is
a fixed mechanism. From one version to the other of the JDK we had some different
notation: sun.*,netscape.*, then com.sun.*,com.ms.*, and at the end we will
use some notation similar to javax.sony.dab.*
94
(Oracle, Adobe) are thinking to develop their applications directly in Java code to reduce
implementation costs for different platforms.
Java for many reason have collect consensus from the entire world of software
producers and instead of finding a way to fight against it, many developer are trying to
find the way to converge towards Java.
The first two are a complete development environment (interpreter, development tools,
compiler, AppletViewer, class libraries); the last one is an implementation integrated
specifically for the Web Browser to use Applet, but also included extended network
facilities to develop complex Web Server applications.
Windows architecture is fundamentally a layered OS with a kernel that manages
the basic functionality (memory management, driver management, Thread scheduling,
process management, etc.) and a series of independent external modules to implement
some specific tasks.
95
Win32 App
Win32 API
native API
ntdll.dll
OS Kernel
Through a well define set of APIs users can develop applications to access the hardware
and software resources.
Each specific VM implementation uses a different number of additional libraries;
we can summarize the specific "core" functions in different families:
Some of these functions groups are collected in single DLL or they can be put in separate
library file.
The first group is a collection of functions that implement the basic VM operation
and it is loaded each time the VM runs: for example javai.dll from Sun and msjava.dll
from MS.
Another group of functions is related to the native calling mechanism, so the
specific set of functions for calling native methods or for loading and calling the Java VM:
generally it resides in the main library.
Many native functions used by the Java API are collected in different libraries
depending on the particular task they do: Graphics native functions (winawt.dll,
awt3240.dll), network communications (net.dll), mathematical functions (math.dll),
special purpose functions (JdbcOdbc.dll).
For those implementations that have a compiler, some additional libraries are
included in the package.
96
In general the core of the Java VM is all implemented in a single library: for Sun
we have javai.dll and for MS msjava.dll. Inside there is a set of functions that are
executed to start up the virtual machine or some internal function to control memory
management or object layout. In general these libraries contain all the native interface
calls and the basic native method implementation (for the core Java classes
java.lang.*).
Win32 API
Then there are the libraries that gather all the native methods for special
functions: graphic interface (awt.dll or winawt.dll), I/O access, network access (net.dll),
multimedia functions (mpeg.dll), etc. Each of these libraries is loaded only when it is
needed.
These main modules are loaded by special "Kick off program" applications
(java.exe, javac.exe from Sun; jview.exe, jvc.exe from MS; etc.) or by the Java classes
using the loadLibrary() call.
The calling applications load the necessary libraries and run special functions
passing the name of the class to execute and the searching path directories (classpath)
where find all Java System classes.
Only Microsoft have developed some special DCOM wrapper interface to use the
Java VM capabilities at a higher level to integrate with its ActiveX/DCOM environment.
97
The following information is derived from the source code of the Kaffe
Implementation (a 100% compatible free source version of the Java VM available on the
net, http://www.transvirtual.com/kaffe.html) and the compiled classes used
in the JDK 1.1.6 provided by Sun; all considerations upon this subject derive from my
personal work and are not related to some document.
The java.net package is one of the smaller and less complex packages, but I think
it contains all the fundamental principles used in the other Java packages; also it is one of
the core packages of the Java platform and basically it is implemented by all Java
platforms available on the market.
I will outline during the dissertation what are the points in which
implementations differ.
A Java API block fundamentally is a set of classes that implement a specific OS
facility available for developers: for examples we have packages for the basic elements of
Java OS (java.lang.*), for I/O communication (java.io.*), for Graphic
Management (java.awt.*), Thread mechanism, Applet interface (java.applet.*),
remote method invocation (java.rmi.*), etc.
All functionality of the Java runtime system are exposed following a well defined
Object Oriented paradigm, in which each service is wrapped inside a well defined class,
which wraps all the method and data needed by this service.
From an abstract point of view, we can distinguish different software layers
between the higher Java API classes to the lower OS API. In this case we need to balance
different opposite aspects: Java object oriented vs. the C procedural approach, platform
dependent services of the Windows OS vs. the platform independent API provided by
Java, etc.
Java package
Java platform independent
Java bycode
interface
platform dependent
implementation
C code
Windows OS OS API
Following the logical block diagram we can distinguish 3 kind of classes inside a Java
package:
• at the lower level we have a platform dependent class that implements all the needed
native calls. In general it extends an abstract class that wraps the Java basic methods
to access a specific service;
98
• in the middle we have a set of matching classes that give to the upper packages a
well defined minimum interface to the services (a set of method calls);
• at the Java API level we have all the rest of the package class that implement all the
complex features related to a particular kind of service.
Look at the following figure (fig 14) to see an example of chain implementation.
As you can notice, this mechanism permits to have a well defined, efficient, standard
way interface to the specific services of a platform dependent OS (UNIX socket,
WinSocket). Using the abstract classes we can specify also the name and the set of
minimal services that we need, in order to reduce the platform dependent access, but at
the same time to give a portable solution for all Java implementations. This 3-step process
not always is followed, but it is a good example of multiplatform approach of Java.
class Socket{
socketImpl impl;
Socket() {
impl = new PlainSocketImpl();
}
...
}
From native method we call native function using the well define JNI
specification and model.
In the underlying OS we need a wrapping DLL (in the case of dynamic library)
to gather all the equal purpose C functions (in our example the net.dll file); from this
library, inside the single functions implementation, we can call the native API and link to
the native API library (in the case of Window platform winsocket.dll, kernek32.dll, etc.).
While the JNI interface is a specification between the Java layer and the native
code layer, the approach followed inside the Java API implementation is a good example
of well defined developing approach. In the case of an external package, we suggest to
follow this way to build a well defined Java package. The JNI specification defines only
the name of the wrapper native functions (C functions); internally each single Java
platform can use different implementation of the native services.
In brief we have seen that also in the Java platform we can distinguish a set of
classes that are tightly bound to the underlying platform and the specific configuration of
99
the system: if it is possible we should create a set of abstract classes to implement a well
defined set of platform independent API and then we should implement separately for
each classes a specific implementation.
Another example of the layered approach is the following figure.
Runtime.java
public synchronized void loadLibrary(String libname){ External.c
...
int loadNativeLibrary(char* lib){
loadInternal(buildLibName(path[path],libname);
...
...
LOADLIBRARY(libHandle[i].name,lib)
}
...
private boolean loadInternal(String filename){
}
...
return loadFileInternal(filename);
}
native private Boolean loadFileInternal(String filename);
slib.h
#if defined(__WIN32__)
#define LIBRARYINIT()
#define LIBRARYLOAD(HAND, LIB) HAND = LoadLibrary(LIB)
Win32 API
#endif
Some packages are separated from the specific implementation of the OS platform or
from a special proprietary solution provided by different Company. In these cases some
special packages have part of the name of the core Java implementation but they differ in
the radix (java.util.*, sun.util.*, netscape.util.*).
100
Some of the new solution are introduced in the different releases of the JDK
packages, while other try to expand the Java API using new packages.
Java is the base platform for different kind of distributed computing
environment: not only the Applet architecture (Code On Demand paradigm) or the
traditional client/server architecture, but also some new agent technology is
implemented in Java.
♣♣♣
New aspects are introduced in the JDK 1.2.x concerning the security mechanism
and policy of the Java VM [11].
There is no built-in notion of "trusted code" and the securityManager has
more advanced capabilities to control the security of the Java Environment [9].
In the previous version of the JVM you basically have two way to load Java
classes: one embedded system dependent "trusted code" way to download classes from
the CLASSPATH (system classes) and the other to use your classLoader and manage
the security access with the securityManager (Applet download).]
Java is born as a proprietary product but today is become a instrument of all
Internet users !!!
101
“They love him, gentlemen, and they respect him, not only for himself,
.but for his character, for his integrity and judgment and iron will;
but he was most loved for the enemies he made"
102
103
Chapter 5 Download of DAB
Applications using Java
104
This is an introduction to the possible future implementations and a framework
to understand the simulation that we will describe in details in the next chapter.
Radio channel. The DAB signal, at the physical layer, carries simultaneously a
multiplex of several digital services, called ensemble, using some advanced modulation
technique (Orthogonal Frequency Division Multiplexing - OFDM) for increasing the
performance for mobile communication.
The bandwidth of the signal is 1.536 MHz with a useful bit rate capacity of
approximately 1.5 Mbit/s. In figure 1 you can see the physical layout of the data
transmitted on air using the DAB system. In figures 2 and 3 there are the logical scheme of
a DAB receiver and transmitter.
The ensemble contains several audio and data services decoded in parallel using
a time interleaving technique: that means that each receiver receives the information of
all the services in parallel and can select one of these.
NULL Symbol
TFPR Time Frequency Phase Reference
0
1 2 3 4 5 6 7 8 9 10 …. 74 75 76
1536 carriers
Guard
Interval
Useful Symbol ….
246 µs 1000 µs
256 1792
• Single Channel,
105
• Dual Channel,
• Stereo and
• Joint Stereo.
In the case of stereo and joint stereo channel the receiver will automatically reproduce the
audio signal as a two channel stereo comprising a left and right channel. In the case of
dual channel we can diffuse mono bilingual transmission.
Independently from the audio mode, the complete audio signal is encoded in one
DAB audio bit stream and can be accessed by the receiver as one integral Service
component (see next section for details about service components).
Using different combination of the previous technique we can have a
transmitting rate for the audio ranging from 32 kbit/s to 384 kbit/s: the DAB audio
system can provide typically 6 high quality stereo audio programmes or up to about 20
restricted quality mono programme.
DAB provides also three different ways to carry data services. A PDA channel
(Programme Associated Data) incorporated at the end of the DAB/ISO audio frame that
provides a data rate from 667 bit/s up to 65 kbit/s. Independent data services: general
data may be transmitted as a separate service; this may be either in the form of
continuous stream segmented into 24 ms logical frames (with data rate of n x 8 kbit/s) or
in a packet mode. A third way is to carry data as a part of FIC (Fast Information
Channel): a unique data channel to transport information about the configuration of the
ensemble, that sometimes is used to transmit extra data.
In the next two figure you can see the scheme of a DAB Transmitter and a DAB
receiver.
OFDM Transmitter
Audio Audio Channel
Services Encoder Coder
Multiplexer
Radio Frequency
MSC
Data
Packet Channel
Services
Mux Coder
106
Tuner OFDM Channel Audio
Demodulator DeCoder Coder Audio Service
The DAB system permits two mode of transmission: stream and packet. Information
inside the MSC channel is time interleaved: this permits to transmit "contemporarily"
different services. Using some additional fragmentation blocks of the MSC we can divide
the whole MSC channel in different subchannel, each carrying a different service
component (audio stream data, stream and packet data).
Services & Service Components. Inside an ensemble are available different services and each
service can contain one or more service components. A service component can be an
audio component or a data service component (see fig. 5).
107
EnsembleID DAB ensemble X
Traffic
Service Audio Message
Service
Information Audio
Component Channel
MCI SI
All the information about the configuration of the ensemble are inside the MCI (Multiple
Configuration Information) in the FIC channel. The programmer can select different
service and different service components using a set of identifiers. The service
organization defines the relationship between the services and the service components
(see fig 5) carried in the ensemble. Each service can be identified by a Service Identifier
which, when used in conjunction with an Extended Country Code, is unique worldwide.
Service components can be carried in a stream or in the packet mode: in the last case we
need some additional signaling of the subchannel and the packet address.
For the management of multimedia objects (image files, HTML pages, Java class), it has
been introduced an additional software layer, the MOT protocol.
MOT (Multimedia Object Transfer) Protocol. For the transmission of multimedia information
the DAB system makes use of the MOT protocol. The MOT is a data transport protocol
specified to provide a framework for the transportation of multimedia objects. Basically
an MOT object is an ordered collection of three parts:
• header core
• header extension
• body
The header core contains information about the size and the contents of the object, so
that the receiver can determine whether it has system resources to decode and present
the object or not. The header extension includes information that supports the handling
of the object and provides additional information that can support an application. The
body carries any kind of data, where structure and content of the data is describe in the
header core and header extension.
108
For transportation the object split into several (at least two) segments. The header is
separated from the body during transportation in order to have the possibility to repeat
the header several times, to send the header in advance and to send the header
unscrambled with the body scrambled.
In MOT protocol are defined different kind of contents: MIME/HTTP, ASCII, ISO 646,
HTML for text; GIF, JFIF, BMB for images, MPEG family for audio; and Java for code.
Today some extension are required for implementing new services and for integrating
new multimedia objects.
109
DAB Browser DAB Navigator
on air
DAB carosel
The basic mechanism that we have used for the integration/simulation of the
Java VM and the DAB channel is based fundamentally on these two applications. In the
case of download Java application we need a more sophisticated framework to manage
the loaded code (see details in the next chapter).
In the DAB navigator we have embed the Java VM as a COM component. Each
time a Java service is required, we load the needed libraries and we initialize the VM. We
have seen that in general we have to pass as argument the name of the starting class; in
the simulation we use a specific class Loader as loader and the file system as the class
repository. In the future, using special native method to control the DAB driver, we can
fetch the data directly from the DAB system. In the next figure we can see the basic
architecture used in the simulation.
110
DAB/MFC
app DABViewer dab.class
DAB.class
JVM
DAB.class
DABViewer.class
c:\dab\java
Figure 45: Integration of the Java VM inside the DAB Navigator (simulator scheme)
111
From the point of view of service providers these functions have to be a high
level API and they have to delegate all specific controls and data management inside the
particular implementation.
Some additional extensions are required in the DAB entries inside the FIC block.
The main parameters, which characterize the DAB applications, are the AppID and the
ProfileID. The first one is a reference of the kind of application inside a DAB data
service: up to now there are two AppID, one for the Broadcasting Web site and the other
for the Slides Show application. For adding the Java services we need a specific AppID
that refers to the Java VM.
Traffic
Service Audio Message
Service
Information Audio Java
Component Channel VM
MCI SI
Figure 46: New services could be available with the Java VM integration
112
Java classes: trusted and untrusted code. The first one is referred to Java classes of the
core APIs (java.lang.*, java.io.*) loaded by the system class loader (sometime
called primordial class loader): no checks are performed on these classes because are
considered trusted. [It is up to the user to manage the CLASSPATH variables]. The
second are all the classes loaded by a subclass of the classLoader class: for example
Applet loaded by the URLClassLoader used by Browsers or the DABClassLoader
used in our project (see next chapter for details).
In JDK 1.1 a digital signed/certification mechanism has been introduced for load trusted
code, but at the moment we don't consider this particular case.
Each time an untrusted class attemps to access a critical resources, inside the API
methods there is an explicit call to the securityManager and a check is performed
calling a specific checkXXX() method. For example when an Applet try to access the file
system reading or writing a file, inside the read() and write() methods there is a call
to the corresponding checkRead()/checkWrite() methods of the
securityManager; it is up to the securityManager implementation performs all the
checks and in case throw a securityAccess Exception (see chapter 4 for more details).
Although Java is a general purpose distributed platform, most of the default
protection mechanisms are implemented for a specific computer-based, network
machine: it follows a list of all the critical resources checked by the securityManager.
Developers can extend the set of checkXXX methods to perform some specific
controls. This is the basic approach that we will follow for our DAB Security policy.
113
Level 3 Changing the DAB tune()
ensemble
We need now some information about the requirements of the selected services
(information taken from the DAB FIC data) and the local security configuration data that
users are supposed to provide for each kind of selected services.
From DAB channel we can retrieve for example three fields in the FIC block:
ServiceID (relative to the service provider), ApplicationID (relative to the kind of service)
and ProfileID (relative to source or security requirements).
For example: provider X (ServiceID) broadcasts a data service that needs a
certain level of accessibility (ProfileID) for executing the contents of MOT java objects
(AppID). User A can choose to configure the security permission or accessibility locally
to its DAB receiver depending of the kind of services or AppID (Slides Show, HTML
Browsing, Java Applets) or the kind of provider or ServiceID (Sony, BBC, CNN, HP).
At start up the information from FIC block and from local configuration is
compared and only the services that match the requirements are shown. At runtime each
critical access is checked by the securityManager to control if the application follow the
local security constraints.
The securityManager have to implement some extra checkXXX() methods (for
example checkGetObject()) in which we can implement our controls; for each critical
methods we have to call the securityManager checkXXX(). This is compliant to some
aspects related to our simulation: in fact we use for example for accessing a native
method service a special class inside our DAB package. The Applet will use our class, but
inside we implement our control.
Applet
DAB Audio services
carosel
Applet MOT
Applet
securityManager
114
115
116
Chapter 6 Simulation
117
This simulation can be seen as the future framework for a complete integration
between DAB/Java (see next chapter).
Step 1. At start up we execute a simple dialog base frame in which we list all the
service available. All these information in the simulation are embedded in the
code, but in the real application are retrieved from the FIC block of the DAB
system.
Step 2. The user select a service. If it is a HTML service we use the AciveX Web
Browser control in a separate frame for showing the contents of some pages. If
we select the Java service the following service follow:
Step 3. We instantiate the C++ JView class. This class is only a wrapper class to load
the msjava.dll library (using the COM mechanism) in the process memory
space.
Step 4. We start the execution of the VM calling a special Invocation API (see next
sections for details) function and passing as arguments the name of the
DABFrameViewer and the location information of the Applet (name and
position). These information in the simulator are just the name of the Applet
class and the directory location; in real application we can pass all the needed
information to localize and control the Applet.
Step 5. The Java DABFrameViewer class is started and a new Frame appears in the
video; we instantiate the DABSecurityManager and the DABClassLoader;
the arguments passed to the DABFrameViewer are used by the
DABClassLoader to localise the Applet.
Step 6. The Applet is loaded by the DABClassLoader, it is instantiated and shown
inside the Panel of the main Frame of the DABFrameViewer.
Step 7. User can start manually the Applet using a START button.
118
1 Ex:
sony c:\sony
dab c:\sony\dab
resources c:\sony\dab\resources
2 html java
…\java
…\html
img …\html\img
service1 serviceN …\java\service1
service2
3
pJV = new CJView(argc,argv);
c:\sony\dab\java
..
pJV->Initialize();
DABApplet.class
4
C++
servicesAvailable[0].appID = JAVA_APP;
servicesAvailable[0].fileName = "TicTacToe";
servicesAvailable[0].resourcePath = "service3";
... pJV->ExecuteClass(..)
5 7
JAVA
6
DABClassLoader
DABSecurityManager
3. call a set of functions (Invocation APIs) to inizialise and start up the JVM;
4. pass the name of the first Java application (normally loaded from file
system).
119
DECLARE_INTERFACE_(IJavaExecute, IUnknown)
{
/* IUnknown methods */
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID *ppvObj) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
/* IJavaExecute methods */
STDMETHOD(GetDefaultClassPath)(THIS_ LPOLESTR *ppszClassPath) PURE;
STDMETHOD(Execute)(THIS_ LPJAVAEXECUTEINFO pjei, LPERRORINFO *pperrorinfo) PURE;
};
DECLARE_INTERFACE_(IJavaExecute2, IJavaExecute)
{
/* IUnknown methods */
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID *ppvObj) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
/* IJavaExecute methods */
STDMETHOD(GetDefaultClassPath)(THIS_ LPOLESTR *ppszClassPath) PURE;
STDMETHOD(Execute)(THIS_ LPJAVAEXECUTEINFO pjei, LPERRORINFO *pperrorinfo) PURE;
/* IJavaExecute2 methods */
STDMETHOD(SetSystemProperties)(THIS_ LPENUMJAVAPROPERTY penumProperties) PURE;
STDMETHOD(SetClassSource)(THIS_ DWORD dwType, LPVOID pData, DWORD dwLen) PURE;
};
// {3EFB1800-C2A1-11cf-960C-0080C7C2BA87}
DEFINE_GUID(CLSID_JavaExecute,0x3efb1800, 0xc2a1, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0xc2, 0xba, 0x87);
// {3EFB1803-C2A1-11cf-960C-0080C7C2BA87}
DEFINE_GUID(IID_IJavaExecute,0x3efb1803, 0xc2a1, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0xc2, 0xba, 0x87);
// {D7658820-01DD-11d0-9746-00AA00342BD8}
DEFINE_GUID(IID_IJavaExecute2,0xd7658820, 0x1dd, 0x11d0, 0x97, 0x46, 0x0, 0xaa, 0x0, 0x34, 0x2b, 0xd8);
DABClassLoader. It is the more important components of our project. Using the flexibility
of this component we can implement our specific loading process through different
channels: in this case it is a search inside a particular hierarchy directory; in the future we
will implement a particular access to the DAB channel using native methods.
DABSecurityManager. This is the central control for every critical access to the resources of
the DAB terminal. Before starting the implementation of the securityManager we have to
gather all the critical methods we want to control: for example the access to the file
system, the access to some DAB services (accessing MOT files, tuning, etc). Then inside
these methods we have to call explicitly the securityManager to control and filter the
access.
120
DABApplet. For the simulation we have used two very simple Applets. Applet are a good
model for moving application in a network: flexibility, security and easiness. Although
Applets are a good example, they are implemented for being execute inside a Web
Browser: the methods they use are suitable for managing the behavior inside a Web Page,
the special interface is suitable for linking to the particular framework of the Web
context, etc.
An alternative solution could be a new Applet design: new methods, new attributes, new
context. In these case we lose all compatibility to the Internet applications, but we can
develop a more flexible solutions for the DAB system.
These alternatives are linked to the requirements of the DAB download applications: in
the case Java would be a possible platform for DAB applications, the DAB community
have to open a discussion also on these aspects related to the DAB design.
DABNative. These component has been introduced for testing the call to a native function.
This class is stored in the package that have to be provided locally (trusted code - see
chapter 4 for details). There are different possible implementation. One is to use the
DABNative as a normal system classes (for example as the Socket.class or the
System.class); in this case the Applet can use directly a DABNative object and call the
special methods. The second solution is to use static methods: in this case we don't need
to instantiate any object, but we can directly call the required methods. At the moment
we have chosen the first solution.
The native library is implemented using the RNI provided by Microsoft (see fig.
50). Inside the DABNative.class we load the external library (TrafficMS.dll) and
we implement the native mathod.
#include <varargs.h>
#include <native.h>
#include <stdio.h>
#include "DABNativeInterface.h"
__declspec(dllexport)
DWORD __cdecl RNIGetCompatibleVersion()
{
return RNIVER;
}
__declspec(dllexport)
struct Hjava_lang_String *
__cdecl DABNativeInterface_getTrafficMS (struct HTrafficAppletMS *phThis)
{
return makeJavaString("Hello from native code !!!!", 27);
}
121
This component is the basic skeleton for the implementation of native methods to
access the DAB devices.
122
123
Chapter 7 Java DAB Package: a
Complete Java Solution.
124
all the necessary functionality to access specific platform dependent resources, for
example the DAB system.
Some parts of the DAB system are not still standardized (the DAB API at the
application levels, the OS platform for DAB receivers, the contents types for MOT
objects), but we can give some basic steps to use as a starting point for the DAB/Java
integration.
Java is a ″open″ technology and Java developers have thought about a way to
expand the Java VM both at the API level (packages) and at the OS level (Java Native
Interface) (see chapter 4 for details); also Java could be a suitable platform for the DAB
system (see chapter 3).
Using the standard way to expand the JVM and following the different examples
of native extension of JVM core packages (AWT, Serial Communication, JDBC) we tried
to give some basic principles for building a complete DAB package in order to apply
completely the ″Java paradigm″.
The Java platform will be a useful platform to develop both download
applications, but also to develop application inside the DAB system. Java provide 4
different implementation of the Java VM related to different hardware profile: Full Java,
Personal Java, Embedded Java and Java Card. Using the flexible platform, API, and the
extension mechanism we can fit Java in the DAB system.
Usually the native applications are pre-installed in the receiver by the
manufacturers. Personal Java, for example, provides some interesting features for
creating native application in a very dynamic way; we can divide the applications in two
separate portion: one is the core code for the main services, and the second is an
additional part that can be update for adding more features.
* a native library to initialize, control and access the DAB system (we can call
Jdab.dll)
* a new extension to the Java API (a new package javax.sony.dab)
* possible embedded Java DAB applications
The first part is a complete set of functions written in native code (C or C++) that access
the DAB services at high level through a particular interface (RS232, FireWire link or
specific card). All the interface mechanisms for managing the DAB system should be
implemented at this level: setup of the connection, MOT rebuilding, selection of services,
tuning, access to the native API (WIN32), etc.
125
New extension
Java DAB
javax.sony.dab.Applet.class
java.lang.*
java.io.* Java core javax.sony.dab.Viewer.class
java.awt.*
API API javax.sony.dab.ClassLoader
…..
…..
JdbcOdbc.dll
…..
The second part is an additional package that create a complete set of Java classes
to control and manage a DAB system in the Java platform. This package will be the DAB
API for all applications written upon the Java VM (see the figure 3) and it will the platform
independent API for all possible JDAB applications.
The third part refers to the possibility of implementing some special application
using the JDAB. In general it not secure (but possible) to load Java applications from the
external environment (from the network, but also from the DAB channel). Applications
are developed and stored locally in the system (or embedded inside the davice): for
example an HTML Browser, a Slides Show Viewer, but also a DAB System Manager, etc.
Traditionally the Broadcast receivers are not accessible as a network computer, but
sometimes there is the need to develop sophisticated applications.
The security of the applications in this case is assured partially by the DAB manufactories
(Sony, Mitsubishi, Grundig) and by the physical storage inside the DAB receiver (ROM).
126
Basically we need an extension package to implement the DAB access from the Java
system because the Java API is developed to be portable. The DAB system is a new
medium for the Java platform for receiving information and it is not a standard device
implemented inside the core Java API as a file or a socket network access.
Another reason to add some extra facilities to the JAVA API platform is that the
DAB system need some special management mechanism and some special data objects to
receive information: events management, special control, calling services, security
architecture.
We can summarize in some specific sections the needed extra classes for the DAB
package:
* Security Management
* Resources Loading Process
* Special Data Classes
* General Management of a DAB System
* DABApplets
* DAB Controls
* DAB Event Management: Asynchronous Events
Resources Loading. The Java environment gives the necessary class to implement a
particular loading mechanism: the ClassLoader class.
We have to implement a new mechanism to load the Java application from the DAB
channel: in these case we can use some special native methods to load the data from
special buffers or we can implement a callback mechanism to receive the needed code
from the file system. Also we have to manage the loading of resources from the DAB
channel: Java application (single or jar files), but also images, text, mail, etc.
We have to decide where load the system classes (including the DAB package): from a
file system, from a ROM memory.
Java is suited for embed inside ROM memory all the necessary code, both the interpreter
and the basic API: today there are some example of Java embedded inside small devices
as phones, TV set-tops, hand held devices, cell phones, pagers, watches, etc.
(http://www.javasoft.com/features/1997/oct/Personal.Embedded.html)
127
Special Data Classes. We have seen that the DAB system use a special protocol to code
multimedia information, the MOT; but also we have seen that on the DAB channel there
are a collection of information related to specific services. We have to create some special
objects (in Java all is an object) to wrap the information received through the DAB
services. A class for MOT objects, for FIC data (configuration information), for Service
Label associated to audio services, etc.
General Management. To manage the DAB application environment we need some extra
classes like new event classes, new exception classes, etc.
All these additional classes are used to exchange specific information related to the DAB
environment and are used to control and manage information between each single part
of the DAB Framework. We need also a container for the loaded application
(DABApplet), that manages in a dynamic way the interaction with the downloaded code.
We need to manage the runtime environment to limit the access to resources (video,
memory, CPU, etc.).
Also we need to define the interaction with the user to implement a new model for
interacting with the DAB applications.
Normally in the Applets framework there is a set of interfaces that create all the
necessary connections for managing the interactions between different objects: for
example the AppletContext and the AppletStub interfaces; developers are in that
way free to implement in a flexible way their computing environment, but they use the
same architecture.
API
• Exceptions • Interface
• Errors • Hooks to Runtime
• Events • Permission
• Synchronization • Certification
• DABViewer mechanism
DABApplet. This is the base mobile object to move code through the DAB channel. We can
define a subclass of the Applet class and specialized the DAB Applet or we can build a
completely new object component for adapting to the DAB requirements.
128
We have to think of the internal behavior of the loaded application (a well define set of
methods) and all the possible hooks to the runtime environment or the DAB controller.
Also in this case we need to define the interaction of the user with the DABApplet.
DAB Control. This is the most critical section of the entire package. We have to study all the
details about the accessibility to the DAB device. The majority of the methods to
implement here are native, because they access the native environment ! These set of
classes are the bridge to the native library implemented in a platform dependent
languages.
Some of the services to implement are: initialization of the DAB device, communication,
exchange information, request/replay/notify mechanisms, data caching, etc.
For implementing these particular class (or set of classes) a standard DAB API is a must:
developer need specific interface for reducing time for porting in different DAB platform.
DAB Event Management. In the DAB system, some interactions are asynchronous. Some
notification mechanism are implemented used some specific callback mechanism. In Java
we can implement that mechanism using the approach followed in the AWT Event
architecture. In this case we have to define some Event dispatcher thread, some new
events and some new Event listener.
A simple implementation could be: a dispatcher thread polls an event queues and using a
native call retrieve some event object; for each particular object a source object is bound
to the event; if a listener object is defined and set for that particular source, the
corresponding callback method is called.
D A B Weather
B r o w s e r Broadcast
DAB package
Java DAB Apps
Multimedia GPS Slide
Show NavigationSystem Show
Java VM
Java API Java DAB sony.dab.Applet.class,
API
java.lang.*, java.awt.*,java.net.*, sony.dab.Viewer.class,
java.io.*, java.applet.*, etc sony.dab.ClassLoader
Win32 platform
Win Basic API
GDI32.dll, KERNEL32.dll,
USER32.dll, ADVAPI32.dll,
etc
129
" Not high tech, not low tech, just the right tech."
(Mark W. McBride on Scandinavian PC Systems)
130
Conclusions
Distributed computing, DAB, Java: these three words are the main topics in this
work.
Distributed computing is a revolutionary paradigm in computer industry; DAB
is a revolution in the Broadcast systems; Java is a revolution in the programming
languages. In this thesis we have tried to find an integration for these three technology
for implementing modern services and for adding a new step toward the concepts of
ubiquitous computing.
We have used the typical approach of industry researchers: we started from
theoretical aspects of mobile code models, we passed through the available technologies
present in the market and finally we have developed a new sperimental application to
test the possibility offered by a specific tools, Java.
131
We know that there is no a optimal technology to solve every problem: software
engineering is a branch of engineering that tries to find out for each particular system the
best solution.
Our investigation proved first that a mobile code approach extends the
capabilities of the DAB terminal environment; it prepares the DAB system to the
challenge of the future competition for providing data services between different
communication technologies: GSM, GPS, Internet, etc.
In this context Java can be a good choice from different point of view. From the
manufacturer point of view Java is a common solution for most of the present and future
embedded system; it is a de facto standard platform and a standadisation process is
running for a de iure acceptance. From the content provider point of view Java is a very
flexible and complete platform to integrate different computing fields: data manipulation
, multimedia, network access, etc. Finally from the developer point of view Java is an
easy programming language for fast development.
Now it is time to start a dialogue between different parts in the DAB community
for exchanging the sperimental results and think about the next steps.
132
133
References
Chapter 1 and 2
Programming Languages for Mobile Code - T.Thorne - INRIA n°3134 (Mars
1997)
Understand Code Mobility - A.Fuggetta, G.Picco, G.Vigna - IEEE (1998)
Mole - Concept of a Mobile Agent system - J.Baumann, F.Hohl, K.Rothermel,
M.Strasser - Universität Stuttgart (August 1997)
A Note on Distributed Computing - J.Waldo, G.Wyant, A.Wollrath, S.Kendall -
Sun Microsystem - (November 1994)
Design Distributed Applications with Mobile Code Paradigm - A.Fuggetta,
G.Picco, G.Vigna - Politecnico di Torino/Milano (1997)
6. Mobile Code Paradigms and Technologies: A Case of Study - C.Ghezzi, G.Vigna -
Dip. Di Elettronica e Informazione, Politecnico di Milano
7. Comparison of Mobile Agent Toolkits for Java (Draft) - Steven Versteeg - June 19,
1998
8. WWW sites (http://):
a) www.worlddab.org
b) www.club-internet.fr/dabfrance/
Chapter 3
134
1. Java Beans and ActiveX go head to head - Merlyn Hughes [JavaWorld (March 1997)]
2. Java Beans Specification - Sun Papers
3. The Java language Specification - Java language Series
4. Using Inferno to Execute Java on Small devices - C.F.Yurkoski, L.R.Rau, B.K.Ellis -
Bell Labs -
5. Tcl and Java Integration - Ray Johnson - Sun Microsystem Laboratories (February 3,
1998)
6. Java Aglet Application Programming Interface - D.B. Lange - White Paper -
7. Inferno Programmers Guide (http://www.lucent-inferno.com)
8. Choosing a Scripting Language - C.Laird K.Soraiz SunWorld - October 1997
9. Mico is CORBA by Kay Römer, Arno Puder
10. Mole - Concept of a Mobile Agent system [chapter 1 ref 3]
11. Programming Languages for Mobile Code - T.Thorne - INRIA n°3134 (Mars 1997)
Chapter 4
1. Java Native Interface Specification - Release 1.1 - Sun Microsystem (May 1997)
2. The Java Virtual Machine Specification - T. Lindholm, F. Yellin
3. Thinking in Java - Bruce Eckel
4. Experience with Secure Multiprocessing in Java - Li Gong, D. Barfanz
5. Java Garbage Collection for Real Time System - A. Petit-Bianco - [DR.Dobbs october
1998]
6. Extensible Security Architecture for Java - D.Wallach, D.Balfanz, D.Dean, E.Felten
[Department of Computer Science Princeton University]
7. Java Security - J.A.Bank - MIT Report
8. CACAO - A 64 bit Java VM Just-in-Time Compiler - A.Krall, R.Grafl - Institut für
Computersprachen technische Universität ( Wien)
9. The Java Extension Framework
(http://java.sun.com/products/jdk/1.2/docs/guide/extensions)
10. Java Security - J.A.Bank - MIT Report
11. Java Security Architecture -(JDK 1.2) Li Gong
(www.javasoft.com/products/jdk/1.2/docs/)
12. Java for Embedded System: a tutorial (D.Mulchandani) IEEE Internet Computing [
May-June 1998]
Chapter 5
1. Window NT Internals
2. Radio broadcast system: DAB to mobile, portable and fixed receiver (Final draft ETS
300 401) November 1994
3. Specification of the Multimedia Object Transfer Protocol (MOT) - Eureka Projects
147 -
4. DAB Data Service - Overview of Current Technology - R.Bittner, R.Schäfer - 104th
AES Convention
Chapter 6
1. Java Native Interface Specification - Release 1.1 - Sun Microsystems (May 1997)
2. Web sites (http://):
a)premium.microsoft.com/msdn/library/ - MSDN Library
135
b)www.q-tek.com/scripting/JavaDocs/ - Microsoft SDK for
Java 2.0
c)msdn.microsoft.com/developer/sdk/inetsdk/
3. MSDN Library - January 1998 by Microsoft
Chapter 7
1. Web sites (http://):
a)
b)
c)
2.
136
137