
Object-Oriented Programming across Native-Virtual Boundaries Paul Werbicki Rob Kremer Computer Science Department Computer Science Department University of Calgary University of Calgary 2500 University Dr., NW, 2500 University Dr., NW, Calgary, Canada, T2N 1N4 Calgary, Canada, T2N 1N4 1-403-2841718 1-403-2205112 [email protected] [email protected] [email protected] ABSTRACT Keywords There exist many implementations of object-oriented Native-virtual boundary, interoperability, object integration, C++, programming languages that execute on virtual computers which Java, Java Virtual Machine, Java Native Interface, design abstract from native host environments. These languages provide patterns. developers with a highly mobile platform where applications may easily execute on multiple environments. However, there exist situations where it is not possible to abstract from the host 1. INTRODUCTION environment, forcing the developer to program at least part of the One of the tenets of interpreted programming languages, Java in application specifically to a specific environment. Developing a particular, is the ability to develop and compile software once and single application using both native and virtual code allows those have it execute, without modification, on all environments mobile portions to remain abstracted from the environment while supported by the virtual machine [4]. To achieve this, the at the same time providing the required native access. software must generally be written entirely in the interpreted programming language. In some applications, however, it may be This paper discusses using object-oriented programming to allow necessary to have portions of the software highly mobile, while the use of C++ and Java in a single application. A class library, other portions must take advantage of optimizations only developed as part of the investigation, is used to enhance the provided on a single native host environment. native-virtual boundary interface and provide the developer with support for the use of objects. By examining how the library A practical example of this type of application exists in the area of works it is possible to gauge the level of support currently Multi-Agent Systems (MAS). In these types of applications, all available for this technique. An analysis of the available support agent processes need to communicate regardless of the highlights where virtual machines need to provide additional environment in which they execute, but some provide services functionality to fully enable this method of programming. and use resources only available on specific operating systems and hardware platforms. Some components of each entity, specifically the communications library, benefit from being Categories and Subject Descriptors mobile without having to be ported to each new environment. D.3 [ Software ]: Programming Languages; D.1.5 [ Programming However, it may not be possible to port the entire agent. Techniques ]: Object-oriented Programming; D.2.3 [ Software Engineering ]: Coding Tools and Techniques – Object-oriented Some virtual machines provide methods for integrating both Programming ; D.3.4 [ Programming Languages ]: Processors - virtual code and native code within the same program. The Java Interpreters Virtual Machine (JVM) with its Java Native Interface (JNI) is a good example. Using the JNI it is possible to make calls into mobile components of the application without having to write the General Terms entire program in an interpreted programming language [5]. The Experimentation, Standardization, Languages. JNI exposes a set of C functions that provide a low-level method of manipulating, controlling and executing code compiled to run on the virtual machine. The JVM executes in the same process space and interacts with native code across the native-virtual Permission to make digital or hard copies of all or part of this work for boundary defined by the JNI. personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that The procedural approach used by the JNI does not lend itself well copies bear this notice and the full citation on the first page. To copy to using mobile code written as an object-oriented library. Instead otherwise, or republish, to post on servers or to redistribute to lists, of accessing objects using procedural-style JNI functions, it is requires prior specific permission and/or a fee. highly desirable from a software engineering standpoint to treat Virtual Execution Environments (Vee’05) , June 11-12, 2005, Chicago, these interpreted objects as normal objects within the native Illinois, USA. Copyright 200 5 ACM 1 -58113 -000 -0/00/0004…$5.00. portions of the application. To investigate this approach, JavaCOM [11] was developed, a class library written in C++ all supporting libraries and third-party software provided by under the Microsoft Windows family of operating systems. The all of the programming languages used in the application. use of JavaCOM makes it somewhat possible to treat objects 3. Single language for library/API development . Due to the within an interpreted library as objects within a C++ application increased access to supporting libraries, researchers and or as components within the Component Object Model (COM) third-party software developers do not need to support [6] in languages such as Microsoft Visual Basic and C++. different version of their software, one for each programming language they need to support. Instead they can concentrate This paper describes the challenges of trying to integrate on creating a single, mobile language API and allow the end- interpreted objects and native objects within the same application. user to integrate this into their application by integrating the The goal of this research is to attempt to achieve complete re-use programming language in which it was developed. of an object-oriented communication library for Multi-Agent 4. Code reuse without access to the original source code . In Systems written in Java within an agent application developed in situations where applications are being ported from one C++. In doing so the hope is to discover ways to achieve object- language to another (such as in legacy systems) the original oriented development using interpreted and native code within the source code may not be available. In cases like this it is same process. Where this is not possible, the goal is to propose possible to contain the original code and use it directly, requirements of virtual machines needed to support such instead of re-writing it and potentially introducing errors. applications. 5. Integration of specialized operating system components, hardware platform components and legacy software . 1.1 Paper Overview Accessing specialized components and integrating with This paper is structured as follows. Section 2 specifies the legacy systems is common in Software Engineering. problem further, providing reasons why it is desirable to mix Combining native and virtual code makes it possible to use native and interpreted code and introduces an application that these exiting pieces from newer programming languages. benefits from such a scenario. Section 3 outlines approaches used to contain the JVM in a native application. Section 4 describes With the popularity of new object-oriented programming the JavaCOM class library and how it abstracts from the JNI languages, such as Java, that are free from any procedural heritage using design patterns to achieve a level of integration. Section 5 (unlike C++) more code is begin developed and shared in analyses how JavaCOM use of proxy classes provides support for languages that promote only object-oriented development. object-oriented programming between C++ and Java. Section 6 Integration of these libraries into a native application using a presents requirements for the JVM and virtual machines in procedural interface, such as the JNI, is awkward. It breaks down general to fully support object-oriented programming. We the object-oriented paradigm [9] making it difficult for the conclude with the benefits this research has for software developer to write a “good” program. engineering in general and future work in this area. If a language is said to support object-oriented programming then it must provide facilities to make it easy to program using objects. 2. PROBLEM SPECIFICATION Even though two programming languages both support object- The ability to integrate libraries written in an interpreted oriented programming it may be difficult for the flow of control to programming language (such as Java) into an application written 1 pass from the first programming language to the second. This in a native programming language presents some interesting interaction may take exceptional effort or skill on behalf of the opportunities in software development. Interoperability between developer and merely enable the use of multiple programming programming languages impacts many aspects of an application’s languages within a single application, but not support it. To fully development cycle, from initial design decisions, to the cost of support object-oriented programming using multiple maintaining the completed application. From a software programming languages there must be support for making it easy engineering viewpoint, some obvious advantages include: to integrate objects. 1. Decreased need to choose a single programming language Support for object-oriented development
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages7 Page
-
File Size-