CN101566967A - Quick automatic amendment method aimed at java byte code files - Google Patents
Quick automatic amendment method aimed at java byte code files Download PDFInfo
- Publication number
- CN101566967A CN101566967A CNA200910072170XA CN200910072170A CN101566967A CN 101566967 A CN101566967 A CN 101566967A CN A200910072170X A CNA200910072170X A CN A200910072170XA CN 200910072170 A CN200910072170 A CN 200910072170A CN 101566967 A CN101566967 A CN 101566967A
- Authority
- CN
- China
- Prior art keywords
- byte code
- java byte
- code files
- information
- name
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
The invention provides a quick automatic amendment method aimed at java byte code files. The method includes the following steps of: reading a java byte code file according to an input path of the java byte code file; acquiring all the stated methods in the java byte code file and storing the information of the methods in an array; examining the information of a next method in the array; acquiring the name of the original method of a method that possibly throws an exception; renaming the original method; according to the information of the original method, creating a new method; constructing a body of the new method; adding a mark to the treated java byte code file; and writing all the amendments in the java byte code file. The improved system consisting of the java byte code files has rather good differentiable property, and not only is applicable to a situation of passive files, but also saves the expenses of secondary compilation by processing to the java byte code files, thus realizing the function of automatic treatment and saving the time and energy of developers or code amending staff.
Description
(1) technical field
The present invention relates to the computer software of a kind of automatic improvement by the java language compilation, make it to have the technology of fast self-recovery ability, especially the software systems that make based on micro-reboot technology have the automatic improvement technology of fast self-recovery ability.
(2) background technology
Along with becoming stronger day by day of software system function, its structure also becomes increasingly complex, and inevitably bug is also more and more.Eliminate fully bug become impossible, but people but do not reduce the requirement of software systems.Therefore, the quick emphasis that must recover to have become the research of academia and industry after thrashing how.
Self-recovery method has a lot, and little to restart be wherein the most simple and effective a kind of.The application number that applicant for example of the present invention proposes in earlier stage is " a kind of general mission critical system fast self-recovery method based on recursion micro-reboot technology " of proposing in 200810064941.6 the patent application document etc.
Have with the maximally related prior art of this patent: the interior field of Japanese electric apparatus Co., Ltd. smoke applied in 2003 patent " program of recovery type certainly, program creating method and equipment, messaging device " (application number: 03107849.4, publication number: CN1447226).Use this patent and can generate, but its principle of work is all different with present patent application with the scope of application from recovery type program; Document " Transformation of ExistingPrograms into Autonomic and Self-healing Entities " (In proceedings ofthe 14th Annual IEEE International Conference and Workshops on theEngineering of Computer-Based Systems, 2007 (ECBS ' 07)) (translate: " program that will have now is converted to self-discipline self-healing entity " (the 14th computer based systems engineering year international conference, 2007) conversion method that proposes) is used clone and the reflex mechanism of java and is implemented to recover, and its Restoration Mechanism is different based on the recovery of recursion micro-reboot with this patent.
(3) summary of the invention
The object of the present invention is to provide a kind of java byte code files (.class file) that can improve automatically to make by its system that forms and have fast automatic amending method at the java byte code files based on the fast self-recovery ability of recursion micro-reboot.
The object of the present invention is achieved like this:
A) pathname (the url address of the absolute path name of local file or network file) according to the java byte code files of importing reads java byte code files (file of .class), and check whether this java byte code files was modified, if be modified, then no longer this document is handled, otherwise, change step b);
B) obtain the method for all statements in the java byte code files, and deposit the information of method in an array, comprise method name, rreturn value, the exception table information of method in the method information, will travel through pointer and place the array reference position;
C) check next method information in the array,, change step d) if it may be dished out unusually, otherwise, continue to check the next method in the array, if read the array tail, change step h);
D), obtain its method name to the former method of the unusual method of may dishing out;
E) former method is renamed;
F) according to the information (comprising information such as its method name, rreturn value, exception table) of former method, create new method, and use the method name of the method name of former method as new method, and the rreturn value of former method is as the rreturn value of new method, and the exception table of former method is as the exception table of new method;
G) the method body of structure new method calls former method in its method body, and call statement is encapsulated as can littlely restarts element, concrete method for packing, use the method that is proposed in the patent " general fast self-recovery method ", successfully after the encapsulation, change step c) based on recursion micro-reboot technology;
H) add mark in processed java byte code files, this mark shows that this java byte code files handled by this method, this java byte code files is repeated to improve avoiding;
I) above institute is made an amendment write the java byte code files.
In the said method proposed by the invention, about strategy to the processing of the unusual method of may dishing out, used the method that is proposed in the patent " general fast self-recovery method " of applying for before the present patent application person based on recursion micro-reboot technology, soon may produce unusual statement is packaged into and can littlely restarts element, the usable condition of method and only is suitable at the java byte code files described in " the general fast self-recovery method based on recursion micro-reboot technology ".
Advantage of the present invention has: (1) uses the method improvement java byte code files that is proposed in " the general fast self-recovery method based on recursion micro-reboot technology ", because it is successful, effectively that the method that is proposed in " the general fast self-recovery method based on recursion micro-reboot technology " experimental results show that, thus use the present invention the improved system that forms by the java byte code files have well and can littlely restart characteristic; (2) the present invention is directed to the java byte code files and handle, not only go for the not having source file situation of (.java file) has been saved the expense of secondary compiling simultaneously; (3) the present invention has realized the function of automatic processing, thereby has avoided the improvement one by one to original (.java file or .class file), can save the time and efforts that developer or code improve personnel.The system applies of being write by java is very extensive, and therefore, this method has broad application prospects.
(4) description of drawings
Fig. 1 is an algorithm pie graph of the present invention;
Fig. 2 is the process flow diagram of method of the present invention.
(5) embodiment
For example the present invention is done description in more detail below in conjunction with accompanying drawing:
The invention provides a kind of at the java byte code files, it improved automatically and make by its system that forms have technology based on the fast self-recovery ability of recursion micro-reboot.About revising the technology of java byte code files, can directly read the java byte code files, then it is analyzed, revises.Also can adopt the technology of some existing operation java byte code files.In the embodiment below, be to adopt the method that is provided among the class libraries javassisit that the java byte code files is made amendment to the modification of java byte code files.Before writing automatic handling procedure, import the javassist.jar bag earlier, just the method that can utilize wherein to be provided, and to producing unusual statement it is packaged into little method of restarting element in conjunction with what propose in " general fast self-recovery method " based on recursion micro-reboot technology, the java byte code files is made amendment.Its concrete modification flow process is as follows:
A) pathname of java byte code files by input reads the java byte code files, and checks that the current software product that is reading this java byte code files whether this java byte code files has been employed this method revised.If be modified, then this java byte code files is no longer handled, otherwise, change step k);
B) obtain the method for all statements in the java byte code files, and deposit the information of method in an array, comprise the information such as method name, rreturn value, exception table of access method in the method information;
C) read the information of each method in the array successively, check whether current method has by the throws key word statement unusual information of dishing out.If have, carry out step m~p), otherwise, continue to check. the information of the next method in the array, if read the array tail, change step q);
D) to by the unusual method of may dishing out of throws key word statement (hereinafter referred to as: former method), obtain its method name;
E) former method is renamed;
F) according to the information (comprising information such as its method name, rreturn value, exception table) of former method, create new method, and use the method name of the method name of former method as new method, the rreturn value of former method is as the rreturn value of new method, and the exception table of former method is as the exception table of new method (being that new method is equally by dish out unusual with former method same type of throws key word statement);
G) the method body of structure new method calls former method in its method body, and call statement is encapsulated as can littlely restarts element.Concrete method for packing is used the method that is proposed in the patent " the general fast self-recovery method based on recursion micro-reboot technology ";
H) add mark in processed java byte code files, this mark shows that this java byte code files handled by this method, so that this software product just can not repeat to improve to this document;
I) above institute is made an amendment write the java byte code files.
According to above-mentioned embodiment, as follows with the partial code that the java language is write:
ClassPool?pool=ClassPool.getDefault();
BufferedInputStream?bis=new?BufferedInputStream(
new?FileInputStream(inputPath));
// obtain the java byte code files that provides by pathname
CtClass?cc=pool.makeClass(bis);
//ismodified: whether expression carried out processing to the .class file that obtains
boolean?ismodified=false;
CtField[]ccf=cc.getFields();
for(int?i=0;i<ccf.length;i++){
if(ccf[i].getName().equals(″isaddedblock″)){
ismodified=true;
break;
}
}
if(!ismodified){
......
// check each method in the class one by one, see whether can produce unusually
for(int?i=0;i<cm.length;i++){
State dish out unusual by throws in the // acquisition methods, and deposit array in
CtClass?etc[]=cm[i].getExceptionTypes();
if(etc.length!=0){
// obtain the method name that may produce unusual method
String?oldname=cm[i].getName().toString();
String?cmname=oldname;
The name that // definition the method will be made into
String?newname=oldname+″$impl″;
// with former method RNTO newname
cm[i].setName(newname);
// create a new method, the method name is used former method name, is oldname
CtMethod?cmnew=CtNewMethod.copy(cm[i],oldname,cc,
null);
// obtain the return type of former method
String?type=cm[i].getReturnType().getName();
// begin to construct the method body * * * * * * * * * * * * * * * * * of new method
Call former method in the // new method, and call statement is encapsulated as littlely restarts element
StringBuffer?body=new?StringBuffer();
body.append(″{\n″);
// in class file, write and restart code in a subtle way
body.append(″}\n″);
cmnew.setBody(body.toString());
cc.addMethod(cmnew);
// leave it at that to the structure * * * * * * * * * * * * * * * * * * of new method method body
}
}
// the java byte code files of revising is added mark, expression was carried out modification to it
CtField?cf=CtField.make(″public?boolean?isaddedblock=false;″,
cc);
cc.addField(cf);
// will improve content to write the java byte code files
cc.writeFile();
}
More than for adopting the code sample of the inventive method institute written program.Through experimental verification, only need provide the path at the Java byte code files place that needs modification, this method just can be finished the automatic improvement to all java byte code files under this catalogue, and make by the system that formed of improved java byte code files have the characteristic that can littlely restart, thereby make system have the ability of fast self-recovery.The enforcement of this method is the pre-service to goal systems, additional littlely restart the expense of mechanism when program run and almost can ignore, and therefore, uses this method processing target system can not influence the execution of goal systems and only need pay very little cost.
Claims (3)
1, a kind of fast automatic amending method at the java byte code files is characterized in that:
A) pathname according to the java byte code files of importing reads the java byte code files, and checks whether this java byte code files was modified, if be modified, then no longer this document was handled, otherwise, change step b);
B) obtain the method for all statements in the java byte code files, and deposit the information of method in an array, comprise method name, rreturn value, the exception table information of method in the method information, will travel through pointer and place the array reference position;
C) check next method information in the array,, change step d) if it may be dished out unusually, otherwise, continue to check the next method in the array, if read the array tail, change step h);
D), obtain its method name to the former method of the unusual method of may dishing out;
E) former method is renamed;
F) according to the information of former method, create new method, and use the method name of the method name of former method as new method, the rreturn value of former method is as the rreturn value of new method, and the exception table of former method is as the exception table of new method;
G) the method body of structure new method calls former method in its method body, and call statement is encapsulated as can littlely restarts element, successfully after the encapsulation, changes step c);
H) add mark in processed java byte code files, this mark shows that this java byte code files handled by this method, this java byte code files is repeated to improve avoiding;
I) above institute is made an amendment write the java byte code files.
2, the fast automatic amending method at the java byte code files according to claim 1 is characterized in that: the absolute path name of the local file by name of the path described in the step a) or the url address of network file.
3, the fast automatic amending method at the java byte code files according to claim 1 and 2 is characterized in that: the information of the former method described in the step f) is its method name, rreturn value, exception table information.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN200910072170XA CN101566967B (en) | 2009-06-03 | 2009-06-03 | Quick automatic amendment method aimed at java byte code files |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN200910072170XA CN101566967B (en) | 2009-06-03 | 2009-06-03 | Quick automatic amendment method aimed at java byte code files |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101566967A true CN101566967A (en) | 2009-10-28 |
CN101566967B CN101566967B (en) | 2012-01-04 |
Family
ID=41283125
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN200910072170XA Expired - Fee Related CN101566967B (en) | 2009-06-03 | 2009-06-03 | Quick automatic amendment method aimed at java byte code files |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101566967B (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102004694A (en) * | 2010-11-26 | 2011-04-06 | 北京握奇数据系统有限公司 | Java-based exception handling method and exception handling mechanism |
CN102736905A (en) * | 2011-04-12 | 2012-10-17 | 深圳市金蝶中间件有限公司 | Method for dynamically replacing field in classes |
CN105404498A (en) * | 2014-09-16 | 2016-03-16 | 网宿科技股份有限公司 | Method for forwarding traffic in application of mobile intelligent terminal |
CN105653458A (en) * | 2016-01-06 | 2016-06-08 | 北京京东尚科信息技术有限公司 | Method and device for detecting high-time-consumption Java method in target Java items |
CN106055334A (en) * | 2016-06-01 | 2016-10-26 | 努比亚技术有限公司 | Code management system and method |
CN106990955A (en) * | 2017-03-09 | 2017-07-28 | 武汉斗鱼网络科技有限公司 | A kind of method and system got ready application program |
CN111435312A (en) * | 2019-01-15 | 2020-07-21 | 北京嘀嘀无限科技发展有限公司 | Application program management method and device and electronic equipment |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003280755A (en) * | 2002-03-25 | 2003-10-02 | Nec Corp | Self-restorable program, program forming method and device, information processor and program |
CN101320343A (en) * | 2008-07-18 | 2008-12-10 | 哈尔滨工程大学 | Universal fast self-recovery method based on recursion micro-reboot technology |
-
2009
- 2009-06-03 CN CN200910072170XA patent/CN101566967B/en not_active Expired - Fee Related
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102004694A (en) * | 2010-11-26 | 2011-04-06 | 北京握奇数据系统有限公司 | Java-based exception handling method and exception handling mechanism |
CN102004694B (en) * | 2010-11-26 | 2013-04-24 | 北京握奇数据系统有限公司 | Java-based exception handling method and exception handling mechanism |
CN102736905A (en) * | 2011-04-12 | 2012-10-17 | 深圳市金蝶中间件有限公司 | Method for dynamically replacing field in classes |
CN102736905B (en) * | 2011-04-12 | 2015-04-15 | 深圳市金蝶中间件有限公司 | Method for dynamically replacing field in classes |
CN105404498B (en) * | 2014-09-16 | 2019-03-22 | 网宿科技股份有限公司 | The method of flow in application program is forwarded under mobile intelligent terminal |
CN105404498A (en) * | 2014-09-16 | 2016-03-16 | 网宿科技股份有限公司 | Method for forwarding traffic in application of mobile intelligent terminal |
CN105653458A (en) * | 2016-01-06 | 2016-06-08 | 北京京东尚科信息技术有限公司 | Method and device for detecting high-time-consumption Java method in target Java items |
CN105653458B (en) * | 2016-01-06 | 2018-12-18 | 北京京东尚科信息技术有限公司 | The method and apparatus for detecting the time-consuming Java method of height in target Java project |
CN106055334A (en) * | 2016-06-01 | 2016-10-26 | 努比亚技术有限公司 | Code management system and method |
CN106055334B (en) * | 2016-06-01 | 2019-05-31 | 努比亚技术有限公司 | Code management system and method |
CN106990955A (en) * | 2017-03-09 | 2017-07-28 | 武汉斗鱼网络科技有限公司 | A kind of method and system got ready application program |
CN111435312A (en) * | 2019-01-15 | 2020-07-21 | 北京嘀嘀无限科技发展有限公司 | Application program management method and device and electronic equipment |
CN111435312B (en) * | 2019-01-15 | 2023-09-29 | 北京嘀嘀无限科技发展有限公司 | Application program management method and device and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN101566967B (en) | 2012-01-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101566967A (en) | Quick automatic amendment method aimed at java byte code files | |
Mellish | Computer interpretation of natural language descriptions | |
US9218163B2 (en) | Generating complex event processing rules | |
CN109829096B (en) | Data acquisition method and device, electronic equipment and storage medium | |
WO2002005088A1 (en) | Method and apparatus for extracting knowledge from software code or other structured data | |
JP2010267264A (en) | Method for constructing executable code for component-based application, computer-readable storage medium for executing the method, and compiler | |
JP2011100447A (en) | Entity morphing in metamodel-based tool | |
CN112286575A (en) | Intelligent contract similarity detection method and system based on graph matching model | |
CN109408101A (en) | A kind of code development maintaining method and electronic equipment for programming | |
CN111159268B (en) | Method and device for running ETL (extract-transform-load) process in Spark cluster | |
Sanchez et al. | Bigraphical modelling of architectural patterns | |
CN112989008A (en) | Multi-turn dialog rewriting method and device and electronic equipment | |
CA3147633A1 (en) | Automatically converting a program written in a procedural programming language into a dataflow graph and related systems and methods | |
CN106843857B (en) | Method and device for realizing SDK (software development kit) conversion of code base based on SRP (sequence-related protocol) | |
Fokkink et al. | Lazy rewriting on eager machinery | |
Rahien | DSLs in Boo: Domain Specific Languages in. Net | |
CN111158665B (en) | Code generation method and device, electronic equipment and storage medium | |
Itzstein et al. | Applications of join Java | |
Godfrey | Fuzzy Logic with MATLAB | |
US8522198B2 (en) | Model-operative pattern representation harvesting using an automated exemplar-directed approach | |
CN111176618B (en) | Method and system for developing program by voice wakeup | |
Son et al. | SMTL Oriented Model Transformation Mechanism for Heterogeneous Smart Mobile Models | |
Kraas | Realizing Model Simplifications with QVT Operational Mappings. | |
Biernacka et al. | Context-based proofs of termination for typed delimited-control operators | |
Gallagher et al. | Regular tree languages as an abstract domain in program specialisation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20120104 Termination date: 20170603 |