Abstract:
The present invention concerns an algorithm for optimising object code having a call chain of first, second and third methods, at least two of which are constructor methods. The algorithm comprises determining whether the second method only calls the first method, and if so replacing the call from the third method to the second method with a call from the third method to the first method. This code optimising algorithm is performed by an optimiser (52), which may for example, be implemented in a communications device, such as a terminal device (60)

Description:
BACKGROUND OF THE INVENTION  
         [0001]    The present invention relates to computer programming. More particularly, it relates to the production and use of optimised object code from object oriented source code.  
           [0002]    [0002]FIG. 1 of the accompanying drawings illustrates a programming process. In order to develop a program, a computer is required, with an editor  10  and compiler  20 , in addition to a processor  30  and operating system. The operating system provides an interface to the computer&#39;s hardware, so as to enable reading and writing to the computer&#39;s disk (memory), managing the files, etc. It also enables the programmer to activate editor and compiler software. The programmer writes a sequence of instructions using editor  10 . These instructions are collectively known as source code, and are generally in ASCII format. This source code is input to the compiler  20 . The compiler performs two functions. Firstly, it checks the validity of the source code and indicates syntax errors. Then, once any errors have been corrected, and the source code has been successfully compiled, the compiler translates the source code into compiled code. This compiled code takes the form of machine instructions of the computer&#39;s processor. This developed program is executed (run) by the computer&#39;s processor  30 , which activates it through the operating system. During the development process, the results are checked for any errors in the program&#39;s logic, and the process repeated, if necessary.  
           [0003]    The processor  30  used to run a program may be a processor of a particular platform (e.g. Macintosh, Pentium). In such a case, the compiler  20  translates the source code into machine code specific for that processor. Consequently, different object code is required for different platforms. However, alternatively, the processor  30  may be a virtual machine. A virtual machine may take the form of software installed on a computer to run a particular set of bytecodes that are platform independent. Programs may be run on the same computer on which they are written, or on another computer. If it is to be run on a different computer, the program may be loaded onto that computer or accessed remotely. FIG. 2 of the accompanying drawings illustrates a network of computers, terminals  21 - 24  and host  25 , through which remote accessing is possible. Assuming that the computers are of the same type (or they comprise a virtual machine), then the object code can be sent to and from any of the computers. For example, in an Internet scenario, if each of the terminals  21  to  24  has a Java enabled browser, then the host  25  sends Java over the net in object code format, known as bytecode. The virtual machine in each terminal&#39;s browser can understand the bytecode and interpret it into commands for the operating system of the recipient terminal (e.g., Windows, Macintosh, Solaris).  
           [0004]    Alternatively, if, say, terminals  21  and  22  are of different types, then either the source code would need to be sent and compiled by the recipient terminal, or the host would need to determine the type of the recipient terminal and send the appropriate object code for that type.  
           [0005]    [0005]FIG. 3 illustrates an alternative computer in the form of a handheld device  30 . As in the example of FIG. 2, object code may be stored on this device, or the device may be a wireless terminal which can access object code over a communications network  31 ,  32 . The host may form part of the wireless or fixed network.  
         SUMMARY OF THE INVENTION  
         [0006]    According to one aspect of the present invention there is provided an algorithm for optimising object code having a call chain of first, second and third methods, at least two of which are constructor methods, the algorithm comprising: determining whether the second method only calls the first method, and if so replacing the call from the third method to the second method with a call from the third method to the first method.  
           [0007]    According to another aspect of the present invention there is provided a method of optimising object code, the method comprising: identifying non-operative constructors within the class hierarchy; and replacing a call to a non-operative constructor with a call to the first operative constructor in the call chain; and/or eliminating a call to a non-operative constructor when all the constructors in the call chain are non-operative.  
           [0008]    According to a further aspect of the present invention there is provided an optimiser for optimising object code having a call chain of first, second and third methods, at least two of which are constructor methods, the optimiser comprising: a code analyser for determining whether the second method only calls the first method, and a code modifier for replacing the call from the third method to the second method with a call from the third method to the first method if the second method does only call the first method.  
           [0009]    According to yet another aspect of the present invention there is provided an optimiser for optimising object code, the optimiser comprising: a constructor type identifier for identifying non-operative constructors within the class hierarchy; and a code modifier for replacing a call to a non-operative constructor with a call to the first operative constructor in the call chain; and/or eliminating a call to a non-operative constructor when all the constructors in the call chain are non-operative.  
           [0010]    Aspects of the invention also extend to a device and/or system comprising an optimiser of the invention, as well as to a computer program for performing the algorithm/method of the invention and carrier, optimiser and device comprising such a program. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0011]    Embodiments of the present invention will now be described, by way of example, with reference to the accompanying drawings, of which:  
         [0012]    [0012]FIG. 1 illustrates the programming process;  
         [0013]    [0013]FIG. 2 illustrates a network in which a program may be run;  
         [0014]    [0014]FIG. 3 illustrates an alternative network to that shown in FIG. 2;  
         [0015]    [0015]FIG. 4 illustrates a program consisting of a number of classes;  
         [0016]    [0016]FIG. 5 illustrates a modified programming process according to an embodiment of the present invention; and  
         [0017]    [0017]FIG. 6 illustrates a terminal device according to an embodiment of the present invention. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0018]    The present invention is concerned with alleviating overheads inherent in object oriented programs. A brief summary of the fundamentals of object oriented programming is outlined below, so as to facilitate understanding of the present invention. Java is used as an exemplary object oriented programming language, but it will be appreciated that the invention may extend to other languages.  
         [0019]    A Java program consists of classes, as illustrated in FIG. 4. The program in FIG. 4 has four classes: Object, Mammal, Feline and Cat. Each class inherits from the class above it. For example, Cat inherits from Feline.  
         [0020]    The properties of a class include its name, structure (data members) and capabilities (methods). Take, for example, the code in Example 1. public class Mammal indicates the class name as Mammal, and that the class inherits from class Object (classes inherit from class Object by default, as is the case here; inheritance from other classes can be specified by the keyword extends). Next, the class includes a declaration private int numLegs=2, which is an integer number. The declaration sets aside storage in the computer&#39;s memory for each instance of this class, the amount of which depends on the type. Finally the class comprises a method public int legs ( ). That is, the method is called legs. A method definition includes the method name, return type and any parameters, followed by declarations and statements (instructions). In Example 1, the method legs has a return type statement, return numLegs. Other statement types include assignment, invocation, repetition, selection and exception.  
         [0021]    The structure of a Java program includes a class name, followed by a main method including any declarations and statements. In Example 1 the program has the class name createMammal. The main method is a void static method, indicating that it is a class method and doesn&#39;t return anything. It invokes a method callA that, in turn, creates an instance of Mammal (named myMammal) and invokes the legs method of class Mammal on this instance. When the Java virtual machine (JVM) is activated, it is given the name of the class containing the main method (createMammal in this case), and then looks for the method named main in that class and starts running it from there.  
       EXAMPLE 1 
       [0022]    [0022]                                                                                                                                             //Mammal.java           public class Mammal {                private int numLegs = 2;           public int legs () {                return numLegs;                }                }           //createMammal.java           public class createMammal {           public static void main (String args []) {                callA ();                }           public static void callA () {                Mammal myMammal = new Mammal ();           myMammal.legs ();                }                }                        
         [0023]    Java has a number of mechanisms dedicated to ensuring proper initialisation of objects. One such mechanism is a constructor. A constructor is called when an object is created in the program. In source code, a constructor looks like a method declaration that does not have a return type. The programmer may define constructors. In the absence of constructors defined by the programmer, the compiler will add a default constructor, a constructor that takes no parameters and simply invokes the superclass constructor without arguments. Example 2 illustrates source code with no constructors for class Mammal. As in the previous example, public class Mammal indicates the class name as Mammal, and that the class inherits from class Object. Since class Mammal comprises no explicit constructor, the compiler adds a default constructor that simply invokes the constructor of class Object without arguments. Thus, class Mammal is compiled as if the programmer had defined an empty constructor:  
                                                                                                               public class Mammal {                public Mammal () {           }                }           or, even more explicitly:           public class Mammal {                public Mammal () {                super ();                }                }                      
 
         [0024]    A constructor always takes the name of the class. The createMammal class has a method callA that creates myMammal as a Mammal which inherits features of its superclass. When the new operator (e.g. Mammal myMammal=new Mammal( )) is called, the JVM allocates memory for a new object, prepares the memory with well-known values, and initialises that memory by calling a constructor. Thus, the JVM ensures that initialisation code is run before the newly allocated memory can be used.  
       EXAMPLE 2 
       [0025]    [0025]                                                                                                               //Mammal.java           public class Mammal {           }           //createMammal.java           public class createMammal {                public static void main (String args []) {                callA ();                }           public static void callA () {                Mammal myMammal = new Mammal ();                }                }                        
         [0026]    A constructor of a class may invoke another constructor of the same class. This is achieved using the this ( ) statement. This is shown in Example 3. In this case, the constructor with no parameters (public Mammal ( )) invokes the other constructor (public Mammal (int legs)) and passes 2 to the other constructor, which assigns that value to numlegs.  
         [0027]    When a class is compiled, the Java compiler generates an instance initialisation method for each constructor in that class. This method is given a reserved name, &lt;init&gt;, and has the constructor return type (void) and parameters of the constructor from which it is generated.  
       EXAMPLE 3  
       [0028]    [0028]                                                                                                               //Mammal.java           public class Mammal {                private int numLegs;           public Mammal () {                this (2);                }           public Mammal (int legs) {                numLegs = legs;                }                }                        
         [0029]    The &lt;init&gt; method is not actually part of the Java language, but is something which the JVM expects to see in a Java class file. Hence, it should be understood here that when the term &lt;init&gt; method is used, it is synonymous with constructor method.  
         [0030]    The first statement (instruction) in an &lt;init&gt; method will be a call (invocation) to another &lt;init&gt; method in the same class (the this( ) invocation), or a call to the superclass&#39;s &lt;init&gt; method (the super( ) invocation). (The only exception to this rule is that class Object&#39;s &lt;init&gt; method does not call its superclass&#39;s &lt;init&gt; method because Object has no superclass; Object&#39;s &lt;init&gt; method actually does nothing.)  
         [0031]    Taking the class hierarchy in FIG. 4, when constructing an instance of Cat (with new Cat ( )), the following methods will be called in the order as listed (assuming for simplicity that there is only one constructor per class): Cat.&lt;init&gt;, Feline.&lt;init&gt;, Mammal.&lt;init&gt;, Object.&lt;init&gt;.  
         [0032]    Naturally, constructors can perform other tasks than calling their superclass&#39;s constructor. However, the constructors often contain no other code than the call to the superclass&#39;s constructor (super( )). This is inefficient both in terms of speed and space.  
         [0033]    The present invention addresses this. FIG. 5 illustrates a modified programming process according to an embodiment of the present invention. As can be seen, the process involves a Java editor  50 , a compiler  51  and a processor (JVM)  53  as in the prior art of FIG. 1. However, it also comprises an optimiser  52 . The compiler of this embodiment of the invention is a conventional compiler comprising a conventional syntax error checker  510 , translator  511  and code generator  512 . Accordingly, the compiler checks the validity of the source code, indicates any compilation or syntax errors, and once the errors have been corrected and the source code successfully recompiled, it translates and generates the object code (.class file). However, rather than forwarding this object code directly to the JVM  53 , the code generator  512  forwards it to the optimiser  52 . The optimiser optimises the object code, for example, using one of the techniques explained below, and outputs an optimised object code (.class2 file) to the JVM  53 . The JVM  53 , in turn, executes the program.  
         [0034]    Whilst the optimiser is illustrated as separate from the compiler in FIG. 5, it will be appreciated that it could actually form part of the compiler.  
         [0035]    The optimiser  52  aims to alleviate constructor overhead on the following basis. Firstly, it can be determined statically from the bytecode whether a constructor performs any function other than calling its superclass&#39;s constructor. Secondly, it can also be determined statically, from anywhere in the code, which class&#39;s constructor is being called. The latter is true in Java, for example, because the constructors are called only by the instruction invokespecial, which is specified to be statically resolved. In an embodiment of the present invention, this principle may be implemented by the optimiser  52  in accordance with the following routine.  
         [0036]    Optimiser Routine  
         [0037]    (1) Starting from the top of the class hierarchy, each &lt;init&gt; method of each class is examined. Let&#39;s call such a method “init 1”.  
         [0038]    If init 1 contains no other code than a call to another &lt;init&gt; method that takes no parameter, then init 1 is marked as non-operative.  
         [0039]    Follow the chain of &lt;init&gt; method calls from init 1, and  
         [0040]    If all the methods in that chain were marked earlier as non-operative, eliminate the call to &lt;init&gt; in init 1;  
         [0041]    Otherwise, replace the call to &lt;init&gt; in init 1 with a call to the first &lt;init&gt; method in the call chain that was not marked as non-operative.  
         [0042]    (2) Examine all other methods than &lt;init&gt; methods. In these methods, examine each call to an &lt;init&gt; method. Let&#39;s call such a call “call 1”.  
         [0043]    If call 1&#39;s callee was not marked as a non-operative method in step  1 , processing of call 1 is stopped;  
         [0044]    Otherwise, call 1&#39;s callee is examined. In this case:  
         [0045]    If call l&#39;s callee has a call to an &lt;init&gt; method, then we know that that &lt;init&gt; method was not marked as a non-operative method in step  1 : hence call 1 is replaced with a call to that &lt;init&gt; method;  
         [0046]    Otherwise, call1 is eliminated.  
         [0047]    (3) Since the constructors marked as non-operative are not used any further, then they may optionally be removed altogether (assuming that they form a closed set and cannot be called by other classes; otherwise, this step must not be performed).  
         [0048]    This technique removes all the non-operative constructors from Java class files. Thus, the resultant modified Java class file (e.g. .class2 file in FIG. 5) is smaller than the original (e.g. class file in FIG. 5), resulting in space savings. In addition, many object constructions are considerably sped up because only the useful parts of the constructors of the original Java class file are retained by the optimiser in the modified file.  
         [0049]    The optimiser that implements this routine may form part of any of the communications devices in FIGS. 2 and 3. In a preferred embodiment, the optimiser forms part of a terminal device, for example as illustrated in FIG. 6. The terminal device  60  of FIG. 6 may download files of object code from the communications network and also retrieve local files stored in the device&#39;s memory  61 .  
         [0050]    Code received from the network (e.g. class file) is input to the JVM&#39;s verifier  632  and is verified prior to input to the optimiser  62 . The optimiser  62 , in turn, optimises the code in accordance with the present invention, and the resultant optimised code (e.g. .class2 file) is then forwarded to the JVM&#39;s interpreter  631  for interpretation and execution.  
         [0051]    In contrast, local files are preprocessed once by the optimiser  62  for optimisation according to the present invention. They are then stored, in optimised format in memory  61 . It is usual practice for a JVM verifier  632  to be run on downloaded files, but not local ones. Hence, in this embodiment the optimised local files (e.g. .class2 files) are forwarded directly to the interpreter  631  for interpretation and execution, bypassing the verifier  632 .  
         [0052]    In an alternative embodiment, the optimiser may form part of an MSC/BSC. In this case, the MSC/BSC may receive and/or store object code (e.g. class file) and optimise that code in accordance with the present invention (e.g. .class2 file), prior to transmitting it to the recipient terminal. The recipient terminal may then run the received optimised code. Such a solution is advantageous if the recipient terminal is a dummy terminal (in that it receives all object code from a remote server), as it eliminates the need for an optimiser in such a terminal. However, either the optimised code would need to bypass verification (e.g. by turning the verifier of a conventional JVM off) in order for it to run, or a conventional verifier would need to be modified to exclude the current requirement that an &lt;init&gt; method (except Object.&lt;init&gt;) must start with a call to an &lt;init&gt; method.  
         [0053]    Of course, a hybrid arrangement is also possible in which the optimiser is provided both in the network (e.g. MSC/BSC) for downloaded files and in the terminal for local files.  
         [0054]    Optimising code according to an embodiment of the present invention will now be described with reference to an example (Example 4).  
         [0055]    Let us note that since the constructors of classes A, C and D contain no statement in the source code, the programmer could leave them out. In this case, the compiler would automatically generate constructors (default constructors) identical to the ones shown here, resulting in exactly the same bytecodes.  
         [0056]    In the programming process of FIG. 5, the source code of Example 4 may be output from the Java editor  50  and forwarded to the compiler  51 . As mentioned above, the compiler of this Figure comprises a conventional syntax error checker  510 , translator  511 , and code generator  512 . Accordingly, the compiler checks the validity of the source code, indicates any compilation or syntax errors, and once the errors have been corrected and the source code successfully recompiled, it translates and generates the object code (.class file), the bytecodes of which are shown below. (The files Object.class, A.class, etc., actually contain binary data; only their disassembled form is shown here.)  
       EXAMPLE 4  
     Source Code  
       [0057]    [0057]                                                                                                                                                                                                                   // Object.java           class Object {                Object() {}           [...]                }           // A.java           class A extends Object {                A() {                }           // B.java           class B extends A {                B() {                System.out.println(“Hello!”);                }                }           // C.java           class C extends B {                C() {}                }           // D.java           class D extends C {                D() {}                }           // App.java           class App {                public static void main(String[] args) {                B b = new B();           D d = new D();           A a = new A();                }                }                        
       EXAMPLE 4  
     Bytecode  
       [0058]    [0058]                                                                                                                                                                           // Object.class (disassembled)           .class public java/lang/Object           .method public &lt;init&gt;()V                return                .end method           // A.class (disassembled)           .class A           .super java/lang/Object           .method &lt;init&gt;()V                aload_0           invokespecial java/lang/Object/&lt;init&gt;()V           return                .end method           // B. class (disassembled)           .class B           .super A           .method &lt;init&gt;()V                aload_0           invokespecial A/&lt;init&gt;()V           getstatic java/lang/System/out Ljava/io/PrintStream;           ldc “Hello!”           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V           return                .end method           // C. class (disassembled)           .class C           .super B           .method &lt;init&gt;()V                aload_0           invokespecial B/&lt;init&gt;()V           return                .end method           // D. class (disassembled)           .class D           .super C           .method &lt;init&gt;()V                aload_0           invokespecial C/&lt;init&gt;()V           return                .end method           // App. class (disassembled)           .class App           .super java/lang/Object           .method public static main([Ljava/lang/String;)V                new B           dup           invokespecial B/&lt;init&gt;()V           astore_1           new D           dup           invokespecial D/&lt;init&gt;()V           astore_2           new A           dup           invokespecial A/&lt;init&gt;()V           astore_3           return                .end method                        
         [0059]    Example 4 illustrates the class hierarchy Object.java, A.java, B.java, C.java, D.java and App.java.  
         [0060]    The Object class, which is part of the Java library, contains a constructor with no parameters, Object( ). Since class Object has no superclass, Object( ) does not invoke any superclass constructor; instead, this constructor just returns. (The Object class has a lot of code in addition to Object( ), but that code is not relevant to our discussion and therefore is not shown.)  
         [0061]    The A class inherits from the Object class, by virtue of the code class A extends Object. The A class is declared to have a single method. Since this method, A( ), is a constructor, it takes on the name of the class. Furthermore, it invokes a constructor of the next class in the hierarchy (i.e. of the class Object in this example). (Let us recall that since the statement super ( ) is not explicitly stated in this method, it is automatically generated by the compiler to invoke Object ( ))  
         [0062]    The B class inherits from the A class, by virtue of the code class B extends A. The class itself comprises a constructor, B ( ), with no parameter. This constructor has a statement, System.out.print1n(“Hello!”);, which prints a string onto the standard output. In addition, this constructor invokes a constructor of the next class in the hierarchy (i.e. of the class A in this example).  
         [0063]    The C class inherits from the B class, by virtue of the code class C extends B. The C class is declared to have a single method. Since this method, c ( ), is a constructor, it takes on the name of the class. Furthermore, it invokes a constructor of the next class in the hierarchy (i.e. of the class B in this example).  
         [0064]    The D class inherits from the C class, by virtue of the code class D extends C. The D class is declared to have a single method. Since this method, D ( ), is a constructor, it takes on the name of the class. Furthermore, it invokes a constructor of the next class in the hierarchy (i.e. of the class C in this example).  
         [0065]    The App class contains the program. It comprises a method, namely the main method. When the JVM is activated, it is given the name of the class, and then looks for the method named main in that class and starts running it from there (main must be declared public, static and returning void). This method contains three object creations, creating new instances of classes B, D and A.  
         [0066]    In the programming process of FIG. 5, after the compiler has successfully generated the object code (.class file), it forwards it to the optimiser  52 . Let us now expose how the optimiser routine described above works in Example 4.  
         [0067]    In step  1  of the optimiser routine described above, the optimiser optimises the object code by examining each individual .class file, in the order Object, A, B, C, D, looking for constructors that only call the superclass&#39;s constructor (or even, in the case of Object ( ), do nothing but return), marking these methods as non-operative in the .class file and following the chain of constructor calls to replace calls to a respective superclass&#39;s constructor with a call to the first operational constructor above it in the hierarchy.  
         [0068]    Step  1  is shown below for Example 4.  
       EXAMPLE 4  
     Optimiser (Step  1 )  
       [0069]    [0069]                                                                                                                                                                                 // Object.class (disassembled)           .class public java/lang/Object       .method public &lt;init&gt;()V   NON-OPERATIVE                return            .end method           // A.class (disassembled)       .class A       .super java/lang/Object       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0               invokespecial java/lang/Object/&lt;init&gt;()V   this call is eliminated           return            .end method           // B. class (disassembled)       .class B       .super A       .method &lt;init&gt;()V   OPERATIVE                aload_0               invokespecial A/&lt;init&gt;()V   this call is eliminated                getstatic java/lang/System/out Ljava/io/PrintStream;           ldc “Hello!”           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V           return            .end method           // C. class (disassembled)       .class C       .super B       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0               invokespecial B/&lt;init&gt;()V   this call is left unchanged           return            .end method           // D. class (disassembled)       .class D       .super C       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0               invokespecial C/&lt;init&gt;()V   this call is replaced by:               invokespecial B/&lt;init&gt;()V           return            .end method       // App. class (disassembled)       .class App       .super java/lang/Object       .method public static main([Ljava/lang/String;)V                new B           dup           invokespecial B/&lt;init&gt;()V           astore_1           new D           dup           invokespecial D/&lt;init&gt;()V           astore_2           new A           dup           invokespecial A/&lt;init&gt;()V           astore_3           return            .end method                    
         [0070]    The constructor of class Object (Object.&lt;init&gt;) does nothing but returns. Therefore, it is marked as non-operative.  
         [0071]    The constructor of class A (A.&lt;init&gt;) contains no other code than a call to another &lt;init&gt; method. Therefore, it is marked as non-operative. Furthermore, since the chain of &lt;init&gt; methods called from A.&lt;init&gt; consists solely of Object.&lt;init&gt;, and since Object.&lt;init&gt; was marked as non-operative, the call to Object.&lt;init&gt; (and its associated instruction a_load0) is eliminated from A.&lt;init&gt;.  
         [0072]    The constructor of class B (B.&lt;init&gt;) contains other code than a call to another &lt;init&gt; method. Therefore, it is not marked as non-operative (i.e., it is marked as operative). Furthermore, since the chain of &lt;init&gt; methods called from B.&lt;init&gt;consists of A.&lt;init&gt; and Object.&lt;init&gt;, and since both A.&lt;init&gt; and Object.&lt;init&gt; were marked as non-operative, the call to A.&lt;init&gt; (and its associated instruction a_load0) is eliminated from B.&lt;init&gt;.  
         [0073]    The constructor of class C (C.&lt;init&gt;) contains no other code than a call to another &lt;init&gt; method. Therefore, it is marked as non-operative. Furthermore, since the chain of &lt;init&gt; methods called from C.&lt;init&gt; consists of B.&lt;init&gt;, A.&lt;init&gt; and Object.&lt;init&gt;, and since one of these &lt;init&gt; methods, B.&lt;init&gt;, was marked as operative, the call to B.&lt;init&gt; (and its associated instruction a_load0) is not eliminated from C.&lt;init&gt;. And then, since the first &lt;init&gt; method that was not marked as non-operative in the chain of &lt;init&gt; methods called from C.&lt;init&gt; is B.&lt;init&gt;, the call to B.&lt;init&gt; is replaced by itself; that is, the call to B.&lt;init&gt; is left unchanged in C.&lt;init&gt;.  
         [0074]    The constructor of class D (D.&lt;init&gt;) contains no other code than a call to another &lt;init&gt; method. Therefore, it is marked as non-operative. Furthermore, since the chain of &lt;init&gt; methods called from D.&lt;init&gt; consists of C.&lt;init&gt;, B.&lt;init&gt;, A.&lt;init&gt; and Object.&lt;init&gt;, and since one of these &lt;init&gt; methods, B.&lt;init&gt;, was marked as operative, the call to C.&lt;init&gt; (and its associated instruction a_load0) is not eliminated from D.&lt;init&gt;. And then, since the first &lt;init&gt; method that was not marked as non-operative in the chain of &lt;init&gt; methods called from D.&lt;init&gt; is B.&lt;init&gt;, the call to C.&lt;init&gt; is replaced by a call to B.&lt;init&gt;.  
         [0075]    The disassembled bytecodes for Example 4 after step  1  are shown below.  
       EXAMPLE 4  
     Optimiser (After Step  1 )  
       [0076]    [0076]                                                                                                                                                       // Object.class (disassembled)           .class public java/lang/Object       .method public &lt;init&gt;()V   NON-OPERATIVE                return            .end method           // A.class (disassembled)       .class A       .super java/lang/Object       .method &lt;init&gt;()V   NON-OPERATIVE                return            .end method           // B. class (disassembled)       .class B       .super A       .method &lt;init&gt;()V   OPERATIVE                getstatic java/lang/System/out Ljava/io/PrintStream;           ldc “Hello!”           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V           return            .end method           // C. class (disassembled)       .class C       .super B       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0           invokespecial B/&lt;init&gt;()V           return            .end method           // D. class (disassembled)       .class D       .super C       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0           invokespecial B/&lt;init&gt;()V           return            .end method       // App. class (disassembled)       .class App       .super java/lang/Object       .method public static main([Ljava/lang/String;)V                new B           dup           invokespecial B/&lt;init&gt;()V           astore_1           new D           dup           invokespecial D/&lt;init&gt;()V           astore_2           new A           dup           invokespecial A/&lt;init&gt;()V           astore_3           return            .end method                    
         [0077]    In step  2  of the optimiser routine described above, the optimiser optimises the object code by examining all other methods than &lt;init&gt; methods in each individual .class file, in any order, looking for calls to &lt;init&gt; methods, and possibly replacing these calls by more efficient ones.  
         [0078]    Step  2  is shown below for Example 4.  
       EXAMPLE 4  
     Optimiser (Step  2 )  
       [0079]    [0079]                                                                                                                                                           // Object.class (disassembled)           .class public java/lang/Object       .method public &lt;init&gt;()V   NON-OPERATIVE                return            .end method           // A.class (disassembled)       .class A       .super java/lang/Object       .method &lt;init&gt;()V   NON-OPERATIVE                return            .end method           //B. class (disassembled)       .class B       .super A       .method &lt;init&gt;()V   OPERATIVE                getstatic java/lang/System/out Ljava/io/PrintStream;           ldc “Hello!”           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V           return            .end method           // C. class (disassembled)       .class C       .super B       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0           invokespecial B/&lt;init&gt;()V           return            .end method           // D. class (disassembled)       .class D       .super C       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0           invokespecial B/&lt;init&gt;()V           return            .end method       // App. class (disassembled)       .class App       .super java/lang/Object       .method public static main([Ljava/lang/String;)V                new B               dup           invokespecial B/&lt;init&gt;()V   this call is left unchanged           astore_1           new D           dup           invokespecial D/&lt;init&gt;()V   this call is replaced by:           astore_2   invokespecial B/&lt;init&gt;()V           new A           dup           invokespecial A/&lt;init&gt;()V   this call is eliminated           astore_3           return            .end method                    
         [0080]    In this example, all the calls to &lt;init&gt; methods from non &lt;init&gt; methods are located in App.main. Let us review each of these three calls.  
         [0081]    B.&lt;init&gt; was marked as operative. Therefore, the call to B.&lt;init&gt; is left unchanged in App.main.  
         [0082]    D.&lt;init&gt; was marked as non-operative. Furthermore, D.&lt;init&gt; contains a call to B.&lt;init&gt;. Therefore, the call to D.&lt;init&gt; is replaced by a call to B.&lt;init&gt; in App.main.  
         [0083]    A.&lt;init&gt; was marked as non-operative. Furthermore, A.&lt;init&gt; contains no call to any &lt;init&gt; method. Therefore, the call to A.&lt;init&gt; (and its associated instruction dup) is eliminated from App.main.  
         [0084]    The disassembled bytecodes after step  2  are shown below.  
                                                                                                                                         EXAMPLE 4                       Optimiser (after step 2)                                // Object.class (disassembled)           .class public java/lang/Object       .method public &lt;init&gt;()V   NON-OPERATIVE                return            .end method           // A.class (disassembled)       .class A       .super java/lang/Object       .method &lt;init&gt;()V   NON-OPERATIVE                return            .end method           // B. class (disassembled)       .class B       .super A       .method &lt;init&gt;()V   OPERATIVE                getstatic java/lang/System/out Ljava/io/PrintStream;           ldc “Hello!”           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V           return            .end method           // C. class (disassembled)       .class C       .super B       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0           invokespecial B/&lt;init&gt;()V           return            .end method           // D. class (disassembled)       .class D       .super C       .method &lt;init&gt;()V   NON-OPERATIVE                aload_0           invokespecial B/&lt;init&gt;()V           return            .end method       // App. class (disassembled)       .class App       .super java/lang/Object       .method public static main([Ljava/lang/String;)V                new B           dup           invokespecial B/&lt;init&gt;()V           astore_1           new D           dup           invokespecial B/&lt;init&gt;()V           astore_2           new A           astore_3           return            .end method                  
 
         [0085]    In step  3  of the optimiser routine described above, the optimiser optimises the object code by removing all the &lt;init&gt; methods that were marked as non-operative. (Let us recall that this step is optional and may only be performed if the classes to be modified form a closed set, because if not the &lt;init&gt; methods could be called by other classes and therefore cannot be removed.)  
         [0086]    Step  3  is shown below for Example 4.  
       EXAMPLE 4  
     Optimiser (Step  3 )  
       [0087]    [0087]                                                                   // Object.class (disassembled)       .class public java/lang/Object       [&lt;init&gt;()V removed]       // A.class (disassembled)       .class A       .super java/lang/Object       [&lt;init&gt;()V removed]       // B.class (disassembled)       .class B       .super A       .method &lt;init&gt;()V                getstatic java/lang/System/out Ljava/io/PrintStream;           ldc “Hello!”           invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V           return            .end method       // C. class (disassembled)       .class C       .super B       [&lt;init&gt;()V removed]       // D. class (disassembled)       .class D       .super C       [&lt;init&gt;()V removed]       // App. class (disassembled)       .class App       .super java/lang/Object       .method public static main([Ljavallang/String;)V                new B           dup           invokespecial B/&lt;init&gt;()V           astore_1           new D           dup           invokespecial B/&lt;init&gt;()V           astore_2           new A           astore_3           return            .end method                    
         [0088]    The present invention includes any novel feature or combination of features disclosed herein either explicitly or any generalisation thereof irrespective of whether or not it relates to the claimed invention or mitigates any or all of the problems addressed.  
         [0089]    In view of the foregoing description it will be evident to a person skilled in the art that various modifications may be made within the scope of the invention.