The invention relates generally to methods of and computer systems for loading object-oriented computer programs. More specifically, although not exclusively the invention is concerned with object-oriented programs in which the code is provided in the form of class files, each containing a plurality of methods.
A well known example of an object-oriented programming language is “Java” (a trade mark of Sun Microsystems Inc.). A “Java implementation” is a software system which allows a software application consisting of one or more class files to be run. These class files must conform to some version of the standard Java Virtual Machine Specification, as published by Sun Microsystems Inc. A class file defines the data and program code required for a particular class.
Although there is some interaction, the Java implementation can conceptually be divided into two parts:
The program code in a class file is in an instruction format known as Java bytecode (JBC), or simply as bytecode. Each method in the class has its own sequence of bytecode. The bytecode for a method consists of a sequence of JBC instructions.
There are two schemes which JVMs use to execute the bytecode:
Some JVMs use a combination of the two schemes, where only program code which is being executed many times is compiled, and the rest is interpreted.
Linking is the process by which a reference from one class C1 to another class C2 (or data or a method in C2) is resolved. If C2 is not already loaded, it is loaded, and compiled if using the compiler scheme, and itself linked. Then the reference in C1 to C2 (or some item of data or a method in C2) is modified such that there is now a direct pointer to whatever in C2 is being referred to.
Sun's Java Virtual Machine Specification allows for a range of linking schemes:
In operation, when a particular method of a particular class is invoked, the particular class required may or may not already be resident in the JVM. If the required class is not resident, then the class file for that class must first be loaded from outside the JVM (for example from a disk or from a network), linked and initialised into the JVM. Then, the required method can be found by looking down the list of methods for the class. Once the required method has been found, the Java bytecode of that method is executed until a return is encountered, whereupon the method has ended and control is returned to the invoker of the method. A method invocation can also be terminated by an exception being thrown which is not caught in the method.
The server 210 supplies the class files 211, as necessary, across a communications network generally indicated at 250 to the clients 230,240. In this example, the processors 230,240 are of two different types—namely client type 1 and client type 2 respectively. Each of the clients maintains its own JIT, respectively 231,241, enabling it to compile the received class file 211 to its own version of native code 233,243, and to store that in its own native code store 232,242. In addition, and as previously described with reference to
In an alternative prior art arrangement (not shown) the client JITs 231,241 may be maintained on the server 210, with the conversion to native code being done there rather than at the clients 230,240.
There are several disadvantages with either prior art arrangement. Firstly, in each case, a large execution environment is required on each of the clients. In addition, either the Java class file 211 or the native versions 233,243 along with the class file remains 234,244 need to be transmitted across the communications network 250, and remain in client memory. Either approach is unsatisfactory in practice, particularly in the context of wireless client networks such as mobile cellular phone networks, since the class files are typically large.
According to a first aspect of the present invention there is provided a method of loading an object-oriented computer program comprising program code provided in the form of classes each containing a plurality of methods, the methods comprising compiling a method of the class into compiled code and holding that code, ready for execution, in an execution environment which does not necessarily also hold program code of the said class. Typically, although not necessarily, each class will be defined by an individual class file, in which case the invention provides that the execution environment does not necessarily also need to hold the original class file.
The program code representing the original class and/or class file is in the present invention not required to allow the compiled code to run in the execution environment.
In the preferred embodiment, compilation proceeds by a two step process. In the first step, the program code (for the example the bytecode of the class) is translated into virtual processor code which uses the instruction set of a virtual processor. In the second step, the virtual processor code is translated into native code, which uses the instruction set of a real, physical processor.
The invention in its various aspects improves memory utilisation by dispensing with the need for the original class file to be held in memory, in case it should be needed by the executing application. By using the two stage translation process described above, application programmers can design programs in a high level language (such as Java), without having to worry about the typically large size of the Java class files. The invention in its preferred form allows an application to be written in a high level memory-intensive programming language such as Java, while at the same time allowing the resultant program to be run within an extremely small “footprint”. This is particularly useful when the application is to be used in an embedded system, such as for example, a mobile phone, a hand held computer, or a games console.
The invention may be used in conjunction with a number of different linking schemes, for example static linking, dynamic load time linking, and dynamic late binding.
According to a further aspect of the invention there is provided a computer system for loading an object-oriented computer program comprising code provided in the form of classes each containing a plurality of methods, the system defining an execution environment and being operable to compile a method of the class into compiled code and to hold the compiled code, ready for execution, in the execution environment, the execution environment not necessarily also holding program code of the said class.
According to yet a further aspect of the invention there is provided a distributed computer system comprising a server in communication via a transmission means with a plurality of client devices, each having a respective execution environment for executing an object-oriented computer program comprising program code, provided in the form of classes each containing a plurality of methods, the system including:
According to yet a further aspect of the invention there is provided a computer system for loading an object-oriented computer program comprising program code provided in the form of classes each containing a plurality of methods into a plurality of client devices, the devices each containing a respective execution environment, the system comprising:
The invention, in this aspect, allows application programs to be multiply uploaded into a plurality of individual client devices, for example mobile phones. The compiled code may be uploaded into the phone memories without any need for the original class file or the program code to be uploaded.
According to another aspect of the present invention there is provided a method of loading an object-oriented computer program comprising code provided in the form of classes each containing a plurality of methods, the method including:
The method of the invention provides all of the dynamic features of the Java Virtual Machine (JVM), but with a substantially reduced footprint compared with conventional approaches.
In its preferred form, the invention provides fine granularity of binding/linking, loading, compilation and transmission across a communications network. More specifically, the granularity is at the method/tool level rather than the class level as with conventional object-oriented systems. The invention is particularly although not exclusively applicable to a Java Virtual Machine (JVM) environment. The invention provides for the entire range of JVM linking schemes, namely static linking, dynamic load time linking and dynamic late binding. Specific fields of application for preferred embodiments of the invention include wireless communications (wireless client networks), and specifically although not exclusively mobile cellular phone networks. The invention may also be applied to other embedded devices, preferably networked devices, such as (without limitation) hand-held computers, games consoles, cameras, or indeed any other type of networked or networkable device. In one embodiment the system may consist of or include a wireless network, whereas in other embodiments it may include a private or public fixed network, or the Internet. Where the client devices are not capable of wireless communication, provision may be made for them to be coupled to the Internet as required (for example via a standard modem or ISDN link). In such a way, the invention could be applicable to a wide range of embedded devices, including for example cameras, televisions, washing machines, motor vehicles or indeed virtually any other type of computer operated device that can be conceived of.
One advantage of the invention, when applied to wireless client networks, is that each individual transmission (of a method/tool) is of a significantly shorter duration than with conventional systems in which the entire class file has to be downloaded. This means that the network provider does not need to keep the virtual circuits of the network open for long periods. Each small method/tool to be transmitted can if necessary be routed differently. In addition, the transmission of smaller discrete chunks of data means that lower redundancy and error correction is required. The load on the network can therefore be reduced by a greater amount than would be expected merely by a consideration of the data transfer rates.
In its preferred form, the invention is particularly applicable for use with object-oriented computer programs that are to be compiled (rather than interpreted) prior to execution. When the invention is used in the context of a distributed computer system, the individual methods may be compiled either before or after they are sent across the network to the client device.
Preferably, the invention includes the preliminary step of translating the classes into a plurality of virtual processor tools which use the instruction set of a virtual processor. Then, the step of selecting one of the methods for execution may include selecting one of the virtual processor tools. When used in the context of a networked system, either the virtual processor tools may individually be transmitted across the network to the client device, or alternatively the individual virtual processor tools may first be compiled and the native compiled code transmitted across the network.
The invention further extends to a computer system adapted to carry out a method as previously described.
The invention further extends to a computer system for loading and/or executing an object-oriented computer program comprising code provided in the form of classes each containing a plurality of methods, the system defining an execution environment and being operable to select for execution one of the methods of one of the classes, and to load the selected method into the execution environment without necessarily loading into the execution environment the whole of the selected class.
According to another aspect of the invention there is provided a distributed computer system comprising a server in communication via a transmission means with a plurality of client devices, each having a respective execution environment for executing an object-oriented computer program comprising code provided in the form of classes each containing a plurality of methods, the system including:
The invention extends not only to methods and apparatus for loading object oriented computer programs, but also to methods and apparatus for compiling such programs, binding such programs, executing such programs, and transmitting such programs across a communications network.
Finally, the invention also extends to a computer program for implementing any of the described methods whether or not embodied on a data carrier. It also extends to a data stream representative of a computer program for carrying out the described method.
It is to be understood that; where used in the description and claims, the word “code” includes data where that data is part of the program itself. Accordingly, but without limitation, the expression “code” includes such things as constants, variable names and types, flags, pointers, object names and so on.
The invention may be carried into practice in various ways and one specific embodiment will now be described, by way of example, with reference to the accompanying drawings, in which:
a illustrates a variation of the embodiment shown in
The compiler 720 may be arranged to effect static linking, dynamic load time linking or dynamic late binding. It may convert the class directly into native code or, alternatively, as described below it may carry out the conversion in two stages.
In the present invention, conversion from bytecode to native code preferably takes place in two separate stages:
Once the code has been checked, it is passed to the jcode translator 212 which converts it, as described in more detail below, into VP code 213. The VP code 213 is then converted by the native translator 214 to the native code 230.
It is important to appreciate that the class verifier 211, the jcode translator 212 and the VP code 213 are all processor-independent. It is only the native translator 214 and of course the final native code 230 which is processor-specific.
Shown on the right hand side of
The use of the preferred embodiment within a heterogeneous multiprocessor environment is shown schematically in
In
The use of VP on the server, as shown in
With the approach described, it is not necessary to download across the network the Java class file 480, nor all of its individual methods 481. Only those VP tools which are actually required by the individual client applications need be transmitted across the network. The required VP tools may be either downloaded on demand (for example by means of a control signal transmitted from the client back to the server), or alternatively may be transmitted when the server determines that it is necessary. In one embodiment, for example, the server may transmit updated VP tools across the network in order to update an applications program which is running on the client. That could be done in real time, in a way which is entirely transparent to the end user. Alternatively or in addition the individual transmitted VP tools may represent “add-ins”, or additional functionality that the user wishes to add to an application program to be run on the client. In one particularly convenient approach, when the user attempts to make use of functionality in an application program for which code is not available at the client, the client automatically transmits a signal to the server requesting that the necessary VP tools be downloaded. The server responds by transmitting the requested VP tools which are then translated into native form by the local native translator 424,425.
Once the class file 480 has been converted to appropriate VP tools 482, the class file may be discarded from the server memory. Likewise, on each of the clients, once the downloaded VP tools have been converted into native methods 483,484, the VP tools may be discarded from client memory.
a shows an alternative embodiment in which the individual native translators are maintained on the server. In
In one version of this embodiment, a full collection of native methods for each of the client processors is stored on the server within respective native code stores 432′,442′. Since it cannot necessarily be determined in advance which methods will be needed by the individual clients, it is preferred that the entirety of the VP tools 482 be passed through the respective native translators 424,425 to provide a comprehensive selection of native methods 483,484. When a particular new or updated method is called for by the client, or is required to be sent by the server, the appropriate individual native method is sent across the communications network 450. As before, only individual methods are sent, not the entire class, nor all of the native methods which have been created from the original class.
In this embodiment, both the entirety of the class file 480 and the individual VP tools 482 may be discarded from server memory once the native methods 483, 484 have been constructed. It should be noted that no part of the class file, nor any VP tools, are downloaded across the network. Likewise, no part of the class file nor any VP tools are present in client memory. This ensures particularly efficient client memory utilisation.
In yet a further alternative method, the server need not maintain a complete collection of pre-translated methods for each possible client processor. Instead, when a particular VP tool is needed, it is translated on the fly by the appropriate native translator 424,425 and the native method transmitted immediately to the client.
Once specific implementation, illustrated in
Implementing a mobile telephone network (or indeed any other type of wireless client network) in this way allows the clients to download individual methods (each of which might be for example 100 bytes in length) instead of having to download an entire class (which might be for example 1 megabyte). Transmitting individual methods in this way also has advantages for the wireless network provider since virtual circuits do not need to be maintained open for lengthy periods while large files are being transmitted. Each small individual method can be routed differently. Also, the transmission of smaller chunks of data reduces the need for redundancy and error correction techniques, thereby increasing the capacity of the network over and above that which would be expected merely by a comparison of raw data transfer rates. The fact that no part of the original class file, nor the VP tools, need to remain in client memory means that the entirety of that memory can be dedicated to the storage of native methods, and to the running of applications in native.
For completeness, a detailed description will now be given of the preferred method by which the class file is converted into VP and the VP tools are converted into native. It will be understood that this is purely exemplary, and that the present invention is not limited to an embodiment in which there is a two-stage translation, first from bytecode into VP and then from VP into native.
Turning back now to
The JVM and the bytecode instructions it implements are stack based, which means that operands (numbers, pointers to objects) are kept on a stack, on which the last item to be pushed on is the first to be popped off. A bytecode instruction typically removes one or more operands from the stack, performs some action, and pushes the result operand (if any) back on the stack. On the other hand, VP is register based, in that it has a set of registers which are addressed directly by the VP instructions. An instruction typically takes its operand(s) from register(s) specified in the instruction, performs some action, and puts the result operand (if any) into a further register specified in the instruction. This register based architecture is more similar to most real processors, except that VP has a very large number of registers, large enough such that any system converting to VP does not need to worry about how many there are.
VP instructions are based around expressions. A single instruction typically has one or two operands, and each operand can be a constant, a register, or an expression. An expression then has one or two operands, each of which can be a constant, a register or an expression. In this way, an arbitrarily complex instruction can be built up.
There now follows a more detailed description of how parts of a class file are converted. The description uses the term “fixup”; this is a small item of data attached to a particular point in the compiler's output code or data which instructs the JVM that the code or data at that point needs to be modified in some way before it can be used. Fixups are used to change a native instruction or a data item such that the native code can obtain a direct reference to another class, or to a field or method therein.
A java class file consists of the following parts:
The Java class file is converted to VP tools as follows:
The jcode translator uses a VP register for each item on the stack.
VP code does not directly implement the class file's mechanisms for accessing another class, method or field from within the bytecode. In the bytecode there are instructions for, but not limited to, calling a method (in this or another class), getting the contents of a field (in this or another class), pushing a value onto the stack, popping a value off the stack and setting the contents of a field. The jcode translator converts these into VP instructions which may do one of the following (this is not an exhaustive list):
The constant pool within a class file is converted as follows:
The code section within a class file is converted as follows:
The calling conventions are rather different in bytecode and VP. In conventional byte code such as Java byte code, the parameters to be passed to a subroutine are placed on the stack, followed by a reference to the method to be called. A byte code instructions to call a method is then executed which takes the method reference from the stack, resolves it and starts executing the new method with the parameters from the stack. Control is returned to original method when a return instruction is executed. This is converted to VP which loads all the parameters into VP registers before executing a gos (goto subroutine) instruction which has been fixedup to point to the destination method (this fixup may be statically or dynamically found). Execution is passed to the subroutine and returns when a ‘ret’ instruction is executed.
Other parts of the file are converted as follows:
The final VP class comprises one or more named tools, normally including at least the data tool, the class tool, the fixup tool and zero or more method tools. The tool names are generated automatically by the jcode translator, each name being related to the name of the class and the function of each tool within the implementation of that class.
Turning back again to
The native translator 214 is quite a small piece of code (around 150 k, depending upon the processor), so that it can easily be stored in memory within an embedded system. The translator 214 maps VP registers to the registers of the particular processor being used. The translator uses its knowledge of the real processor's register architecture to decide at each point in the output native code which VP registers should be mapped to the real processor's registers, and which should be kept in memory (which is slower to access). The translator also provides machine-dependent optimisation of instructions. Until the native code is bound in, it will still normally contain sections of fixup code. On binding (or sometimes at run-time) the fixup code will be replaced with appropriate machine-dependent instructions. For example, the fixup for a non-static method will be converted to an atom in the native code.
Both the jcode translator and the native translator are themselves preferably written in VP code and can thus be translated (using the native translator itself) to run on any desired platform. From that initial VP code, compiled versions of both translators may be provided in native code, optimized for the particular processor on which the translator is to execute. To compile the VP code for the jcode translator, that code is passed through the native translator. To compile the VP code for the native translator, that code is passed through the native translator itself.
Although the preferred embodiment uses the Java Virtual Machine, the overall inventive concept is more general, and it is not essential to use the JVM, or indeed Java at all. Where Java is used, however, the invention described allows Java-skilled applicators programmers to develop programs in their preferred language, without having to understand, or even to know anything about, VP code.
| Number | Date | Country | Kind |
|---|---|---|---|
| 9921720.0 | Sep 1999 | GB | national |
This is a continuation of International Application PCT/GB99/04415 with an international filing date of Dec. 23, 1999, published in English under PCT article 21(2).
| Number | Name | Date | Kind |
|---|---|---|---|
| 5005152 | Knutsen | Apr 1991 | A |
| 5155847 | Kirouac et al. | Oct 1992 | A |
| 5295263 | Kojima et al. | Mar 1994 | A |
| 5367685 | Gosling | Nov 1994 | A |
| 5414855 | West | May 1995 | A |
| 5421017 | Scholz et al. | May 1995 | A |
| 5513355 | Doellinger et al. | Apr 1996 | A |
| 5560013 | Scalzi et al. | Sep 1996 | A |
| 5615400 | Cowsar et al. | Mar 1997 | A |
| 5634058 | Allen et al. | May 1997 | A |
| 5636276 | Brugger | Jun 1997 | A |
| 5684996 | Westerholm et al. | Nov 1997 | A |
| 5764989 | Gustafsson et al. | Jun 1998 | A |
| 5794049 | Lindholm | Aug 1998 | A |
| 5815708 | Kessler et al. | Sep 1998 | A |
| 5815718 | Tock | Sep 1998 | A |
| 5832269 | Döllinger et al. | Nov 1998 | A |
| 5838978 | Buzbee | Nov 1998 | A |
| 5920720 | Toutonghi et al. | Jul 1999 | A |
| 5937421 | Petrov et al. | Aug 1999 | A |
| 5950008 | van Hoff | Sep 1999 | A |
| 5978585 | Crelier | Nov 1999 | A |
| 6078744 | Wolczko et al. | Jun 2000 | A |
| 6081665 | Nilsen et al. | Jun 2000 | A |
| 6092120 | Swaminathan et al. | Jul 2000 | A |
| 6093216 | Adl-Tabatabai et al. | Jul 2000 | A |
| 6110226 | Bothner | Aug 2000 | A |
| 6115719 | Purdy et al. | Sep 2000 | A |
| 6139199 | Rodriguez | Oct 2000 | A |
| 6141794 | Dice et al. | Oct 2000 | A |
| 6151618 | Wahbe et al. | Nov 2000 | A |
| 6151703 | Crelier | Nov 2000 | A |
| 6158048 | Lueh et al. | Dec 2000 | A |
| 6219045 | Leahy et al. | Apr 2001 | B1 |
| 6295642 | Blandy | Sep 2001 | B1 |
| 6298477 | Kessler | Oct 2001 | B1 |
| 6330709 | Johnson et al. | Dec 2001 | B1 |
| 6338160 | Patel et al. | Jan 2002 | B1 |
| 6339841 | Merrick et al. | Jan 2002 | B1 |
| 6412107 | Cyran et al. | Jun 2002 | B1 |
| 6438745 | Kanamaru et al. | Aug 2002 | B1 |
| 6442753 | Gerard et al. | Aug 2002 | B1 |
| 6496575 | Vasell et al. | Dec 2002 | B1 |
| 6523171 | Dupuy et al. | Feb 2003 | B1 |
| 6530075 | Beadle et al. | Mar 2003 | B1 |
| 6584612 | Mueller et al. | Jun 2003 | B1 |
| 6606743 | Raz et al. | Aug 2003 | B1 |
| 6631521 | Curtis | Oct 2003 | B1 |
| 6637025 | Beadle et al. | Oct 2003 | B1 |
| 6691306 | Cohen et al. | Feb 2004 | B1 |
| 6704926 | Blandy et al. | Mar 2004 | B1 |
| 6745386 | Yellin | Jun 2004 | B1 |
| 6748588 | Fraser et al. | Jun 2004 | B1 |
| 6820252 | Sakamoto et al. | Nov 2004 | B2 |
| 6823509 | Webb | Nov 2004 | B2 |
| 6851111 | McGuire et al. | Feb 2005 | B2 |
| 6915511 | Susarla et al. | Jul 2005 | B2 |
| 6973646 | Bordawekar et al. | Dec 2005 | B1 |
| 6996829 | Meyer | Feb 2006 | B2 |
| 7017824 | Thiriet | Mar 2006 | B1 |
| 7031990 | Garthwaite | Apr 2006 | B2 |
| 7051323 | Lam et al. | May 2006 | B2 |
| 7058929 | Charnell et al. | Jun 2006 | B2 |
| 7076765 | Omori | Jul 2006 | B1 |
| Number | Date | Country |
|---|---|---|
| 0 406 028 | Jan 1991 | EP |
| 0 546 794 | Jun 1993 | EP |
| DE 196 20 888 | Nov 1997 | EP |
| DE 196 37 883 | Nov 1997 | EP |
| 0 811 911 | Dec 1997 | EP |
| 0810522 | Dec 1997 | EP |
| 0913769 | May 1999 | EP |
| 0 924 611 | Jun 1999 | EP |
| 0930567 | Jul 1999 | EP |
| 0913769 | Dec 1999 | EP |
| WO 9742728 | Nov 1997 | WO |
| WO 9743711 | Nov 1997 | WO |
| WO 9819237 | May 1998 | WO |
| WO 9837486 | Aug 1998 | WO |
| WO 9853398 | Nov 1998 | WO |
| Number | Date | Country | |
|---|---|---|---|
| 20040015914 A1 | Jan 2004 | US |
| Number | Date | Country | |
|---|---|---|---|
| Parent | PCT/GB99/04415 | Dec 1999 | US |
| Child | 10094241 | US |