Abstract:
A method for protecting java program is provided, which relates the field of software protection. The method includes: java virtual machine loading class file; transplanting java instruction corresponding java class method into preset buffer when java instruction corresponding to java class method in class file meets preset condition of portable instruction; obtaining the deepest stack level and the maximum number of local variable of java class method, java class method for obtaining stack and local variable, java method executing the virtual machine in encryption lock and java class method for modifying stack and local variable are filled into position of the transplanted java instruction in class file. By the technical solution, a part of java instructions are transplanted into the encryption lock, the java programs protected are modified, the logic of which is incomplete, and the original code cannot be restored, the security of the which are improved.

Description:
CROSS REFERENCES OF RELATED APPLICATIONS 
       [0001]    This application claims the priority to Chinese Patent Application No. 201310159747.7, entitled “A METHOD FOR PROTECTING JAVA PROGRAM”, filed on May 3, 2013 with State Intellectual Property Office of People&#39;s Republic of China, which is incorporated herein by reference in its entirety. 
       FIELD 
       [0002]    The present disclosure relates to the software protection field, and particularly, to a method for protecting a java program. 
       BACKGROUND 
       [0003]    Java programming language is an interpreted language. A Java instruction file is generated by compiling Java source codes, and the Java instruction file generated is interpreted and executed in a Java virtual machine (JVM). The operation mechanism of interpreting and executing makes the Java source code easily decompiled. At present, there are many decompilation tools with the effects of which are very efficient, and the decompilation tools makes any Java software user more easily decompiles and reconstructs the source code of products. As a result, any authorization certificate license based on the Java programming language becomes meaningless. 
         [0004]    Therefore, in the software protection field based on the Java programming language, an important problem that needs to be resolved is to ensure that the java software program cannot be decompiled and reconstructed or to increase difficulty of decompiling and reconstructing. 
       SUMMARY 
       [0005]    The present disclosure is to overcome disadvantages of the conventional technology by providing a method for protecting a Java program. 
         [0006]    The technical solution adopted by the present disclosure is a method for protecting a Java program, which includes: 
         [0007]    step A, loading, by a Java virtual machine, a class file, and determining whether the class file is a legal file, executing step B if the class file is the legal file; replying error information and ending if the class file is not the legal file; 
         [0008]    step B, obtaining, by the Java virtual machine, a total number of java class methods and an initial position of the java class methods in the class file, and finding a current java class method in accordance with the initial position; 
         [0009]    step C, parsing, by the java virtual machine, a java instruction corresponding to the current java class method, and determining whether the java instruction is successfully parsed; executing step D if the java instruction is successfully parsed; replying error information and ending if the java instruction is not successfully parsed; 
         [0010]    step D, determining, by the java virtual machine, whether the java instruction corresponding to the current java class method meets a preset condition of a portable instruction, transplanting and storing the java instruction corresponding to the current java class method into a preset buffer and executing step E if the java instruction meets the preset condition of the portable instruction; executing step G if the java instruction does not meet the preset condition of the portable instruction; 
         [0011]    step E, obtaining, by the java virtual machine, the deepest stack level of the java virtual machine and the maximum number of local variables of the current java class method; 
         [0012]    step F, in accordance with the deepest stack level of the java virtual machine and the maximum number of the local variables, filling, by the java virtual machine, a position of the transplanted java instruction in the class file with a java class method for obtaining a stack and a local variable, a java class method for executing a virtual machine in an encryption lock and a java class method for modifying a stack and a local variable, and executing step G; 
         [0013]    step G, determining, by the java virtual machine, whether the number of java class methods which have been parsed reaches a total number of the java class methods in the class file, transplanting a java instruction corresponding to a current java class method in the preset buffer into an encryption lock and ending if the number of the java class methods which have been parsed reaches the total number of the java class methods in the class file; continuing to obtain a next java class method and making the next java class method as the current java class method, and returning to execute step C if the number of the java class methods which have been parsed does not reach the total number of the java class methods in the class file. 
         [0014]    In step A, the step of determining whether the class file is a legal file comprises: obtaining the class file and determining whether a file header of the class file is a preset string, the class file is the legal file if the file header of the class file is the preset string; the class file is an illegal file if the file header of the class file is not the preset string. 
         [0015]    In step C, the step of parsing a java instruction corresponding to the current java class method includes: 
         [0016]    step C- 1 , obtaining, by the java virtual machine, the number of constant pools and an initial position of the constant pools in the class file; 
         [0017]    step C- 2 , obtaining, by the java virtual machine, in accordance with a first member variable and a second member variable of the current java class method, a name of a java class method and a descriptor of the java class method from the constant pools, and determining whether the name of the java class method and the descriptor of the java class method are successfully obtained, executing step C- 3  if the name of the java class method and the descriptor of the java class method are successfully obtained; replying error information and ending if the name of the java class method and the descriptor of the java class method are not successfully obtained; 
         [0018]    step C- 3 , obtaining, by the java virtual machine, in accordance with a third member variable and a fourth member variable of the current java class method, an additive attribute of the current java class method, and determining whether the additive attribute is successfully obtained, executing step D if the additive attribute is successfully obtained; replying error information and ending if the additive attribute is not successfully obtained. 
         [0019]    The first member variable of the current java class method is an index of a name of a java class method in the constant pools; the second member variable of the current java class method is an index of a descriptor of the java class method in the constant pools; the third member variable of the current java class method is the number of additive attributes of the current java class method; the fourth member variable of the current java class method is an initial position of the additive attributes of the current java class method. 
         [0020]    The additive attributes include a code attribute, the code attribute comprises a java instruction of the current java class method and a length of the java instruction of the current java class method. 
         [0021]    Between step C and step D, the method includes: 
         [0022]    step A- 1 , displaying, by the java virtual machine, the current java class method of the class file and the java instruction corresponding to the current java class method; 
         [0023]    step B- 1 , determining, by the java virtual machine, whether the number of java class methods which have been parsed is more than a total number of the java class methods in the class file, executing step C- 1  if the number of java class methods which have been parsed is more than the total number of the java class methods in the class file; making a next java class method as the current java class method and returning to execute step C if the number of java class methods which have been parsed is not more than the total number of the java class methods in the class file; 
         [0024]    step C- 1 , receiving, by the java virtual machine, a choice of a user for the displayed java class method and the java instruction corresponding to the java class method, and obtaining the initial position of the java instruction corresponding to the java class method which has been chosen by the user according to the additive attribute, and finding the java instruction corresponding to the current java class method according to the initial position, and executing step D. 
         [0025]    Step D includes: 
         [0026]    step A- 2 , determining, by the java virtual machine, whether the java instruction corresponding to the current java class method meets a preset condition of a portable instruction, executing step B- 2  if the java instruction corresponding to the current java class method meets the preset condition of the portable instruction; executing step G if the java instruction corresponding to the current java class method does not meet the preset condition of the portable instruction; 
         [0027]    step B- 2 , displaying, by the java virtual machine, the current java class method of the java file and the java instruction corresponding to the current java class method; 
         [0028]    step C- 2 , determining, by the java virtual machine, whether the number of java class methods which have been parsed is more than a total number of the java class methods in class files, executing step D- 2  if the number of the java class methods which have been parsed is more than the total number of the java class methods in class files; making a next java class method as the current java class method and returning to execute step C if the number of the java class methods which have been parsed is not more than the total number of the java class methods in class files; 
         [0029]    step D- 2 , receiving, by the java virtual machine, a choice of a user for the displayed java class method and java instruction corresponding to the java class method, and according to the additive attribute, obtaining an initial position of a java instruction which has been chosen, and making a java instruction in the initial position as a current java instruction, and transplanting and storing the current java instruction into a preset buffer, and executing step E. 
         [0030]    Determining whether the java instruction corresponding to the current java class method meets a preset condition of a portable instruction includes: 
         [0031]    step D- 1 , determining, by the java virtual machine, whether a type of the java instruction corresponding to the current java class method is in a preset collection of types of a portable java instruction, executing step D- 2  if the type of the java instruction corresponding to the current java class method is in the preset collection of the type of a portable java instruction; executing step G if the type of the java instruction corresponding to the current java class method is not in the preset collection of the type of a portable java instruction, which indicates that the current instruction cannot be transplanted; 
         [0032]    step D- 2 , determining, by the java virtual machine, whether the java instruction corresponding to the current java class method is in a preset instruction collection of a reference constant pool, executing step G if the java instruction corresponding to the current java class method is in the preset instruction collection of the reference constant pool, which indicates that the current instruction cannot be transplanted; executing step D- 3  if the java instruction corresponding to the current java class method is not in the preset instruction collection of the reference constant pool; 
         [0033]    step D- 3 , determining, by the java virtual machine, whether the java instruction corresponding to the current java class method relates to a memory operation, executing step G if the java instruction corresponding to the current java class method relates to the memory operation, which indicates that the current instruction cannot be transplanted; executing step D- 4  if the java instruction corresponding to the current java class method does not relate to the memory operation; 
         [0034]    step D- 4 , determining, by the java virtual machine, whether the java instruction corresponding to the current java class method operates a member variable of the class file structure, executing step G if the java instruction corresponding to the current java class method operates the member variable of the class file structure, which indicates that the current instruction cannot be transplanted; executing step D- 5  if the java instruction corresponding to the current java class method does not operate the member variable of the class file structure; 
         [0035]    step D- 5 , determining, by the java virtual machine, whether the java instruction corresponding to the current java class method invokes an external java class method, executing step G if the java instruction corresponding to the current java class method invokes the external java class method, which indicates that the current instruction cannot be transplanted; executing step E if the java instruction corresponding to the current java class method does not invoke the external java class method. 
         [0036]    The preset collection of types of the portable java instruction includes a stack operation instruction type, a logical operation instruction type, a bitwise operation instruction type, and an arithmetic operation instruction type. 
         [0037]    In step F, filling the position of the transplanted java instruction in the class file with the java class method for obtaining the stack and the local variable includes: 
         [0038]    step F- 11 , locating, by the java virtual machine, a position of a transplanted current java class method; 
         [0039]    step F- 12 , creating, by the java virtual machine, a index of a constant pool of the current java class method; 
         [0040]    step F- 13 , filling, by the java virtual machine, the position of the transplanted current java class method with the index of the constant pool and the java class method for obtaining stacks and local variables. 
         [0041]    In step F, filling, by the java virtual machine, the position of the transplanted java instruction in the class file with the java class method for executing the virtual machine in the encryption lock includes: 
         [0042]    step F- 21 , locating, by the java virtual machine, a position of a transplanted current java class method; 
         [0043]    step F- 22 , creating, by the java virtual machine, a constant pool index of the current java class method; 
         [0044]    step F- 23 , filling, by the java virtual machine, the position of the transplanted current java class method with the index of the constant pool and the java class method for executing the virtual machine in the encryption lock. 
         [0045]    In step F, filling the position of the transplanted java instruction in the class file with the java class method for modifying stacks and local variables includes: 
         [0046]    step F- 31 , locating, by the java virtual machine, a position of a transplanted current java class method; 
         [0047]    step F- 32 , creating, by the java virtual machine, a constant pool index of the current java class method; 
         [0048]    step F- 33 , filling, by the java virtual machine, the position of the transplanted current java class method in the class file with the index of the constant pool and the java class method for modifying the stacks and the local variables. 
         [0049]    The advantage of the present disclosure is that a few of java instructions are transplanted into an encryption lock, the java programs protected are modified, thus the logic of the program is incomplete, and the original software code cannot be restored, thus the security of the java programs are improved. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0050]      FIG. 1  shows a flow diagram of a method for protecting a java program according to embodiment 1 of the disclosure; and 
           [0051]      FIG. 2  shows a detail drawing of step  108  of embodiment 1. 
       
    
    
     DETAILED DESCRIPTION 
       [0052]    The technical solution in the embodiments of the present disclosure is further described more clearly and completely with the drawings in the embodiments of the present disclosure. Apparently, embodiments described are just a few of all embodiments of the present disclosure. On the basis of embodiments of the disclosure, all other related embodiments made by common technicians of the field without creative work belong to the scope of the disclosure. 
       Embodiment 1 
       [0053]    Embodiment 1 of the present disclosure provides a method for protecting a java program as showing in  FIG. 1 , including steps  101  to  114 . 
         [0054]    In step  101 , a java virtual machine loads a class file. 
         [0055]    In step  102 , the java virtual machine determines whether the class file loaded is a legal file; stores the class file into a memory and executes step  103  if the class file loaded is a legal file; replies error information and operation is ended if the class file loaded is not the illegal file. 
         [0056]    In the embodiment, a file header of the class file is a classfile structure. 
         [0057]    the classfile structure is: 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 Classfile{ 
               
               
                   
                 u4 magic; 
               
               
                   
                 u2 magic_version; 
               
               
                   
                 u2 magic_version; 
               
               
                   
                 u2 constant_pool_count; 
               
               
                   
                 cp_infoconstant_pool[constant_pool_cpunt−1]; 
               
               
                   
                 u2 access_flags; 
               
               
                   
                 u2 superclass; 
               
               
                   
                 u2 interfaces_count; 
               
               
                   
                 u2 fields_count; 
               
               
                   
                 field_info fields[fields_count]; 
               
               
                   
                 u2 methods_count; 
               
               
                   
                 method_info methods[methods_count]; 
               
               
                   
                 u2 attributes_count; 
               
               
                   
                 attribute_info attributes[attributes_count]; 
               
               
                   
                 } 
               
               
                   
                   
               
             
          
         
       
     
         [0058]    Optionally, whether the member variable magic in the classfile struct is 0xCAFEBABE is determined, the class file is the legal file if the member variable magic in the classfile structure is 0xCAFEBABE; the class file is an illegal file if the member variable magic in the classfile structure is not 0xCAFEBABE. 
         [0059]    In step  103 , the java virtual machine obtains the number of constant pools and an initial position of the constant pools in the class file, and obtains the total number of java class methods and the initial position of java class methods, and finds a current java class method in accordance with the initial position. 
         [0060]    A constant pool contains a name of a java class method and a descriptor of the java class method. 
         [0061]    Optionally, a obtained value of a member variable constant pool_count in the Classfile structure is the number of the constant pools in the class file, and the initial position of the constant pools can be gotten according to a member variable Cp_infoconstantpool[constantpool_cpunt-1] in the Classfile struct. 
         [0062]    A value of a member variable methods_count in the Classfile struct obtained is the total number of the java class methods; and an initial position of the java class method may be gotten according to the member variable Method_infomethods[methods_count] in the Classfile struct. 
         [0063]    The current java class method is: 
         [0000]    
       
         
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 public class CRC32 { 
               
               
                   
                 public static int getCRC32(String _source){ 
               
             
          
           
               
                   
                 intcrc = 0xFFFFFFFF; 
               
             
          
           
               
                   
                 int poly = 0xEDB88320; 
               
             
          
           
               
                   
                 byte[ ] bytes = _source.getBytes( ); 
               
               
                   
                 for (byte b : bytes) { 
               
               
                   
                 int temp = (crc {circumflex over ( )} b) &amp; 0xff; 
               
               
                   
                 for (inti = 0; i&lt; 8; i++) 
               
             
          
           
               
                   
                 { if ((temp &amp; 1) == 1) 
               
             
          
           
               
                   
                 temp = (temp &gt;&gt;&gt; 1) {circumflex over ( )} poly; 
               
               
                   
                 else 
               
               
                   
                 temp = (temp &gt;&gt;&gt; 1); 
               
               
                   
                  } 
               
               
                   
                 crc = (crc&gt;&gt;&gt; 8 {circumflex over ( )} temp); 
               
             
          
           
               
                   
                 } 
               
               
                   
                 crc = crc {circumflex over ( )} 0xffffffff; 
               
               
                   
                 returncrc; 
               
             
          
           
               
                   
                 } 
               
               
                   
                 } 
               
               
                   
                   
               
             
          
         
       
     
         [0064]    In step  104 , the java virtual machine parses the current java class method and a java instruction corresponding to the current java class method in accordance with the obtained constant pool and java class method, and determines whether the current java class method and the java instruction are successfully parsed, executes step  105  if the current java class method and the java instruction are successfully parsed; replies error information and the program ends if the current java class method and the java instruction are not successfully parsed. 
         [0065]    The process of parsing the current java class method includes step  104 - 1  to step  104 - 2 . 
         [0066]    In step  104 - 1 , the java virtual machine obtains a name of a java class method and a descriptor of the java class method from the constant pools in accordance with a first member variable and a second member variable of the current java class method, and determines whether the name and the descriptor of the java class method is successfully obtained, executes step  104 - 2  if the name and the descriptor of the java class method are successfully obtained; replies error information and the program ends if the name and the descriptor of the java class method are not successfully obtained. 
         [0067]    The structure of the method is: 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 Method_info{ 
               
               
                   
                 u2 access_flags; 
               
               
                   
                 u2 name_index; 
               
               
                   
                 u2 descriptor_index; 
               
               
                   
                 u2 attributes_count; 
               
               
                   
                 Attribute_info attributes[attributes_count]; 
               
               
                   
                 } 
               
               
                   
                   
               
             
          
         
       
     
         [0068]    The first member variable is name_index which is an index of a name of a java class method in the constant pools, the second member variable is u2 descriptor_index which is an index of a descriptor of the java class method in the constant pools. 
         [0069]    In step  104 - 2 , the java virtual machine obtains an additive attribute in accordance with a third member variable and a fourth member variable of the current java class method, and determines whether the additive attribute is successfully obtained, executes step  105  if the additive attribute is successfully obtained; replies error information and the program ends if the additive attribute is successfully obtained. 
         [0070]    The third member variable is attributes_count which is a number of additive attributes, the fourth member variable is attribute_info attributes [attributes count], which indicates an initial position of the additive attributes. 
         [0071]    In the embodiment, the additive attributes include a code attribute and an Exceptions attribute, where, the code attribute is used for interpreting a value of a java instruction, and the Exceptions attribute is used for pointing out possibly thrown exceptions, which need to be checked, of the java class method. 
         [0072]    The process of parsing the java instruction corresponding to the current java class method includes: obtaining a total length of the java instruction corresponding to the current java class method and an offset of the java instruction corresponding to the current java class method in a code attribute structure. 
         [0073]    The code attribute structure is: 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 code_attribute { 
               
               
                   
                 u2 attribute_name_index; 
               
               
                   
                 u4 attribute_length; 
               
               
                   
                 u2 max_stack; 
               
               
                   
                 u2 max_locals; 
               
               
                   
                 u4 code_length; 
               
               
                   
                 u1 code[code_length]; 
               
               
                   
                 u2 exception_table_length; 
               
               
                   
                 { u2 start_pc; 
               
               
                   
                 u2 end_pc; 
               
               
                   
                 u2 handler_pc; 
               
               
                   
                 u2 catch_type; 
               
               
                   
                 } exception_table[exception_table_length]; 
               
               
                   
                 u2 attributes_count; 
               
               
                   
                 attribute_info attributes[attributes_count];} 
               
               
                   
                   
               
             
          
         
       
     
         [0074]    A value of the member variable code_length of the code attribute structure obtained is the length of the java instruction corresponding to the current java class method. The initial position of the java instruction corresponding to the current java class method in accordance with the member variable code[code_length] of the code attribute structure is obtained, and traversing the java instruction corresponding to the current java class methods in turn. 
         [0075]    In step  105 , the java virtual machine displays the current java class method in the class file and the java instruction corresponding to the current java class method. 
         [0076]    In step  106 , the java virtual machine determines whether the number of displayed java class methods is more than the total number of java class methods, executes step  107  if the number of displayed java class methods is more than the total number of java class methods; makes next java class method as the current java class method and returns to execute step  104  if the number of displayed java class methods is not more than the total number of java class methods. 
         [0077]    In step  107 , the java virtual machine receives a choice of a user for the displayed java class method and the java instruction corresponding to the java class method, and according to the additive attribute, obtains the initial position of the java instructions corresponding to the java class method, and finds the java instruction corresponding to the current java class method in accordance with the initial position. 
         [0078]    The initial position of the java instruction corresponding to the current java class method is obtained in accordance with the member variable code[code_length] in the additive attribute, and the java instruction corresponding to the current java class method is found according to the initial position. 
         [0079]    In the embodiment, the java instruction corresponding to the current java class methods are: 
         [0000]    
       
         
               
               
               
             
               
               
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 0: 
                 iconst_m1 
               
               
                   
                 1: 
                 istore_1 
               
               
                   
                 2: 
                 ldc -306674912 
               
               
                   
                 4: 
                 istore_2 
               
               
                   
                 5: 
                 aload_0 
               
               
                   
                 6: 
                 invokevirtual java.lang.String.getBytes ( )[B 
               
               
                   
                 9: 
                 astore_3 
               
               
                   
                 10: 
                 aload_3 
               
             
          
           
               
                   
                 11: 
                 astore 
                   %4 
               
               
                   
                 13: 
                 aload 
                 %4 
               
               
                   
                 15: 
                 arraylength 
               
               
                   
                 16: 
                 istore 
                 %5 
               
               
                   
                 18: 
                 iconst_0 
               
               
                   
                 19: 
                 istore 
                 %6 
               
               
                   
                 21: 
                 iload 
                 %6 
               
               
                   
                 23: 
                 iload 
                 %5 
               
               
                   
                 25: 
                 if_icmpge 
                    #100 
               
               
                   
                 28: 
                 aload 
                 %4 
               
               
                   
                 30: 
                 iload 
                 %6 
               
               
                   
                 32: 
                 baload 
               
               
                   
                 33: 
                 istore 
                 %7 
               
               
                   
                 35: 
                 iload_1 
               
               
                   
                 36: 
                 iload 
                 %7 
               
               
                   
                 38: 
                 ixor 
               
               
                   
                 39: 
                 sipush 
                   255 
               
               
                   
                 42: 
                 iand 
               
               
                   
                 43: 
                 istore 
                 %8 
               
               
                   
                 45: 
                 iconst_0 
               
               
                   
                 46: 
                 istore 
                 %9 
               
               
                   
                 48: 
                 iload 
                 %9 
               
               
                   
                 50: 
                 bipush 
                   8 
               
               
                   
                 52: 
                 if_icmpge 
                    #86 
               
               
                   
                 55: 
                 iload 
                 %8 
               
               
                   
                 57: 
                 iconst_1 
               
               
                   
                 58: 
                 iand 
               
               
                   
                 59: 
                 iconst_1 
               
               
                   
                 60: 
                 if_icmpne 
                    #74 
               
               
                   
                 63: 
                 iload 
                 %8 
               
               
                   
                 65: 
                 iconst_1 
               
               
                   
                 66: 
                 iushr 
               
               
                   
                 67: 
                 iload_2 
               
               
                   
                 68: 
                 ixor 
               
               
                   
                 69: 
                 istore 
                 %8 
               
               
                   
                 71: 
                 goto 
                 #80 
               
               
                   
                 74: 
                 iload 
                 %8 
               
               
                   
                 76: 
                 iconst_1 
               
               
                   
                 77: 
                 iushr 
               
               
                   
                 78: 
                 istore 
                 %8 
               
               
                   
                 80: 
                 iinc 
                 %9 1 
               
               
                   
                 83: 
                 goto 
                 #48 
               
               
                   
                 86: 
                 iload_1 
               
               
                   
                 87: 
                 bipush 
                   8 
               
               
                   
                 89: 
                 iushr 
               
               
                   
                 90: 
                 iload 
                 %8 
               
               
                   
                 92: 
                 ixor 
               
               
                   
                 93: 
                 istore_1 
               
               
                   
                 94: 
                 iinc 
                 %6 1 
               
               
                   
                 97: 
                 goto 
                 #21 
               
               
                   
                 100: 
                 iload_1 
               
               
                   
                 101: 
                 iconst_m1 
               
               
                   
                 102: 
                 ixor 
               
               
                   
                 103: 
                 istore_1 
               
               
                   
                 104: 
                 iload_1 
               
               
                   
                 105: 
                 ireturn 
               
               
                   
                   
               
             
          
         
       
     
         [0080]    In step  108 , the java virtual machine determines whether the java instruction corresponding to the current java class method meets a preset condition of a portable instruction, executes step  109  if the java instruction corresponding to the current java class method meets the preset condition of the portable instruction; executes step  114  if the java instruction corresponding to the current java class method does not meet the preset condition of the portable instruction. 
         [0081]    As shown in  FIG. 2 , the process of determining whether the java instruction corresponding to the current java class method meets the preset condition of the portable instructions includes step  108 - 1  to step  108 - 5 . 
         [0082]    In step  108 - 1 , determining whether a type of the java instruction corresponding to the current java class method is in a preset collection of types of the portable java instruction, storing the java instruction corresponding to the current java class method into the preset buffer and executing step  108 - 2  if the type of the java instruction corresponding to the current java class method is in the preset collection of types of the portable java instruction; executing step  114  if the type of the java instruction corresponding to the current java class method is not in the preset collection of types of the portable java instruction. 
         [0083]    The preset collection of types of the portable java instruction contains a stack operation instruction type, a logical operation instruction type, a bitwise operation instruction type, and an arithmetic operation instruction type. 
         [0084]    Optionally, the first bit of the current java instruction being 0x01 indicates that the type of the java instruction is the stack operation instruction type; the first bit of the current java instruction being 0x7e indicates that the type of the java instruction is the logical operation instruction type; the first bit of the current java instruction being 0x7a indicates that the type of the java instruction is the bitwise operation instruction type; the first bit of the current java instruction being 0x6c indicates that the type of the java instruction is the arithmetic operation instruction type. 
         [0085]    In step  108 - 2 , determining whether the java instruction corresponding to the current java class method is in an preset instruction collection of a reference constant pool, executing step  114  if the java instruction corresponding to the current java class method is in the preset instruction collection of the reference constant pool, which indicates that the java instructions corresponding to the current java class method cannot be transplanted; executing step  108 - 3  if the java instruction corresponding to the current java class method is not in the preset instruction collection of the reference constant pool. 
         [0086]    For instance, in case that the java instruction corresponding to the current java class method is ldc instruction which is used for extracting data from the constant pool and putting the data into a stack, the java instruction is in the preset instruction collection of the reference constant pool and it cannot be transplanted. 
         [0087]    In step  108 - 3 , determining whether the java instruction corresponding to the current java class method relates to a memory operation, executing step  114  if the java instruction corresponding to the current java class method relates to the memory operation; executing step  108 - 4  if the java instruction corresponding to the current java class method does not relate to the memory operation. 
         [0088]    For instance, in case that the java instruction corresponding to the current java class method is a “new” instruction used for creating an object, the “new” instruction relates to the memory operation, thus the “new” instruction cannot be transplanted. 
         [0089]    In step  108 - 4 , determining whether the java instruction corresponding to the current java class method operates a member variable of classfile, executing step  114  if the java instruction corresponding to the current java class method operates the member variable of classfile; executing step  108 - 5  if the java instruction corresponding to the current java class method does not operate the member variable of classfile. 
         [0090]    For instance, in case that the java instruction corresponding to the current java class method is getfield instruction used for obtaining a member variable in the classfile. The getfield instruction relates to operating member variables, thus the getfield instruction cannot be transplanted. 
         [0091]    In step  108 - 5 , determining whether the java instruction corresponding to the current java class method that invokes an external method of the java virtual machine, executing step  114  if the java instruction corresponding to the current java class method invokes the external method of the java virtual machine; executing step  109  if the java instruction corresponding to the current java class method does not invoke the external java class method. 
         [0092]    For instance, in case that the java instruction corresponding to the current java class method is invokevirtual instruction used for invoking instance method, the invokevirtual instruction may invoke an external method, thus the invokevirtual instruction cannot be transplanted. 
         [0093]    The steps from step  105  to step  108  can also be step A- 1  to step D- 1  as follows. 
         [0094]    In step A- 1 , the java virtual machine determines whether the java instruction corresponding to the current java class method meets a preset condition of a portable instruction, executes step B- 1  if the java instruction corresponding to the current java class method meets the preset condition of the portable instruction; executes step  114  if the java instruction corresponding to the current java class method does not meet the preset condition of the portable instruction. 
         [0095]    In step B- 1 , the java virtual machine displays the current java class method of the java file and the java instruction corresponding to the current java class method. 
         [0096]    In step C- 1 , the java virtual machine determines the number of java class methods which have been parsed is more than a total number of java class methods, executes step D- 1  if the number of the java class methods which have been parsed is more than the total number of the java class methods; makes a next java class method as the current java class method and returns to execute step  104  if the number of the java class methods which have been parsed is not more than the total number of the java class methods. 
         [0097]    In step D- 1 , the java virtual machine receives a choice of a user for displayed java class methods and java instructions corresponding to the java class methods, and according to the additive attribute, obtains an initial position of a java instruction corresponding to a chosen java class method, and finds the java instruction corresponding to a current java class method in accordance with the initial position, transplants and stores the java instruction corresponding to the current java class method into the preset buffer, and executes step  109 . 
         [0098]    The steps from step  105  to step  108  can also be steps A- 2  to B- 2  as follows. 
         [0099]    In step A- 2 , the java virtual machine determines whether the java instruction corresponding to the current java class method meets a preset condition of a portable instruction, executes step B- 2  if the java instruction corresponding to the current java class method meets the preset condition of the portable instruction; executes step  114  if the java instruction corresponding to the current java class method does not meet the preset condition of the portable instruction. 
         [0100]    In step B- 2 , the java virtual machine transplants and stores the java instruction corresponding to the current java class method into the preset buffer and executes step  109 . 
         [0101]    In step  109 , the java virtual machine obtains the deepest stack level of the java virtual machine and the maximum number of local variables of a java class method. 
         [0102]    The java virtual machine obtains the deepest stack level of the java class method in accordance with the member max stack in the code attribute structure, and obtains the maximum number of the local variables of the java class method in accordance with the member max locals in the code attribute structure. 
         [0103]    In step  110 , the java virtual machine fills a position of the transplanted java instruction in the class file with a java class method for obtaining stacks and local variables. Step  110  includes step  110 - 1  to  110 - 3 . 
         [0104]    In step  110 - 1 , the java virtual machine locates a position of the transplanted current java class method. 
         [0105]    In step  110 - 2 , the java virtual machine creates an index of a constant pool of the current java class method. 
         [0106]    Optionally, the index of the constant pool, which points to stored data structure CONSTANT_Methodref_info, is used for describing the current java class method. The index of constant pool occupies two bytes, for instance, in case that the constant pool index is 0001, the index points to the java class method javaanalyzer.R7JavaRuntime.GetLocalData(B)[B in the constant pools. 
         [0107]    The data structure CONSTANT_Methodref_info is: 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 CONSTANT_InterfaceMethodref_info { 
               
               
                   
                 u1 tag; 
               
               
                   
                 u2 class_index; 
               
               
                   
                 u2 name_and_type_index; }. 
               
               
                   
                   
               
             
          
         
       
     
         [0108]    Where class_index indicates class r7javaanalyzer.R7JavaRuntime, name_and_type_index indicates method descriptor GetStackData(B)[B. 
         [0109]    In the case where the index of the constant pool is 0002, the index points to the java class method r7javaanalyzer.R7JavaRuntime.GetStackData(B)[B in the constant pools. 
         [0110]    In step  110 - 3 , the java virtual machine fills the position of the transplanted current java class method with the index of the constant pool and the java class method for obtaining stacks and local variables. 
         [0111]    The java class method for obtaining stacks and local variables is an invokestatic method, and the value of the method is 0xb8 which may need an operator of two bytes, and the operator is an index of the constant pool. 
         [0112]    In the embodiment, in a case that a content which is inserted into the position of the transplanted java instruction is Invokestatic r7 javaanalyzer.R7JavaRuntime.GetLocalData (B)[B, a corresponding value of which is 0xb8 00 01; and in the case that a content which is inserted into the position of the transplanted java instruction is invokestaticr7javaanalyzer.R7JavaRuntime.GetStackData (B)[B, a corresponding value of which is 0xb8 00 02. 
         [0113]    In step  111 , the java virtual machine fills the position of the transplanted java instruction in the class with a java class method for executing the virtual machine in an encryption lock. The step  111  includes step  111 - 1  to step  111 - 3 . 
         [0114]    In step  111 - 1 , the java virtual machine locates a position of the transplanted current java class method. 
         [0115]    In step  111 - 2 , the java virtual machine creates an index of a constant pool of the current java class method. 
         [0116]    Optionally, an index of the constant pool occupies two bytes, for instance, in case that an index of a constant pool is 0003, a method pointed at by the index in the constant pools is r7javaanalyzer.R7JavaRuntime.R7Java_RunJava(SS)V. 
         [0117]    In step  111 - 3 , the java virtual machine fills the position of the transplanted current java class method with the index of the constant pool and the java class method for executing the virtual machine in the encryption lock. 
         [0118]    The java instruction for executing the virtual machine in the encryption lock is an invokevirtual instruction, and the value of the instruction is 0xC7 which may need an operator of two bytes, and the operator is an index of the constant pool. 
         [0119]    In the embodiment, a content inserted into the position of the transplanted java instruction is invokevirtualr7javaanalyzer.R7JavaRuntime.R7Java_RunJava(SS)V, and a corresponding value of which is 0xb80001. 
         [0120]    In step  112 , the java virtual machine fills the position of transplanted java instructions in the class file with a java class method for modifying stacks and local variables. The step  112  includes step  112 - 1  to  112 - 3 . 
         [0121]    In step  112 - 1 , the java virtual machine locates a position of the transplanted current java class method. 
         [0122]    In step  112 - 2 , the java virtual machine creates an index of a constant pool of the current java class method. 
         [0123]    Optionally, the index of the constant pool occupies two bytes, for instance, if the index of the constant pool is 0005, the method pointed at by the index in the constant pool is r7javaanalyzer.R7JavaRuntime.SetLocalData (B)[B. 
         [0124]    If the index of the constant pool is 0006, the method pointed at by the index in the constant pools is invokestaticr7javaanalyzer.R7JavaRuntime.SetStackData (B)[B. 
         [0125]    In step  112 - 3 , the java virtual machine fills the position of the transplanted current java class method with the index of the constant pool and the java class method which modifies stacks and local variables. 
         [0126]    The instruction for modifying stacks and local variables is an invokestatic instruction, the value of the instruction is 0xD8, and the instruction may need an operator of two bytes which is the index of the constant pool. 
         [0127]    In the embodiment, in case that the content inserted into the position of the transplanted java instruction is invokestaticr7javaanalyzer,R7JavaRuntime.SetLocalData(B)[B, a corresponding value of which is 0xD8 00 05; and in case that the content inserted into the position of the transplanted java instruction is invokestatic r7javaanalyzer.R7JavaRuntime.SetStackData(B)[B, a corresponding value of which is 0xD8 00 06. 
         [0128]    In step  113 , the java virtual machine updates member information of the additive attribute of the java class method. 
         [0129]    For instance, because the contents of filled java instructions increase, the length of the code attribute of the additive attributes needs to be modified. 
         [0130]    In step  114 , the java virtual machine determines whether the number of java class methods which have been parsed equals to a total number of the java class methods in the class file, transplants the java instruction corresponding to the current java class method in the preset buffer into the encryption lock and finishes the process of transplanting if the number of the java class methods which have been parsed equals to the total number of the java class methods in the class file; makes a next java class method as the current java class method and returns to execute step  108  if the number of the java class methods which have been parsed does not equal to the total number of the java class methods in the class file. 
         [0131]    In the embodiment, the filled java class method is: 
         [0000]    
       
         
               
               
             
               
               
               
             
               
               
             
               
               
             
           
               
                   
               
             
             
               
                 invokestatic 
                 r7javaanalyzer.R7JavaRuntime.GetLocalData (B)[B 
               
               
                 invokestatic 
                 r7javaanalyzer.R7JavaRuntime.GetStackData (B)[B 
               
             
          
           
               
                 sipush 
                 1 
                 dirID 
               
               
                 sipush 
                 1 
                 filedID 
               
             
          
           
               
                 invokevirtual 
                 r7javaanalyzer.R7JavaRuntime.R7Java_RunJava 
               
               
                   
                 (SS)V 
               
             
          
           
               
                 invokestatic 
                 r7javaanalyzer.R7JavaRuntime.SetLocalData (B)[B 
               
               
                 invokestatic 
                 r7javaanalyzer.R7JavaRuntime.SetStackData (B)[B. 
               
               
                   
               
             
          
         
       
     
         [0132]    While all above are preferred embodiments of the present disclosure, scope of the disclosure is not limited to hereof, variations and changes which can be made by those skilled in the art easily belong to scope of the disclosure. It is intended that the claims defined the scope of the disclosure and that method and structures within the scope of these claims and their equivalents be covered thereby.